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

Can't get correct ts url with CacheDataSource when playing hls with a 302 status code #2360

Closed
cr1944 opened this issue Jan 23, 2017 · 1 comment
Assignees
Labels

Comments

@cr1944
Copy link

cr1944 commented Jan 23, 2017

  • Condition:
  1. a hls video url URL1( host is "A"), the response code is 302 and the location is the real m3u8 url URL2( host is "B")
  2. the response is hls playlist, and the segment url is not absolute path, like this:

/u7wPKxRMeOWP3oNt3QCX7_8Ot1w=/luFxh3E0vkK_W_gtsUvwNTzPRszl/000000.ts?e=1485201754

  1. use DefaultDataSource or CacheDataSource to load the data.
  • Result:
  1. if I use DefaultDataSource:
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, BANDWIDTH_METER,
                new OkHttpDataSourceFactory(getOkHttpClient(), getUa(), BANDWIDTH_METER));
return new HlsMediaSource(uri, dataSourceFactory, mainHandler, eventLogger);

the ParsingLoadable will use datasource's uri:
result = parser.parse(dataSource.getUri(), inputStream);
exoplayer will correctly use URL2's host "B" to join the ts segment url.
2. if I use CacheDataSource, however,exoplayer will use URL1's host "A", which is wrong, the response code will be 404:

 CacheEvictor cacheEvictor = new LeastRecentlyUsedCacheEvictor(100 * 1024 * 1024);
        Cache cache = new SimpleCache(new File(getExternalCacheDir(), "media_cache"), cacheEvictor);
        DataSource.Factory upstreamFactory = new OkHttpDataSourceFactory(getOkHttpClient(), getUa(), BANDWIDTH_METER);
        DataSource.Factory dataSourceFactory = new CacheDataSourceFactory(cache, upstreamFactory, CacheDataSource.FLAG_BLOCK_ON_CACHE, 100 * 1024 * 1024);
return new HlsMediaSource(uri, dataSourceFactory, mainHandler, eventLogger);

The reason is, DefaultDataSource.getUri() calls OkHttpDataSource.getUri(), which handle 302 correctly.But CacheDataSource.getUri() will just return the original uri, which is wrong.

  • The version of ExoPlayer is r2.1.1.
@cr1944 cr1944 changed the title Can get correct ts url with CacheDataSource when playing hls with a 302 status code Can't get correct ts url with CacheDataSource when playing hls with a 302 status code Jan 23, 2017
@cr1944
Copy link
Author

cr1944 commented Jan 23, 2017

I have send a test url to [email protected]

@ojw28 ojw28 added the bug label Aug 5, 2017
ojw28 pushed a commit that referenced this issue Mar 28, 2018
Issue: #2360

-------------
Created by MOE: https:/google/moe
MOE_MIGRATED_REVID=190597773
@ojw28 ojw28 closed this as completed Mar 28, 2018
@google google locked and limited conversation to collaborators Aug 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants