> Documentation index: https://developer.android.com/reference/llms.txt

# RtspMediaSource.Factory

Artifact: [androidx.media3:media3-exoplayer-rtsp](https://developer.android.com/jetpack/androidx/releases/media3.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/rtsp/RtspMediaSource.java+class:androidx.media3.exoplayer.rtsp.RtspMediaSource.Factory)

*** ** * ** ***


```
public final class RtspMediaSource.Factory implements MediaSourceFactory
```

<br />

*** ** * ** ***

Factory for `RtspMediaSource`

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

- `setDrmSessionManagerProvider`
- `setLoadErrorHandlingPolicy`

## Summary

| ### Public constructors |
|---|
| `Factory()` |

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

### Inherited Constants

From [androidx.media3.exoplayer.source.MediaSource.Factory](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory.md.txt) `static final MediaSource.Factory` `@UnstableApi
UNSUPPORTED`

An instance that throws `UnsupportedOperationException` from `createMediaSource` and `getSupportedTypes`.
From [androidx.media3.exoplayer.source.MediaSourceFactory](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceFactory.md.txt) `static final MediaSourceFactory` `@UnstableApi
UNSUPPORTED`

An instance that throws `UnsupportedOperationException` from `createMediaSource` and `getSupportedTypes`.

### Inherited methods

From [androidx.media3.exoplayer.source.MediaSource.Factory](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory.md.txt) `MediaSource.Factory` `@UnstableApi
@ExperimentalApi
[experimentalParseSubtitlesDuringExtraction](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.Factory.md.txt#experimentalParseSubtitlesDuringExtraction(boolean))(
boolean parseSubtitlesDuringExtraction
)`

**This method is deprecated.**

This method (and all support for 'legacy' subtitle decoding during rendering) will be removed in a future release.

<br />

`MediaSource.Factory` `@UnstableApi
setCmcdConfigurationFactory(
CmcdConfiguration.Factory cmcdConfigurationFactory
)`

Sets the `CmcdConfiguration.Factory` used to obtain a `CmcdConfiguration` for a `MediaItem`.
`MediaSource.Factory` `@UnstableApi
@CanIgnoreReturnValue
setDownloadExecutor(Supplier<ReleasableExecutor> downloadExecutor)`

Sets a supplier for an `ReleasableExecutor` that is used for loading the media.
`MediaSource.Factory` `@UnstableApi
setSubtitleParserFactory(SubtitleParser.Factory subtitleParserFactory)`

Sets the `SubtitleParser.Factory` to be used for parsing subtitles during extraction.

## Public constructors

### Factory

```
public Factory()
```

## Public methods

### createMediaSource

```
public RtspMediaSource createMediaSource(MediaItem mediaItem)
```

Returns a new `RtspMediaSource` using the current parameters.

| Parameters |
|---|---|
| `MediaItem mediaItem` | The `MediaItem`. |

| Returns |
|---|---|
| `RtspMediaSource` | The new `RtspMediaSource`. |

| Throws |
|---|---|
| `java.lang.NullPointerException` | if `localConfiguration` is `null`. |

### getSupportedTypes

```
@C.ContentType
public int[] getSupportedTypes()
```

Returns the `content types` supported by media sources created by this factory.

### 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 |
|---|---|
| `boolean debugLoggingEnabled` | Whether to log RTSP messages. |

| Returns |
|---|---|
| `RtspMediaSource.Factory` | This Factory, for convenience. |

### setDrmSessionManagerProvider

```
public RtspMediaSource.Factory setDrmSessionManagerProvider(
    DrmSessionManagerProvider drmSessionManager
)
```

Does nothing. `RtspMediaSource` does not support DRM.

### 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 |
|---|---|
| `boolean forceUseRtpTcp` | Whether force to use TCP for streaming. |

| Returns |
|---|---|
| `RtspMediaSource.Factory` | This Factory, for convenience. |

### setLoadErrorHandlingPolicy

```
public RtspMediaSource.Factory setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)
```

Does nothing. `RtspMediaSource` does not support error handling policies.

### setSocketFactory

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

Sets a socket factory for `RtspClient`'s connection, the default value is `getDefault`.

| Parameters |
|---|---|
| `SocketFactory socketFactory` | A socket factory. |

| Returns |
|---|---|
| `RtspMediaSource.Factory` | This Factory, for convenience. |

### setTimeoutMs

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

Sets the timeout in milliseconds, the default value is `DEFAULT_TIMEOUT_MS`.

A positive number of milliseconds to wait before lack of received RTP packets is treated as the end of input.

| Parameters |
|---|---|
| `@IntRange(from = 1) long timeoutMs` | The timeout measured in milliseconds. |

| Returns |
|---|---|
| `RtspMediaSource.Factory` | This Factory, for convenience. |

### setUserAgent

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

Sets the user agent, the default value is `VERSION_SLASHY`.

| Parameters |
|---|---|
| `String userAgent` | The user agent. |

| Returns |
|---|---|
| `RtspMediaSource.Factory` | This Factory, for convenience. |