consume method
void
consume({
- required String id,
- required String producerId,
- required String peerId,
- required RTCRtpMediaType kind,
- required RtpParameters rtpParameters,
- Map<
String, dynamic> appData = const <String, dynamic>{}, - Function? accept,
Create a Consumer to consume a remote Producer. use consumerCallback to receive a new Consumer.
Implementation
void consume({
required String id,
required String producerId,
required String peerId,
required RTCRtpMediaType kind,
required RtpParameters rtpParameters,
Map<String, dynamic> appData = const <String, dynamic>{},
Function? accept,
}) {
_logger.debug('consume()');
rtpParameters = RtpParameters.copy(rtpParameters);
if (_closed) {
throw ('closed');
} else if (_direction != Direction.recv) {
throw ('not a receiving Transport');
} else if (kind != RTCRtpMediaType.RTCRtpMediaTypeAudio &&
kind != RTCRtpMediaType.RTCRtpMediaTypeVideo) {
throw ('invalid kind ${RTCRtpMediaTypeExtension.value(kind)}');
} else if (listeners('connect').isEmpty && _connectionState == 'new') {
throw ('no "connect" listener set into this transport');
}
_flexQueue.addTask(
FlexTaskAdd(
id: id,
message: 'transport.consume()',
execFun: _consume,
argument: ConsumeArguments(
id: id,
producerId: producerId,
kind: kind,
rtpParameters: rtpParameters,
appData: appData,
accept: accept,
peerId: peerId,
),
),
);
}