Bug 1297307 - Add extra video duration element for EOS sample. r=snorp
authorJohn Lin <jolin@mozilla.com>
Tue, 30 Aug 2016 17:40:49 +0800
changeset 313046 847eab1caa7c8e78fd0e5bdc8ac41a5c13bed299
parent 313045 5f10d3f47379248797c381742d69af738cf31aad
child 313047 d5338a598b481b9c4653c8b64ab70db66b9362b4
push id20479
push userkwierso@gmail.com
push dateThu, 08 Sep 2016 01:08:46 +0000
treeherderfx-team@fb7c6b034329 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1297307
milestone51.0a1
Bug 1297307 - Add extra video duration element for EOS sample. r=snorp MozReview-Commit-ID: 4QUTABCNT06
dom/media/platforms/android/RemoteDataDecoder.cpp
mobile/android/base/java/org/mozilla/gecko/media/Sample.java
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -144,17 +144,17 @@ public:
       MOZ_ASSERT(ok);
 
       int32_t size;
       ok |= NS_SUCCEEDED(aInfo->Size(&size));
       MOZ_ASSERT(ok);
 
       NS_ENSURE_TRUE_VOID(ok);
 
-      if (size > 0) {
+      if (size > 0 && durationUs.value() > 0) {
         RefPtr<layers::Image> img =
           new SurfaceTextureImage(mDecoder->mSurfaceTexture.get(), mDecoder->mConfig.mDisplay,
                                   gl::OriginPos::BottomLeft);
 
         RefPtr<VideoData> v =
           VideoData::CreateFromImage(mDecoder->mConfig,
                                     offset,
                                     presentationTimeUs,
@@ -166,17 +166,16 @@ public:
                                                   mDecoder->mConfig.mDisplay.width,
                                                   mDecoder->mConfig.mDisplay.height));
 
         mDecoderCallback->Output(v);
       }
 
       if ((flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM) != 0) {
         mDecoderCallback->DrainComplete();
-        return;
       }
     }
 
     friend class RemoteDataDecoder;
 
   private:
     RemoteVideoDecoder* mDecoder;
   };
@@ -218,16 +217,25 @@ public:
   }
 
   nsresult Flush() override
   {
     mInputDurations.Clear();
     return RemoteDataDecoder::Flush();
   }
 
+  nsresult Drain() override
+  {
+    nsresult res = RemoteDataDecoder::Drain();
+    NS_ENSURE_SUCCESS(res, res);
+
+    mInputDurations.Put(0);
+    return NS_OK;
+  }
+
   nsresult Input(MediaRawData* aSample) override
   {
     nsresult res = RemoteDataDecoder::Input(aSample);
     NS_ENSURE_SUCCESS(res, res);
 
     mInputDurations.Put(aSample->mDuration);
     return NS_OK;
   }
@@ -435,17 +443,17 @@ nsresult
 RemoteDataDecoder::Drain()
 {
   BufferInfo::LocalRef bufferInfo;
   nsresult rv = BufferInfo::New(&bufferInfo);
   NS_ENSURE_SUCCESS(rv, rv);
   bufferInfo->Set(0, 0, -1, MediaCodec::BUFFER_FLAG_END_OF_STREAM);
 
   mJavaDecoder->Input(nullptr, bufferInfo);
-  return NS_ERROR_FAILURE;
+  return NS_OK;
 }
 
 nsresult
 RemoteDataDecoder::Shutdown()
 {
   LOG("");
   MOZ_ASSERT(mJavaDecoder && mJavaCallbacks);
 
--- a/mobile/android/base/java/org/mozilla/gecko/media/Sample.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/Sample.java
@@ -34,17 +34,17 @@ public final class Sample implements Par
 
     public static Sample createDummyWithInfo(BufferInfo info) {
         BufferInfo dummyInfo = new BufferInfo();
         dummyInfo.set(0, 0, info.presentationTimeUs, info.flags);
         return new Sample(null, dummyInfo);
     }
 
     public boolean isDummy() {
-        return bytes == null && info.size == 0;
+        return !isEOS() && bytes == null && info.size == 0;
     }
 
     public boolean isEOS() {
         return (info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
     }
 
     public static final Creator<Sample> CREATOR = new Creator<Sample>() {
         @Override