Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
warren-bank opened this issue Jun 8, 2023 · 0 comments

Comments

@warren-bank
Copy link

warren-bank commented Jun 8, 2023

  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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants