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

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: fixed remaining style issues Created 7 years, 6 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
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 cdm::DecryptedBlock* decrypted_block) { 302 cdm::DecryptedBlock* decrypted_block) {
303 DVLOG(1) << "Decrypt()"; 303 DVLOG(1) << "Decrypt()";
304 DCHECK(encrypted_buffer.data); 304 DCHECK(encrypted_buffer.data);
305 305
306 scoped_refptr<media::DecoderBuffer> buffer; 306 scoped_refptr<media::DecoderBuffer> buffer;
307 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 307 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
308 308
309 if (status != cdm::kSuccess) 309 if (status != cdm::kSuccess)
310 return status; 310 return status;
311 311
312 DCHECK(buffer->GetData()); 312 DCHECK(buffer->data());
313 decrypted_block->SetDecryptedBuffer( 313 decrypted_block->SetDecryptedBuffer(
314 host_->Allocate(buffer->GetDataSize())); 314 host_->Allocate(buffer->data_size()));
315 memcpy(reinterpret_cast<void*>(decrypted_block->DecryptedBuffer()->Data()), 315 memcpy(reinterpret_cast<void*>(decrypted_block->DecryptedBuffer()->Data()),
316 buffer->GetData(), 316 buffer->data(),
317 buffer->GetDataSize()); 317 buffer->data_size());
318 decrypted_block->DecryptedBuffer()->SetSize(buffer->GetDataSize()); 318 decrypted_block->DecryptedBuffer()->SetSize(buffer->data_size());
319 decrypted_block->SetTimestamp(buffer->GetTimestamp().InMicroseconds()); 319 decrypted_block->SetTimestamp(buffer->timestamp().InMicroseconds());
320 320
321 return cdm::kSuccess; 321 return cdm::kSuccess;
322 } 322 }
323 323
324 cdm::Status ClearKeyCdm::InitializeAudioDecoder( 324 cdm::Status ClearKeyCdm::InitializeAudioDecoder(
325 const cdm::AudioDecoderConfig& audio_decoder_config) { 325 const cdm::AudioDecoderConfig& audio_decoder_config) {
326 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) 326 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
327 if (!audio_decoder_) 327 if (!audio_decoder_)
328 audio_decoder_.reset(new webkit_media::FFmpegCdmAudioDecoder(host_)); 328 audio_decoder_.reset(new webkit_media::FFmpegCdmAudioDecoder(host_));
329 329
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 405
406 scoped_refptr<media::DecoderBuffer> buffer; 406 scoped_refptr<media::DecoderBuffer> buffer;
407 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 407 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
408 408
409 if (status != cdm::kSuccess) 409 if (status != cdm::kSuccess)
410 return status; 410 return status;
411 411
412 const uint8_t* data = NULL; 412 const uint8_t* data = NULL;
413 int32_t size = 0; 413 int32_t size = 0;
414 int64_t timestamp = 0; 414 int64_t timestamp = 0;
415 if (!buffer->IsEndOfStream()) { 415 if (!buffer->end_of_stream()) {
416 data = buffer->GetData(); 416 data = buffer->data();
417 size = buffer->GetDataSize(); 417 size = buffer->data_size();
418 timestamp = encrypted_buffer.timestamp; 418 timestamp = encrypted_buffer.timestamp;
419 } 419 }
420 420
421 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame); 421 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame);
422 } 422 }
423 423
424 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples( 424 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples(
425 const cdm::InputBuffer& encrypted_buffer, 425 const cdm::InputBuffer& encrypted_buffer,
426 cdm::AudioFrames* audio_frames) { 426 cdm::AudioFrames* audio_frames) {
427 DVLOG(1) << "DecryptAndDecodeSamples()"; 427 DVLOG(1) << "DecryptAndDecodeSamples()";
428 428
429 scoped_refptr<media::DecoderBuffer> buffer; 429 scoped_refptr<media::DecoderBuffer> buffer;
430 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 430 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
431 431
432 if (status != cdm::kSuccess) 432 if (status != cdm::kSuccess)
433 return status; 433 return status;
434 434
435 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) 435 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
436 const uint8_t* data = NULL; 436 const uint8_t* data = NULL;
437 int32_t size = 0; 437 int32_t size = 0;
438 int64_t timestamp = 0; 438 int64_t timestamp = 0;
439 if (!buffer->IsEndOfStream()) { 439 if (!buffer->end_of_stream()) {
440 data = buffer->GetData(); 440 data = buffer->data();
441 size = buffer->GetDataSize(); 441 size = buffer->data_size();
442 timestamp = encrypted_buffer.timestamp; 442 timestamp = encrypted_buffer.timestamp;
443 } 443 }
444 444
445 return audio_decoder_->DecodeBuffer(data, size, timestamp, audio_frames); 445 return audio_decoder_->DecodeBuffer(data, size, timestamp, audio_frames);
446 #elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) 446 #elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
447 int64 timestamp_in_microseconds = kNoTimestamp; 447 int64 timestamp_in_microseconds = kNoTimestamp;
448 if (!buffer->IsEndOfStream()) { 448 if (!buffer->end_of_stream()) {
449 timestamp_in_microseconds = buffer->GetTimestamp().InMicroseconds(); 449 timestamp_in_microseconds = buffer->GetTimestamp().InMicroseconds();
450 DCHECK(timestamp_in_microseconds != kNoTimestamp); 450 DCHECK(timestamp_in_microseconds != kNoTimestamp);
451 } 451 }
452 return GenerateFakeAudioFrames(timestamp_in_microseconds, audio_frames); 452 return GenerateFakeAudioFrames(timestamp_in_microseconds, audio_frames);
453 #else 453 #else
454 return cdm::kSuccess; 454 return cdm::kSuccess;
455 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 455 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
456 } 456 }
457 457
458 void ClearKeyCdm::Destroy() { 458 void ClearKeyCdm::Destroy() {
(...skipping 16 matching lines...) Expand all
475 timer_delay_ms_ = std::min(2 * timer_delay_ms_, kMaxTimerDelayMs); 475 timer_delay_ms_ = std::min(2 * timer_delay_ms_, kMaxTimerDelayMs);
476 } 476 }
477 477
478 cdm::Status ClearKeyCdm::DecryptToMediaDecoderBuffer( 478 cdm::Status ClearKeyCdm::DecryptToMediaDecoderBuffer(
479 const cdm::InputBuffer& encrypted_buffer, 479 const cdm::InputBuffer& encrypted_buffer,
480 scoped_refptr<media::DecoderBuffer>* decrypted_buffer) { 480 scoped_refptr<media::DecoderBuffer>* decrypted_buffer) {
481 DCHECK(decrypted_buffer); 481 DCHECK(decrypted_buffer);
482 scoped_refptr<media::DecoderBuffer> buffer = 482 scoped_refptr<media::DecoderBuffer> buffer =
483 CopyDecoderBufferFrom(encrypted_buffer); 483 CopyDecoderBufferFrom(encrypted_buffer);
484 484
485 if (buffer->IsEndOfStream()) { 485 if (buffer->end_of_stream()) {
486 *decrypted_buffer = buffer; 486 *decrypted_buffer = buffer;
487 return cdm::kSuccess; 487 return cdm::kSuccess;
488 } 488 }
489 489
490 // Callback is called synchronously, so we can use variables on the stack. 490 // Callback is called synchronously, so we can use variables on the stack.
491 media::Decryptor::Status status = media::Decryptor::kError; 491 media::Decryptor::Status status = media::Decryptor::kError;
492 // The AesDecryptor does not care what the stream type is. Pass kVideo 492 // The AesDecryptor does not care what the stream type is. Pass kVideo
493 // for both audio and video decryption. 493 // for both audio and video decryption.
494 decryptor_.Decrypt( 494 decryptor_.Decrypt(
495 media::Decryptor::kVideo, 495 media::Decryptor::kVideo,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 int samples_generated = GenerateFakeAudioFramesFromDuration( 559 int samples_generated = GenerateFakeAudioFramesFromDuration(
560 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), 560 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(),
561 audio_frames); 561 audio_frames);
562 total_samples_generated_ += samples_generated; 562 total_samples_generated_ += samples_generated;
563 563
564 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; 564 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess;
565 } 565 }
566 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 566 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
567 567
568 } // namespace webkit_media 568 } // namespace webkit_media
OLDNEW
« media/filters/ffmpeg_audio_decoder.cc ('K') | « 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