blackuy / react-native-twilio-video-webrtc

Twilio Video (WebRTC) for React Native
https://www.twilio.com/docs/video
MIT License
609 stars 404 forks source link

Allow callback for H264 codec not support for Android Devices #596

Closed brycnguyen closed 2 years ago

brycnguyen commented 2 years ago

I was facing the same issue reported here: https://github.com/blackuy/react-native-twilio-video-webrtc/issues/517 on an Android Pixel 6 Pro, a relatively new device.

The issue stems from that some android devices do not fully support H264 codec, therefore video tracks from other participants could not be subscribed and throws an exception. I currently have the codec preference set for all my users to be ['H264', 'VP8'] from the web and other devices in a Small Group setting. Which means H264 will always be the codec negotiated by the Selective Forwarding Unit from Twilio if at least one participant has this preference.

According to Twilio Support, if I want to support Android Devices that do not have H264 support, I should change all the preferences to be ['VP8'].

I want to continue using H264, but also support VP8, so what I am adding here to the library is a way for my app to know when an unsupported H264 device has been used to connect, and properly handle it by changing the other participants codec to be ['VP8'] instead of ['H264', 'VP8'] and re-connect. This way the video tracks are published using VP8 and can be subscribed to.

Most of the code for H264 detection comes from here: https://www.twilio.com/docs/video/managing-codecs

slycoder commented 2 years ago

Thank you for the great PR and the thoughtful explanation. I just had one question inline but otherwise lgtm!

brycnguyen commented 2 years ago

@slycoder , Verified on a Samsung S10 that I receive a list ['VP8', 'H264'] and on a Pixel I get ['VP8']. This PR should be good to go. Thanks!

slycoder commented 2 years ago

Thank you for that update!