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

Unable to enable gzip Encoding SingleSampleMediaSource #4771

Closed
kartdroid opened this issue Sep 4, 2018 · 4 comments
Closed

Unable to enable gzip Encoding SingleSampleMediaSource #4771

kartdroid opened this issue Sep 4, 2018 · 4 comments
Assignees

Comments

@kartdroid
Copy link

kartdroid commented Sep 4, 2018

Issue description

Unable to enable gzip Encoding for SingleSampleMediaSource

We are using this media source for loading side-car Subtitle tracks and we are seeing improvements if gzip is enabled.
So requesting to add a provision to pass an option to enable/disable gzip encoding acceptance.

Reproduction steps

There is no constructor in SingleSampleMediaSource that accepts allowGzipEncoding as parameter

Link to test content

Mailed to dev.exoplayer@gmail.com

Version of ExoPlayer being used

2.8.4

Device(s) and version(s) of Android being used

Any Androi Device is Applicable

A full bug report captured from the device

This is more of an enhancement request

@ojw28
Copy link
Contributor

ojw28 commented Sep 4, 2018

So requesting to add a provision to pass an option to enable/disable gzip encoding acceptance.

We expect the DataSource to transparently decompress the data. This should happen automatically if you're requesting the data over http using one of ExoPlayer's standard DataSource implementations. So either (a) you're doing this and something is not working as expected, or (b) you're loading data from somewhere else. In the (b) case it may or may not be less clear why gzip would be beneficial, depending on where the data is being loaded from.

Either way I don't think you've described the use case in sufficient detail for us to know what the next steps are. Could you please elaborate a little :). Thanks!

@kartdroid
Copy link
Author

kartdroid commented Sep 7, 2018

@ojw28 We download subtitles from CDN (akamai) using SingleSampleMediaSource which in turn uses DefaultHttpDataSource for pulling it from internet.

When SingleSampleMediaSource is constructed , it creates DataSpec with just URI(there is no provision in SingleSampleMediaSource constructor to pass a DataSpec#Flags)
So , DefaultHttpDataSource hard-codes the Accept-Encoding as identity , compelling the Server to transfer an uncompressed data over internet .

if (!allowGzip) {
      connection.setRequestProperty("Accept-Encoding", "identity");
    }

What we are requesting here is, to expose a parameter in SingleSampleMediaSource to allow passing flags to it's DataSpec object while creation :

private SingleSampleMediaSource(
      Uri uri,
      DataSource.Factory dataSourceFactory,
      Format format,
      long durationUs,
      int minLoadableRetryCount,
      boolean treatLoadErrorsAsEndOfStream,
      @Nullable Object tag) {
    this.dataSourceFactory = dataSourceFactory;
    this.format = format;
    this.durationUs = durationUs;
    this.minLoadableRetryCount = minLoadableRetryCount;
    this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream;
     //################################
     dataSpec = new DataSpec(uri);
   //#################################
    timeline =
        new SinglePeriodTimeline(durationUs, /* isSeekable= */ true, /* isDynamic= */ false, tag);
  }

@ojw28
Copy link
Contributor

ojw28 commented Sep 7, 2018

Got it. I'm not actually sure why we don't use DataSpec.FLAG_ALLOW_GZIP | DataSpec.FLAG_ALLOW_CACHING_UNKNOWN_LENGTH by default in SingleSampleMediaSource, as we do when loading manifests in ParsingLoadable. I can't think of anything that would go wrong. If no-one objects, I'll probably go ahead and do that.

@kartdroid
Copy link
Author

@ojw28 thanks a lot !

ojw28 added a commit that referenced this issue Sep 12, 2018
Issue: #4771

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=212623142
@ojw28 ojw28 closed this as completed Sep 12, 2018
@google google locked and limited conversation to collaborators Jan 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants