Bug 1351132 - Fix keystatus and decode logging in ChromiumCDMChild. r?gerald draft
authorChris Pearce <cpearce@mozilla.com>
Tue, 28 Mar 2017 11:05:48 +1300
changeset 552080 439653f6c5b332dd22fec23f6086ff1ede2f1be7
parent 552079 05f80a9025abea168ca2ee649316422418d08dc0
child 553358 0ff4dd7e4fce740177cf6149e1decce3065c1ce4
child 553371 f1c5709acdefd4da002ff859aa9c3ef6fb275a4d
push id51244
push userbmo:cpearce@mozilla.com
push dateTue, 28 Mar 2017 00:24:23 +0000
reviewersgerald
bugs1351132
milestone55.0a1
Bug 1351132 - Fix keystatus and decode logging in ChromiumCDMChild. r?gerald MozReview-Commit-ID: xwfJ4WwbmN
dom/media/gmp/ChromiumCDMChild.cpp
--- a/dom/media/gmp/ChromiumCDMChild.cpp
+++ b/dom/media/gmp/ChromiumCDMChild.cpp
@@ -8,16 +8,17 @@
 #include "WidevineUtils.h"
 #include "WidevineFileIO.h"
 #include "WidevineVideoFrame.h"
 #include "GMPLog.h"
 #include "GMPPlatform.h"
 #include "mozilla/Unused.h"
 #include "nsPrintfCString.h"
 #include "base/time.h"
+#include "GMPUtils.h"
 
 namespace mozilla {
 namespace gmp {
 
 ChromiumCDMChild::ChromiumCDMChild(GMPContentChild* aPlugin)
   : mPlugin(aPlugin)
 {
   MOZ_ASSERT(IsOnMessageLoopThread());
@@ -149,25 +150,21 @@ ChromiumCDMChild::OnSessionMessage(const
                                  message);
 }
 
 static nsCString
 ToString(const cdm::KeyInformation* aKeysInfo, uint32_t aKeysInfoCount)
 {
   nsCString str;
   for (uint32_t i = 0; i < aKeysInfoCount; i++) {
-    nsCString keyId;
-    const cdm::KeyInformation& key = aKeysInfo[i];
-    for (size_t k = 0; k < key.key_id_size; k++) {
-      keyId.Append(nsPrintfCString("%hhX", key.key_id[k]));
-    }
     if (!str.IsEmpty()) {
       str.AppendLiteral(",");
     }
-    str.Append(keyId);
+    const cdm::KeyInformation& key = aKeysInfo[i];
+    str.Append(ToHexString(key.key_id, key.key_id_size));
     str.AppendLiteral("=");
     str.AppendInt(key.status);
   }
   return str;
 }
 
 void
 ChromiumCDMChild::OnSessionKeysChange(const char *aSessionId,
@@ -504,34 +501,36 @@ ChromiumCDMChild::RecvResetVideoDecoder(
   Unused << SendResetVideoDecoderComplete();
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ChromiumCDMChild::RecvDecryptAndDecodeFrame(const CDMInputBuffer& aBuffer)
 {
   MOZ_ASSERT(IsOnMessageLoopThread());
-  GMP_LOG("ChromiumCDMChild::RecvDecryptAndDecodeFrame()");
+  GMP_LOG("ChromiumCDMChild::RecvDecryptAndDecodeFrame() t=%" PRId64 ")",
+          aBuffer.mTimestamp());
   MOZ_ASSERT(mDecoderInitialized);
 
   // The output frame may not have the same timestamp as the frame we put in.
   // We may need to input a number of frames before we receive output. The
   // CDM's decoder reorders to ensure frames output are in presentation order.
   // So we need to store the durations of the frames input, and retrieve them
   // on output.
   mFrameDurations.Insert(aBuffer.mTimestamp(), aBuffer.mDuration());
 
   cdm::InputBuffer input;
   nsTArray<cdm::SubsampleEntry> subsamples;
   InitInputBuffer(aBuffer, subsamples, input);
 
   WidevineVideoFrame frame;
   cdm::Status rv = mCDM->DecryptAndDecodeFrame(input, &frame);
-  GMP_LOG("WidevineVideoDecoder::Decode(timestamp=%" PRId64 ") rv=%d",
-          input.timestamp,
+  GMP_LOG("ChromiumCDMChild::RecvDecryptAndDecodeFrame() t=%" PRId64
+          " CDM decoder rv=%d",
+          aBuffer.mTimestamp(),
           rv);
 
   switch (rv) {
     case cdm::kNoKey:
       GMP_LOG("NoKey for sample at time=%" PRId64 "!", input.timestamp);
       // Somehow our key became unusable. Typically this would happen when
       // a stream requires output protection, and the configuration changed
       // such that output protection is no longer available. For example, a