WebRTC on Android: how to enable hardware encoding on multiple devices
--
For video calls on Badoo and Bumble apps, we use WebRTC with H.264 codec. Relying on relevant documentation, you would think that this codec should work seamlessly on any Android device, starting with Android 5.0. However, in practice, it didn’t go exactly this way. This article covers implementation features of hardware encoding for H.264 codec in WebRTC and the ways of enabling it on multiple devices.
Why H.264?
When connected through WebRTC all devices participating in the session transmit different communication parameters, including video- and audio-codecs. If a device supports multiple codecs (e.g. VP8 and H.264), the codecs with the highest priority for the platform are listed first. These codecs are used in the negotiation stage in WebRTC, after which only the codecs supported by all devices are left. See this document for a detailed example of such data.
For video calls, if one of the devices does not support H.264 codec, then both devices can switch to, for example, VP8 codec, which does not depend on the device hardware implementation. However, our application works on different devices, including previous-generations smartphones. This is why we wanted to use hardware encoding for video communication, where possible because it reduces the load on the processor and consumes less battery power, which is essential for legacy devices. Also, H.264 hardware encoding is supported on lots of devices, in contrast to VP8 mentioned above.
H.264 support on Android
According to the description of the support for multimedia formats, H.264 Baseline Profile decoding should work on all Android devices, while encoding should work on devices from Android 3.0 onwards. In Badoo and Bumble, we support devices starting with Android 5.0. Thus, we should not have encountered any problems. But it turned out not to be that simple, because we discovered lots of particularities in the devices, even with the 5.x version.
What might be the reason?
As we know, when developing a new Android device any manufacturer should undergo a Compatibility Test Suite. It runs on a PC which is connected to the device, and the results need to be sent to Google for…