subscribe method Null safety
Establish WebRTC connection with Millicast Server as Subscriber role.
sdp
- The SDP information created by your offer.
options
- Signaling Subscribe Options.
Returns Future object which represents the SDP command response.
var response = await millicastSignaling.subscribe(sdp)
Implementation
Future<String> subscribe(String sdp, {Map<String, dynamic>? options}) async {
_logger.i('Starting subscription to streamName: $streamName');
_logger.d('Subscription local description: $sdp');
String? sdpString =
SdpParser.adaptCodecName(sdp, 'AV1X', videoCodec['AV1']!);
Map<String, dynamic> data = {
'sdp': sdpString,
'streamId': streamName,
'pinnedSourceId': options?['pinnedSourceId'],
'excludedSourceIds': options?['excludedSourceIds']
};
if (options != null) {
if (options['vad'] != null) {
data['vad'] = true;
}
if (options['events'] != null) {
data['events'] = options['events'];
}
}
try {
await connect();
_logger.i('Sending view command');
var result = await transactionManager?.cmd('view', data);
return result['data']['sdp'];
} catch (e) {
_logger.e('Error sending view command, error: $e');
throw Exception(e);
}
}