Support for a "preparation" state that can take care of lengthy

operations in NuPlayer and its sources. Sources also can publish their
flags now and the mediaplayer UI will be able to pick up on these.

Change-Id: I4f2b7e5d105dcb4b6c9132cd0e8799efa0c6a14b
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
index d38ee62..ae67906 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
@@ -66,7 +66,7 @@
     }
 }
 
-void NuPlayer::HTTPLiveSource::start() {
+void NuPlayer::HTTPLiveSource::prepareAsync() {
     mLiveLooper = new ALooper;
     mLiveLooper->setName("http live");
     mLiveLooper->start();
@@ -81,6 +81,26 @@
             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() {
 }
 
 sp<MetaData> NuPlayer::HTTPLiveSource::getFormatMeta(bool audio) {
@@ -194,18 +214,5 @@
     return OK;
 }
 
-uint32_t NuPlayer::HTTPLiveSource::flags() const {
-    uint32_t flags = 0;
-    if (mLiveSession->isSeekable()) {
-        flags |= FLAG_SEEKABLE;
-    }
-
-    if (mLiveSession->hasDynamicDuration()) {
-        flags |= FLAG_DYNAMIC_DURATION;
-    }
-
-    return flags;
-}
-
 }  // namespace android