OLD | NEW |
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 "media/filters/decrypting_audio_decoder.h" | 5 #include "media/filters/decrypting_audio_decoder.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 void DecryptingAudioDecoder::EnqueueFrames( | 452 void DecryptingAudioDecoder::EnqueueFrames( |
453 const Decryptor::AudioBuffers& frames) { | 453 const Decryptor::AudioBuffers& frames) { |
454 queued_audio_frames_ = frames; | 454 queued_audio_frames_ = frames; |
455 | 455 |
456 for (Decryptor::AudioBuffers::iterator iter = queued_audio_frames_.begin(); | 456 for (Decryptor::AudioBuffers::iterator iter = queued_audio_frames_.begin(); |
457 iter != queued_audio_frames_.end(); | 457 iter != queued_audio_frames_.end(); |
458 ++iter) { | 458 ++iter) { |
459 scoped_refptr<DataBuffer>& frame = *iter; | 459 scoped_refptr<DataBuffer>& frame = *iter; |
460 | 460 |
461 DCHECK(!frame->IsEndOfStream()) << "EOS frame returned."; | 461 DCHECK(!frame->end_of_stream()) << "EOS frame returned."; |
462 DCHECK_GT(frame->GetDataSize(), 0) << "Empty frame returned."; | 462 DCHECK_GT(frame->data_size(), 0) << "Empty frame returned."; |
463 | 463 |
464 base::TimeDelta cur_timestamp = output_timestamp_base_ + | 464 base::TimeDelta cur_timestamp = output_timestamp_base_ + |
465 NumberOfSamplesToDuration(total_samples_decoded_); | 465 NumberOfSamplesToDuration(total_samples_decoded_); |
466 if (IsOutOfSync(cur_timestamp, frame->GetTimestamp())) { | 466 if (IsOutOfSync(cur_timestamp, frame->timestamp())) { |
467 DVLOG(1) << "Timestamp returned by the decoder (" | 467 DVLOG(1) << "Timestamp returned by the decoder (" |
468 << frame->GetTimestamp().InMilliseconds() << " ms)" | 468 << frame->timestamp().InMilliseconds() << " ms)" |
469 << " does not match the input timestamp and number of samples" | 469 << " does not match the input timestamp and number of samples" |
470 << " decoded (" << cur_timestamp.InMilliseconds() << " ms)."; | 470 << " decoded (" << cur_timestamp.InMilliseconds() << " ms)."; |
471 } | 471 } |
472 frame->SetTimestamp(cur_timestamp); | 472 frame->set_timestamp(cur_timestamp); |
473 | 473 |
474 int frame_size = frame->GetDataSize(); | 474 int frame_size = frame->data_size(); |
475 DCHECK_EQ(frame_size % bytes_per_sample_, 0) << | 475 DCHECK_EQ(frame_size % bytes_per_sample_, 0) << |
476 "Decoder didn't output full samples"; | 476 "Decoder didn't output full samples"; |
477 int samples_decoded = frame_size / bytes_per_sample_; | 477 int samples_decoded = frame_size / bytes_per_sample_; |
478 total_samples_decoded_ += samples_decoded; | 478 total_samples_decoded_ += samples_decoded; |
479 | 479 |
480 base::TimeDelta next_timestamp = output_timestamp_base_ + | 480 base::TimeDelta next_timestamp = output_timestamp_base_ + |
481 NumberOfSamplesToDuration(total_samples_decoded_); | 481 NumberOfSamplesToDuration(total_samples_decoded_); |
482 base::TimeDelta duration = next_timestamp - cur_timestamp; | 482 base::TimeDelta duration = next_timestamp - cur_timestamp; |
483 frame->SetDuration(duration); | 483 frame->set_duration(duration); |
484 } | 484 } |
485 } | 485 } |
486 | 486 |
487 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( | 487 base::TimeDelta DecryptingAudioDecoder::NumberOfSamplesToDuration( |
488 int number_of_samples) const { | 488 int number_of_samples) const { |
489 DCHECK(samples_per_second_); | 489 DCHECK(samples_per_second_); |
490 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * | 490 return base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond * |
491 number_of_samples / | 491 number_of_samples / |
492 samples_per_second_); | 492 samples_per_second_); |
493 } | 493 } |
494 | 494 |
495 } // namespace media | 495 } // namespace media |
OLD | NEW |