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

Side by Side Diff: media/cast/audio_receiver/audio_decoder_unittest.cc

Issue 109413004: Cast:Adding cast_transport_config and cleaning up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 11 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
« no previous file with comments | « media/cast/audio_receiver/audio_decoder.cc ('k') | media/cast/audio_receiver/audio_receiver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/test/simple_test_tick_clock.h" 5 #include "base/test/simple_test_tick_clock.h"
6 #include "media/cast/audio_receiver/audio_decoder.h" 6 #include "media/cast/audio_receiver/audio_decoder.h"
7 #include "media/cast/cast_environment.h" 7 #include "media/cast/cast_environment.h"
8 #include "media/cast/test/fake_task_runner.h" 8 #include "media/cast/test/fake_task_runner.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 10
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 }; 24 };
25 } // namespace. 25 } // namespace.
26 26
27 class AudioDecoderTest : public ::testing::Test { 27 class AudioDecoderTest : public ::testing::Test {
28 protected: 28 protected:
29 AudioDecoderTest() { 29 AudioDecoderTest() {
30 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(1234)); 30 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(1234));
31 task_runner_ = new test::FakeTaskRunner(&testing_clock_); 31 task_runner_ = new test::FakeTaskRunner(&testing_clock_);
32 cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_, 32 cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_,
33 task_runner_, task_runner_, task_runner_, task_runner_, 33 task_runner_, task_runner_, task_runner_, task_runner_, task_runner_,
34 GetDefaultCastLoggingConfig()); 34 GetDefaultCastLoggingConfig());
35 } 35 }
36 virtual ~AudioDecoderTest() {} 36 virtual ~AudioDecoderTest() {}
37 37
38 void Configure(const AudioReceiverConfig& audio_config) { 38 void Configure(const AudioReceiverConfig& audio_config) {
39 audio_decoder_.reset( 39 audio_decoder_.reset(
40 new AudioDecoder(cast_environment_, audio_config, &cast_feedback_)); 40 new AudioDecoder(cast_environment_, audio_config, &cast_feedback_));
41 } 41 }
42 42
43 TestRtpPayloadFeedback cast_feedback_; 43 TestRtpPayloadFeedback cast_feedback_;
44 base::SimpleTestTickClock testing_clock_; 44 base::SimpleTestTickClock testing_clock_;
45 scoped_refptr<test::FakeTaskRunner> task_runner_; 45 scoped_refptr<test::FakeTaskRunner> task_runner_;
46 scoped_refptr<CastEnvironment> cast_environment_; 46 scoped_refptr<CastEnvironment> cast_environment_;
47 scoped_ptr<AudioDecoder> audio_decoder_; 47 scoped_ptr<AudioDecoder> audio_decoder_;
48 }; 48 };
49 49
50 TEST_F(AudioDecoderTest, Pcm16MonoNoResampleOnePacket) { 50 TEST_F(AudioDecoderTest, Pcm16MonoNoResampleOnePacket) {
51 AudioReceiverConfig audio_config; 51 AudioReceiverConfig audio_config;
52 audio_config.rtp_payload_type = 127; 52 audio_config.rtp_payload_type = 127;
53 audio_config.frequency = 16000; 53 audio_config.frequency = 16000;
54 audio_config.channels = 1; 54 audio_config.channels = 1;
55 audio_config.codec = kPcm16; 55 audio_config.codec = transport::kPcm16;
56 audio_config.use_external_decoder = false; 56 audio_config.use_external_decoder = false;
57 Configure(audio_config); 57 Configure(audio_config);
58 58
59 RtpCastHeader rtp_header; 59 RtpCastHeader rtp_header;
60 rtp_header.webrtc.header.payloadType = 127; 60 rtp_header.webrtc.header.payloadType = 127;
61 rtp_header.webrtc.header.sequenceNumber = 1234; 61 rtp_header.webrtc.header.sequenceNumber = 1234;
62 rtp_header.webrtc.header.timestamp = 0x87654321; 62 rtp_header.webrtc.header.timestamp = 0x87654321;
63 rtp_header.webrtc.header.ssrc = 0x12345678; 63 rtp_header.webrtc.header.ssrc = 0x12345678;
64 rtp_header.webrtc.header.paddingLength = 0; 64 rtp_header.webrtc.header.paddingLength = 0;
65 rtp_header.webrtc.header.headerLength = 12; 65 rtp_header.webrtc.header.headerLength = 12;
(...skipping 28 matching lines...) Expand all
94 for (size_t i = 10; i < audio_frame.samples.size(); ++i) { 94 for (size_t i = 10; i < audio_frame.samples.size(); ++i) {
95 EXPECT_EQ(0x3412, audio_frame.samples[i]); 95 EXPECT_EQ(0x3412, audio_frame.samples[i]);
96 } 96 }
97 } 97 }
98 98
99 TEST_F(AudioDecoderTest, Pcm16StereoNoResampleTwoPackets) { 99 TEST_F(AudioDecoderTest, Pcm16StereoNoResampleTwoPackets) {
100 AudioReceiverConfig audio_config; 100 AudioReceiverConfig audio_config;
101 audio_config.rtp_payload_type = 127; 101 audio_config.rtp_payload_type = 127;
102 audio_config.frequency = 16000; 102 audio_config.frequency = 16000;
103 audio_config.channels = 2; 103 audio_config.channels = 2;
104 audio_config.codec = kPcm16; 104 audio_config.codec = transport::kPcm16;
105 audio_config.use_external_decoder = false; 105 audio_config.use_external_decoder = false;
106 Configure(audio_config); 106 Configure(audio_config);
107 107
108 RtpCastHeader rtp_header; 108 RtpCastHeader rtp_header;
109 rtp_header.frame_id = 0; 109 rtp_header.frame_id = 0;
110 rtp_header.webrtc.header.payloadType = 127; 110 rtp_header.webrtc.header.payloadType = 127;
111 rtp_header.webrtc.header.sequenceNumber = 1234; 111 rtp_header.webrtc.header.sequenceNumber = 1234;
112 rtp_header.webrtc.header.timestamp = 0x87654321; 112 rtp_header.webrtc.header.timestamp = 0x87654321;
113 rtp_header.webrtc.header.ssrc = 0x12345678; 113 rtp_header.webrtc.header.ssrc = 0x12345678;
114 rtp_header.webrtc.header.paddingLength = 0; 114 rtp_header.webrtc.header.paddingLength = 0;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 audio_decoder_->SendCastMessage(); 164 audio_decoder_->SendCastMessage();
165 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(33)); 165 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(33));
166 audio_decoder_->SendCastMessage(); 166 audio_decoder_->SendCastMessage();
167 } 167 }
168 168
169 TEST_F(AudioDecoderTest, Pcm16Resample) { 169 TEST_F(AudioDecoderTest, Pcm16Resample) {
170 AudioReceiverConfig audio_config; 170 AudioReceiverConfig audio_config;
171 audio_config.rtp_payload_type = 127; 171 audio_config.rtp_payload_type = 127;
172 audio_config.frequency = 16000; 172 audio_config.frequency = 16000;
173 audio_config.channels = 2; 173 audio_config.channels = 2;
174 audio_config.codec = kPcm16; 174 audio_config.codec = transport::kPcm16;
175 audio_config.use_external_decoder = false; 175 audio_config.use_external_decoder = false;
176 Configure(audio_config); 176 Configure(audio_config);
177 177
178 RtpCastHeader rtp_header; 178 RtpCastHeader rtp_header;
179 rtp_header.webrtc.header.payloadType = 127; 179 rtp_header.webrtc.header.payloadType = 127;
180 rtp_header.webrtc.header.sequenceNumber = 1234; 180 rtp_header.webrtc.header.sequenceNumber = 1234;
181 rtp_header.webrtc.header.timestamp = 0x87654321; 181 rtp_header.webrtc.header.timestamp = 0x87654321;
182 rtp_header.webrtc.header.ssrc = 0x12345678; 182 rtp_header.webrtc.header.ssrc = 0x12345678;
183 rtp_header.webrtc.header.paddingLength = 0; 183 rtp_header.webrtc.header.paddingLength = 0;
184 rtp_header.webrtc.header.headerLength = 12; 184 rtp_header.webrtc.header.headerLength = 12;
(...skipping 26 matching lines...) Expand all
211 // Resampling makes the variance worse. 211 // Resampling makes the variance worse.
212 for (size_t i = 100 * audio_config.channels; i < audio_frame.samples.size(); 212 for (size_t i = 100 * audio_config.channels; i < audio_frame.samples.size();
213 ++i) { 213 ++i) {
214 EXPECT_NEAR(0x3412, audio_frame.samples[i], 400); 214 EXPECT_NEAR(0x3412, audio_frame.samples[i], 400);
215 if (0x3412 == audio_frame.samples[i]) count++; 215 if (0x3412 == audio_frame.samples[i]) count++;
216 } 216 }
217 } 217 }
218 218
219 } // namespace cast 219 } // namespace cast
220 } // namespace media 220 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/audio_receiver/audio_decoder.cc ('k') | media/cast/audio_receiver/audio_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698