# SegmentDownloader.BaseFactory

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/offline/SegmentDownloader.java+class:androidx.media3.exoplayer.offline.SegmentDownloader.BaseFactory)

*** ** * ** ***


```
protected abstract class SegmentDownloader.BaseFactory<M extends FilterableManifest<M>>
```

<br />

Known direct subclasses [DashDownloader.Factory](https://developer.android.com/reference/androidx/media3/exoplayer/dash/offline/DashDownloader.Factory), [HlsDownloader.Factory](https://developer.android.com/reference/androidx/media3/exoplayer/hls/offline/HlsDownloader.Factory), [SsDownloader.Factory](https://developer.android.com/reference/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.Factory)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/offline/DashDownloader.Factory` | A factory for `https://developer.android.com/reference/androidx/media3/exoplayer/dash/offline/DashDownloader`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/offline/HlsDownloader.Factory` | A factory for `https://developer.android.com/reference/androidx/media3/exoplayer/hls/offline/HlsDownloader`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.Factory` | A factory for `https://developer.android.com/reference/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader`. |

*** ** * ** ***

A base class of the factory of the concrete extension of `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader`.

## Summary

| ### Protected fields |
|---|---|
| `final https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#cacheDataSourceFactory()` |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#durationUs()` |
| `https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#executor()` |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<M>` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#manifestParser()` |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#maxMergedSegmentStartTimeDiffMs()` |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#startPositionUs()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#BaseFactory(androidx.media3.datasource.cache.CacheDataSource.Factory,androidx.media3.exoplayer.upstream.ParsingLoadable.Parser<M>)( https://developer.android.com/reference/androidx/media3/datasource/cache/CacheDataSource.Factory cacheDataSourceFactory, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/ParsingLoadable.Parser<M> manifestParser )` |

| ### Public methods |
|---|---|
| `abstract https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader<@https://developer.android.com/reference/androidx/annotation/NonNull ?>` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#create(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Creates the segment downloader. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory<M>` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#setDurationUs(long)(long durationUs)` Sets the duration in microseconds from the `startPositionUs` to be downloaded, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the media should be downloaded to the end. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory<M>` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#setExecutor(java.util.concurrent.Executor)(https://developer.android.com/reference/java/util/concurrent/Executor.html executor)` Sets the `https://developer.android.com/reference/java/util/concurrent/Executor.html` used to make requests for the media being downloaded. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory<M>` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#setMaxMergedSegmentStartTimeDiffMs(long)( long maxMergedSegmentStartTimeDiffMs )` Sets the maximum difference of the start time of two segments, up to which the segments (of the same URI) should be merged into a single download segment, in milliseconds. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory<M>` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/offline/SegmentDownloader.BaseFactory#setStartPositionUs(long)(long startPositionUs)` Sets the start position in microseconds that the download should start from. |

## Protected fields

### cacheDataSourceFactory

```
protected final CacheDataSource.Factory cacheDataSourceFactory
```

### durationUs

```
protected long durationUs
```

### executor

```
protected Executor executor
```

### manifestParser

```
protected ParsingLoadable.Parser<M> manifestParser
```

### maxMergedSegmentStartTimeDiffMs

```
protected long maxMergedSegmentStartTimeDiffMs
```

### startPositionUs

```
protected long startPositionUs
```

## Public constructors

### BaseFactory

```
public BaseFactory(
    CacheDataSource.Factory cacheDataSourceFactory,
    ParsingLoadable.Parser<M> manifestParser
)
```

## Public methods

### create

```
public abstract SegmentDownloader<@NonNull ?> create(MediaItem mediaItem)
```

Creates the segment downloader.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` to be downloaded. |

### setDurationUs

```
@CanIgnoreReturnValue
public SegmentDownloader.BaseFactory<M> setDurationUs(long durationUs)
```

Sets the duration in microseconds from the `startPositionUs` to be downloaded, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the media should be downloaded to the end.

### setExecutor

```
@CanIgnoreReturnValue
public SegmentDownloader.BaseFactory<M> setExecutor(Executor executor)
```

Sets the `https://developer.android.com/reference/java/util/concurrent/Executor.html` used to make requests for the media being downloaded. Providing an `https://developer.android.com/reference/java/util/concurrent/Executor.html` that uses multiple threads will speed up the download by allowing parts of it to be executed in parallel.

### setMaxMergedSegmentStartTimeDiffMs

```
@CanIgnoreReturnValue
public SegmentDownloader.BaseFactory<M> setMaxMergedSegmentStartTimeDiffMs(
    long maxMergedSegmentStartTimeDiffMs
)
```

Sets the maximum difference of the start time of two segments, up to which the segments (of the same URI) should be merged into a single download segment, in milliseconds.

### setStartPositionUs

```
@CanIgnoreReturnValue
public SegmentDownloader.BaseFactory<M> setStartPositionUs(long startPositionUs)
```

Sets the start position in microseconds that the download should start from.