当没有摄像头的用户A用摄像头呼叫用户B时,你将收到没有视频的流
轨道。在这种情况下,用户B生成带有此类字符串a=group:BUNDLE audio
的SDP,通常它包含有关a=group:BUNDLE audio video
和m=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
为什么这种奇怪的行为以及如何避免它?
答案 0 :(得分:0)
您需要在RTCPeerConnection创建中加入约束,告诉SDP您愿意发送/接收哪些媒体。
示例:
var sdpConstraints = { 'mandatory': { 'OfferToReceiveAudio': true, 'OfferToReceiveVideo': false } };