Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 "media/cdm/stub/stub_cdm.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/strings/string_number_conversions.h" | |
| 9 | |
| 10 // Version number for this stub. The third number represents the | |
| 11 // cdm::ContentDecryptionModule version. | |
| 12 const char kStubCdmVersion[] = "1.4.8.0"; | |
| 13 | |
| 14 void INITIALIZE_CDM_MODULE() { | |
| 15 } | |
| 16 | |
| 17 void DeinitializeCdmModule() { | |
| 18 } | |
| 19 | |
| 20 void* CreateCdmInstance(int cdm_interface_version, | |
| 21 const char* /* key_system */, | |
| 22 uint32_t /* key_system_size */, | |
| 23 GetCdmHostFunc get_cdm_host_func, | |
| 24 void* user_data) { | |
| 25 DVLOG(1) << "CreateCdmInstance()"; | |
| 26 | |
| 27 if (cdm_interface_version != media::StubCdmInterface::kVersion) | |
| 28 return nullptr; | |
| 29 | |
| 30 media::StubCdmInterface::Host* host = | |
| 31 static_cast<media::StubCdmInterface::Host*>(get_cdm_host_func( | |
| 32 media::StubCdmInterface::Host::kVersion, user_data)); | |
| 33 if (!host) | |
| 34 return nullptr; | |
| 35 | |
| 36 return new media::StubCdm(host); | |
| 37 } | |
| 38 | |
| 39 const char* GetCdmVersion() { | |
| 40 return kStubCdmVersion; | |
| 41 } | |
| 42 | |
| 43 namespace media { | |
| 44 | |
| 45 StubCdm::StubCdm(Host* host) : host_(host), next_session_id_(0) { | |
| 46 } | |
| 47 | |
| 48 StubCdm::~StubCdm() { | |
| 49 } | |
| 50 | |
| 51 void StubCdm::Initialize(bool /* allow_distinctive_identifier */, | |
| 52 bool /* allow_persistent_state */) { | |
| 53 } | |
| 54 | |
| 55 void StubCdm::CreateSessionAndGenerateRequest( | |
|
ddorwin
2015/04/01 23:27:32
Add a comment that we provide a dummy message to e
jrummell
2015/04/02 23:47:55
Done.
| |
| 56 uint32 promise_id, | |
| 57 cdm::SessionType /* session_type */, | |
| 58 cdm::InitDataType /* init_data_type */, | |
| 59 const uint8* /* init_data */, | |
| 60 uint32 /* init_data_size */) { | |
| 61 // Generate a trivial session ID. | |
| 62 std::string session_id(base::UintToString(next_session_id_++)); | |
| 63 host_->OnResolveNewSessionPromise(promise_id, session_id.data(), | |
| 64 session_id.length()); | |
| 65 host_->OnSessionMessage(session_id.data(), session_id.length(), | |
| 66 cdm::kLicenseRequest, NULL, 0, NULL, 0); | |
| 67 } | |
| 68 | |
| 69 void StubCdm::LoadSession(uint32 promise_id, | |
| 70 cdm::SessionType /* session_type */, | |
| 71 const char* /* session_id */, | |
| 72 uint32_t /* session_id_length */) { | |
| 73 FailRequest(promise_id); | |
| 74 } | |
| 75 | |
| 76 void StubCdm::UpdateSession(uint32 promise_id, | |
| 77 const char* /* session_id */, | |
| 78 uint32_t /* session_id_length */, | |
| 79 const uint8* /* response */, | |
| 80 uint32 /* response_size */) { | |
| 81 FailRequest(promise_id); | |
| 82 } | |
| 83 | |
| 84 void StubCdm::CloseSession(uint32 promise_id, | |
| 85 const char* /* session_id */, | |
| 86 uint32_t /* session_id_length */) { | |
| 87 FailRequest(promise_id); | |
| 88 } | |
| 89 | |
| 90 void StubCdm::RemoveSession(uint32 promise_id, | |
| 91 const char* /* session_id */, | |
| 92 uint32_t /* session_id_length */) { | |
| 93 FailRequest(promise_id); | |
| 94 } | |
| 95 | |
| 96 void StubCdm::SetServerCertificate( | |
| 97 uint32 promise_id, | |
| 98 const uint8_t* /* server_certificate_data */, | |
| 99 uint32_t /* server_certificate_data_size */) { | |
| 100 FailRequest(promise_id); | |
| 101 } | |
| 102 | |
| 103 void StubCdm::TimerExpired(void* /* context */) { | |
| 104 } | |
| 105 | |
| 106 cdm::Status StubCdm::Decrypt(const cdm::InputBuffer& /* encrypted_buffer */, | |
| 107 cdm::DecryptedBlock* /* decrypted_block */) { | |
| 108 return cdm::kDecryptError; | |
| 109 } | |
| 110 | |
| 111 cdm::Status StubCdm::InitializeAudioDecoder( | |
| 112 const cdm::AudioDecoderConfig& /* audio_decoder_config */) { | |
| 113 return cdm::kDecryptError; | |
| 114 } | |
| 115 | |
| 116 cdm::Status StubCdm::InitializeVideoDecoder( | |
| 117 const cdm::VideoDecoderConfig& /* video_decoder_config */) { | |
| 118 return cdm::kDecryptError; | |
| 119 } | |
| 120 | |
| 121 void StubCdm::ResetDecoder(cdm::StreamType /* decoder_type */) { | |
| 122 } | |
| 123 | |
| 124 void StubCdm::DeinitializeDecoder(cdm::StreamType /* decoder_type */) { | |
| 125 } | |
| 126 | |
| 127 cdm::Status StubCdm::DecryptAndDecodeFrame( | |
| 128 const cdm::InputBuffer& /* encrypted_buffer */, | |
| 129 cdm::VideoFrame* /* decoded_frame */) { | |
| 130 return cdm::kDecryptError; | |
| 131 } | |
| 132 | |
| 133 cdm::Status StubCdm::DecryptAndDecodeSamples( | |
| 134 const cdm::InputBuffer& /* encrypted_buffer */, | |
| 135 cdm::AudioFrames* /* audio_frames */) { | |
| 136 return cdm::kDecryptError; | |
| 137 } | |
| 138 | |
| 139 void StubCdm::Destroy() { | |
| 140 delete this; | |
| 141 } | |
| 142 | |
| 143 void StubCdm::OnPlatformChallengeResponse( | |
| 144 const cdm::PlatformChallengeResponse& /* response */) { | |
| 145 NOTREACHED(); | |
| 146 } | |
| 147 | |
| 148 void StubCdm::OnQueryOutputProtectionStatus( | |
| 149 cdm::QueryResult /* result */, | |
| 150 uint32_t /* link_mask */, | |
| 151 uint32_t /* output_protection_mask */) { | |
| 152 NOTREACHED(); | |
| 153 }; | |
| 154 | |
| 155 void StubCdm::FailRequest(uint32 promise_id) { | |
| 156 std::string message("Operation not supported by stub CDM."); | |
| 157 host_->OnRejectPromise(promise_id, cdm::kInvalidAccessError, 0, | |
| 158 message.data(), message.length()); | |
| 159 } | |
| 160 | |
| 161 } // namespace media | |
| OLD | NEW |