From b7b490326268a4a097a2c276e42474a5df52cdd4 Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Tue, 2 Nov 2021 15:07:46 +0000 Subject: [PATCH] some RTSP docs --- docs/rtsp.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/rtsp.md b/docs/rtsp.md index 9c4cd38753..674f100efd 100644 --- a/docs/rtsp.md +++ b/docs/rtsp.md @@ -51,6 +51,30 @@ player.prepare(); ~~~ {: .language-java} +### Passing a custom SocketFactory + +By default, `RtspMediaSource` will use Java's standard socket factory (`SocketFactory.getDefault()`) +to create connections to the remote endpoints. This behavior can be overridden using +`.setSocketFactory()`. + +~~~ +// Create an RTSP media source pointing to an RTSP uri and override the socket factory. +MediaSource mediaSource = + new RtspMediaSource.Factory() + .setSocketFactory(...) + .createMediaSource(MediaItem.fromUri(rtspUri)); +// Create a player instance. +ExoPlayer player = new ExoPlayer.Builder(context).build(); +// Set the media source to be played. +player.setMediaSource(mediaSource); +// Prepare the player. +player.prepare(); +~~~ +{: .language-java} + +Custom `SocketFactory` instances can be useful when particular routing is required (e.g. when RTSP +traffic needs to pass a specific interface, or the socket needs additional connectivity flags). + ## Using RTSP behind a NAT (RTP/TCP support) ## ExoPlayer uses UDP as the default protocol for RTP transport.