From 2a4499a3c10823fad7575b4559cec37e4a65255a Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Wed, 2 Dec 2015 15:37:09 +1300 Subject: [PATCH] Bug 1229508 - Support current and previous GMP_API_DECRYPTORs. r=gerald To allow GMPs time to update to new GMPDecryptor versions, we support the latest GMPDecryptor version, and the previous. In order to support a consistent interface to Gecko, we adapt the previous GMPDecryptor version to the latest in the GMP child process. So Gecko always thinks it's talking to the latest version. We also make gmp-fake deliberately support the previous GMPDecryptor version, to ensure this code path remains tested. --- dom/media/gmp-plugin/fake.info | 2 +- dom/media/gmp-plugin/gmp-fake.cpp | 2 +- dom/media/gmp/GMPContentChild.cpp | 11 ++++++++++- dom/media/gmp/GMPParent.cpp | 6 ++++++ dom/media/gmp/gmp-api/gmp-decryption.h | 4 +++- media/gmp-clearkey/0.1/clearkey.info.in | 4 ++-- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/dom/media/gmp-plugin/fake.info b/dom/media/gmp-plugin/fake.info index 59813a220ca..b0592ff639c 100644 --- a/dom/media/gmp-plugin/fake.info +++ b/dom/media/gmp-plugin/fake.info @@ -1,5 +1,5 @@ Name: fake -Description: Fake GMP Plugin +Description: Fake GMP Plugin, which deliberately uses GMP_API_DECRYPTOR_BACKWARDS_COMPAT for its decryptor. Version: 1.0 APIs: decode-video[h264:broken], eme-decrypt-v7[fake] Libraries: dxva2.dll diff --git a/dom/media/gmp-plugin/gmp-fake.cpp b/dom/media/gmp-plugin/gmp-fake.cpp index 48dd8c43918..53946276adf 100644 --- a/dom/media/gmp-plugin/gmp-fake.cpp +++ b/dom/media/gmp-plugin/gmp-fake.cpp @@ -72,7 +72,7 @@ extern "C" { // happens when decoder init fails. return GMPGenericErr; #if defined(GMP_FAKE_SUPPORT_DECRYPT) - } else if (!strcmp (aApiName, GMP_API_DECRYPTOR)) { + } else if (!strcmp (aApiName, GMP_API_DECRYPTOR_BACKWARDS_COMPAT)) { *aPluginApi = new FakeDecryptor(static_cast (aHostAPI)); return GMPNoErr; } else if (!strcmp (aApiName, GMP_API_ASYNC_SHUTDOWN)) { diff --git a/dom/media/gmp/GMPContentChild.cpp b/dom/media/gmp/GMPContentChild.cpp index 8cb03e4a127..9c35b03874b 100644 --- a/dom/media/gmp/GMPContentChild.cpp +++ b/dom/media/gmp/GMPContentChild.cpp @@ -119,7 +119,16 @@ GMPContentChild::RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor) void* session = nullptr; GMPErr err = mGMPChild->GetAPI(GMP_API_DECRYPTOR, host, &session); if (err != GMPNoErr || !session) { - return false; + // We Adapt the previous GMPDecryptor version to the current, so that + // Gecko thinks it's only talking to the current version. Helpfully, + // v7 is ABI compatible with v8, it only has different enumerations. + // If the GMP uses a v8-only enum value in an IPDL message, the IPC + // layer will terminate, so we rev'd the API version to signal to the + // GMP that it's safe to use the new enum values. + err = mGMPChild->GetAPI(GMP_API_DECRYPTOR_BACKWARDS_COMPAT, host, &session); + if (err != GMPNoErr || !session) { + return false; + } } child->Init(static_cast(session)); diff --git a/dom/media/gmp/GMPParent.cpp b/dom/media/gmp/GMPParent.cpp index df39aa6efd9..7154262ef4a 100644 --- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -868,6 +868,12 @@ GMPParent::ReadGMPMetaData() } } + // We support the current GMPDecryptor version, and the previous. + // We Adapt the previous to the current in the GMPContentChild. + if (cap->mAPIName.EqualsLiteral(GMP_API_DECRYPTOR_BACKWARDS_COMPAT)) { + cap->mAPIName.AssignLiteral(GMP_API_DECRYPTOR); + } + if (cap->mAPIName.EqualsLiteral(GMP_API_DECRYPTOR)) { mCanDecrypt = true; diff --git a/dom/media/gmp/gmp-api/gmp-decryption.h b/dom/media/gmp/gmp-api/gmp-decryption.h index 86c845a424a..ddf27cfb041 100644 --- a/dom/media/gmp/gmp-api/gmp-decryption.h +++ b/dom/media/gmp/gmp-api/gmp-decryption.h @@ -244,7 +244,9 @@ enum GMPSessionType { kGMPSessionInvalid = 2 // Must always be last. }; -#define GMP_API_DECRYPTOR "eme-decrypt-v7" +// Gecko supports the current GMPDecryptor version, and the previous. +#define GMP_API_DECRYPTOR "eme-decrypt-v8" +#define GMP_API_DECRYPTOR_BACKWARDS_COMPAT "eme-decrypt-v7" // API exposed by plugin library to manage decryption sessions. // When the Host requests this by calling GMPGetAPIFunc(). diff --git a/media/gmp-clearkey/0.1/clearkey.info.in b/media/gmp-clearkey/0.1/clearkey.info.in index aca4bc28602..392f47f20ad 100644 --- a/media/gmp-clearkey/0.1/clearkey.info.in +++ b/media/gmp-clearkey/0.1/clearkey.info.in @@ -2,9 +2,9 @@ Name: clearkey Description: ClearKey Gecko Media Plugin Version: 1 #ifdef ENABLE_WMF -APIs: eme-decrypt-v7[org.w3.clearkey], decode-audio[aac:org.w3.clearkey], decode-video[h264:org.w3.clearkey] +APIs: eme-decrypt-v8[org.w3.clearkey], decode-audio[aac:org.w3.clearkey], decode-video[h264:org.w3.clearkey] Libraries: dxva2.dll, d3d9.dll, msmpeg2vdec.dll, msmpeg2adec.dll, MSAudDecMFT.dll, evr.dll, mfheaacdec.dll, mfh264dec.dll, mfplat.dll #else -APIs: eme-decrypt-v7[org.w3.clearkey] +APIs: eme-decrypt-v8[org.w3.clearkey] Libraries: #endif