1301869: try draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 03 Oct 2016 18:56:19 +1100
changeset 420089 a471e4c5b910b4ce3e2f6dbb9413fb656d81e8c2
parent 420088 309104a1b4695c8e92f43a5799eb2cd65aa05c01
child 532714 45406024fedc3887139828ab4b1a38a5043bd6b4
push id31087
push userbmo:jyavenard@mozilla.com
push dateMon, 03 Oct 2016 08:57:18 +0000
bugs1301869
milestone52.0a1
1301869: try MozReview-Commit-ID: Cpij13ICeUo
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -537,16 +537,17 @@ WMFVideoMFTManager::Input(MediaRawData* 
   }
 
   HRESULT hr = mDecoder->CreateInputSample(aSample->Data(),
                                            uint32_t(aSample->Size()),
                                            mCurrentId,
                                            &mLastInput);
   NS_ENSURE_TRUE(SUCCEEDED(hr) && mLastInput != nullptr, hr);
 
+  LOG("Input id:%u", mCurrentId);
   mSamplesTable.AppendElement(SampleEntry(mCurrentId++, aSample->mTime, aSample->mDuration));
 
   mLastDuration = aSample->mDuration;
 
   // Forward sample data to the decoder.
   return mDecoder->Input(mLastInput);
 }
 
@@ -895,47 +896,58 @@ WMFVideoMFTManager::Output(int64_t aStre
           return E_FAIL;
         }
         continue;
       }
       LONGLONG id = 0;
       HRESULT hr = sample->GetSampleTime(&id);
       NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
+      LOG("Output unprocessed id:%lld", id);
       if (id && !mTimestampRatio) {
+        MOZ_ASSERT(mSamplesTable.Length());
         // This is our first non-zero sample. Attempt to determine
         // by how much the MFT has messed with our time.
         int64_t lowestPts = INT64_MAX;
         uint32_t index = 0;
         for (uint32_t i = 0; i < mSamplesTable.Length(); i++) {
           const SampleEntry& entry = mSamplesTable[i];
           if (entry.mTime < lowestPts) {
             lowestPts = entry.mTime;
             index = i;
           }
         }
+        if (!mSamplesTable[index].mId) {
+          // We're about to crash.
+          NS_WARNING(nsPrintfCString("id=%lld index=%u", id, index).get());
+          for (uint32_t i = 0; i < mSamplesTable.Length(); i++) {
+            const SampleEntry& entry = mSamplesTable[i];
+            NS_WARNING(nsPrintfCString("mSamplesTable[%u].mId=%u .mTime=%lld .mDuration=%lld", entry.mId, entry.mTime, entry.mDuration).get());
+          }
+        }
         MOZ_ASSERT(mSamplesTable[index].mId);
         mTimestampRatio = Some(id / mSamplesTable[index].mId);
       }
       id /= mTimestampRatio.refOr(1);
+      LOG("Output processed id:%lld", id);
 
       // Lookup sample id in our table.
       size_t i = 0;
       for (; i < mSamplesTable.Length(); i++) {
         const SampleEntry& entry = mSamplesTable[i];
         if (entry.mId == id) {
           pts = media::TimeUnit::FromMicroseconds(entry.mTime);
           duration = media::TimeUnit::FromMicroseconds(entry.mDuration);
           break;
         }
       }
       if (i == mSamplesTable.Length()) {
         // Entry not found in table... We're doomed.
-        LOG("Unexpected sample id returned.");
         // Return a unique error code that we can identify later.
+        NS_WARNING("Unexpected sample id returned.");
         return NAP_E_MISMATCHED_ID;
       }
       mSamplesTable.RemoveElementAt(i);
 
       if (mSeekTargetThreshold.isSome()) {
         if ((pts + duration) < mSeekTargetThreshold.ref()) {
           LOG("Dropping video frame which pts is smaller than seek target.");
           // It is necessary to clear the pointer to release the previous output