summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/httplive
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/httplive')
-rw-r--r--media/libstagefright/httplive/LiveSession.cpp17
-rw-r--r--media/libstagefright/httplive/LiveSession.h3
-rw-r--r--media/libstagefright/httplive/M3UParser.cpp34
3 files changed, 35 insertions, 19 deletions
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index bd12ddc..fc1353a 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -514,7 +514,8 @@ sp<PlaylistFetcher> LiveSession::addFetcher(const char *uri) {
status_t LiveSession::fetchFile(
const char *url, sp<ABuffer> *out,
- int64_t range_offset, int64_t range_length) {
+ int64_t range_offset, int64_t range_length,
+ String8 *actualUrl) {
*out = NULL;
sp<DataSource> 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<M3UParser> LiveSession::fetchPlaylist(
*unchanged = false;
sp<ABuffer> buffer;
- status_t err = fetchFile(url, &buffer);
+ String8 actualUrl;
+ status_t err = fetchFile(url, &buffer, 0, -1, &actualUrl);
if (err != OK) {
return NULL;
@@ -632,9 +640,6 @@ sp<M3UParser> LiveSession::fetchPlaylist(
// playlist unchanged
*unchanged = true;
- ALOGV("Playlist unchanged, refresh state is now %d",
- (int)mRefreshState);
-
return NULL;
}
@@ -644,7 +649,7 @@ sp<M3UParser> LiveSession::fetchPlaylist(
#endif
sp<M3UParser> 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<ABuffer> *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<M3UParser> fetchPlaylist(
const char *url, uint8_t *curPlaylistHash, bool *unchanged);
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp
index dd248cb..5ef7c0f 100644
--- a/media/libstagefright/httplive/M3UParser.cpp
+++ b/media/libstagefright/httplive/M3UParser.cpp
@@ -416,22 +416,32 @@ static bool MakeURL(const char *baseURL, const char *url, AString *out) {
} else {
// URL is a relative path
- size_t n = strlen(baseURL);
- if (baseURL[n - 1] == '/') {
- out->setTo(baseURL);
- out->append(url);
+ // Check for a possible query string
+ const char *qsPos = strchr(baseURL, '?');
+ size_t end;
+ if (qsPos != NULL) {
+ end = qsPos - baseURL;
} else {
- const char *slashPos = strrchr(baseURL, '/');
-
- if (slashPos > &baseURL[6]) {
- out->setTo(baseURL, slashPos - baseURL);
- } else {
- out->setTo(baseURL);
+ end = strlen(baseURL);
+ }
+ // Check for the last slash before a potential query string
+ for (ssize_t pos = end - 1; pos >= 0; pos--) {
+ if (baseURL[pos] == '/') {
+ end = pos;
+ break;
}
+ }
- out->append("/");
- out->append(url);
+ // Check whether the found slash actually is part of the path
+ // and not part of the "http://".
+ if (end > 6) {
+ out->setTo(baseURL, end);
+ } else {
+ out->setTo(baseURL);
}
+
+ out->append("/");
+ out->append(url);
}
ALOGV("base:'%s', url:'%s' => '%s'", baseURL, url, out->c_str());