问题
A large number, though not all, of Android devices support hardware acceleration of the H.264 video codec but not the VP8/VP9 codecs. To provide a higher quality user experience, we would like to select the codec that is hardware accelerated when possible. Hence, would like runtime detection of whether the specific device has H.264 hardware acceleration support or not and based on this will set the particular codecs that is used in the SDP for session negotiation of the webRTC peerconnection. I.e., if H.264 is supported with hardware then will set that as the higher priority codec as opposed to VP8/VP9. Any thoughts on this would be greatly appreciated.
回答1:
Use the MediaCodecList API to iterate over the available encoders and decoders. Encoders whose name start with OMX.google.
are SW codecs - any other codec can more or less be assumed to be a HW codec. The easiest is probably to use findEncoderForFormat
(and findDecoderForFormat
) and see what name this returns. If you need more detail, you can iterate through the list manually.
回答2:
According to Justin Uberti's comment here, you will only get H.264 in Android WebRTC if there is an HW encoder on the device. So you can simply set WebRTC to prefer H.264 - if there is an HW encoder, HW H.264 will be used. If not, then it's VP8/VP9.
来源:https://stackoverflow.com/questions/39166122/how-to-detect-android-h-264-hardware-acceleration-capability