Class RtspMediaSource.Factory
- java.lang.Object
-
- com.google.android.exoplayer2.source.rtsp.RtspMediaSource.Factory
-
- All Implemented Interfaces:
MediaSource.Factory,MediaSourceFactory
- Enclosing class:
- RtspMediaSource
public static final class RtspMediaSource.Factory extends Object implements MediaSourceFactory
Factory forRtspMediaSourceThis factory doesn't support the following methods from
MediaSourceFactory:
-
-
Field Summary
-
Fields inherited from interface com.google.android.exoplayer2.source.MediaSourceFactory
UNSUPPORTED
-
-
Constructor Summary
Constructors Constructor Description Factory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RtspMediaSourcecreateMediaSource(MediaItem mediaItem)Returns a newRtspMediaSourceusing the current parameters.int[]getSupportedTypes()Returns thecontent typessupported by media sources created by this factory.RtspMediaSource.FactorysetDebugLoggingEnabled(boolean debugLoggingEnabled)Sets whether to log RTSP messages, the default value isfalse.RtspMediaSource.FactorysetDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManager)Does nothing.RtspMediaSource.FactorysetForceUseRtpTcp(boolean forceUseRtpTcp)Sets whether to force using TCP as the default RTP transport.RtspMediaSource.FactorysetLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy)Does nothing.RtspMediaSource.FactorysetSocketFactory(SocketFactory socketFactory)Sets a socket factory forRtspClient's connection, the default value isSocketFactory.getDefault().RtspMediaSource.FactorysetTimeoutMs(long timeoutMs)Sets the timeout in milliseconds, the default value isRtspMediaSource.DEFAULT_TIMEOUT_MS.RtspMediaSource.FactorysetUserAgent(String userAgent)Sets the user agent, the default value isExoPlayerLibraryInfo.VERSION_SLASHY.
-
-
-
Method Detail
-
setForceUseRtpTcp
public RtspMediaSource.Factory setForceUseRtpTcp(boolean forceUseRtpTcp)
Sets whether to force using TCP as the default RTP transport.The default value is
false, the source will first try streaming RTSP with UDP. If no data is received on the UDP channel (for instance, when streaming behind a NAT) for a while, the source will switch to streaming using TCP. If this value is set totrue, the source will always use TCP for streaming.- Parameters:
forceUseRtpTcp- Whether force to use TCP for streaming.- Returns:
- This Factory, for convenience.
-
setUserAgent
public RtspMediaSource.Factory setUserAgent(String userAgent)
Sets the user agent, the default value isExoPlayerLibraryInfo.VERSION_SLASHY.- Parameters:
userAgent- The user agent.- Returns:
- This Factory, for convenience.
-
setSocketFactory
public RtspMediaSource.Factory setSocketFactory(SocketFactory socketFactory)
Sets a socket factory forRtspClient's connection, the default value isSocketFactory.getDefault().- Parameters:
socketFactory- A socket factory.- Returns:
- This Factory, for convenience.
-
setDebugLoggingEnabled
public RtspMediaSource.Factory setDebugLoggingEnabled(boolean debugLoggingEnabled)
Sets whether to log RTSP messages, the default value isfalse.This option presents a privacy risk, since it may expose sensitive information such as user's credentials.
- Parameters:
debugLoggingEnabled- Whether to log RTSP messages.- Returns:
- This Factory, for convenience.
-
setTimeoutMs
public RtspMediaSource.Factory setTimeoutMs(@IntRange(from=1L) long timeoutMs)
Sets the timeout in milliseconds, the default value isRtspMediaSource.DEFAULT_TIMEOUT_MS.A positive number of milliseconds to wait before lack of received RTP packets is treated as the end of input.
- Parameters:
timeoutMs- The timeout measured in milliseconds.- Returns:
- This Factory, for convenience.
-
setDrmSessionManagerProvider
public RtspMediaSource.Factory setDrmSessionManagerProvider(@Nullable DrmSessionManagerProvider drmSessionManager)
Does nothing.RtspMediaSourcedoes not support DRM.- Specified by:
setDrmSessionManagerProviderin interfaceMediaSource.Factory- Returns:
- This factory, for convenience.
-
setLoadErrorHandlingPolicy
public RtspMediaSource.Factory setLoadErrorHandlingPolicy(@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy)
Does nothing.RtspMediaSourcedoes not support error handling policies.- Specified by:
setLoadErrorHandlingPolicyin interfaceMediaSource.Factory- Parameters:
loadErrorHandlingPolicy- ALoadErrorHandlingPolicy, ornullto use theDefaultLoadErrorHandlingPolicy.- Returns:
- This factory, for convenience.
-
getSupportedTypes
public int[] getSupportedTypes()
Description copied from interface:MediaSource.FactoryReturns thecontent typessupported by media sources created by this factory.- Specified by:
getSupportedTypesin interfaceMediaSource.Factory
-
createMediaSource
public RtspMediaSource createMediaSource(MediaItem mediaItem)
Returns a newRtspMediaSourceusing the current parameters.- Specified by:
createMediaSourcein interfaceMediaSource.Factory- Parameters:
mediaItem- TheMediaItem.- Returns:
- The new
RtspMediaSource. - Throws:
NullPointerException- ifMediaItem.localConfigurationisnull.
-
-