WebRTC Chrome和Firefox connection.setRemoteDescription

时间:2014-08-15 01:54:22

标签: javascript google-chrome firefox webrtc

以下是我接受创建的优惠并创建答案的方法:

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浏览器之间启动会话时,一切正常。

1 个答案:

答案 0 :(得分:5)

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

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