flutter webrtc RTCPeerConnection.addStream not working

1k views Asked by At

Friends, I want to develop an application for Flutter using webrtc, but unfortunately I am facing problems that I am not able to solve.

errorCode: AddStream is not available with Unified Plan SdpSemantics. Please use AddTrack instead.

Thanks

Map<String, dynamic> configuration = {
  "iceServers": [
    {"url": "stun:stun1.l.google.com:19302"},
  ]
};
final Map<String, dynamic> offerSdpConstraints = {
  "mandatory": {
    "OfferToReceiveAudio": true,
    "OfferToReceiveVideo": true,
  },
  'optional': [
    {'DollsSftpKeyAgreement': true},
  ],
};

Map<String,dynamic> mediaConstraints = {
  'audio': true,
  'video': true,
};
_localStream = await navigator.mediaDevices.getUserMedia(mediaConstraints);
_localRenderer.srcObject = _localStream;


RTCPeerConnection pc = await createPeerConnection(configuration,offerSdpConstraints);
pc.addStream(_localStream!);
1

There are 1 answers

0
EbrahimAghdasi On BEST ANSWER

I finally found the cause of this error and realized that

RTCPeerConnection.addStream(localStream) It is obsolete

and I use it

localStream?.getTracks().forEach((track) { peerConnection?.addTrack(track, localStream!); });

I hope it will be useful for you