google / google/ExoPlayer

[question] unexpected interactions between: (MediaItem and DownloadRequest) or (TrackSelectionParameters and DownloadService)

Open
#11,200 0 comments 1 reaction 1 assignee Claimed by @microkatz View on GitHub
needs triage question
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

```java
MediaItem.Builder builder = new MediaItem.Builder();

// OK
builder
.setUri(uri)
.setMimeType(uri_mimeType)
.setDrmUuid(Util.getDrmUuid(drm_scheme))
.setDrmLicenseUri(drm_license_server)
.setDrmForceDefaultLicenseUri(false)
.setDrmSessionForClearPeriods(false)
.setDrmPlayClearContentWithoutKey(true)
.setDrmMultiSession(true)
.setDrmLicenseRequestHeaders(drmHeadersMap);

// not OK
builder
.setClipEndPositionMs(stopPosition)
.setClipRelativeToDefaultPosition(true);

// not OK
builder
.setSubtitleConfigurations(subtitleConfigurations);

MediaItem mediaItem = builder.build();

TrackSelectionParameters trackSelectionParameters = DownloadHelper.getDefaultTrackSelectorParameters(context);
DownloadHelper downloadHelper = DownloadHelper.forMediaItem(mediaItem, trackSelectionParameters, renderersFactory, httpDataSourceFactory);
DownloadRequest downloadRequest = downloadHelper.getDownloadRequest( Util.getUtf8Bytes( mediaItem.playbackProperties.uri.toString() ) );

if (downloadRequest.streamKeys.isEmpty()) {
// not OK
}

DownloadService.sendAddDownload(context, MyDownloadService.class, downloadRequest, /* foreground= */ false);
```

* calls to any/all of the `MediaItem.Builder` methods that are marked "not OK", result in:
- `downloadRequest.streamKeys.isEmpty() == true`
- `trackSelectionParameters` are ignored
* every stream in an adaptive manifest will download

1. by avoiding calls that are "not OK" to `MediaItem.Builder`..
* `downloadRequest.streamKeys.isEmpty() == false`
* `trackSelectionParameters` are not ignored
- only the enabled (or "default") tracks are downloaded
2. however, this matter is farther complicated..
* when __both__..
- `trackSelectionParameters` are configured by the user,
and obtained from `player.getTrackSelectionParameters()` for the media that is currently playing
- the media that is currently playing is a `MergingMediaSource`,
and includes at least one external subtitles file (ex: .srt)
* `trackSelectionParameters` obtained in this way are ignored..
- only the "default" tracks are downloaded

Is there a way to sanitize the instance of `TrackSelectionParameters`..
obtained from `player.getTrackSelectionParameters()` when __both__ of the above conditions are true..
that would allow the correct (ie: manually selected) video stream(s) to download?

For example:
```java
TrackSelectionParameters trackSelectionParameters = player.getTrackSelectionParameters()
.buildUpon()
.XXX('???')
.build();
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.