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" | |
ddorwin
2015/04/03 23:43:39
Do we need this?
jrummell
2015/04/03 23:58:43
Logging on line 25 and the NOTREACHED() at the bot
| |
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( | |
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 // Provide a dummy message (with a trivial session ID) to enable some testing | |
62 // and be consistent with existing testing without a license server. | |
63 std::string session_id(base::UintToString(next_session_id_++)); | |
64 host_->OnResolveNewSessionPromise(promise_id, session_id.data(), | |
65 session_id.length()); | |
66 host_->OnSessionMessage(session_id.data(), session_id.length(), | |
67 cdm::kLicenseRequest, NULL, 0, NULL, 0); | |
xhwang
2015/04/03 23:54:19
nit: use nullptr
jrummell
2015/04/03 23:58:43
Done.
| |
68 } | |
69 | |
70 void StubCdm::LoadSession(uint32 promise_id, | |
71 cdm::SessionType /* session_type */, | |
72 const char* /* session_id */, | |
73 uint32_t /* session_id_length */) { | |
74 FailRequest(promise_id); | |
75 } | |
76 | |
77 void StubCdm::UpdateSession(uint32 promise_id, | |
78 const char* /* session_id */, | |
79 uint32_t /* session_id_length */, | |
80 const uint8* /* response */, | |
81 uint32 /* response_size */) { | |
82 FailRequest(promise_id); | |
83 } | |
84 | |
85 void StubCdm::CloseSession(uint32 promise_id, | |
86 const char* /* session_id */, | |
87 uint32_t /* session_id_length */) { | |
88 FailRequest(promise_id); | |
89 } | |
90 | |
91 void StubCdm::RemoveSession(uint32 promise_id, | |
92 const char* /* session_id */, | |
93 uint32_t /* session_id_length */) { | |
94 FailRequest(promise_id); | |
95 } | |
96 | |
97 void StubCdm::SetServerCertificate( | |
98 uint32 promise_id, | |
99 const uint8_t* /* server_certificate_data */, | |
100 uint32_t /* server_certificate_data_size */) { | |
101 FailRequest(promise_id); | |
102 } | |
103 | |
104 void StubCdm::TimerExpired(void* /* context */) { | |
105 } | |
106 | |
107 cdm::Status StubCdm::Decrypt(const cdm::InputBuffer& /* encrypted_buffer */, | |
108 cdm::DecryptedBlock* /* decrypted_block */) { | |
109 return cdm::kDecryptError; | |
110 } | |
111 | |
112 cdm::Status StubCdm::InitializeAudioDecoder( | |
113 const cdm::AudioDecoderConfig& /* audio_decoder_config */) { | |
114 return cdm::kDecryptError; | |
115 } | |
116 | |
117 cdm::Status StubCdm::InitializeVideoDecoder( | |
118 const cdm::VideoDecoderConfig& /* video_decoder_config */) { | |
119 return cdm::kDecryptError; | |
120 } | |
121 | |
122 void StubCdm::ResetDecoder(cdm::StreamType /* decoder_type */) { | |
123 } | |
124 | |
125 void StubCdm::DeinitializeDecoder(cdm::StreamType /* decoder_type */) { | |
126 } | |
127 | |
128 cdm::Status StubCdm::DecryptAndDecodeFrame( | |
129 const cdm::InputBuffer& /* encrypted_buffer */, | |
130 cdm::VideoFrame* /* decoded_frame */) { | |
131 return cdm::kDecryptError; | |
132 } | |
133 | |
134 cdm::Status StubCdm::DecryptAndDecodeSamples( | |
135 const cdm::InputBuffer& /* encrypted_buffer */, | |
136 cdm::AudioFrames* /* audio_frames */) { | |
137 return cdm::kDecryptError; | |
138 } | |
139 | |
140 void StubCdm::Destroy() { | |
141 delete this; | |
142 } | |
143 | |
144 void StubCdm::OnPlatformChallengeResponse( | |
145 const cdm::PlatformChallengeResponse& /* response */) { | |
146 NOTREACHED(); | |
147 } | |
148 | |
149 void StubCdm::OnQueryOutputProtectionStatus( | |
150 cdm::QueryResult /* result */, | |
151 uint32_t /* link_mask */, | |
152 uint32_t /* output_protection_mask */) { | |
153 NOTREACHED(); | |
154 }; | |
155 | |
156 void StubCdm::FailRequest(uint32 promise_id) { | |
157 std::string message("Operation not supported by stub CDM."); | |
158 host_->OnRejectPromise(promise_id, cdm::kInvalidAccessError, 0, | |
159 message.data(), message.length()); | |
160 } | |
161 | |
162 } // namespace media | |
OLD | NEW |