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 {
  final jsTrack = track is MediaStreamTrackWeb ? track.jsTrack : null;
  final kindString = kind != null ? typeRTCRtpMediaTypetoString[kind] : null;
  final trackOrKind = jsTrack ?? kindString;
  assert(trackOrKind != null, 'track or kind must not be null');

  final transceiver = jsutil.callMethod(
    _jsPc,
    'addTransceiver',
    [
      trackOrKind,
      if (init != null) init.toJsObject(),
    ],
  );

  return RTCRtpTransceiverWeb.fromJsObject(
    transceiver,
    peerConnectionId: _peerConnectionId,
  );
}