Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/cdm/renderer/android_key_systems.h" | 5 #include "components/cdm/renderer/android_key_systems.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 request.codecs = media::EME_CODEC_ALL; | 32 request.codecs = media::EME_CODEC_ALL; |
| 33 content::RenderThread::Get()->Send( | 33 content::RenderThread::Get()->Send( |
| 34 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); | 34 new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); |
| 35 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL)) | 35 DCHECK(!(response.compositing_codecs & ~media::EME_CODEC_ALL)) |
| 36 << "unrecognized codec"; | 36 << "unrecognized codec"; |
| 37 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL)) | 37 DCHECK(!(response.non_compositing_codecs & ~media::EME_CODEC_ALL)) |
| 38 << "unrecognized codec"; | 38 << "unrecognized codec"; |
| 39 return response; | 39 return response; |
| 40 } | 40 } |
| 41 | 41 |
| 42 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems, | 42 void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { |
| 43 bool is_non_compositing_supported) { | |
| 44 SupportedKeySystemResponse response = QueryKeySystemSupport( | 43 SupportedKeySystemResponse response = QueryKeySystemSupport( |
| 45 kWidevineKeySystem); | 44 kWidevineKeySystem); |
| 46 | 45 |
| 47 // When creating the WIDEVINE key system, BrowserCdmFactoryAndroid configures | |
| 48 // the CDM's security level based on a pref. Therefore the supported | |
| 49 // codec/robustenss combinations depend on that pref, represented by | |
| 50 // |bool is_non_compositing_supported|. | |
| 51 // TODO(sandersd): For unprefixed, set the security level based on the | |
| 52 // requested robustness instead of the flag. http://crbug.com/467779 | |
| 53 // We should also stop using the term "non_compositing." | |
| 54 SupportedCodecs codecs = response.compositing_codecs; | |
| 55 EmeRobustness max_audio_robustness = EmeRobustness::SW_SECURE_CRYPTO; | |
| 56 EmeRobustness max_video_robustness = EmeRobustness::SW_SECURE_CRYPTO; | |
| 57 if (is_non_compositing_supported) { | |
| 58 codecs = response.non_compositing_codecs; | |
| 59 max_audio_robustness = EmeRobustness::HW_SECURE_CRYPTO; | |
| 60 max_video_robustness = EmeRobustness::HW_SECURE_ALL; | |
| 61 } | |
| 62 | |
| 63 // We are using MediaDrm API on Android and we cannot guarantee that API | 46 // We are using MediaDrm API on Android and we cannot guarantee that API |
| 64 // doesn't use persistent storage on the device. Therefore always set | 47 // doesn't use persistent storage on the device. Therefore always set |
| 65 // persistent state to EmeFeatureSupport::ALWAYS_ENABLED to err on the | 48 // persistent state to EmeFeatureSupport::ALWAYS_ENABLED to err on the |
| 66 // safe side. | 49 // safe side. |
| 67 | 50 if (response.compositing_codecs != media::EME_CODEC_NONE) { |
|
ddorwin
2015/04/30 18:18:04
Should we DCHECK that this is not NONE if noncomp
sandersd (OOO until July 31)
2015/04/30 19:57:44
Done.
| |
| 68 if (codecs != media::EME_CODEC_NONE) { | |
| 69 AddWidevineWithCodecs( | 51 AddWidevineWithCodecs( |
| 70 WIDEVINE, codecs, max_audio_robustness, max_video_robustness, | 52 WIDEVINE, |
| 71 media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. | 53 response.compositing_codecs, // Regular codecs. |
| 72 media::EmeSessionTypeSupport:: | 54 response.non_compositing_codecs, // Hardware-secure codecs. |
| 73 NOT_SUPPORTED, // persistent-release-message. | 55 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. |
| 74 media::EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. | 56 EmeRobustness::HW_SECURE_ALL, // Max video robustness. |
| 75 media::EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive | 57 media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-license. |
|
jrummell
2015/04/30 02:08:37
Shouldn't these be media::EmeSessionTypeSupport::?
sandersd (OOO until July 31)
2015/04/30 18:19:34
Done.
| |
| 76 // identifier. | 58 media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message. |
| 59 media::EME_FEATURE_ALWAYS_ENABLED, // Persistent state. | |
| 60 media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier. | |
| 77 concrete_key_systems); | 61 concrete_key_systems); |
| 78 } | 62 } |
| 79 | 63 |
| 80 // For compatibility with the prefixed API, register a separate L1 key system. | 64 // For compatibility with the prefixed API, register a separate L1 key system. |
| 81 // When creating the WIDEVINE_HR_NON_COMPOSITING key system, | 65 // This key systems acts as though only hardware-secure codecs are available. |
| 82 // BrowserCdmFactoryAndroid does not configure the CDM's security level (that | 66 // (The prefixed API only consults the regular codecs field.) |
| 83 // is, leaves it as L1); therefore only secure codecs are supported. | 67 // TODO(sandersd): Only register if the hardware-secure codecs pref is set. |
| 84 // TODO(ddorwin): Remove with unprefixed. http://crbug.com/249976 | |
| 85 if (response.non_compositing_codecs != media::EME_CODEC_NONE) { | 68 if (response.non_compositing_codecs != media::EME_CODEC_NONE) { |
| 69 SupportedCodecs codecs = response.compositing_codecs & | |
|
ddorwin
2015/04/30 18:18:04
Probably worth a comment explaining why.
sandersd (OOO until July 31)
2015/04/30 19:57:44
Done.
| |
| 70 response.non_compositing_codecs; | |
| 86 AddWidevineWithCodecs( | 71 AddWidevineWithCodecs( |
| 87 WIDEVINE_HR_NON_COMPOSITING, response.non_compositing_codecs, | 72 WIDEVINE_HR_NON_COMPOSITING, |
| 88 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. | 73 (response.compositing_codecs & |
| 89 EmeRobustness::HW_SECURE_ALL, // Max video robustness. | 74 response.non_compositing_codecs), // Regular codecs. |
|
jrummell
2015/04/30 02:08:37
Can't you just use codecs here? Surprised the comp
sandersd (OOO until July 31)
2015/04/30 18:19:34
Done.
| |
| 90 media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. | 75 media::EME_CODEC_NONE, // Hardware-secure codecs. |
| 91 media::EmeSessionTypeSupport:: | 76 EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness. |
| 92 NOT_SUPPORTED, // persistent-release-message. | 77 EmeRobustness::HW_SECURE_ALL, // Max video robustness. |
| 93 media::EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. | 78 media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-license. |
| 94 media::EmeFeatureSupport::ALWAYS_ENABLED, // Distinctive | 79 media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message. |
| 95 // identifier. | 80 media::EME_FEATURE_ALWAYS_ENABLED, // Persistent state. |
| 81 media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier. | |
| 96 concrete_key_systems); | 82 concrete_key_systems); |
| 97 } | 83 } |
| 98 } | 84 } |
| 99 | 85 |
| 100 void AddAndroidPlatformKeySystems( | 86 void AddAndroidPlatformKeySystems( |
| 101 std::vector<KeySystemInfo>* concrete_key_systems) { | 87 std::vector<KeySystemInfo>* concrete_key_systems) { |
| 102 std::vector<std::string> key_system_names; | 88 std::vector<std::string> key_system_names; |
| 103 content::RenderThread::Get()->Send( | 89 content::RenderThread::Get()->Send( |
| 104 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); | 90 new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); |
| 105 | 91 |
| 106 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); | 92 for (std::vector<std::string>::const_iterator it = key_system_names.begin(); |
| 107 it != key_system_names.end(); ++it) { | 93 it != key_system_names.end(); ++it) { |
| 108 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); | 94 SupportedKeySystemResponse response = QueryKeySystemSupport(*it); |
| 109 if (response.compositing_codecs != media::EME_CODEC_NONE) { | 95 if (response.compositing_codecs != media::EME_CODEC_NONE) { |
| 110 KeySystemInfo info; | 96 KeySystemInfo info; |
| 111 info.key_system = *it; | 97 info.key_system = *it; |
| 112 info.supported_codecs = response.compositing_codecs; | 98 info.supported_codecs = response.compositing_codecs; |
| 113 // Here we assume that support for a container implies support for the | 99 // Here we assume that support for a container implies support for the |
| 114 // associated initialization data type. KeySystems handles validating | 100 // associated initialization data type. KeySystems handles validating |
| 115 // |init_data_type| x |container| pairings. | 101 // |init_data_type| x |container| pairings. |
| 116 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL) | 102 if (response.compositing_codecs & media::EME_CODEC_WEBM_ALL) |
| 117 info.supported_init_data_types |= media::kInitDataTypeMaskWebM; | 103 info.supported_init_data_types |= media::kInitDataTypeMaskWebM; |
| 118 #if defined(USE_PROPRIETARY_CODECS) | 104 #if defined(USE_PROPRIETARY_CODECS) |
| 119 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL) | 105 if (response.compositing_codecs & media::EME_CODEC_MP4_ALL) |
| 120 info.supported_init_data_types |= media::kInitDataTypeMaskCenc; | 106 info.supported_init_data_types |= media::kInitDataTypeMaskCenc; |
| 121 #endif // defined(USE_PROPRIETARY_CODECS) | 107 #endif // defined(USE_PROPRIETARY_CODECS) |
| 122 info.max_audio_robustness = EmeRobustness::EMPTY; | 108 info.max_audio_robustness = EmeRobustness::EMPTY; |
| 123 info.max_video_robustness = EmeRobustness::EMPTY; | 109 info.max_video_robustness = EmeRobustness::EMPTY; |
| 124 // Assume the worst case (from a user point of view). | 110 // Assume that plaform key systems support no features but can and will |
|
jrummell
2015/04/30 02:08:37
s/plaform/platform/
sandersd (OOO until July 31)
2015/04/30 18:19:34
Done.
| |
| 111 // make use of persistence and identifiers. | |
| 125 info.persistent_license_support = | 112 info.persistent_license_support = |
| 126 media::EmeSessionTypeSupport::NOT_SUPPORTED; | 113 media::EmeSessionTypeSupport::NOT_SUPPORTED; |
| 127 info.persistent_release_message_support = | 114 info.persistent_release_message_support = |
| 128 media::EmeSessionTypeSupport::NOT_SUPPORTED; | 115 media::EmeSessionTypeSupport::NOT_SUPPORTED; |
| 129 info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED; | 116 info.persistent_state_support = media::EmeFeatureSupport::ALWAYS_ENABLED; |
| 130 info.distinctive_identifier_support = | 117 info.distinctive_identifier_support = |
| 131 media::EmeFeatureSupport::ALWAYS_ENABLED; | 118 media::EmeFeatureSupport::ALWAYS_ENABLED; |
| 132 concrete_key_systems->push_back(info); | 119 concrete_key_systems->push_back(info); |
| 133 } | 120 } |
| 134 } | 121 } |
| 135 } | 122 } |
| 136 | 123 |
| 137 } // namespace cdm | 124 } // namespace cdm |
| OLD | NEW |