summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice/nuplayer
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2013-02-06 10:44:39 -0800
committerAndreas Huber <andih@google.com>2013-02-06 10:44:39 -0800
commit0c3f0fa983107a8b5a4d6274179d15333fde8d3c (patch)
tree6ede9b14751812fcd5b9101e3f53a1910a3ac7a5 /media/libmediaplayerservice/nuplayer
parent7f475c34ffc8e35345f2cceee2ef56a50bb5fea6 (diff)
downloadframeworks_av-0c3f0fa983107a8b5a4d6274179d15333fde8d3c.zip
frameworks_av-0c3f0fa983107a8b5a4d6274179d15333fde8d3c.tar.gz
frameworks_av-0c3f0fa983107a8b5a4d6274179d15333fde8d3c.tar.bz2
HLS now properly publishes its "seekable" flags after connection
has successfully completed and a sufficient amount of data fetched, and only then signals that preparation is completed. Change-Id: I7684a14238b826909f518f2af506966e522dfcfc
Diffstat (limited to 'media/libmediaplayerservice/nuplayer')
-rw-r--r--media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp74
-rw-r--r--media/libmediaplayerservice/nuplayer/HTTPLiveSource.h8
2 files changed, 65 insertions, 17 deletions
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
index ae67906..655ee55 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
@@ -71,7 +71,10 @@ void NuPlayer::HTTPLiveSource::prepareAsync() {
mLiveLooper->setName("http live");
mLiveLooper->start();
+ sp<AMessage> notify = new AMessage(kWhatSessionNotify, id());
+
mLiveSession = new LiveSession(
+ notify,
(mFlags & kFlagIncognito) ? LiveSession::kFlagIncognito : 0,
mUIDValid, mUID);
@@ -81,23 +84,6 @@ void NuPlayer::HTTPLiveSource::prepareAsync() {
mURL.c_str(), mExtraHeaders.isEmpty() ? NULL : &mExtraHeaders);
mTSParser = new ATSParser;
-
- notifyVideoSizeChanged(0, 0);
-
- uint32_t flags = FLAG_CAN_PAUSE;
- if (mLiveSession->isSeekable()) {
- flags |= FLAG_CAN_SEEK;
- flags |= FLAG_CAN_SEEK_BACKWARD;
- flags |= FLAG_CAN_SEEK_FORWARD;
- }
-
- if (mLiveSession->hasDynamicDuration()) {
- flags |= FLAG_DYNAMIC_DURATION;
- }
-
- notifyFlagsChanged(flags);
-
- notifyPrepared();
}
void NuPlayer::HTTPLiveSource::start() {
@@ -214,5 +200,59 @@ status_t NuPlayer::HTTPLiveSource::seekTo(int64_t seekTimeUs) {
return OK;
}
+void NuPlayer::HTTPLiveSource::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatSessionNotify:
+ {
+ onSessionNotify(msg);
+ break;
+ }
+
+ default:
+ Source::onMessageReceived(msg);
+ break;
+ }
+}
+
+void NuPlayer::HTTPLiveSource::onSessionNotify(const sp<AMessage> &msg) {
+ int32_t what;
+ CHECK(msg->findInt32("what", &what));
+
+ switch (what) {
+ case LiveSession::kWhatPrepared:
+ {
+ notifyVideoSizeChanged(0, 0);
+
+ uint32_t flags = FLAG_CAN_PAUSE;
+ if (mLiveSession->isSeekable()) {
+ flags |= FLAG_CAN_SEEK;
+ flags |= FLAG_CAN_SEEK_BACKWARD;
+ flags |= FLAG_CAN_SEEK_FORWARD;
+ }
+
+ if (mLiveSession->hasDynamicDuration()) {
+ flags |= FLAG_DYNAMIC_DURATION;
+ }
+
+ notifyFlagsChanged(flags);
+
+ notifyPrepared();
+ break;
+ }
+
+ case LiveSession::kWhatPreparationFailed:
+ {
+ status_t err;
+ CHECK(msg->findInt32("err", &err));
+
+ notifyPrepared(err);
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
index 269f3c0..067d1da 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
@@ -49,12 +49,18 @@ protected:
virtual sp<MetaData> getFormatMeta(bool audio);
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
private:
enum Flags {
// Don't log any URLs.
kFlagIncognito = 1,
};
+ enum {
+ kWhatSessionNotify,
+ };
+
AString mURL;
KeyedVector<String8, String8> mExtraHeaders;
bool mUIDValid;
@@ -66,6 +72,8 @@ private:
sp<LiveSession> mLiveSession;
sp<ATSParser> mTSParser;
+ void onSessionNotify(const sp<AMessage> &msg);
+
DISALLOW_EVIL_CONSTRUCTORS(HTTPLiveSource);
};