[英]How to change Webrtc rtcpMuxPolicy?
我正在嘗試更改rtcpMuxPolicy
和bundlePolicy
,但似乎無法更改
這是我的代碼:
嘗試 1:
var servers = {
'iceServers': [{
'urls': 'stun-url..'
}, {
'urls': 'stun-url-2..'
}, {
'urls': 'turn-url..',
'credential': 'psw',
'username': 'user'
}],
peerIdentity: [{bundlePolicy: 'max-bundle', rtcpMuxPolicy: 'negotiate'}]//added this line
};
var pc;
var sendChannel;
navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);
pc = new RTCPeerConnection(servers);
嘗試 2:
var servers = {
'iceServers': [{
'urls': 'stun-url..'
}, {
'urls': 'stun-url-2..'
}, {
'urls': 'turn-url..',
'credential': 'psw',
'username': 'user'
}]
};
var pc;
var sendChannel;
navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);
pc = new RTCPeerConnection(servers);
pc.setConfiguration([{bundlePolicy: 'max-bundle', rtcpMuxPolicy: 'negotiate'}]);
對於這兩個示例,我仍然看到默認值:
pc.getConfiguration()
bundlePolicy: "balanced"
rtcpMuxPolicy: "require"
我只能注意到一個變化,即iceServers
數組為空,但bundlePolicy
和rtcpMuxPolicy
仍然是默認值。
我有與 Android 應用程序通信的 WebRtc Web 解決方案,並且在流式傳輸視頻時一切正常,當我添加 dataChannel 時出現問題,即
sendChannel = pc.createDataChannel('sendDataChannel');
在我的 web 解決方案中添加以上行后,android 拋出一個錯誤說:
setSDP 錯誤:無法設置遠程報價 sdp:會話錯誤代碼:ERROR_CONTENT。 會話錯誤描述:未能設置 RTCP 多路復用過濾器..
首先,刪除peerIdentity: [{
and }]
。 只有iceServers
需要一個數組。 語法是:
const pc = new RTCPeerConnection({
iceServers: [{urls: 'stun-url..'}, {urls: 'stun-url-2..'}],
bundlePolicy: 'max-bundle', // add this line
rtcpMuxPolicy: 'negotiate' // and this one
});
pc.setConfiguration({bundlePolicy: 'max-bundle', rtcpMuxPolicy: 'negotiate'});
其次,請注意,即使某些瀏覽器支持rtcpMuxPolicy
, 'negotiate'
值控制的功能在規范中被標記為“有風險的功能” ,因此很可能不支持設置此值。
規范說: “用戶代理可能不會實現非多路復用的 RTCP,在這種情況下,它將拒絕嘗試使用協商策略構建 RTCPeerConnection。”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.