I am working on a React Native 0.78 app and using WebRTC for peer-to-peer (P2P) video streaming. I successfully set up a WebRTC connection and received a WebRTC stream as a MediaStream
(MediaTrack format).
The problem is that I want to play this WebRTC stream using the React Native VLC media player (react-native-vlc-media-player
), but the player only accepts URL-based streams (like RTSP or HTTP). My WebRTC stream does not have a URL, so I can't play it directly.
My WebRTC stream is in H.265 (HEVC) format, and React Native VLC media player can decode and play H.265 video.
However, since VLC requires a URL-based stream, I need to convert the WebRTC stream into an RTSP stream so I can provide an RTSP URL to the VLC player.
I also need to handle multiple WebRTC streams at the same time, so each stream should have its own RTSP URL.
How can I create a React Native native module in Java to convert a WebRTC MediaStream
into an RTSP stream in real time?
How can I manage multiple WebRTC streams and generate unique RTSP URLs for each?
I appreciate any help, sample code, or guidance on how to achieve this. Thanks!
No conversion is needed now.
Google's official Chromium documentation mentions that H.265 support in WebRTC is currently in development. It has been released under 'Implemented behind flags' status: Chromium Feature.
This feature can be enabled using the following command:
For macOS:
open -a "Google Chrome" --args --enable-features=WebRtcAllowH265Send,WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled/
For Windows:
start chrome --enable-features=WebRtcAllowH265Send,WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled/
For Android: I used the WebView implementation to switch from Android System WebView (M134) to Android System WebView Dev (M136). It works perfectly, but the switch has to be done manually.
Chromium M136 stable release: Tue, Apr 29, 2025 Chromium.