没有摄像头的用户无法接受来自其他用户的视频

时间:2014-09-08 14:45:52

标签: html5-video webrtc

当没有摄像头的用户A用摄像头呼叫用户B时,你将收到没有视频的流 轨道。在这种情况下,用户B生成带有此类字符串a=group:BUNDLE audio的SDP,通常它包含有关a=group:BUNDLE audio videom=video 1 RTP/SAVPF 100 116 117 96等视频的提及

这是我在coffeescript中接受报价的代码:

acccept_offer: (sdp, success) ->
  sdp = new _RTCSessionDescription sdp

  @connection.setRemoteDescription sdp, =>
    if @candidates.length
      for candidate in @candidates
        @connection.addIceCandidate candidate
      @candidates = []
    @connection.createAnswer (description) =>
      description = new _RTCSessionDescription
        sdp: @set_bandwidth description.sdp
        type: description.type
      @local_description = description
      @connection.setLocalDescription @local_description, ->
        success()
      , (e) ->
        console.log e
    , (e) ->
      console.log e
  , (e) ->
    console.log e

为什么这种奇怪的行为以及如何避免它?

1 个答案:

答案 0 :(得分:0)

您需要在RTCPeerConnection创建中加入约束,告诉SDP您愿意发送/接收哪些媒体。

示例:

var sdpConstraints = { 'mandatory': { 'OfferToReceiveAudio': true, 'OfferToReceiveVideo': false } };