OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cast/test/fake_media_source.h" | 5 #include "media/cast/test/fake_media_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 // This is set to the frequency we send to the receiver. | 463 // This is set to the frequency we send to the receiver. |
464 // Not the frequency of the source file. This is because we | 464 // Not the frequency of the source file. This is because we |
465 // increment the frame count by samples we sent. | 465 // increment the frame count by samples we sent. |
466 audio_sent_ts_.reset( | 466 audio_sent_ts_.reset( |
467 new AudioTimestampHelper(output_audio_params_.sample_rate())); | 467 new AudioTimestampHelper(output_audio_params_.sample_rate())); |
468 // For some files this is an invalid value. | 468 // For some files this is an invalid value. |
469 base::TimeDelta base_ts; | 469 base::TimeDelta base_ts; |
470 audio_sent_ts_->SetBaseTimestamp(base_ts); | 470 audio_sent_ts_->SetBaseTimestamp(base_ts); |
471 } | 471 } |
472 | 472 |
473 scoped_refptr<AudioBuffer> buffer = | 473 scoped_refptr<AudioBuffer> buffer = AudioBuffer::CopyFrom( |
474 AudioBuffer::CopyFrom( | 474 AVSampleFormatToSampleFormat(av_audio_context()->sample_fmt, |
475 AVSampleFormatToSampleFormat( | 475 av_audio_context()->codec_id), |
476 av_audio_context()->sample_fmt), | 476 ChannelLayoutToChromeChannelLayout(av_audio_context()->channel_layout, |
477 ChannelLayoutToChromeChannelLayout( | 477 av_audio_context()->channels), |
478 av_audio_context()->channel_layout, | 478 av_audio_context()->channels, av_audio_context()->sample_rate, |
479 av_audio_context()->channels), | 479 frames_read, &avframe->data[0], |
480 av_audio_context()->channels, | 480 PtsToTimeDelta(avframe->pkt_pts, av_audio_stream()->time_base)); |
481 av_audio_context()->sample_rate, | |
482 frames_read, | |
483 &avframe->data[0], | |
484 PtsToTimeDelta(avframe->pkt_pts, av_audio_stream()->time_base)); | |
485 audio_algo_.EnqueueBuffer(buffer); | 481 audio_algo_.EnqueueBuffer(buffer); |
486 av_frame_unref(avframe); | 482 av_frame_unref(avframe); |
487 } while (packet_temp.size > 0); | 483 } while (packet_temp.size > 0); |
488 av_frame_free(&avframe); | 484 av_frame_free(&avframe); |
489 | 485 |
490 const int frames_needed_to_scale = | 486 const int frames_needed_to_scale = |
491 playback_rate_ * av_audio_context()->sample_rate / | 487 playback_rate_ * av_audio_context()->sample_rate / |
492 kAudioPacketsPerSecond; | 488 kAudioPacketsPerSecond; |
493 while (frames_needed_to_scale <= audio_algo_.frames_buffered()) { | 489 while (frames_needed_to_scale <= audio_algo_.frames_buffered()) { |
494 if (!audio_algo_.FillBuffer(audio_fifo_input_bus_.get(), 0, | 490 if (!audio_algo_.FillBuffer(audio_fifo_input_bus_.get(), 0, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 AVCodecContext* FakeMediaSource::av_audio_context() { | 609 AVCodecContext* FakeMediaSource::av_audio_context() { |
614 return av_audio_stream()->codec; | 610 return av_audio_stream()->codec; |
615 } | 611 } |
616 | 612 |
617 AVCodecContext* FakeMediaSource::av_video_context() { | 613 AVCodecContext* FakeMediaSource::av_video_context() { |
618 return av_video_stream()->codec; | 614 return av_video_stream()->codec; |
619 } | 615 } |
620 | 616 |
621 } // namespace cast | 617 } // namespace cast |
622 } // namespace media | 618 } // namespace media |
OLD | NEW |