Package com.google.android.exoplayer2.source.rtsp

## 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 for `RtspMediaSource`

  This factory doesn't support the following methods from `MediaSourceFactory`:

  - `setDrmSessionManagerProvider(DrmSessionManagerProvider)`
  - `setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy)`

- - ### 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
    --- | --- | ---
    `RtspMediaSource` | `createMediaSource​(MediaItem mediaItem)` | Returns a new `RtspMediaSource` using the current parameters.
    `@com.google.android.exoplayer2.C.ContentType int[]` | `getSupportedTypes()` | Returns the `content types` supported by media sources created by this factory.
    `RtspMediaSource.Factory` | `setDebugLoggingEnabled​(boolean debugLoggingEnabled)` | Sets whether to log RTSP messages, the default value is `false`.
    `RtspMediaSource.Factory` | `setDrmSessionManagerProvider​(DrmSessionManagerProvider drmSessionManager)` | Does nothing.
    `RtspMediaSource.Factory` | `setForceUseRtpTcp​(boolean forceUseRtpTcp)` | Sets whether to force using TCP as the default RTP transport.
    `RtspMediaSource.Factory` | `setLoadErrorHandlingPolicy​(LoadErrorHandlingPolicy loadErrorHandlingPolicy)` | Does nothing.
    `RtspMediaSource.Factory` | `setSocketFactory​(SocketFactory socketFactory)` | Sets a socket factory for `RtspClient`'s connection, the default value is `SocketFactory.getDefault()`.
    `RtspMediaSource.Factory` | `setTimeoutMs​(long timeoutMs)` | Sets the timeout in milliseconds, the default value is `RtspMediaSource.DEFAULT_TIMEOUT_MS`.
    `RtspMediaSource.Factory` | `setUserAgent​(String userAgent)` | Sets the user agent, the default value is `ExoPlayerLibraryInfo.VERSION_SLASHY`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Factory

          public Factory()

  - ### Method Detail

    - #### setForceUseRtpTcp

          @CanIgnoreReturnValue
          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 to `true`, the source will always use TCP for streaming.

      Parameters:
        `forceUseRtpTcp` - Whether force to use TCP for streaming.
      Returns:
        This Factory, for convenience.

    - #### setUserAgent

          @CanIgnoreReturnValue
          public RtspMediaSource.Factory setUserAgent​(String userAgent)

      Sets the user agent, the default value is `ExoPlayerLibraryInfo.VERSION_SLASHY`.
      Parameters:
        `userAgent` - The user agent.
      Returns:
        This Factory, for convenience.

    - #### setSocketFactory

          @CanIgnoreReturnValue
          public RtspMediaSource.Factory setSocketFactory​(SocketFactory socketFactory)

      Sets a socket factory for `RtspClient`'s connection, the default value is `SocketFactory.getDefault()`.
      Parameters:
        `socketFactory` - A socket factory.
      Returns:
        This Factory, for convenience.

    - #### setDebugLoggingEnabled

          @CanIgnoreReturnValue
          public RtspMediaSource.Factory setDebugLoggingEnabled​(boolean debugLoggingEnabled)

      Sets whether to log RTSP messages, the default value is `false`.

      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

          @CanIgnoreReturnValue
          public RtspMediaSource.Factory setTimeoutMs​(@IntRange(from=1L)
                                                      long timeoutMs)

      Sets the timeout in milliseconds, the default value is `RtspMediaSource.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​(DrmSessionManagerProvider drmSessionManager)

      Does nothing. `RtspMediaSource` does not support DRM.
      Specified by:
        `setDrmSessionManagerProvider` in interface `MediaSource.Factory`
      Returns:
        This factory, for convenience.

    - #### setLoadErrorHandlingPolicy

          public RtspMediaSource.Factory setLoadErrorHandlingPolicy​(LoadErrorHandlingPolicy loadErrorHandlingPolicy)

      Does nothing. `RtspMediaSource` does not support error handling policies.
      Specified by:
        `setLoadErrorHandlingPolicy` in interface `MediaSource.Factory`
      Returns:
        This factory, for convenience.

    - #### getSupportedTypes

          @ContentType
          public @com.google.android.exoplayer2.C.ContentType int[] getSupportedTypes()

      Description copied from interface: `MediaSource.Factory`
      Returns the `content types` supported by media sources created by this factory.
      Specified by:
        `getSupportedTypes` in interface `MediaSource.Factory`

    - #### createMediaSource

          public RtspMediaSource createMediaSource​(MediaItem mediaItem)

      Returns a new `RtspMediaSource` using the current parameters.
      Specified by:
        `createMediaSource` in interface `MediaSource.Factory`
      Parameters:
        `mediaItem` - The `MediaItem`.
      Returns:
        The new `RtspMediaSource`.
      Throws:
        `NullPointerException` - if `MediaItem.localConfiguration` is `null`.