Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: media/cdm/ppapi/clear_key_cdm.cc

Issue 26592003: Switch CdmWrapper to use uint32_t for size types per style guide. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Stub out deferred impl. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/cdm/ppapi/clear_key_cdm.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "media/cdm/ppapi/clear_key_cdm.h" 5 #include "media/cdm/ppapi/clear_key_cdm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const int64 kMaxTimerDelayMs = 1 * kSecondsPerMinute * kMsPerSecond; 67 const int64 kMaxTimerDelayMs = 1 * kSecondsPerMinute * kMsPerSecond;
68 // Heart beat message header. If a key message starts with |kHeartBeatHeader|, 68 // Heart beat message header. If a key message starts with |kHeartBeatHeader|,
69 // it's a heart beat message. Otherwise, it's a key request. 69 // it's a heart beat message. Otherwise, it's a key request.
70 const char kHeartBeatHeader[] = "HEARTBEAT"; 70 const char kHeartBeatHeader[] = "HEARTBEAT";
71 71
72 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is 72 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is
73 // empty, an empty (end-of-stream) media::DecoderBuffer is returned. 73 // empty, an empty (end-of-stream) media::DecoderBuffer is returned.
74 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( 74 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom(
75 const cdm::InputBuffer& input_buffer) { 75 const cdm::InputBuffer& input_buffer) {
76 if (!input_buffer.data) { 76 if (!input_buffer.data) {
77 DCHECK_EQ(input_buffer.data_size, 0); 77 DCHECK(!input_buffer.data_size);
78 return media::DecoderBuffer::CreateEOSBuffer(); 78 return media::DecoderBuffer::CreateEOSBuffer();
79 } 79 }
80 80
81 // TODO(tomfinegan): Get rid of this copy. 81 // TODO(tomfinegan): Get rid of this copy.
82 scoped_refptr<media::DecoderBuffer> output_buffer = 82 scoped_refptr<media::DecoderBuffer> output_buffer =
83 media::DecoderBuffer::CopyFrom(input_buffer.data, input_buffer.data_size); 83 media::DecoderBuffer::CopyFrom(input_buffer.data, input_buffer.data_size);
84 84
85 std::vector<media::SubsampleEntry> subsamples; 85 std::vector<media::SubsampleEntry> subsamples;
86 for (int32_t i = 0; i < input_buffer.num_subsamples; ++i) { 86 for (uint32_t i = 0; i < input_buffer.num_subsamples; ++i) {
87 media::SubsampleEntry subsample; 87 media::SubsampleEntry subsample;
88 subsample.clear_bytes = input_buffer.subsamples[i].clear_bytes; 88 subsample.clear_bytes = input_buffer.subsamples[i].clear_bytes;
89 subsample.cypher_bytes = input_buffer.subsamples[i].cipher_bytes; 89 subsample.cypher_bytes = input_buffer.subsamples[i].cipher_bytes;
90 subsamples.push_back(subsample); 90 subsamples.push_back(subsample);
91 } 91 }
92 92
93 scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig( 93 scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig(
94 std::string(reinterpret_cast<const char*>(input_buffer.key_id), 94 std::string(reinterpret_cast<const char*>(input_buffer.key_id),
95 input_buffer.key_id_size), 95 input_buffer.key_id_size),
96 std::string(reinterpret_cast<const char*>(input_buffer.iv), 96 std::string(reinterpret_cast<const char*>(input_buffer.iv),
(...skipping 23 matching lines...) Expand all
120 DVLOG(2) << "FFmpeg libraries initialized: " << g_ffmpeg_lib_initialized; 120 DVLOG(2) << "FFmpeg libraries initialized: " << g_ffmpeg_lib_initialized;
121 av_register_all(); 121 av_register_all();
122 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER 122 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
123 } 123 }
124 124
125 void DeinitializeCdmModule() { 125 void DeinitializeCdmModule() {
126 } 126 }
127 127
128 void* CreateCdmInstance( 128 void* CreateCdmInstance(
129 int cdm_interface_version, 129 int cdm_interface_version,
130 const char* key_system, int key_system_size, 130 const char* key_system, uint32_t key_system_size,
131 GetCdmHostFunc get_cdm_host_func, void* user_data) { 131 GetCdmHostFunc get_cdm_host_func, void* user_data) {
132 DVLOG(1) << "CreateCdmInstance()"; 132 DVLOG(1) << "CreateCdmInstance()";
133 133
134 if (std::string(key_system, key_system_size) != kExternalClearKeyKeySystem) { 134 if (std::string(key_system, key_system_size) != kExternalClearKeyKeySystem) {
135 DVLOG(1) << "Unsupported key system."; 135 DVLOG(1) << "Unsupported key system.";
136 return NULL; 136 return NULL;
137 } 137 }
138 138
139 if (cdm_interface_version != cdm::ContentDecryptionModule_1::kVersion) 139 if (cdm_interface_version != cdm::ContentDecryptionModule_1::kVersion)
140 return NULL; 140 return NULL;
141 141
142 cdm::Host* host = static_cast<cdm::Host*>( 142 cdm::Host* host = static_cast<cdm::Host*>(
xhwang 2013/10/22 20:43:03 Use cdm::ContentDecryptionModule_1::Host
DaleCurtis 2013/10/22 21:03:09 Done.
143 get_cdm_host_func(cdm::ContentDecryptionModule_1::kVersion, user_data)); 143 get_cdm_host_func(cdm::ContentDecryptionModule_1::kVersion, user_data));
xhwang 2013/10/22 20:43:03 Use cdm::ContentDecryptionModule_1::Host::kVersion
DaleCurtis 2013/10/22 21:03:09 Done.
144 if (!host) 144 if (!host)
145 return NULL; 145 return NULL;
146 146
147 return new media::ClearKeyCdm(host); 147 return new media::ClearKeyCdm(host);
148 } 148 }
149 149
150 const char* GetCdmVersion() { 150 const char* GetCdmVersion() {
151 return kClearKeyCdmVersion; 151 return kClearKeyCdmVersion;
152 } 152 }
153 153
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 channel_count_ = 0; 196 channel_count_ = 0;
197 bits_per_channel_ = 0; 197 bits_per_channel_ = 0;
198 samples_per_second_ = 0; 198 samples_per_second_ = 0;
199 output_timestamp_base_in_microseconds_ = kNoTimestamp; 199 output_timestamp_base_in_microseconds_ = kNoTimestamp;
200 total_samples_generated_ = 0; 200 total_samples_generated_ = 0;
201 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 201 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
202 } 202 }
203 203
204 ClearKeyCdm::~ClearKeyCdm() {} 204 ClearKeyCdm::~ClearKeyCdm() {}
205 205
206 cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type, int type_size, 206 cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type,
207 uint32_t type_size,
207 const uint8_t* init_data, 208 const uint8_t* init_data,
208 int init_data_size) { 209 uint32_t init_data_size) {
209 DVLOG(1) << "GenerateKeyRequest()"; 210 DVLOG(1) << "GenerateKeyRequest()";
210 base::AutoLock auto_lock(client_lock_); 211 base::AutoLock auto_lock(client_lock_);
211 ScopedResetter<Client> auto_resetter(&client_); 212 ScopedResetter<Client> auto_resetter(&client_);
212 decryptor_.GenerateKeyRequest(std::string(type, type_size), 213 decryptor_.GenerateKeyRequest(std::string(type, type_size),
213 init_data, init_data_size); 214 init_data, init_data_size);
214 215
215 if (client_.status() != Client::kKeyMessage) { 216 if (client_.status() != Client::kKeyMessage) {
216 host_->SendKeyError(NULL, 0, cdm::kUnknownError, 0); 217 host_->SendKeyError(NULL, 0, cdm::kUnknownError, 0);
217 return cdm::kSessionError; 218 return cdm::kSessionError;
218 } 219 }
219 220
220 host_->SendKeyMessage( 221 host_->SendKeyMessage(
221 client_.session_id().data(), client_.session_id().size(), 222 client_.session_id().data(), client_.session_id().size(),
222 reinterpret_cast<const char*>(&client_.key_message()[0]), 223 reinterpret_cast<const char*>(&client_.key_message()[0]),
223 client_.key_message().size(), 224 client_.key_message().size(),
224 client_.default_url().data(), client_.default_url().size()); 225 client_.default_url().data(), client_.default_url().size());
225 226
226 // Only save the latest session ID for heartbeat messages. 227 // Only save the latest session ID for heartbeat messages.
227 heartbeat_session_id_ = client_.session_id(); 228 heartbeat_session_id_ = client_.session_id();
228 229
229 return cdm::kSuccess; 230 return cdm::kSuccess;
230 } 231 }
231 232
232 cdm::Status ClearKeyCdm::AddKey(const char* session_id, 233 cdm::Status ClearKeyCdm::AddKey(const char* session_id,
233 int session_id_size, 234 uint32_t session_id_size,
234 const uint8_t* key, 235 const uint8_t* key,
235 int key_size, 236 uint32_t key_size,
236 const uint8_t* key_id, 237 const uint8_t* key_id,
237 int key_id_size) { 238 uint32_t key_id_size) {
238 DVLOG(1) << "AddKey()"; 239 DVLOG(1) << "AddKey()";
239 base::AutoLock auto_lock(client_lock_); 240 base::AutoLock auto_lock(client_lock_);
240 ScopedResetter<Client> auto_resetter(&client_); 241 ScopedResetter<Client> auto_resetter(&client_);
241 decryptor_.AddKey(key, key_size, key_id, key_id_size, 242 decryptor_.AddKey(key, key_size, key_id, key_id_size,
242 std::string(session_id, session_id_size)); 243 std::string(session_id, session_id_size));
243 244
244 if (client_.status() != Client::kKeyAdded) 245 if (client_.status() != Client::kKeyAdded)
245 return cdm::kSessionError; 246 return cdm::kSessionError;
246 247
247 if (!timer_set_) { 248 if (!timer_set_) {
248 ScheduleNextHeartBeat(); 249 ScheduleNextHeartBeat();
249 timer_set_ = true; 250 timer_set_ = true;
250 } 251 }
251 252
252 return cdm::kSuccess; 253 return cdm::kSuccess;
253 } 254 }
254 255
255 cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id, 256 cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id,
256 int session_id_size) { 257 uint32_t session_id_size) {
257 DVLOG(1) << "CancelKeyRequest()"; 258 DVLOG(1) << "CancelKeyRequest()";
258 base::AutoLock auto_lock(client_lock_); 259 base::AutoLock auto_lock(client_lock_);
259 ScopedResetter<Client> auto_resetter(&client_); 260 ScopedResetter<Client> auto_resetter(&client_);
260 decryptor_.CancelKeyRequest(std::string(session_id, session_id_size)); 261 decryptor_.CancelKeyRequest(std::string(session_id, session_id_size));
261 return cdm::kSuccess; 262 return cdm::kSuccess;
262 } 263 }
263 264
264 void ClearKeyCdm::TimerExpired(void* context) { 265 void ClearKeyCdm::TimerExpired(void* context) {
265 std::string heartbeat_message; 266 std::string heartbeat_message;
266 if (!next_heartbeat_message_.empty() && 267 if (!next_heartbeat_message_.empty() &&
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 int samples_generated = GenerateFakeAudioFramesFromDuration( 554 int samples_generated = GenerateFakeAudioFramesFromDuration(
554 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), 555 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(),
555 audio_frames); 556 audio_frames);
556 total_samples_generated_ += samples_generated; 557 total_samples_generated_ += samples_generated;
557 558
558 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; 559 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess;
559 } 560 }
560 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 561 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
561 562
562 } // namespace media 563 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/ppapi/clear_key_cdm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698