![](/img/trans.png)
[英]offer created again after setting remote answer sdp webrtc android
[英]Chrome Android not using all codec options in SDP offer
當我運行RTCRtpSender.getCapabilities("video").codecs;
在 Chrome Android 上,它包括 H264。 但是,我運行var offer = RTCPeerConnection.createOffer()
並查看offer.sdp
,它有時只會在報價中包含 H264。 這導致我使用需要 H264 的應用程序出現問題 - 由於拒絕那些不包含 H264 的報價,它的工作方式不一致,而且我不知道如何強制 SDP 報價包含它。 如何確保createOffer
包含所有可用的編解碼器? 我寧願不必對 SDP 進行任何手動編輯。
我一直面臨着同樣的問題。 正如 Pedro Vergara 評論的那樣,它看起來像是 Chrome Android 的最新版本中引入的一個錯誤。 目前,我通過繼續調用RTCRtpSender.getCapabilities('video')
做了一個簡單的解決方法,直到它列出了預期的 H.264 編解碼器支持,然后再嘗試創建 SDP 報價。 像這樣的東西:
console.log('Waiting for H.264 codec support');
checkH264(20);
function checkH264(count) {
if (count > 0) {
console.log('Getting video codec capabilities');
let capabilities = JSON.stringify(RTCRtpSender.getCapabilities('video').codecs);
console.log(capabilities);
if (capabilities.toLowerCase().includes('video/h264')) {
console.log('H.264 support found. Ready to proceed now! =)');
// Proceed to SDP offer creation...
} else {
setTimeout(checkH264, 1000, count - 1);
}
} else {
console.warn('H.264 support not found');
// Proceed with caution. SDP offer may not contain H.264...
}
}
請注意,上面的代碼通過使用setTimeout()
為 Chrome 提供了一些時間來使 H.264 可用。 只是在沒有真正等待的情況下調用RTCRtpSender.getCapabilities('video')
兩次或更多次可能行不通。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.