OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "media/cast/audio_sender/audio_encoder.h" | 7 #include "media/cast/audio_sender/audio_encoder.h" |
8 #include "media/cast/cast_config.h" | 8 #include "media/cast/cast_config.h" |
9 #include "media/cast/cast_thread.h" | 9 #include "media/cast/cast_thread.h" |
10 #include "media/cast/test/fake_task_runner.h" | 10 #include "media/cast/test/fake_task_runner.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 audio_config.codec = kOpus; | 38 audio_config.codec = kOpus; |
39 audio_config.use_external_encoder = false; | 39 audio_config.use_external_encoder = false; |
40 audio_config.frequency = 48000; | 40 audio_config.frequency = 48000; |
41 audio_config.channels = 2; | 41 audio_config.channels = 2; |
42 audio_config.bitrate = 64000; | 42 audio_config.bitrate = 64000; |
43 audio_config.rtp_payload_type = 127; | 43 audio_config.rtp_payload_type = 127; |
44 | 44 |
45 audio_encoder_ = new AudioEncoder(cast_thread_, audio_config); | 45 audio_encoder_ = new AudioEncoder(cast_thread_, audio_config); |
46 } | 46 } |
47 | 47 |
48 virtual ~AudioEncoderTest() {} | 48 ~AudioEncoderTest() {} |
49 | 49 |
50 base::SimpleTestTickClock testing_clock_; | 50 base::SimpleTestTickClock testing_clock_; |
51 scoped_refptr<test::FakeTaskRunner> task_runner_; | 51 scoped_refptr<test::FakeTaskRunner> task_runner_; |
52 scoped_refptr<AudioEncoder> audio_encoder_; | 52 scoped_refptr<AudioEncoder> audio_encoder_; |
53 scoped_refptr<CastThread> cast_thread_; | 53 scoped_refptr<CastThread> cast_thread_; |
54 }; | 54 }; |
55 | 55 |
56 TEST_F(AudioEncoderTest, Encode20ms) { | 56 TEST_F(AudioEncoderTest, Encode20ms) { |
57 PcmAudioFrame* audio_frame = new PcmAudioFrame(); | 57 PcmAudioFrame* audio_frame = new PcmAudioFrame(); |
58 audio_frame->channels = 2; | 58 audio_frame->channels = 2; |
59 audio_frame->frequency = 48000; | 59 audio_frame->frequency = 48000; |
60 audio_frame->samples.insert(audio_frame->samples.begin(), 480 * 2 * 2, 123); | 60 audio_frame->samples.insert(audio_frame->samples.begin(), 480 * 2 * 2, 123); |
61 | 61 |
62 base::TimeTicks recorded_time; | 62 base::TimeTicks recorded_time; |
63 audio_encoder_->InsertRawAudioFrame(audio_frame, recorded_time, | 63 audio_encoder_->InsertRawAudioFrame(audio_frame, recorded_time, |
64 base::Bind(&FrameEncoded), | 64 base::Bind(&FrameEncoded), |
65 base::Bind(&RelaseFrame, audio_frame)); | 65 base::Bind(&RelaseFrame, audio_frame)); |
66 task_runner_->RunTasks(); | 66 task_runner_->RunTasks(); |
67 } | 67 } |
68 | 68 |
69 } // namespace cast | 69 } // namespace cast |
70 } // namespace media | 70 } // namespace media |
OLD | NEW |