Bug 1075199 - More logging in ClearKey CDM - r=cpearce a=lmandel
authorEdwin Flores <edwin@mozilla.com>
Tue, 27 Jan 2015 18:35:36 +1300
changeset 250192 8fb0193c1399
parent 250191 6cb6bddb9b9d
child 250193 ed78f124783d
push id4521
push usercpearce@mozilla.com
push date2015-03-04 01:22 +0000
treeherdermozilla-beta@8abdbdecd2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1075199
milestone37.0
Bug 1075199 - More logging in ClearKey CDM - r=cpearce a=lmandel
media/gmp-clearkey/0.1/AudioDecoder.cpp
media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
media/gmp-clearkey/0.1/ClearKeyUtils.cpp
--- a/media/gmp-clearkey/0.1/AudioDecoder.cpp
+++ b/media/gmp-clearkey/0.1/AudioDecoder.cpp
@@ -112,16 +112,17 @@ AudioDecoder::DecodeTask(GMPAudioSamples
   std::vector<uint8_t> buffer(inBuffer, inBuffer + aInput->Size());
   if (crypto) {
     // Plugin host should have set up its decryptor/key sessions
     // before trying to decode!
     GMPErr rv =
       ClearKeyDecryptionManager::Get()->Decrypt(&buffer[0], buffer.size(), crypto);
 
     if (GMP_FAILED(rv)) {
+      CK_LOGE("Failed to decrypt with key id %08x...", *(uint32_t*)crypto->KeyId());
       GetPlatform()->runonmainthread(WrapTask(mCallback, &GMPAudioDecoderCallback::Error, rv));
       return;
     }
   }
 
   hr = mDecoder->Input(&buffer[0],
                        buffer.size(),
                        aInput->TimeStamp());
--- a/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
@@ -56,24 +56,24 @@ ClearKeyDecryptionManager::~ClearKeyDecr
     it->second->Release();
   }
   mDecryptors.clear();
 }
 
 bool
 ClearKeyDecryptionManager::HasSeenKeyId(const KeyId& aKeyId) const
 {
-  CK_LOGD("ClearKeyDecryptionManager::HasSeenKeyId");
+  CK_LOGD("ClearKeyDecryptionManager::SeenKeyId %s", mDecryptors.find(aKeyId) != mDecryptors.end() ? "t" : "f");
   return mDecryptors.find(aKeyId) != mDecryptors.end();
 }
 
 bool
 ClearKeyDecryptionManager::IsExpectingKeyForKeyId(const KeyId& aKeyId) const
 {
-  CK_LOGD("ClearKeyDecryptionManager::IsExpectingKeyForKeyId");
+  CK_LOGD("ClearKeyDecryptionManager::IsExpectingKeyForId %08x...", *(uint32_t*)&aKeyId[0]);
   const auto& decryptor = mDecryptors.find(aKeyId);
   return decryptor != mDecryptors.end() && !decryptor->second->HasKey();
 }
 
 bool
 ClearKeyDecryptionManager::HasKeyForKeyId(const KeyId& aKeyId) const
 {
   CK_LOGD("ClearKeyDecryptionManager::HasKeyForKeyId");
@@ -86,36 +86,38 @@ ClearKeyDecryptionManager::GetDecryption
 {
   MOZ_ASSERT(HasKeyForKeyId(aKeyId));
   return mDecryptors[aKeyId]->DecryptionKey();
 }
 
 void
 ClearKeyDecryptionManager::InitKey(KeyId aKeyId, Key aKey)
 {
-  CK_LOGD("ClearKeyDecryptionManager::InitKey");
+  CK_LOGD("ClearKeyDecryptionManager::InitKey %08x...", *(uint32_t*)&aKeyId[0]);
   if (IsExpectingKeyForKeyId(aKeyId)) {
     mDecryptors[aKeyId]->InitKey(aKey);
   }
 }
 
 void
 ClearKeyDecryptionManager::ExpectKeyId(KeyId aKeyId)
 {
-  CK_LOGD("ClearKeyDecryptionManager::ExpectKeyId");
+  CK_LOGD("ClearKeyDecryptionManager::ExpectKeyId %08x...", *(uint32_t*)&aKeyId[0]);
   if (!HasSeenKeyId(aKeyId)) {
     mDecryptors[aKeyId] = new ClearKeyDecryptor();
   }
   mDecryptors[aKeyId]->AddRef();
 }
 
 void
 ClearKeyDecryptionManager::ReleaseKeyId(KeyId aKeyId)
 {
   CK_LOGD("ClearKeyDecryptionManager::ReleaseKeyId");
+  MOZ_ASSERT(HasKeyForKeyId(aKeyId));
+
   ClearKeyDecryptor* decryptor = mDecryptors[aKeyId];
   if (!decryptor->Release()) {
     mDecryptors.erase(aKeyId);
   }
 }
 
 GMPErr
 ClearKeyDecryptionManager::Decrypt(uint8_t* aBuffer, uint32_t aBufferSize,
@@ -133,17 +135,17 @@ ClearKeyDecryptionManager::Decrypt(uint8
 
 ClearKeyDecryptor::ClearKeyDecryptor()
 {
   CK_LOGD("ClearKeyDecryptor ctor");
 }
 
 ClearKeyDecryptor::~ClearKeyDecryptor()
 {
-  CK_LOGD("ClearKeyDecryptor dtor; key ID = %08x...", *(uint32_t*)&mKey[0]);
+  CK_LOGD("ClearKeyDecryptor dtor; key = %08x...", *(uint32_t*)&mKey[0]);
 }
 
 void
 ClearKeyDecryptor::InitKey(const Key& aKey)
 {
   mKey = aKey;
 }
 
--- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
@@ -15,28 +15,28 @@
 #include "mozilla/Assertions.h"
 
 using namespace mozilla;
 using namespace std;
 
 ClearKeySessionManager::ClearKeySessionManager()
   : mDecryptionManager(ClearKeyDecryptionManager::Get())
 {
-  CK_LOGD("ClearKeySessionManager ctor");
+  CK_LOGD("ClearKeySessionManager ctor %p", this);
   AddRef();
 
   if (GetPlatform()->createthread(&mThread) != GMPNoErr) {
     CK_LOGD("failed to create thread in clearkey cdm");
     mThread = nullptr;
   }
 }
 
 ClearKeySessionManager::~ClearKeySessionManager()
 {
-  CK_LOGD("ClearKeySessionManager dtor");
+  CK_LOGD("ClearKeySessionManager dtor %p", this);
    MOZ_ASSERT(!mRefCount);
 }
 
 static bool
 CanDecode()
 {
   return
 #if defined(ENABLE_WMF)
@@ -367,28 +367,28 @@ ClearKeySessionManager::DoDecrypt(GMPBuf
                                               aMetadata);
   CK_LOGD("DeDecrypt finished with code %x\n", rv);
   mCallback->Decrypted(aBuffer, rv);
 }
 
 void
 ClearKeySessionManager::Shutdown()
 {
-  CK_LOGD("ClearKeySessionManager::Shutdown");
+  CK_LOGD("ClearKeySessionManager::Shutdown %p", this);
 
   for (auto it = mSessions.begin(); it != mSessions.end(); it++) {
     delete it->second;
   }
   mSessions.clear();
 }
 
 void
 ClearKeySessionManager::DecryptingComplete()
 {
-  CK_LOGD("ClearKeySessionManager::DecryptingComplete");
+  CK_LOGD("ClearKeySessionManager::DecryptingComplete %p", this);
 
   GMPThread* thread = mThread;
   thread->Join();
 
   Shutdown();
   mDecryptionManager = nullptr;
   Release();
 }
--- a/media/gmp-clearkey/0.1/ClearKeyUtils.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyUtils.cpp
@@ -30,16 +30,17 @@ CK_Log(const char* aFmt, ...)
 {
   va_list ap;
 
   va_start(ap, aFmt);
   vprintf(aFmt, ap);
   va_end(ap);
 
   printf("\n");
+  fflush(stdout);
 }
 
 static void
 IncrementIV(vector<uint8_t>& aIV) {
   using mozilla::BigEndian;
 
   MOZ_ASSERT(aIV.size() == 16);
   BigEndian::writeUint64(&aIV[8], BigEndian::readUint64(&aIV[8]) + 1);