From a1076eb135b74a32e9bdc1aed17aee4374eb41af Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 22 Nov 2013 17:57:31 +0200 Subject: LiveSession: Use the actual, possibly redirected url as base in the M3U This fixes playback of HLS streams where the M3U playlists use relative paths and the main playlist is opened via a redirect. Bug: 13174301 Change-Id: I787e1c050daddc566be4c8e3f84803d3f91eec46 --- media/libstagefright/httplive/LiveSession.cpp | 14 +++++++++++--- media/libstagefright/httplive/LiveSession.h | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'media/libstagefright/httplive') diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index 9e30ebd..687e871 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -623,7 +623,8 @@ status_t LiveSession::fetchFile( const char *url, sp *out, int64_t range_offset, int64_t range_length, uint32_t block_size, /* download block size */ - sp *source /* to return and reuse source */) { + sp *source, /* to return and reuse source */ + String8 *actualUrl) { off64_t size; sp temp_source; if (source == NULL) { @@ -719,6 +720,12 @@ status_t LiveSession::fetchFile( } *out = buffer; + if (actualUrl != NULL) { + *actualUrl = (*source)->getUri(); + if (actualUrl->isEmpty()) { + *actualUrl = url; + } + } return OK; } @@ -730,7 +737,8 @@ sp LiveSession::fetchPlaylist( *unchanged = false; sp buffer; - status_t err = fetchFile(url, &buffer); + String8 actualUrl; + status_t err = fetchFile(url, &buffer, 0, -1, 0, NULL, &actualUrl); if (err != OK) { return NULL; @@ -764,7 +772,7 @@ sp LiveSession::fetchPlaylist( #endif sp playlist = - new M3UParser(url, buffer->data(), buffer->size()); + new M3UParser(actualUrl.string(), buffer->data(), buffer->size()); if (playlist->initCheck() != OK) { ALOGE("failed to parse .m3u8 playlist"); diff --git a/media/libstagefright/httplive/LiveSession.h b/media/libstagefright/httplive/LiveSession.h index e26d024..376d451 100644 --- a/media/libstagefright/httplive/LiveSession.h +++ b/media/libstagefright/httplive/LiveSession.h @@ -207,7 +207,8 @@ private: /* download block size */ uint32_t block_size = 0, /* reuse DataSource if doing partial fetch */ - sp *source = NULL); + sp *source = NULL, + String8 *actualUrl = NULL); sp fetchPlaylist( const char *url, uint8_t *curPlaylistHash, bool *unchanged); -- cgit v1.1