Last updated on March 22, 2016
RTSP/RTP streaming is a combined streaming protocol that is frequently available on streaming media servers. RSTP is a protocol used to control streaming media servers. RTSP uses TCP (with default port 554) to maintain end-to-end connection between the client and the server. The media data is however transported with RTP which is a UDP-based protocol. The main difference between TCP and UDP is that TCP includes a network packet retransmission mechanism (when packets are lost) while with UDP packets are sent to the client without any mean to verify that the client actually received those packets. This effectively reduces network overhead but with the risk of packet loss. RTP over UDP is widely used in the broadcast industry. More information on RTSP/RTP can be found here.
Most video/audio streaming to mobile devices today can be done with HLS (iOS and Android 4+) plus optionally MPEG-DASH (for latest Chrome for Android). However there could be some use cases where one could want to reach older or specific devices where RTSP/RTP video/audio streaming could be a valid option - especially for live event.
This blog article will review how to use RTSP/RTP streaming as a fallback to HLS for streaming on mobile devices with Radiant Media Player. This approach could be ported to work with any other web-based media player.
RTSP/RTP video/audio streaming is only supported on some mobile devices. Adobe Flash does not support RTSP/RTP streaming. Modern Desktop browsers do not support RTSP/RTP streaming natively neither. While it is technically possible to play RTSP/RTP streaming on Desktop with plugins like VLC or QuickTime the general public will probably not have the know-how to install/configure them.
RTSP/RTP video/audio streaming support on mobile devices:
While we could use a user agent detection approach to feed RTSP/RTP to specific devices we have chosen a feature detection approach which could provide more consistent results across a fragmented mobile landscape.
It is to be noted that while we could feed an RTSP/RTP URL to an HTML5 video tag this could confuse some browsers/devices and that is why we opt to feed the RTSP/RTP URL to a clickable link (<a> tag). Depending on the device resources the browser will either attempt to play the stream in-browser or try to find an app within the device that could playback the RTSP/RTP stream.
The following player code is a starting to point to add RTSP/RTP support for live video streaming to your player. Note that with this code we use RTSP/RTP as a fallback to HLS. It can also be applied for on-demand video, though it is to be noted that depending on your use case MP4 progressive download with HTML5 video may be a better option for on-demand video.
<!DOCTYPE html> <html> <head> <title>Radiant Media Player with RTSP/RTP fallback</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> </head> <body> <script src="https://cdn.radiantmediatechs.com/rmp/v3/latest/js/rmp.min.js"></script> <div id="rmpPlayer"></div> <script src="js/test-rtsp.js"></script> </body> </html>