这是我接受创建的报价并创建答案的方式:

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
    }
  });

不幸的是,当我通过Firefox在Chrome中创建要约时,我得到了:
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浏览器之间的 session 时,一切正常。

最佳答案

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

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

关于javascript - WebRTC Chrome和Firefox连接。setRemoteDescription,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25320204/

10-11 14:12