produce method

void produce({
  1. required MediaStreamTrack track,
  2. required MediaStream stream,
  3. List<RtpEncodingParameters> encodings = const <RtpEncodingParameters>[],
  4. ProducerCodecOptions? codecOptions,
  5. RtpCodecCapability? codec,
  6. bool stopTracks = true,
  7. bool disableTrackOnPause = true,
  8. bool zeroRtpOnPause = false,
  9. Map<String, dynamic> appData = const <String, dynamic>{},
  10. required String source,
  11. Function? accept,
})

Create a Producer. use producerCallback to receive a new Producer.

Implementation

void produce({
  required MediaStreamTrack track,
  required MediaStream stream,
  List<RtpEncodingParameters> encodings = const <RtpEncodingParameters>[],
  ProducerCodecOptions? codecOptions,
  RtpCodecCapability? codec,
  bool stopTracks = true,
  bool disableTrackOnPause = true,
  bool zeroRtpOnPause = false,
  Map<String, dynamic> appData = const <String, dynamic>{},
  required String source,
  Function? accept,
}) {
  _logger.debug('produce() [track:${track.toString()}');

  if (_direction != Direction.send) {
    throw ('not a sending Transport');
  } else if (track.kind == null ||
      !_canProduceByKind
          .canIt(RTCRtpMediaTypeExtension.fromString(track.kind!))) {
    throw ('cannot produce ${track.kind}');
  } else if (listeners('connect').isEmpty && _connectionState == 'new') {
    throw ('no "connect" listener set into this transport');
  } else if (listeners('produce').isEmpty) {
    throw ('no "pruduce" listener set into this transport');
  }

  _flexQueue.addTask(
    FlexTaskAdd(
      id: '',
      message: 'transport.produce()',
      execFun: _produce,
      argument: ProduceArguments(
        track: track,
        stream: stream,
        encodings: encodings,
        codecOptions: codecOptions,
        codec: codec,
        stopTracks: stopTracks,
        disableTrackOnPause: disableTrackOnPause,
        zeroRtpOnPause: zeroRtpOnPause,
        appData: appData,
        source: source,
        accept: accept,
      ),
    ),
  );
}