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

Side by Side Diff: webkit/renderer/media/crypto/ppapi/clear_key_cdm.cc

Issue 17408005: Refactored DecoderBuffer to use unix_hacker_style naming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@localrefactor
Patch Set: Created 7 years, 5 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
« no previous file with comments | « webkit/plugins/ppapi/content_decryptor_delegate.cc ('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 "webkit/renderer/media/crypto/ppapi/clear_key_cdm.h" 5 #include "webkit/renderer/media/crypto/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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
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),
97 input_buffer.iv_size), 97 input_buffer.iv_size),
98 input_buffer.data_offset, 98 input_buffer.data_offset,
99 subsamples)); 99 subsamples));
100 100
101 output_buffer->SetDecryptConfig(decrypt_config.Pass()); 101 output_buffer->set_decrypt_config(decrypt_config.Pass());
102 output_buffer->SetTimestamp( 102 output_buffer->set_timestamp(
103 base::TimeDelta::FromMicroseconds(input_buffer.timestamp)); 103 base::TimeDelta::FromMicroseconds(input_buffer.timestamp));
104 104
105 return output_buffer; 105 return output_buffer;
106 } 106 }
107 107
108 template<typename Type> 108 template<typename Type>
109 class ScopedResetter { 109 class ScopedResetter {
110 public: 110 public:
111 explicit ScopedResetter(Type* object) : object_(object) {} 111 explicit ScopedResetter(Type* object) : object_(object) {}
112 ~ScopedResetter() { object_->Reset(); } 112 ~ScopedResetter() { object_->Reset(); }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 cdm::DecryptedBlock* decrypted_block) { 292 cdm::DecryptedBlock* decrypted_block) {
293 DVLOG(1) << "Decrypt()"; 293 DVLOG(1) << "Decrypt()";
294 DCHECK(encrypted_buffer.data); 294 DCHECK(encrypted_buffer.data);
295 295
296 scoped_refptr<media::DecoderBuffer> buffer; 296 scoped_refptr<media::DecoderBuffer> buffer;
297 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 297 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
298 298
299 if (status != cdm::kSuccess) 299 if (status != cdm::kSuccess)
300 return status; 300 return status;
301 301
302 DCHECK(buffer->GetData()); 302 DCHECK(buffer->data());
303 decrypted_block->SetDecryptedBuffer( 303 decrypted_block->SetDecryptedBuffer(
304 host_->Allocate(buffer->GetDataSize())); 304 host_->Allocate(buffer->data_size()));
305 memcpy(reinterpret_cast<void*>(decrypted_block->DecryptedBuffer()->Data()), 305 memcpy(reinterpret_cast<void*>(decrypted_block->DecryptedBuffer()->Data()),
306 buffer->GetData(), 306 buffer->data(),
307 buffer->GetDataSize()); 307 buffer->data_size());
308 decrypted_block->DecryptedBuffer()->SetSize(buffer->GetDataSize()); 308 decrypted_block->DecryptedBuffer()->SetSize(buffer->data_size());
309 decrypted_block->SetTimestamp(buffer->GetTimestamp().InMicroseconds()); 309 decrypted_block->SetTimestamp(buffer->timestamp().InMicroseconds());
310 310
311 return cdm::kSuccess; 311 return cdm::kSuccess;
312 } 312 }
313 313
314 cdm::Status ClearKeyCdm::InitializeAudioDecoder( 314 cdm::Status ClearKeyCdm::InitializeAudioDecoder(
315 const cdm::AudioDecoderConfig& audio_decoder_config) { 315 const cdm::AudioDecoderConfig& audio_decoder_config) {
316 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) 316 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
317 if (!audio_decoder_) 317 if (!audio_decoder_)
318 audio_decoder_.reset(new webkit_media::FFmpegCdmAudioDecoder(host_)); 318 audio_decoder_.reset(new webkit_media::FFmpegCdmAudioDecoder(host_));
319 319
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 395
396 scoped_refptr<media::DecoderBuffer> buffer; 396 scoped_refptr<media::DecoderBuffer> buffer;
397 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 397 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
398 398
399 if (status != cdm::kSuccess) 399 if (status != cdm::kSuccess)
400 return status; 400 return status;
401 401
402 const uint8_t* data = NULL; 402 const uint8_t* data = NULL;
403 int32_t size = 0; 403 int32_t size = 0;
404 int64_t timestamp = 0; 404 int64_t timestamp = 0;
405 if (!buffer->IsEndOfStream()) { 405 if (!buffer->end_of_stream()) {
406 data = buffer->GetData(); 406 data = buffer->data();
407 size = buffer->GetDataSize(); 407 size = buffer->data_size();
408 timestamp = encrypted_buffer.timestamp; 408 timestamp = encrypted_buffer.timestamp;
409 } 409 }
410 410
411 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame); 411 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame);
412 } 412 }
413 413
414 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples( 414 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples(
415 const cdm::InputBuffer& encrypted_buffer, 415 const cdm::InputBuffer& encrypted_buffer,
416 cdm::AudioFrames* audio_frames) { 416 cdm::AudioFrames* audio_frames) {
417 DVLOG(1) << "DecryptAndDecodeSamples()"; 417 DVLOG(1) << "DecryptAndDecodeSamples()";
418 418
419 scoped_refptr<media::DecoderBuffer> buffer; 419 scoped_refptr<media::DecoderBuffer> buffer;
420 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 420 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
421 421
422 if (status != cdm::kSuccess) 422 if (status != cdm::kSuccess)
423 return status; 423 return status;
424 424
425 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) 425 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
426 const uint8_t* data = NULL; 426 const uint8_t* data = NULL;
427 int32_t size = 0; 427 int32_t size = 0;
428 int64_t timestamp = 0; 428 int64_t timestamp = 0;
429 if (!buffer->IsEndOfStream()) { 429 if (!buffer->end_of_stream()) {
430 data = buffer->GetData(); 430 data = buffer->data();
431 size = buffer->GetDataSize(); 431 size = buffer->data_size();
432 timestamp = encrypted_buffer.timestamp; 432 timestamp = encrypted_buffer.timestamp;
433 } 433 }
434 434
435 return audio_decoder_->DecodeBuffer(data, size, timestamp, audio_frames); 435 return audio_decoder_->DecodeBuffer(data, size, timestamp, audio_frames);
436 #elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) 436 #elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
437 int64 timestamp_in_microseconds = kNoTimestamp; 437 int64 timestamp_in_microseconds = kNoTimestamp;
438 if (!buffer->IsEndOfStream()) { 438 if (!buffer->end_of_stream()) {
439 timestamp_in_microseconds = buffer->GetTimestamp().InMicroseconds(); 439 timestamp_in_microseconds = buffer->GetTimestamp().InMicroseconds();
440 DCHECK(timestamp_in_microseconds != kNoTimestamp); 440 DCHECK(timestamp_in_microseconds != kNoTimestamp);
441 } 441 }
442 return GenerateFakeAudioFrames(timestamp_in_microseconds, audio_frames); 442 return GenerateFakeAudioFrames(timestamp_in_microseconds, audio_frames);
443 #else 443 #else
444 return cdm::kSuccess; 444 return cdm::kSuccess;
445 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 445 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
446 } 446 }
447 447
448 void ClearKeyCdm::Destroy() { 448 void ClearKeyCdm::Destroy() {
(...skipping 16 matching lines...) Expand all
465 timer_delay_ms_ = std::min(2 * timer_delay_ms_, kMaxTimerDelayMs); 465 timer_delay_ms_ = std::min(2 * timer_delay_ms_, kMaxTimerDelayMs);
466 } 466 }
467 467
468 cdm::Status ClearKeyCdm::DecryptToMediaDecoderBuffer( 468 cdm::Status ClearKeyCdm::DecryptToMediaDecoderBuffer(
469 const cdm::InputBuffer& encrypted_buffer, 469 const cdm::InputBuffer& encrypted_buffer,
470 scoped_refptr<media::DecoderBuffer>* decrypted_buffer) { 470 scoped_refptr<media::DecoderBuffer>* decrypted_buffer) {
471 DCHECK(decrypted_buffer); 471 DCHECK(decrypted_buffer);
472 scoped_refptr<media::DecoderBuffer> buffer = 472 scoped_refptr<media::DecoderBuffer> buffer =
473 CopyDecoderBufferFrom(encrypted_buffer); 473 CopyDecoderBufferFrom(encrypted_buffer);
474 474
475 if (buffer->IsEndOfStream()) { 475 if (buffer->end_of_stream()) {
476 *decrypted_buffer = buffer; 476 *decrypted_buffer = buffer;
477 return cdm::kSuccess; 477 return cdm::kSuccess;
478 } 478 }
479 479
480 // Callback is called synchronously, so we can use variables on the stack. 480 // Callback is called synchronously, so we can use variables on the stack.
481 media::Decryptor::Status status = media::Decryptor::kError; 481 media::Decryptor::Status status = media::Decryptor::kError;
482 // The AesDecryptor does not care what the stream type is. Pass kVideo 482 // The AesDecryptor does not care what the stream type is. Pass kVideo
483 // for both audio and video decryption. 483 // for both audio and video decryption.
484 decryptor_.Decrypt( 484 decryptor_.Decrypt(
485 media::Decryptor::kVideo, 485 media::Decryptor::kVideo,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 int samples_generated = GenerateFakeAudioFramesFromDuration( 549 int samples_generated = GenerateFakeAudioFramesFromDuration(
550 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), 550 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(),
551 audio_frames); 551 audio_frames);
552 total_samples_generated_ += samples_generated; 552 total_samples_generated_ += samples_generated;
553 553
554 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; 554 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess;
555 } 555 }
556 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 556 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
557 557
558 } // namespace webkit_media 558 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/content_decryptor_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698