How to detect Android H.264 hardware acceleration capability

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.

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.