javascript - WebRTC Chrome 和 Firefox connection.setRemoteDescription

标签 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 浏览器之间的 session 时,一切正常。

最佳答案

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

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

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

相关文章:

html - CSS 在 Chrome 中工作但在 Firefox 中不工作(div 高度)

JavaScript - 在选项卡关闭时发送 AJAX 调用(删除请求)

javascript - 通过单击列表滚动到部分

javascript - 不带 eval 的字符串到变量名

google-chrome - Firefox 的 chrome.webrequest.onbeforerequest.addlistener ?

macos - 如何在浏览器窗口中停靠 Firebug?

css - 跨浏览器提示分词

php - 使用 Javascript 编辑页面后保存页面?

javascript - 如何取消异步 promise 中的订阅以避免 Reactjs 中的内存泄漏

jquery - css 中的缩放效果在 firefox 中无法正常工作