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

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

Issue 11929015: Tighten up media::DecoderBuffer API contract for end of stream buffers (round 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/media/crypto/ppapi/clear_key_cdm.h" 5 #include "webkit/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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 cdm::VideoFrame* decoded_frame) { 405 cdm::VideoFrame* decoded_frame) {
406 DVLOG(1) << "DecryptAndDecodeFrame()"; 406 DVLOG(1) << "DecryptAndDecodeFrame()";
407 TRACE_EVENT0("eme", "ClearKeyCdm::DecryptAndDecodeFrame"); 407 TRACE_EVENT0("eme", "ClearKeyCdm::DecryptAndDecodeFrame");
408 408
409 scoped_refptr<media::DecoderBuffer> buffer; 409 scoped_refptr<media::DecoderBuffer> buffer;
410 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 410 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
411 411
412 if (status != cdm::kSuccess) 412 if (status != cdm::kSuccess)
413 return status; 413 return status;
414 414
415 DCHECK(status == cdm::kSuccess); 415 const uint8_t* data = NULL;
416 DCHECK(buffer); 416 int32_t size = 0;
417 return video_decoder_->DecodeFrame(buffer.get()->GetData(), 417 int64_t timestamp = 0;
418 buffer->GetDataSize(), 418 if (!buffer->IsEndOfStream()) {
419 encrypted_buffer.timestamp, 419 data = buffer->GetData();
420 decoded_frame); 420 size = buffer->GetDataSize();
421 timestamp = encrypted_buffer.timestamp;
422 }
423
424 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame);
421 } 425 }
422 426
423 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples( 427 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples(
424 const cdm::InputBuffer& encrypted_buffer, 428 const cdm::InputBuffer& encrypted_buffer,
425 cdm::AudioFrames* audio_frames) { 429 cdm::AudioFrames* audio_frames) {
426 DVLOG(1) << "DecryptAndDecodeSamples()"; 430 DVLOG(1) << "DecryptAndDecodeSamples()";
427 431
428 scoped_refptr<media::DecoderBuffer> buffer; 432 scoped_refptr<media::DecoderBuffer> buffer;
429 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 433 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
430 434
431 if (status != cdm::kSuccess) 435 if (status != cdm::kSuccess)
432 return status; 436 return status;
433 437
434 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) 438 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
435 DCHECK(status == cdm::kSuccess); 439 const uint8_t* data = NULL;
436 DCHECK(buffer); 440 int32_t size = 0;
437 return audio_decoder_->DecodeBuffer(buffer.get()->GetData(), 441 int64_t timestamp = 0;
438 buffer->GetDataSize(), 442 if (!buffer->IsEndOfStream()) {
439 encrypted_buffer.timestamp, 443 data = buffer->GetData();
440 audio_frames); 444 size = buffer->GetDataSize();
445 timestamp = encrypted_buffer.timestamp;
446 }
447
448 return audio_decoder_->DecodeBuffer(data, size, timestamp, audio_frames);
441 #elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) 449 #elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
442 int64 timestamp_in_microseconds = kNoTimestamp; 450 int64 timestamp_in_microseconds = kNoTimestamp;
443 if (!buffer->IsEndOfStream()) { 451 if (!buffer->IsEndOfStream()) {
444 timestamp_in_microseconds = buffer->GetTimestamp().InMicroseconds(); 452 timestamp_in_microseconds = buffer->GetTimestamp().InMicroseconds();
445 DCHECK(timestamp_in_microseconds != kNoTimestamp); 453 DCHECK(timestamp_in_microseconds != kNoTimestamp);
446 } 454 }
447 return GenerateFakeAudioFrames(timestamp_in_microseconds, audio_frames); 455 return GenerateFakeAudioFrames(timestamp_in_microseconds, audio_frames);
448 #else 456 #else
449 return cdm::kSuccess; 457 return cdm::kSuccess;
450 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 458 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 int samples_generated = GenerateFakeAudioFramesFromDuration( 557 int samples_generated = GenerateFakeAudioFramesFromDuration(
550 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), 558 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(),
551 audio_frames); 559 audio_frames);
552 total_samples_generated_ += samples_generated; 560 total_samples_generated_ += samples_generated;
553 561
554 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; 562 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess;
555 } 563 }
556 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 564 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
557 565
558 } // namespace webkit_media 566 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/crypto/ppapi/cdm_video_decoder.h ('k') | webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698