[英]Chrome Android not using all codec options in SDP offer
When I run RTCRtpSender.getCapabilities("video").codecs;
当我运行
RTCRtpSender.getCapabilities("video").codecs;
on Chrome Android it includes H264.在 Chrome Android 上,它包括 H264。 However, I run
var offer = RTCPeerConnection.createOffer()
and look at offer.sdp
it will only sometimes include H264 in the offer.但是,我运行
var offer = RTCPeerConnection.createOffer()
并查看offer.sdp
,它有时只会在报价中包含 H264。 This is causing me issues with an application that requires H264 - it works inconsistently as a result of rejecting those offers that don't include H264, and I don't know how to force the SDP offer to include it.这导致我使用需要 H264 的应用程序出现问题 - 由于拒绝那些不包含 H264 的报价,它的工作方式不一致,而且我不知道如何强制 SDP 报价包含它。 How do I make sure
createOffer
includes all available codecs?如何确保
createOffer
包含所有可用的编解码器? I would prefer not to have to do any manual editing of the SDP.我宁愿不必对 SDP 进行任何手动编辑。
I've been facing the same problem.我一直面临着同样的问题。 As Pedro Vergara commented, it looks like a bug introduced in recent versions of Chrome Android.
正如 Pedro Vergara 评论的那样,它看起来像是 Chrome Android 的最新版本中引入的一个错误。 For now, I did a simple workaround by keep calling
RTCRtpSender.getCapabilities('video')
until it lists the expected H.264 codec support, before any attempt to create the SDP offer.目前,我通过继续调用
RTCRtpSender.getCapabilities('video')
做了一个简单的解决方法,直到它列出了预期的 H.264 编解码器支持,然后再尝试创建 SDP 报价。 Something like this:像这样的东西:
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...
}
}
Notice that the code above gives some time for Chrome to make H.264 available, by using setTimeout()
.请注意,上面的代码通过使用
setTimeout()
为 Chrome 提供了一些时间来使 H.264 可用。 Just calling RTCRtpSender.getCapabilities('video')
twice or more without really waiting may not work.只是在没有真正等待的情况下调用
RTCRtpSender.getCapabilities('video')
两次或更多次可能行不通。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.