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