WebRTC Chrome and Firefox connection.setRemoteDescription

WebRTC Chrome and Firefox connection.setRemoteDescription

本文关键字:connection setRemoteDescription Firefox and Chrome WebRTC      更新时间:2023-09-26

我是如何接受已创建的offer并创建答案的:

var description = new RTCSessionDescription(sdp),
    self = this;
connection.setRemoteDescription(description, function () {
  connection.createAnswer(function (answer) {
    try {
      connection.setLocalDescription(answer, function () {
        self._mediator.sendSDPAnswer({
          data: answer,
          connection: connection.id
        });
        self._isRemoteDescriptionSet[connection.id] = true;
        self._setIceCandidates(connection);
      });
    } catch (e) {
      self._logger.error('Error while setting the remote description', e);
    }
  }, function (error) {
    throw error;
  }, {
    mandatory: {
      OfferToReceiveVideo: false,
      OfferToReceiveAudio: true
    }
  });

不幸的是,当我在Chrome中创建Firefox的报价时,我得到:

Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set data send codecs.. 

在Firefox中,我启动连接:

  connection.createOffer(function (offer) {
    connection.setLocalDescription(offer, function () {
      mediator.sendSDPOffer({
        data: offer,
        connection: connection.id
      });
    });
  }, function (error) {
    throw new Error('Error while connecting', error);
  }, {
    mandatory: {
      OfferToReceiveVideo: false,
      OfferToReceiveAudio: true
    }
  });

我创建的对端连接:

  this._connection = new RTCPeerConnection(servers,
    { optional: [
      { RtpDataChannels: true },
      { DtlsSrtpKeyAgreement: true }
    ]});

当我尝试在Chrome浏览器之间启动会话时,一切正常

尝试将rtpDataChannel设置为false并删除DtlsSrtpKeyAgreement。

this._connection = new RTCPeerConnection(servers,
  { optional: [
  { RtpDataChannels: false }
]});