summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/httplive/M3UParser.cpp
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-07-19 15:04:53 -0700
committerAndreas Huber <andih@google.com>2011-07-19 15:04:53 -0700
commitd6a46a6bda23667e06ee5ccca3781e407c7d1204 (patch)
tree87b9586bceaf9a11880ff9ee1d3150c85c5ed5ea /media/libstagefright/httplive/M3UParser.cpp
parent8ebe5be6b0b3caa7d9d6277a1216ed786bd1e66a (diff)
downloadframeworks_av-d6a46a6bda23667e06ee5ccca3781e407c7d1204.tar.gz
frameworks_av-d6a46a6bda23667e06ee5ccca3781e407c7d1204.tar.bz2
frameworks_av-d6a46a6bda23667e06ee5ccca3781e407c7d1204.zip
More HLS fixes
properly expand URLs where the "new" URL is an absolute path. properly include any extra headers even when fetching the key files. Change-Id: I7cd8879015ea8e3d3e2334f4e7e16b8c1a5d48e9
Diffstat (limited to 'media/libstagefright/httplive/M3UParser.cpp')
-rw-r--r--media/libstagefright/httplive/M3UParser.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp
index 123fbf8b23..9df9f59a8e 100644
--- a/media/libstagefright/httplive/M3UParser.cpp
+++ b/media/libstagefright/httplive/M3UParser.cpp
@@ -106,21 +106,38 @@ static bool MakeURL(const char *baseURL, const char *url, AString *out) {
return true;
}
- size_t n = strlen(baseURL);
- if (baseURL[n - 1] == '/') {
- out->setTo(baseURL);
- out->append(url);
- } else {
- const char *slashPos = strrchr(baseURL, '/');
+ if (url[0] == '/') {
+ // URL is an absolute path.
+
+ char *protocolEnd = strstr(baseURL, "//") + 2;
+ char *pathStart = strchr(protocolEnd, '/');
- if (slashPos > &baseURL[6]) {
- out->setTo(baseURL, slashPos - baseURL);
+ if (pathStart != NULL) {
+ out->setTo(baseURL, pathStart - baseURL);
} else {
out->setTo(baseURL);
}
- out->append("/");
out->append(url);
+ } else {
+ // URL is a relative path
+
+ size_t n = strlen(baseURL);
+ if (baseURL[n - 1] == '/') {
+ out->setTo(baseURL);
+ out->append(url);
+ } else {
+ const char *slashPos = strrchr(baseURL, '/');
+
+ if (slashPos > &baseURL[6]) {
+ out->setTo(baseURL, slashPos - baseURL);
+ } else {
+ out->setTo(baseURL);
+ }
+
+ out->append("/");
+ out->append(url);
+ }
}
LOGV("base:'%s', url:'%s' => '%s'", baseURL, url, out->c_str());