produce method
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,
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,
),
),
);
}