| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chromecast/renderer/key_systems_cast.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/command_line.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "build/build_config.h" | |
| 12 #include "chromecast/media/base/key_systems_common.h" | |
| 13 #include "components/cdm/renderer/android_key_systems.h" | |
| 14 #include "components/cdm/renderer/widevine_key_system_properties.h" | |
| 15 #include "media/base/eme_constants.h" | |
| 16 #include "media/base/key_system_properties.h" | |
| 17 #include "media/media_features.h" | |
| 18 | |
| 19 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | |
| 20 | |
| 21 using ::media::EmeConfigRule; | |
| 22 using ::media::EmeFeatureSupport; | |
| 23 using ::media::EmeInitDataType; | |
| 24 using ::media::EmeMediaType; | |
| 25 using ::media::EmeSessionTypeSupport; | |
| 26 using ::media::SupportedCodecs; | |
| 27 | |
| 28 namespace chromecast { | |
| 29 namespace shell { | |
| 30 namespace { | |
| 31 | |
| 32 #if defined(PLAYREADY_CDM_AVAILABLE) | |
| 33 class PlayReadyKeySystemProperties : public ::media::KeySystemProperties { | |
| 34 public: | |
| 35 explicit PlayReadyKeySystemProperties(bool persistent_license_support) | |
| 36 : persistent_license_support_(persistent_license_support) { | |
| 37 } | |
| 38 | |
| 39 std::string GetKeySystemName() const override { | |
| 40 return media::kChromecastPlayreadyKeySystem; | |
| 41 } | |
| 42 | |
| 43 bool IsSupportedInitDataType(EmeInitDataType init_data_type) const override { | |
| 44 return init_data_type == EmeInitDataType::CENC; | |
| 45 } | |
| 46 | |
| 47 SupportedCodecs GetSupportedCodecs() const override { | |
| 48 SupportedCodecs codecs = | |
| 49 ::media::EME_CODEC_MP4_AAC | ::media::EME_CODEC_MP4_AVC1; | |
| 50 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | |
| 51 codecs |= ::media::EME_CODEC_MP4_HEVC; | |
| 52 #endif | |
| 53 return codecs; | |
| 54 } | |
| 55 | |
| 56 EmeConfigRule GetRobustnessConfigRule( | |
| 57 EmeMediaType media_type, | |
| 58 const std::string& requested_robustness) const override { | |
| 59 return requested_robustness.empty() ? EmeConfigRule::SUPPORTED | |
| 60 : EmeConfigRule::NOT_SUPPORTED; | |
| 61 } | |
| 62 | |
| 63 EmeSessionTypeSupport GetPersistentLicenseSessionSupport() const override { | |
| 64 return persistent_license_support_ ? EmeSessionTypeSupport::SUPPORTED | |
| 65 : EmeSessionTypeSupport::NOT_SUPPORTED; | |
| 66 } | |
| 67 | |
| 68 EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport() | |
| 69 const override { | |
| 70 return EmeSessionTypeSupport::NOT_SUPPORTED; | |
| 71 } | |
| 72 | |
| 73 EmeFeatureSupport GetPersistentStateSupport() const override { | |
| 74 return EmeFeatureSupport::ALWAYS_ENABLED; | |
| 75 } | |
| 76 EmeFeatureSupport GetDistinctiveIdentifierSupport() const override { | |
| 77 return EmeFeatureSupport::ALWAYS_ENABLED; | |
| 78 } | |
| 79 | |
| 80 private: | |
| 81 const bool persistent_license_support_; | |
| 82 }; | |
| 83 #endif // PLAYREADY_CDM_AVAILABLE | |
| 84 | |
| 85 } // namespace | |
| 86 | |
| 87 void AddChromecastKeySystems( | |
| 88 std::vector<std::unique_ptr<::media::KeySystemProperties>>* | |
| 89 key_systems_properties, | |
| 90 bool enable_persistent_license_support, | |
| 91 bool force_software_crypto) { | |
| 92 #if defined(PLAYREADY_CDM_AVAILABLE) | |
| 93 bool enable_persistent_license_playready = enable_persistent_license_support; | |
| 94 #if defined(OS_ANDROID) | |
| 95 LOG_IF(WARNING, enable_persistent_license_playready) | |
| 96 << "Android doesn't support Playready persistent license."; | |
| 97 enable_persistent_license_playready = false; | |
| 98 #endif | |
| 99 key_systems_properties->emplace_back( | |
| 100 new PlayReadyKeySystemProperties(enable_persistent_license_playready)); | |
| 101 #endif // defined(PLAYREADY_CDM_AVAILABLE) | |
| 102 | |
| 103 #if defined(WIDEVINE_CDM_AVAILABLE) | |
| 104 #if defined(OS_ANDROID) | |
| 105 cdm::AddAndroidWidevine(key_systems_properties); | |
| 106 #else | |
| 107 using Robustness = cdm::WidevineKeySystemProperties::Robustness; | |
| 108 ::media::SupportedCodecs codecs = | |
| 109 ::media::EME_CODEC_MP4_AAC | ::media::EME_CODEC_MP4_AVC1 | | |
| 110 ::media::EME_CODEC_MP4_VP9 | ::media::EME_CODEC_WEBM_VP8 | | |
| 111 ::media::EME_CODEC_WEBM_VP9; | |
| 112 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | |
| 113 codecs |= ::media::EME_CODEC_MP4_HEVC; | |
| 114 #endif | |
| 115 key_systems_properties->emplace_back(new cdm::WidevineKeySystemProperties( | |
| 116 codecs, // Regular codecs. | |
| 117 Robustness::HW_SECURE_ALL, // Max audio robustness. | |
| 118 Robustness::HW_SECURE_ALL, // Max video robustness. | |
| 119 enable_persistent_license_support | |
| 120 ? EmeSessionTypeSupport::SUPPORTED | |
| 121 : EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. | |
| 122 EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-release-message. | |
| 123 // Note: On Chromecast, all CDMs may have persistent state. | |
| 124 EmeFeatureSupport::ALWAYS_ENABLED, // Persistent state. | |
| 125 EmeFeatureSupport::ALWAYS_ENABLED)); // Distinctive identifier. | |
| 126 #endif // defined(OS_ANDROID) | |
| 127 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
| 128 } | |
| 129 | |
| 130 } // namespace shell | |
| 131 } // namespace chromecast | |
| OLD | NEW |