Skip to content

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

@warren-bank

Description

@warren-bank
  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:

  TrackSelectionParameters trackSelectionParameters = player.getTrackSelectionParameters()
    .buildUpon()
    .XXX('???')
    .build();

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions