getRTCLocalSDP method

Future<String?> getRTCLocalSDP(
  1. {Map<String, dynamic> options = localSDPOptions}

Get the SDP modified depending the options. Optionally set the SDP information to local peer.

Map options bool options'stereo' - True to modify SDP for support stereo. Otherwise False. bool options'dtx' - True to modify SDP for supporting dtx in opus. Otherwise False.* MediaStream options'mediaStream' - MediaStream to offer in a stream. This object must have 1 audio track and 1 video track, or at least one of them. Alternative you can provide both tracks in an array. VideoCodec options' codec' - Selected codec for support simulcast. String options'scalabilityMode' - Selected scalability mode. You can get the available capabilities using method. Only available in Google Chrome. *bool options'absCaptureTime' - True to modify SDP for supporting absolute capture time header extension. Otherwise False. bool options'dependencyDescriptor' - True to modify SDP for supporting aom dependency descriptor header extension. Otherwise False. bool options'disableAudio' - True to not support audio. bool options'disableVideo' - True to not support video. bool options'setSDPToPeer' - True to set the SDP to local peer. Returns String Future object which represents the SDP information of the created offer.


Future<String?> getRTCLocalSDP(
    {Map<String, dynamic> options = localSDPOptions}) async {
  _logger.i('Getting RTC Local SDP');
  options = {...localSDPOptions, ...options};

  MediaStream? mediaStream =
      await getValidMediaStream(options['mediaStream']);
  if (mediaStream != null) {
    addMediaStreamToPeer(peer, mediaStream, options);
  } else {
    await addReceiveTransceivers(peer, options);

  _logger.i('Creating peer offer');
  _logger.i('my peer $peer');
  RTCSessionDescription? response = await peer?.createOffer();
  _logger.i('Peer offer created');
  _logger.d('Peer offer response: ${response?.sdp}');
  sessionDescription = response;
  if (response != null) {
    String? sdp = response.sdp;
    if (options.containsKey('disableAudio')) {
      if (!options['disableAudio']) {
        if (options['stereo']) {
          sdp = SdpParser.setStereo(sdp);
        if (options['dtx'] != null) {
          sdp = SdpParser.setDTX(sdp);
        if (mediaStream != null) {
          sdp = SdpParser.setMultiopus(sdp, mediaStream);
    if (options['absCaptureTime'] != null) {
      sdp = SdpParser.setAbsoluteCaptureTime(sdp);
    if (options['dependencyDescriptor'] != null) {
      sdp = SdpParser.setDependencyDescriptor(sdp);
    sessionDescription?.sdp = sdp;
    if (options['setSDPToPeer'] != null) {
      await peer?.setLocalDescription(sessionDescription!);
      _logger.i('Peer local description set');
  return sessionDescription?.sdp;