Fix seek in response to OnPrepared() for HLS content
Change-Id: I0e52352845398a4db074e939487f6f6de94bd523
related-to-bug: 8225122
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
index 1fb8b1a..90aed39 100644
--- a/media/libmediaplayerservice/MediaPlayerFactory.cpp
+++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
@@ -206,7 +206,8 @@
return 0.0;
if (!strncasecmp("http://", url, 7)
- || !strncasecmp("https://", url, 8)) {
+ || !strncasecmp("https://", url, 8)
+ || !strncasecmp("file://", url, 7)) {
size_t len = strlen(url);
if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
return kOurScore;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 5387e1a..46d0a5a 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -161,7 +161,8 @@
static bool IsHTTPLiveURL(const char *url) {
if (!strncasecmp("http://", url, 7)
- || !strncasecmp("https://", url, 8)) {
+ || !strncasecmp("https://", url, 8)
+ || !strncasecmp("file://", url, 7)) {
size_t len = strlen(url);
if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
return true;
@@ -833,14 +834,6 @@
(*decoder)->configure(format);
- int64_t durationUs;
- if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) {
- sp<NuPlayerDriver> driver = mDriver.promote();
- if (driver != NULL) {
- driver->notifyDuration(durationUs);
- }
- }
-
return OK;
}
@@ -1271,6 +1264,14 @@
if (driver != NULL) {
driver->notifyPrepareCompleted(err);
}
+
+ int64_t durationUs;
+ if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) {
+ sp<NuPlayerDriver> driver = mDriver.promote();
+ if (driver != NULL) {
+ driver->notifyDuration(durationUs);
+ }
+ }
break;
}
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 962b01c..505bdb3 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -631,22 +631,20 @@
if (index < mPlaylist->size()) {
int32_t newSeqNumber = firstSeqNumberInPlaylist + index;
- if (newSeqNumber != mSeqNumber) {
- ALOGI("seeking to seq no %d", newSeqNumber);
+ ALOGI("seeking to seq no %d", newSeqNumber);
- mSeqNumber = newSeqNumber;
+ mSeqNumber = newSeqNumber;
- mDataSource->reset();
+ mDataSource->reset();
- // reseting the data source will have had the
- // side effect of discarding any previously queued
- // bandwidth change discontinuity.
- // Therefore we'll need to treat these seek
- // discontinuities as involving a bandwidth change
- // even if they aren't directly.
- seekDiscontinuity = true;
- bandwidthChanged = true;
- }
+ // reseting the data source will have had the
+ // side effect of discarding any previously queued
+ // bandwidth change discontinuity.
+ // Therefore we'll need to treat these seek
+ // discontinuities as involving a bandwidth change
+ // even if they aren't directly.
+ seekDiscontinuity = true;
+ bandwidthChanged = true;
}
}