OSDN Git Service

httplive: Dont resume if we have almost fetched till stop time
authorApurupa Pattapu <apurupa@codeaurora.org>
Tue, 14 Oct 2014 22:05:50 +0000 (15:05 -0700)
committerLajos Molnar <lajos@google.com>
Thu, 29 Jan 2015 05:52:09 +0000 (21:52 -0800)
- Use the last enqueued instead of last dequeued time in
  ResumeUntil.
- Set duration in access unit meta as timestamp difference
  between the last two queued access units.

Bug: 18821145
Change-Id: If53ddee1d87775905a6d4f11a6219fe66f498450

media/libstagefright/httplive/PlaylistFetcher.cpp
media/libstagefright/mpeg2ts/AnotherPacketSource.cpp

index 440465c..07c86e5 100644 (file)
@@ -50,7 +50,7 @@ namespace android {
 const int64_t PlaylistFetcher::kMinBufferedDurationUs = 10000000ll;
 const int64_t PlaylistFetcher::kMaxMonitorDelayUs = 3000000ll;
 const int32_t PlaylistFetcher::kDownloadBlockSize = 2048;
-const int32_t PlaylistFetcher::kNumSkipFrames = 10;
+const int32_t PlaylistFetcher::kNumSkipFrames = 5;
 
 PlaylistFetcher::PlaylistFetcher(
         const sp<AMessage> &notify,
@@ -561,7 +561,7 @@ status_t PlaylistFetcher::onResumeUntil(const sp<AMessage> &msg) {
         // Don't resume if we would stop within a resume threshold.
         int32_t discontinuitySeq;
         int64_t latestTimeUs = 0, stopTimeUs = 0;
-        sp<AMessage> latestMeta = packetSource->getLatestDequeuedMeta();
+        sp<AMessage> latestMeta = packetSource->getLatestEnqueuedMeta();
         if (latestMeta != NULL
                 && latestMeta->findInt32("discontinuitySeq", &discontinuitySeq)
                 && discontinuitySeq == mDiscontinuitySeq
@@ -1678,7 +1678,7 @@ void PlaylistFetcher::updateDuration() {
 
 int64_t PlaylistFetcher::resumeThreshold(const sp<AMessage> &msg) {
     int64_t durationUs, threshold;
-    if (msg->findInt64("durationUs", &durationUs)) {
+    if (msg->findInt64("durationUs", &durationUs) && durationUs > 0) {
         return kNumSkipFrames * durationUs;
     }
 
index 0354a2d..f266fe7 100644 (file)
@@ -221,9 +221,16 @@ void AnotherPacketSource::queueAccessUnit(const sp<ABuffer> &buffer) {
         mLatestEnqueuedMeta = buffer->meta()->dup();
     } else {
         int64_t latestTimeUs = 0;
+        int64_t frameDeltaUs = 0;
         CHECK(mLatestEnqueuedMeta->findInt64("timeUs", &latestTimeUs));
         if (lastQueuedTimeUs > latestTimeUs) {
             mLatestEnqueuedMeta = buffer->meta()->dup();
+            frameDeltaUs = lastQueuedTimeUs - latestTimeUs;
+            mLatestEnqueuedMeta->setInt64("durationUs", frameDeltaUs);
+        } else if (!mLatestEnqueuedMeta->findInt64("durationUs", &frameDeltaUs)) {
+            // For B frames
+            frameDeltaUs = latestTimeUs - lastQueuedTimeUs;
+            mLatestEnqueuedMeta->setInt64("durationUs", frameDeltaUs);
         }
     }
 }