summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/httplive/M3UParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/httplive/M3UParser.cpp')
-rw-r--r--media/libstagefright/httplive/M3UParser.cpp54
1 files changed, 26 insertions, 28 deletions
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp
index ae19ffa..587a6d5 100644
--- a/media/libstagefright/httplive/M3UParser.cpp
+++ b/media/libstagefright/httplive/M3UParser.cpp
@@ -126,7 +126,7 @@ void M3UParser::MediaGroup::pickRandomMediaItems() {
mSelectedIndex = strtoul(value, &end, 10);
CHECK(end > value && *end == '\0');
- if (mSelectedIndex >= mMediaItems.size()) {
+ if (mSelectedIndex >= (ssize_t)mMediaItems.size()) {
mSelectedIndex = mMediaItems.size() - 1;
}
} else {
@@ -166,14 +166,14 @@ status_t M3UParser::MediaGroup::selectTrack(size_t index, bool select) {
ALOGE("track %d does not exist", index);
return INVALID_OPERATION;
}
- if (mSelectedIndex == index) {
+ if (mSelectedIndex == (ssize_t)index) {
ALOGE("track %d already selected", index);
return BAD_VALUE;
}
ALOGV("selected track %d", index);
mSelectedIndex = index;
} else {
- if (mSelectedIndex != index) {
+ if (mSelectedIndex != (ssize_t)index) {
ALOGE("track %d is not selected", index);
return BAD_VALUE;
}
@@ -388,18 +388,6 @@ bool M3UParser::getTypeURI(size_t index, const char *key, AString *uri) const {
return true;
}
-bool M3UParser::getAudioURI(size_t index, AString *uri) const {
- return getTypeURI(index, "audio", uri);
-}
-
-bool M3UParser::getVideoURI(size_t index, AString *uri) const {
- return getTypeURI(index, "video", uri);
-}
-
-bool M3UParser::getSubtitleURI(size_t index, AString *uri) const {
- return getTypeURI(index, "subtitles", uri);
-}
-
static bool MakeURL(const char *baseURL, const char *url, AString *out) {
out->clear();
@@ -435,22 +423,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());
@@ -627,7 +625,7 @@ status_t M3UParser::parseMetaDataDuration(
if (meta->get() == NULL) {
*meta = new AMessage;
}
- (*meta)->setInt64(key, (int64_t)x * 1E6);
+ (*meta)->setInt64(key, (int64_t)(x * 1E6));
return OK;
}