diff --git a/packager/media/base/fixed_key_source.cc b/packager/media/base/fixed_key_source.cc index bae4c5de22..2688d01294 100644 --- a/packager/media/base/fixed_key_source.cc +++ b/packager/media/base/fixed_key_source.cc @@ -21,7 +21,8 @@ Status FixedKeySource::FetchKeys(EmeInitDataType init_data_type, return Status::OK; } -Status FixedKeySource::GetKey(TrackType track_type, EncryptionKey* key) { +Status FixedKeySource::GetKey(const std::string& stream_label, + EncryptionKey* key) { DCHECK(key); DCHECK(encryption_key_); *key = *encryption_key_; @@ -43,7 +44,7 @@ Status FixedKeySource::GetKey(const std::vector& key_id, } Status FixedKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key) { // Create a copy of the key. *key = *encryption_key_; diff --git a/packager/media/base/fixed_key_source.h b/packager/media/base/fixed_key_source.h index df07d946de..0a8ed06b76 100644 --- a/packager/media/base/fixed_key_source.h +++ b/packager/media/base/fixed_key_source.h @@ -32,11 +32,11 @@ class FixedKeySource : public KeySource { /// @{ Status FetchKeys(EmeInitDataType init_data_type, const std::vector& init_data) override; - Status GetKey(TrackType track_type, EncryptionKey* key) override; + Status GetKey(const std::string& stream_label, EncryptionKey* key) override; Status GetKey(const std::vector& key_id, EncryptionKey* key) override; Status GetCryptoPeriodKey(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key) override; /// @} diff --git a/packager/media/base/fixed_key_source_unittest.cc b/packager/media/base/fixed_key_source_unittest.cc index 34f61bdf80..9f5aa4b8cb 100644 --- a/packager/media/base/fixed_key_source_unittest.cc +++ b/packager/media/base/fixed_key_source_unittest.cc @@ -53,7 +53,7 @@ TEST(FixedKeySourceTest, CreateFromHexStrings_Succes) { ASSERT_NE(nullptr, key_source); EncryptionKey key; - ASSERT_OK(key_source->GetKey(KeySource::TRACK_TYPE_SD, &key)); + ASSERT_OK(key_source->GetKey("SomeStreamLabel", &key)); EXPECT_HEX_EQ(kKeyIdHex, key.key_id); EXPECT_HEX_EQ(kKeyHex, key.key); @@ -70,7 +70,7 @@ TEST(FixedKeySourceTest, CreateFromHexStrings_EmptyPssh) { ASSERT_NE(nullptr, key_source); EncryptionKey key; - ASSERT_OK(key_source->GetKey(KeySource::TRACK_TYPE_SD, &key)); + ASSERT_OK(key_source->GetKey("SomeStreamLabel", &key)); EXPECT_HEX_EQ(kKeyIdHex, key.key_id); EXPECT_HEX_EQ(kKeyHex, key.key); diff --git a/packager/media/base/key_source.cc b/packager/media/base/key_source.cc index 240c92538b..b652396e85 100644 --- a/packager/media/base/key_source.cc +++ b/packager/media/base/key_source.cc @@ -12,47 +12,12 @@ namespace shaka { namespace media { EncryptionKey::EncryptionKey() {} + EncryptionKey::~EncryptionKey() {} -KeySource::~KeySource() {} - -KeySource::TrackType KeySource::GetTrackTypeFromString( - const std::string& track_type_string) { - if (track_type_string == "SD") - return TRACK_TYPE_SD; - if (track_type_string == "HD") - return TRACK_TYPE_HD; - if (track_type_string == "UHD1") - return TRACK_TYPE_UHD1; - if (track_type_string == "UHD2") - return TRACK_TYPE_UHD2; - if (track_type_string == "AUDIO") - return TRACK_TYPE_AUDIO; - if (track_type_string == "UNSPECIFIED") - return TRACK_TYPE_UNSPECIFIED; - LOG(WARNING) << "Unexpected track type: " << track_type_string; - return TRACK_TYPE_UNKNOWN; -} - -std::string KeySource::TrackTypeToString(TrackType track_type) { - switch (track_type) { - case TRACK_TYPE_SD: - return "SD"; - case TRACK_TYPE_HD: - return "HD"; - case TRACK_TYPE_UHD1: - return "UHD1"; - case TRACK_TYPE_UHD2: - return "UHD2"; - case TRACK_TYPE_AUDIO: - return "AUDIO"; - default: - NOTIMPLEMENTED() << "Unknown track type: " << track_type; - return "UNKNOWN"; - } -} - KeySource::KeySource() {} +KeySource::~KeySource() {} + } // namespace media } // namespace shaka diff --git a/packager/media/base/key_source.h b/packager/media/base/key_source.h index 2883e6cb82..59932a9a9b 100644 --- a/packager/media/base/key_source.h +++ b/packager/media/base/key_source.h @@ -44,17 +44,6 @@ struct EncryptionKey { /// KeySource is responsible for encryption key acquisition. class KeySource { public: - enum TrackType { - TRACK_TYPE_UNKNOWN = 0, - TRACK_TYPE_SD = 1, - TRACK_TYPE_HD = 2, - TRACK_TYPE_UHD1 = 3, - TRACK_TYPE_UHD2 = 4, - TRACK_TYPE_AUDIO = 5, - TRACK_TYPE_UNSPECIFIED = 6, - NUM_VALID_TRACK_TYPES = 6 - }; - KeySource(); virtual ~KeySource(); @@ -65,12 +54,13 @@ class KeySource { virtual Status FetchKeys(EmeInitDataType init_data_type, const std::vector& init_data) = 0; - /// Get encryption key of the specified track type. - /// @param track_type is the type of track for which retrieving the key. + /// Get encryption key of the specified stream label. + /// @param stream_label is the label of stream for which retrieving the key. /// @param key is a pointer to the EncryptionKey which will hold the retrieved /// key. Owner retains ownership, and may not be NULL. /// @return OK on success, an error status otherwise. - virtual Status GetKey(TrackType track_type, EncryptionKey* key) = 0; + virtual Status GetKey(const std::string& stream_label, + EncryptionKey* key) = 0; /// Get the encryption key specified by the CENC key ID. /// @param key_id is the unique identifier for the key being retreived. @@ -83,20 +73,14 @@ class KeySource { /// Get encryption key of the specified track type at the specified index. /// @param crypto_period_index is the sequence number of the key rotation /// period for which the key is being retrieved. - /// @param track_type is the type of track for which retrieving the key. + /// @param stream_label is the label of stream for which retrieving the key. /// @param key is a pointer to the EncryptionKey which will hold the retrieved /// key. Owner retains ownership, and may not be NULL. /// @return OK on success, an error status otherwise. virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key) = 0; - /// Convert string representation of track type to enum representation. - static TrackType GetTrackTypeFromString(const std::string& track_type_string); - - /// Convert TrackType to string. - static std::string TrackTypeToString(TrackType track_type); - private: DISALLOW_COPY_AND_ASSIGN(KeySource); }; diff --git a/packager/media/base/playready_key_source.cc b/packager/media/base/playready_key_source.cc index ed6a6d52cd..bbca55c362 100644 --- a/packager/media/base/playready_key_source.cc +++ b/packager/media/base/playready_key_source.cc @@ -316,9 +316,10 @@ Status PlayReadyKeySource::FetchKeys(EmeInitDataType init_data_type, return Status::OK; } -Status PlayReadyKeySource::GetKey(TrackType track_type, EncryptionKey* key) { +Status PlayReadyKeySource::GetKey(const std::string& stream_label, + EncryptionKey* key) { // TODO(robinconnell): Currently all tracks are encrypted using the same - // key_id and key. Add the ability to encrypt each track_type using a + // key_id and key. Add the ability to encrypt each stream_label using a // different key_id and key. DCHECK(key); DCHECK(encryption_key_); @@ -337,7 +338,7 @@ Status PlayReadyKeySource::GetKey(const std::vector& key_id, } Status PlayReadyKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key) { // TODO(robinconnell): Implement key rotation. *key = *encryption_key_; diff --git a/packager/media/base/playready_key_source.h b/packager/media/base/playready_key_source.h index 290e18281e..90b9fb5f87 100644 --- a/packager/media/base/playready_key_source.h +++ b/packager/media/base/playready_key_source.h @@ -42,11 +42,11 @@ class PlayReadyKeySource : public KeySource { /// @{ Status FetchKeys(EmeInitDataType init_data_type, const std::vector& init_data) override; - Status GetKey(TrackType track_type, EncryptionKey* key) override; + Status GetKey(const std::string& stream_label, EncryptionKey* key) override; Status GetKey(const std::vector& key_id, EncryptionKey* key) override; Status GetCryptoPeriodKey(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key) override; /// @} virtual Status FetchKeysWithProgramIdentifier(const std::string& program_identifier); diff --git a/packager/media/base/widevine_key_source.cc b/packager/media/base/widevine_key_source.cc index 57df7e7f90..49be200a85 100644 --- a/packager/media/base/widevine_key_source.cc +++ b/packager/media/base/widevine_key_source.cc @@ -237,13 +237,14 @@ Status WidevineKeySource::FetchKeys(EmeInitDataType init_data_type, return FetchKeysInternal(!kEnableKeyRotation, 0, widevine_classic); } -Status WidevineKeySource::GetKey(TrackType track_type, EncryptionKey* key) { +Status WidevineKeySource::GetKey(const std::string& stream_label, + EncryptionKey* key) { DCHECK(key); - if (encryption_key_map_.find(track_type) == encryption_key_map_.end()) { + if (encryption_key_map_.find(stream_label) == encryption_key_map_.end()) { return Status(error::INTERNAL_ERROR, - "Cannot find key of type " + TrackTypeToString(track_type)); + "Cannot find key for '" + stream_label + "'."); } - *key = *encryption_key_map_[track_type]; + *key = *encryption_key_map_[stream_label]; return Status::OK; } @@ -261,7 +262,7 @@ Status WidevineKeySource::GetKey(const std::vector& key_id, } Status WidevineKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key) { DCHECK(key_production_thread_.HasBeenStarted()); // TODO(kqyang): This is not elegant. Consider refactoring later. @@ -279,7 +280,7 @@ Status WidevineKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, key_production_started_ = true; } } - return GetKeyInternal(crypto_period_index, track_type, key); + return GetKeyInternal(crypto_period_index, stream_label, key); } void WidevineKeySource::set_signer(std::unique_ptr signer) { @@ -292,12 +293,10 @@ void WidevineKeySource::set_key_fetcher( } Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key) { DCHECK(key_pool_); DCHECK(key); - DCHECK_LE(track_type, NUM_VALID_TRACK_TYPES); - DCHECK_NE(track_type, TRACK_TYPE_UNKNOWN); std::shared_ptr encryption_key_map; Status status = key_pool_->Peek(crypto_period_index, &encryption_key_map, @@ -310,11 +309,11 @@ Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index, return status; } - if (encryption_key_map->find(track_type) == encryption_key_map->end()) { + if (encryption_key_map->find(stream_label) == encryption_key_map->end()) { return Status(error::INTERNAL_ERROR, - "Cannot find key of type " + TrackTypeToString(track_type)); + "Cannot find key for '" + stream_label + "'."); } - *key = *encryption_key_map->at(track_type); + *key = *encryption_key_map->at(stream_label); return Status::OK; } @@ -545,11 +544,9 @@ bool WidevineKeySource::ExtractEncryptionKey( } } - std::string track_type_str; - RCHECK(track_dict->GetString("type", &track_type_str)); - TrackType track_type = GetTrackTypeFromString(track_type_str); - DCHECK_NE(TRACK_TYPE_UNKNOWN, track_type); - RCHECK(encryption_key_map.find(track_type) == encryption_key_map.end()); + std::string stream_label; + RCHECK(track_dict->GetString("type", &stream_label)); + RCHECK(encryption_key_map.find(stream_label) == encryption_key_map.end()); std::unique_ptr encryption_key(new EncryptionKey()); @@ -573,7 +570,7 @@ bool WidevineKeySource::ExtractEncryptionKey( encryption_key->key_system_info.push_back(info); } - encryption_key_map[track_type] = std::move(encryption_key); + encryption_key_map[stream_label] = std::move(encryption_key); } // If the flag exists, create a common system ID PSSH box that contains the diff --git a/packager/media/base/widevine_key_source.h b/packager/media/base/widevine_key_source.h index 65a60f43e3..2e57f12bd0 100644 --- a/packager/media/base/widevine_key_source.h +++ b/packager/media/base/widevine_key_source.h @@ -39,11 +39,11 @@ class WidevineKeySource : public KeySource { /// @{ Status FetchKeys(EmeInitDataType init_data_type, const std::vector& init_data) override; - Status GetKey(TrackType track_type, EncryptionKey* key) override; + Status GetKey(const std::string& stream_label, EncryptionKey* key) override; Status GetKey(const std::vector& key_id, EncryptionKey* key) override; Status GetCryptoPeriodKey(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key) override; /// @} @@ -68,13 +68,14 @@ class WidevineKeySource : public KeySource { void set_key_fetcher(std::unique_ptr key_fetcher); private: - typedef std::map> EncryptionKeyMap; + typedef std::map> + EncryptionKeyMap; typedef ProducerConsumerQueue> EncryptionKeyQueue; // Internal routine for getting keys. Status GetKeyInternal(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key); // The closure task to fetch keys repeatedly. diff --git a/packager/media/base/widevine_key_source_unittest.cc b/packager/media/base/widevine_key_source_unittest.cc index b9d8ebf203..6490ae3bba 100644 --- a/packager/media/base/widevine_key_source_unittest.cc +++ b/packager/media/base/widevine_key_source_unittest.cc @@ -197,17 +197,14 @@ class WidevineKeySourceTest : public Test { void VerifyKeys(bool classic) { EncryptionKey encryption_key; - const std::string kTrackTypes[] = {"SD", "HD", "UHD1", "UHD2", "AUDIO"}; - for (size_t i = 0; i < arraysize(kTrackTypes); ++i) { - ASSERT_OK(widevine_key_source_->GetKey( - KeySource::GetTrackTypeFromString(kTrackTypes[i]), - &encryption_key)); - EXPECT_EQ(GetMockKey(kTrackTypes[i]), ToString(encryption_key.key)); + const std::string kStreamLabels[] = {"SD", "HD", "UHD1", "UHD2", "AUDIO"}; + for (const std::string& stream_label : kStreamLabels) { + ASSERT_OK(widevine_key_source_->GetKey(stream_label, &encryption_key)); + EXPECT_EQ(GetMockKey(stream_label), ToString(encryption_key.key)); if (!classic) { ASSERT_EQ(add_common_pssh_ ? 2u : 1u, encryption_key.key_system_info.size()); - EXPECT_EQ(GetMockKeyId(kTrackTypes[i]), - ToString(encryption_key.key_id)); + EXPECT_EQ(GetMockKeyId(stream_label), ToString(encryption_key.key_id)); EXPECT_EQ(GetMockPsshData(), ToString(encryption_key.key_system_info[0].pssh_data())); @@ -220,10 +217,10 @@ class WidevineKeySourceTest : public Test { const std::vector>& key_ids = encryption_key.key_system_info[1].key_ids(); - ASSERT_EQ(arraysize(kTrackTypes), key_ids.size()); - for (size_t j = 0; j < arraysize(kTrackTypes); ++j) { + ASSERT_EQ(arraysize(kStreamLabels), key_ids.size()); + for (const std::string& stream_label : kStreamLabels) { // Because they are stored in a std::set, the order may change. - const std::string key_id_str = GetMockKeyId(kTrackTypes[j]); + const std::string key_id_str = GetMockKeyId(stream_label); const std::vector key_id(key_id_str.begin(), key_id_str.end()); EXPECT_THAT(key_ids, testing::Contains(key_id)); @@ -243,21 +240,6 @@ class WidevineKeySourceTest : public Test { DISALLOW_COPY_AND_ASSIGN(WidevineKeySourceTest); }; -TEST_F(WidevineKeySourceTest, GetTrackTypeFromString) { - EXPECT_EQ(KeySource::TRACK_TYPE_SD, - KeySource::GetTrackTypeFromString("SD")); - EXPECT_EQ(KeySource::TRACK_TYPE_HD, - KeySource::GetTrackTypeFromString("HD")); - EXPECT_EQ(KeySource::TRACK_TYPE_UHD1, - KeySource::GetTrackTypeFromString("UHD1")); - EXPECT_EQ(KeySource::TRACK_TYPE_UHD2, - KeySource::GetTrackTypeFromString("UHD2")); - EXPECT_EQ(KeySource::TRACK_TYPE_AUDIO, - KeySource::GetTrackTypeFromString("AUDIO")); - EXPECT_EQ(KeySource::TRACK_TYPE_UNKNOWN, - KeySource::GetTrackTypeFromString("FOO")); -} - TEST_F(WidevineKeySourceTest, GenerateSignatureFailure) { EXPECT_CALL(*mock_request_signer_, GenerateSignature(_, _)) .WillOnce(Return(false)); @@ -531,23 +513,19 @@ TEST_P(WidevineKeySourceParameterizedTest, KeyRotationTest) { ASSERT_OK(widevine_key_source_->FetchKeys(content_id_, kPolicy)); EncryptionKey encryption_key; + const std::string kStreamLabels[] = {"SD", "HD", "UHD1", "UHD2", "AUDIO"}; for (size_t i = 0; i < arraysize(kCryptoPeriodIndexes); ++i) { - const std::string kTrackTypes[] = {"SD", "HD", "UHD1", "UHD2", "AUDIO"}; - for (size_t j = 0; j < 5; ++j) { + for (const std::string& stream_label : kStreamLabels) { ASSERT_OK(widevine_key_source_->GetCryptoPeriodKey( - kCryptoPeriodIndexes[i], - KeySource::GetTrackTypeFromString(kTrackTypes[j]), - &encryption_key)); - EXPECT_EQ(GetMockKey(kTrackTypes[j], kCryptoPeriodIndexes[i]), + kCryptoPeriodIndexes[i], stream_label, &encryption_key)); + EXPECT_EQ(GetMockKey(stream_label, kCryptoPeriodIndexes[i]), ToString(encryption_key.key)); } } // The old crypto period indexes should have been garbage collected. Status status = widevine_key_source_->GetCryptoPeriodKey( - kFirstCryptoPeriodIndex, - KeySource::TRACK_TYPE_SD, - &encryption_key); + kFirstCryptoPeriodIndex, kStreamLabels[0], &encryption_key); EXPECT_EQ(error::INVALID_ARGUMENT, status.error_code()); } diff --git a/packager/media/crypto/encryption_handler.cc b/packager/media/crypto/encryption_handler.cc index ec5855c118..96801635cc 100644 --- a/packager/media/crypto/encryption_handler.cc +++ b/packager/media/crypto/encryption_handler.cc @@ -56,18 +56,7 @@ uint8_t GetNaluLengthSize(const StreamInfo& stream_info) { return video_stream_info.nalu_length_size(); } -// TODO(kqyang): Update KeySource to accept string base stream label. -KeySource::TrackType ToTrackType(const std::string& track_type) { - if (track_type == "SD") - return KeySource::TRACK_TYPE_SD; - if (track_type == "HD") - return KeySource::TRACK_TYPE_HD; - if (track_type == "AUDIO") - return KeySource::TRACK_TYPE_AUDIO; - return KeySource::TRACK_TYPE_SD; -} - -KeySource::TrackType GetTrackTypeForEncryption( +std::string GetStreamLabelForEncryption( const StreamInfo& stream_info, const std::function& @@ -84,7 +73,7 @@ KeySource::TrackType GetTrackTypeForEncryption( stream_attributes.oneof.video.width = video_stream_info.width(); stream_attributes.oneof.video.height = video_stream_info.height(); } - return ToTrackType(stream_label_func(stream_attributes)); + return stream_label_func(stream_attributes); } } // namespace @@ -151,7 +140,7 @@ Status EncryptionHandler::ProcessStreamInfo(StreamInfo* stream_info) { stream_info->time_scale(); codec_ = stream_info->codec(); nalu_length_size_ = GetNaluLengthSize(*stream_info); - track_type_ = GetTrackTypeForEncryption( + stream_label_ = GetStreamLabelForEncryption( *stream_info, encryption_options_.stream_label_func); switch (codec_) { case kCodecVP9: @@ -195,7 +184,7 @@ Status EncryptionHandler::ProcessStreamInfo(StreamInfo* stream_info) { // convenience. encryption_key.key = encryption_key.key_id; } else { - status = key_source_->GetKey(track_type_, &encryption_key); + status = key_source_->GetKey(stream_label_, &encryption_key); if (!status.ok()) return status; } @@ -228,7 +217,7 @@ Status EncryptionHandler::ProcessMediaSample(MediaSample* sample) { if (current_crypto_period_index != prev_crypto_period_index_) { EncryptionKey encryption_key; Status status = key_source_->GetCryptoPeriodKey( - current_crypto_period_index, track_type_, &encryption_key); + current_crypto_period_index, stream_label_, &encryption_key); if (!status.ok()) return status; if (!CreateEncryptor(encryption_key)) diff --git a/packager/media/crypto/encryption_handler.h b/packager/media/crypto/encryption_handler.h index 5c795cf7f6..e81ee2883b 100644 --- a/packager/media/crypto/encryption_handler.h +++ b/packager/media/crypto/encryption_handler.h @@ -78,7 +78,7 @@ class EncryptionHandler : public MediaHandler { const EncryptionOptions encryption_options_; KeySource* key_source_ = nullptr; - KeySource::TrackType track_type_ = KeySource::TRACK_TYPE_UNKNOWN; + std::string stream_label_; // Current encryption config and encryptor. std::shared_ptr encryption_config_; std::unique_ptr encryptor_; diff --git a/packager/media/crypto/encryption_handler_unittest.cc b/packager/media/crypto/encryption_handler_unittest.cc index edafd6a394..f5a58b310e 100644 --- a/packager/media/crypto/encryption_handler_unittest.cc +++ b/packager/media/crypto/encryption_handler_unittest.cc @@ -56,10 +56,11 @@ const uint8_t kKeyRotationDefaultKeyId[] = { class MockKeySource : public FixedKeySource { public: - MOCK_METHOD2(GetKey, Status(TrackType track_type, EncryptionKey* key)); + MOCK_METHOD2(GetKey, + Status(const std::string& stream_label, EncryptionKey* key)); MOCK_METHOD3(GetCryptoPeriodKey, Status(uint32_t crypto_period_index, - TrackType track_type, + const std::string& stream_label, EncryptionKey* key)); }; @@ -657,7 +658,7 @@ TEST_F(EncryptionHandlerTrackTypeTest, AudioTrackType) { return kAudioStreamLabel; }; SetUpEncryptionHandler(encryption_options); - EXPECT_CALL(mock_key_source_, GetKey(KeySource::TRACK_TYPE_AUDIO, _)) + EXPECT_CALL(mock_key_source_, GetKey(kAudioStreamLabel, _)) .WillOnce( DoAll(SetArgPointee<1>(GetMockEncryptionKey()), Return(Status::OK))); ASSERT_OK(Process(GetAudioStreamInfoStreamData(kStreamIndex, kTimeScale))); @@ -676,7 +677,7 @@ TEST_F(EncryptionHandlerTrackTypeTest, VideoTrackType) { return kSdVideoStreamLabel; }; SetUpEncryptionHandler(encryption_options); - EXPECT_CALL(mock_key_source_, GetKey(KeySource::TRACK_TYPE_SD, _)) + EXPECT_CALL(mock_key_source_, GetKey(kSdVideoStreamLabel, _)) .WillOnce( DoAll(SetArgPointee<1>(GetMockEncryptionKey()), Return(Status::OK))); std::unique_ptr stream_data = diff --git a/packager/media/formats/wvm/wvm_media_parser.cc b/packager/media/formats/wvm/wvm_media_parser.cc index 5d13b3ff1e..e419c6b2f2 100644 --- a/packager/media/formats/wvm/wvm_media_parser.cc +++ b/packager/media/formats/wvm/wvm_media_parser.cc @@ -1076,8 +1076,8 @@ bool WvmMediaParser::GetAssetKey(const uint8_t* asset_id, return false; } - status = decryption_key_source_->GetKey(KeySource::TRACK_TYPE_HD, - encryption_key); + const char kHdStreamLabel[] = "HD"; + status = decryption_key_source_->GetKey(kHdStreamLabel, encryption_key); if (!status.ok()) { LOG(ERROR) << "Fetch Key(s) failed for AssetID = " << ntohlFromBuffer(asset_id) << ", error = " << status; diff --git a/packager/media/formats/wvm/wvm_media_parser_unittest.cc b/packager/media/formats/wvm/wvm_media_parser_unittest.cc index b7ddf5cc22..47265bc034 100644 --- a/packager/media/formats/wvm/wvm_media_parser_unittest.cc +++ b/packager/media/formats/wvm/wvm_media_parser_unittest.cc @@ -55,8 +55,8 @@ class MockKeySource : public FixedKeySource { MOCK_METHOD2(FetchKeys, Status(EmeInitDataType init_data_type, const std::vector& init_data)); - MOCK_METHOD2(GetKey, Status(TrackType track_type, - EncryptionKey* key)); + MOCK_METHOD2(GetKey, + Status(const std::string& stream_label, EncryptionKey* key)); private: DISALLOW_COPY_AND_ASSIGN(MockKeySource);