Create unique cdm engines per WVDrmPlugin instance
This change creates a unique id in the cdm identifier in order to force a one-to-one mapping between WVDrmPlugin instances and CDM Engines. This change simplifies some assumptions. This includes ensuring that the metrics for a given MediaDrm instance map to a given CdmEngine instance. Bug: 73724453 Test: Updated unit tests. GTS test pass. Shaka Player, Netflix and Google Play test. Change-Id: I7e041b6cdf3e272d067da49d25a297b4a4663f1f
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "media/stagefright/foundation/ABase.h"
|
||||
#include "media/stagefright/foundation/AString.h"
|
||||
#include "media/stagefright/MediaErrors.h"
|
||||
#include "string_conversions.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include "wv_content_decryption_module.h"
|
||||
@@ -33,14 +34,18 @@ const uint8_t* const kUnprovisionResponse =
|
||||
reinterpret_cast<const uint8_t*>("unprovision");
|
||||
const size_t kUnprovisionResponseSize = 11;
|
||||
|
||||
// This is a serialized MetricsGroup message containing a small amount of
|
||||
// This is a serialized WvCdmMetrics message containing a small amount of
|
||||
// sample data. This ensures we're able to extract it via a property.
|
||||
const char kSerializedMetrics[] = {
|
||||
0x0a, 0x0a, 0x0a, 0x04, 0x74, 0x65, 0x73, 0x74, 0x12, 0x02, 0x08, 0x00,
|
||||
0x0a, 0x12, 0x0a, 0x05, 0x74, 0x65, 0x73, 0x74, 0x32, 0x12, 0x09, 0x11,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x15, 0x0a, 0x05,
|
||||
0x74, 0x65, 0x73, 0x74, 0x33, 0x12, 0x0c, 0x1a, 0x0a, 0x74, 0x65, 0x73,
|
||||
0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65};
|
||||
const char kSerializedMetricsHex[] =
|
||||
"0a580a001a0210072202100d2a02100832182216636f6d2e676f6f676c652e616e64726f69"
|
||||
"642e676d734208220631342e302e304a06080112020800520610d5f3fad5056a0b1d00fd4c"
|
||||
"47280132020804a2010608011202080012cb010a0622047369643412b5010a021001520919"
|
||||
"1d5a643bdfff50405a0b1d00d01945280132021001620d1d00f8e84528013204080020006a"
|
||||
"0310b739820102100d8a01060801120248009a010310ff01da0106080112024800e2010e1d"
|
||||
"005243472801320528800248009a020d1d00b016452801320428404800a202060801120248"
|
||||
"19aa0206080212024800b2020b1d8098f047280132024800ba02021001ca020b1d00101945"
|
||||
"280132024800e202021004fa02021002a203021000b2030210021a09196891ed7c3f355040";
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
class MockCDM : public WvContentDecryptionModule {
|
||||
@@ -108,7 +113,8 @@ class MockCDM : public WvContentDecryptionModule {
|
||||
|
||||
MOCK_METHOD1(IsValidServiceCertificate, bool(const std::string&));
|
||||
|
||||
MOCK_METHOD1(GetSerializedMetrics, void(std::string*));
|
||||
MOCK_METHOD2(GetMetrics, CdmResponseType(const CdmIdentifier&,
|
||||
drm_metrics::WvCdmMetrics*));
|
||||
};
|
||||
|
||||
class MockCrypto : public WVGenericCryptoInterface {
|
||||
@@ -850,8 +856,10 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
static const string oemCryptoApiVersion = "10";
|
||||
static const string currentSRMVersion = "1";
|
||||
static const string cdmVersion = "Infinity Minus 1";
|
||||
string serializedMetrics(kSerializedMetrics,
|
||||
kSerializedMetrics + sizeof(kSerializedMetrics));
|
||||
|
||||
drm_metrics::WvCdmMetrics expected_metrics;
|
||||
std::string serialized_metrics = wvcdm::a2bs_hex(kSerializedMetricsHex);
|
||||
ASSERT_TRUE(expected_metrics.ParseFromString(serialized_metrics));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_SECURITY_LEVEL, _))
|
||||
.WillOnce(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L1),
|
||||
@@ -895,8 +903,9 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
.WillOnce(DoAll(SetArgPointee<2>(cdmVersion),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, GetSerializedMetrics(_))
|
||||
.WillOnce(SetArgPointee<0>(serializedMetrics));
|
||||
EXPECT_CALL(*cdm, GetMetrics(_, _))
|
||||
.WillOnce(DoAll(SetArgPointee<1>(expected_metrics),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
String8 stringResult;
|
||||
Vector<uint8_t> vectorResult;
|
||||
@@ -962,8 +971,8 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
vectorResult.clear();
|
||||
res = plugin.getPropertyByteArray(String8("metrics"), vectorResult);
|
||||
ASSERT_EQ(OK, res);
|
||||
EXPECT_THAT(vectorResult, ElementsAreArray(serializedMetrics.data(),
|
||||
serializedMetrics.size()));
|
||||
EXPECT_THAT(vectorResult, ElementsAreArray(serialized_metrics.data(),
|
||||
serialized_metrics.size()));
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginTest, DoesNotGetUnknownProperties) {
|
||||
|
||||
Reference in New Issue
Block a user