From 784faaf1d76902be6b36d3af01fb5325f0d45a04 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. Change-Id: I787e1c050daddc566be4c8e3f84803d3f91eec46 --- media/libstagefright/httplive/LiveSession.cpp | 14 +++++++++++--- media/libstagefright/httplive/LiveSession.h | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index bd12ddc..d4fd2b3 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -514,7 +514,8 @@ sp LiveSession::addFetcher(const char *uri) { status_t LiveSession::fetchFile( const char *url, sp *out, - int64_t range_offset, int64_t range_length) { + int64_t range_offset, int64_t range_length, + String8 *actualUrl) { *out = NULL; sp source; @@ -599,6 +600,12 @@ status_t LiveSession::fetchFile( } *out = buffer; + if (actualUrl != NULL) { + *actualUrl = source->getUri(); + if (actualUrl->isEmpty()) { + *actualUrl = url; + } + } return OK; } @@ -610,7 +617,8 @@ sp LiveSession::fetchPlaylist( *unchanged = false; sp buffer; - status_t err = fetchFile(url, &buffer); + String8 actualUrl; + status_t err = fetchFile(url, &buffer, 0, -1, &actualUrl); if (err != OK) { return NULL; @@ -644,7 +652,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 99b480a8..8f6a4ea 100644 --- a/media/libstagefright/httplive/LiveSession.h +++ b/media/libstagefright/httplive/LiveSession.h @@ -147,7 +147,8 @@ private: status_t fetchFile( const char *url, sp *out, - int64_t range_offset = 0, int64_t range_length = -1); + int64_t range_offset = 0, int64_t range_length = -1, + String8 *actualUrl = NULL); sp fetchPlaylist( const char *url, uint8_t *curPlaylistHash, bool *unchanged); -- cgit v1.1