diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/BUILD.gn | 6 | ||||
-rw-r--r-- | media/blink/encrypted_media_player_support.cc | 8 | ||||
-rw-r--r-- | media/blink/webcontentdecryptionmodulesession_impl.cc | 10 | ||||
-rw-r--r-- | media/cdm/aes_decryptor.cc | 11 | ||||
-rw-r--r-- | media/cdm/aes_decryptor_unittest.cc | 7 | ||||
-rw-r--r-- | media/media.gyp | 6 |
6 files changed, 37 insertions, 11 deletions
diff --git a/media/BUILD.gn b/media/BUILD.gn index e38d77f..21f8148 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -88,8 +88,6 @@ component("media") { "blink/skcanvas_video_renderer.h", "cdm/aes_decryptor.cc", "cdm/aes_decryptor.h", - "cdm/cenc_utils.cc", - "cdm/cenc_utils.h", "cdm/default_cdm_factory.cc", "cdm/default_cdm_factory.h", "cdm/json_web_key.cc", @@ -395,6 +393,8 @@ component("media") { if (proprietary_codecs) { sources += [ + "cdm/cenc_utils.cc", + "cdm/cenc_utils.h", "filters/h264_to_annex_b_bitstream_converter.cc", "filters/h264_to_annex_b_bitstream_converter.h", "formats/mp2t/es_adapter_video.cc", @@ -500,7 +500,6 @@ test("media_unittests") { sources = [ "blink/skcanvas_video_renderer_unittest.cc", "cdm/aes_decryptor_unittest.cc", - "cdm/cenc_utils_unittest.cc", "cdm/json_web_key_unittest.cc", "filters/audio_clock_unittest.cc", "filters/audio_decoder_selector_unittest.cc", @@ -593,6 +592,7 @@ test("media_unittests") { if (proprietary_codecs) { sources += [ + "cdm/cenc_utils_unittest.cc", "filters/ffmpeg_aac_bitstream_converter_unittest.cc", "filters/ffmpeg_h264_to_annex_b_bitstream_converter_unittest.cc", "filters/h264_to_annex_b_bitstream_converter_unittest.cc", diff --git a/media/blink/encrypted_media_player_support.cc b/media/blink/encrypted_media_player_support.cc index e83efd9..ca6411c 100644 --- a/media/blink/encrypted_media_player_support.cc +++ b/media/blink/encrypted_media_player_support.cc @@ -104,11 +104,13 @@ static void ReportMediaKeyExceptionToUMA(const std::string& method, // so we keep it as simple as possible without breaking major use cases. static EmeInitDataType GuessInitDataType(const unsigned char* init_data, unsigned init_data_length) { +#if defined(USE_PROPRIETARY_CODECS) // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes. - if (init_data_length == 16) - return EmeInitDataType::WEBM; + if (init_data_length > 16) + return EmeInitDataType::CENC; +#endif - return EmeInitDataType::CENC; + return EmeInitDataType::WEBM; } EncryptedMediaPlayerSupport::EncryptedMediaPlayerSupport( diff --git a/media/blink/webcontentdecryptionmodulesession_impl.cc b/media/blink/webcontentdecryptionmodulesession_impl.cc index c80a1d5..3d77321 100644 --- a/media/blink/webcontentdecryptionmodulesession_impl.cc +++ b/media/blink/webcontentdecryptionmodulesession_impl.cc @@ -20,7 +20,6 @@ #include "media/blink/cdm_session_adapter.h" #include "media/blink/new_session_cdm_result_promise.h" #include "media/blink/webmediaplayer_util.h" -#include "media/cdm/cenc_utils.h" #include "media/cdm/json_web_key.h" #include "media/cdm/key_system_names.h" #include "third_party/WebKit/public/platform/WebData.h" @@ -29,6 +28,10 @@ #include "third_party/WebKit/public/platform/WebURL.h" #include "third_party/WebKit/public/platform/WebVector.h" +#if defined(USE_PROPRIETARY_CODECS) +#include "media/cdm/cenc_utils.h" +#endif + namespace media { const char kCloseSessionUMAName[] = "CloseSession"; @@ -112,12 +115,17 @@ static bool SanitizeInitData(EmeInitDataType init_data_type, return true; case EmeInitDataType::CENC: +#if defined(USE_PROPRIETARY_CODECS) sanitized_init_data->assign(init_data, init_data + init_data_length); if (!ValidatePsshInput(*sanitized_init_data)) { error_message->assign("Initialization data for CENC is incorrect."); return false; } return true; +#else + error_message->assign("Initialization data type CENC is not supported."); + return false; +#endif case EmeInitDataType::KEYIDS: { // Extract the keys and then rebuild the message. This ensures that any diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc index 77783e3..c145b00 100644 --- a/media/cdm/aes_decryptor.cc +++ b/media/cdm/aes_decryptor.cc @@ -19,9 +19,12 @@ #include "media/base/decrypt_config.h" #include "media/base/video_decoder_config.h" #include "media/base/video_frame.h" -#include "media/cdm/cenc_utils.h" #include "media/cdm/json_web_key.h" +#if defined(USE_PROPRIETARY_CODECS) +#include "media/cdm/cenc_utils.h" +#endif + namespace media { // Keeps track of the session IDs and DecryptionKeys. The keys are ordered by @@ -271,6 +274,7 @@ void AesDecryptor::CreateSessionAndGenerateRequest( keys.push_back(init_data); break; case EmeInitDataType::CENC: +#if defined(USE_PROPRIETARY_CODECS) // |init_data| is a set of 0 or more concatenated 'pssh' boxes. if (!GetKeyIdsForCommonSystemId(init_data, &keys)) { promise->reject(NOT_SUPPORTED_ERROR, 0, @@ -278,6 +282,11 @@ void AesDecryptor::CreateSessionAndGenerateRequest( return; } break; +#else + promise->reject(NOT_SUPPORTED_ERROR, 0, + "Initialization data type CENC is not supported."); + return; +#endif case EmeInitDataType::KEYIDS: { std::string init_data_string(init_data.begin(), init_data.end()); std::string error_message; diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc index 6fd8cec..9896575 100644 --- a/media/cdm/aes_decryptor_unittest.cc +++ b/media/cdm/aes_decryptor_unittest.cc @@ -471,12 +471,19 @@ TEST_F(AesDecryptorTest, CreateSessionWithCencInitData) { 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, 0x00, 0x00, 0x00, 0x00 // datasize }; +#if defined(USE_PROPRIETARY_CODECS) EXPECT_CALL(*this, OnSessionMessage(IsNotEmpty(), _, IsJSONDictionary(), GURL::EmptyGURL())); decryptor_.CreateSessionAndGenerateRequest( MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, std::vector<uint8>(init_data, init_data + arraysize(init_data)), CreateSessionPromise(RESOLVED)); +#else + decryptor_.CreateSessionAndGenerateRequest( + MediaKeys::TEMPORARY_SESSION, EmeInitDataType::CENC, + std::vector<uint8>(init_data, init_data + arraysize(init_data)), + CreateSessionPromise(REJECTED)); +#endif } TEST_F(AesDecryptorTest, CreateSessionWithKeyIdsInitData) { diff --git a/media/media.gyp b/media/media.gyp index 0a772b7..e56e119 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -412,8 +412,6 @@ 'blink/skcanvas_video_renderer.h', 'cdm/aes_decryptor.cc', 'cdm/aes_decryptor.h', - 'cdm/cenc_utils.cc', - 'cdm/cenc_utils.h', 'cdm/default_cdm_factory.cc', 'cdm/default_cdm_factory.h', 'cdm/json_web_key.cc', @@ -983,6 +981,8 @@ }], ['proprietary_codecs==1', { 'sources': [ + 'cdm/cenc_utils.cc', + 'cdm/cenc_utils.h', 'filters/ffmpeg_aac_bitstream_converter.cc', 'filters/ffmpeg_aac_bitstream_converter.h', 'filters/ffmpeg_h264_to_annex_b_bitstream_converter.cc', @@ -1170,7 +1170,6 @@ 'base/yuv_convert_unittest.cc', 'blink/skcanvas_video_renderer_unittest.cc', 'cdm/aes_decryptor_unittest.cc', - 'cdm/cenc_utils_unittest.cc', 'cdm/json_web_key_unittest.cc', 'ffmpeg/ffmpeg_common_unittest.cc', 'filters/audio_clock_unittest.cc', @@ -1284,6 +1283,7 @@ }], ['proprietary_codecs==1', { 'sources': [ + 'cdm/cenc_utils_unittest.cc', 'filters/ffmpeg_aac_bitstream_converter_unittest.cc', 'filters/ffmpeg_h264_to_annex_b_bitstream_converter_unittest.cc', 'filters/h264_to_annex_b_bitstream_converter_unittest.cc', |