addTransceiver method

  1. @override
Future<RTCRtpTransceiver> addTransceiver({
  1. MediaStreamTrack? track,
  2. RTCRtpMediaType? kind,
  3. RTCRtpTransceiverInit? init,
})
override

'audio|video', { 'direction': 'recvonly|sendonly|sendrecv' }

Implementation

@override
Future<RTCRtpTransceiver> addTransceiver(
    {MediaStreamTrack? track,
    RTCRtpMediaType? kind,
    RTCRtpTransceiverInit? init}) async {
  try {
    final response =
        await WebRTC.invokeMethod('addTransceiver', <String, dynamic>{
      'peerConnectionId': _peerConnectionId,
      if (track != null) 'trackId': track.id,
      if (kind != null) 'mediaType': typeRTCRtpMediaTypetoString[kind],
      if (init != null)
        'transceiverInit': RTCRtpTransceiverInitNative.initToMap(init)
    });
    return RTCRtpTransceiverNative.fromMap(response,
        peerConnectionId: _peerConnectionId);
  } on PlatformException catch (e) {
    throw 'Unable to RTCPeerConnection::addTransceiver: ${e.message}';
  }
}