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

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

Issue 74133002: Cast: Removed unnecessary ref counters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge TOT Created 7 years 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
« 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/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "media/cast/audio_receiver/audio_decoder.h" 6 #include "media/cast/audio_receiver/audio_decoder.h"
7 #include "testing/gmock/include/gmock/gmock.h" 7 #include "testing/gmock/include/gmock/gmock.h"
8 8
9 namespace media { 9 namespace media {
10 namespace cast { 10 namespace cast {
11 11
12 class AudioDecoderTest : public ::testing::Test { 12 class AudioDecoderTest : public ::testing::Test {
13 protected: 13 protected:
14 AudioDecoderTest() {} 14 AudioDecoderTest() {}
15 virtual ~AudioDecoderTest() {} 15 virtual ~AudioDecoderTest() {}
16 16
17 void Configure(const AudioReceiverConfig& audio_config) { 17 void Configure(const AudioReceiverConfig& audio_config) {
18 audio_decoder_ = new AudioDecoder(audio_config); 18 audio_decoder_.reset(new AudioDecoder(audio_config));
19 } 19 }
20 20
21 scoped_refptr<AudioDecoder> audio_decoder_; 21 scoped_ptr<AudioDecoder> audio_decoder_;
22 }; 22 };
23 23
24 TEST_F(AudioDecoderTest, Pcm16MonoNoResampleOnePacket) { 24 TEST_F(AudioDecoderTest, Pcm16MonoNoResampleOnePacket) {
25 AudioReceiverConfig audio_config; 25 AudioReceiverConfig audio_config;
26 audio_config.rtp_payload_type = 127; 26 audio_config.rtp_payload_type = 127;
27 audio_config.frequency = 16000; 27 audio_config.frequency = 16000;
28 audio_config.channels = 1; 28 audio_config.channels = 1;
29 audio_config.codec = kPcm16; 29 audio_config.codec = kPcm16;
30 audio_config.use_external_decoder = false; 30 audio_config.use_external_decoder = false;
31 Configure(audio_config); 31 Configure(audio_config);
32 32
33 RtpCastHeader rtp_header; 33 RtpCastHeader rtp_header;
34 rtp_header.webrtc.header.payloadType = 127; 34 rtp_header.webrtc.header.payloadType = 127;
35 rtp_header.webrtc.header.sequenceNumber = 1234; 35 rtp_header.webrtc.header.sequenceNumber = 1234;
36 rtp_header.webrtc.header.timestamp = 0x87654321; 36 rtp_header.webrtc.header.timestamp = 0x87654321;
37 rtp_header.webrtc.header.ssrc = 0x12345678; 37 rtp_header.webrtc.header.ssrc = 0x12345678;
38 rtp_header.webrtc.header.paddingLength = 0; 38 rtp_header.webrtc.header.paddingLength = 0;
39 rtp_header.webrtc.header.headerLength = 12; 39 rtp_header.webrtc.header.headerLength = 12;
40 rtp_header.webrtc.type.Audio.channel = 1; 40 rtp_header.webrtc.type.Audio.channel = 1;
41 rtp_header.webrtc.type.Audio.isCNG = false; 41 rtp_header.webrtc.type.Audio.isCNG = false;
42 42
43 std::vector<int16> payload(640, 0x1234); 43 std::vector<int16> payload(640, 0x1234);
44 int number_of_10ms_blocks = 4;
45 int desired_frequency = 16000;
46 PcmAudioFrame audio_frame;
47 uint32 rtp_timestamp;
48
49 EXPECT_FALSE(audio_decoder_->GetRawAudioFrame(number_of_10ms_blocks,
50 desired_frequency,
51 &audio_frame,
52 &rtp_timestamp));
44 53
45 uint8* payload_data = reinterpret_cast<uint8*>(&payload[0]); 54 uint8* payload_data = reinterpret_cast<uint8*>(&payload[0]);
46 size_t payload_size = payload.size() * sizeof(int16); 55 size_t payload_size = payload.size() * sizeof(int16);
47 56
48 audio_decoder_->IncomingParsedRtpPacket(payload_data, 57 audio_decoder_->IncomingParsedRtpPacket(payload_data,
49 payload_size, rtp_header); 58 payload_size, rtp_header);
50 59
51 int number_of_10ms_blocks = 4;
52 int desired_frequency = 16000;
53 PcmAudioFrame audio_frame;
54 uint32 rtp_timestamp;
55
56 EXPECT_TRUE(audio_decoder_->GetRawAudioFrame(number_of_10ms_blocks, 60 EXPECT_TRUE(audio_decoder_->GetRawAudioFrame(number_of_10ms_blocks,
57 desired_frequency, 61 desired_frequency,
58 &audio_frame, 62 &audio_frame,
59 &rtp_timestamp)); 63 &rtp_timestamp));
60
61 EXPECT_EQ(1, audio_frame.channels); 64 EXPECT_EQ(1, audio_frame.channels);
62 EXPECT_EQ(16000, audio_frame.frequency); 65 EXPECT_EQ(16000, audio_frame.frequency);
63 EXPECT_EQ(640ul, audio_frame.samples.size()); 66 EXPECT_EQ(640ul, audio_frame.samples.size());
64 // First 10 samples per channel are 0 from NetEq. 67 // First 10 samples per channel are 0 from NetEq.
65 for (size_t i = 10; i < audio_frame.samples.size(); ++i) { 68 for (size_t i = 10; i < audio_frame.samples.size(); ++i) {
66 EXPECT_EQ(0x3412, audio_frame.samples[i]); 69 EXPECT_EQ(0x3412, audio_frame.samples[i]);
67 } 70 }
68 } 71 }
69 72
70 TEST_F(AudioDecoderTest, Pcm16StereoNoResampleTwoPackets) { 73 TEST_F(AudioDecoderTest, Pcm16StereoNoResampleTwoPackets) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Resampling makes the variance worse. 180 // Resampling makes the variance worse.
178 for (size_t i = 100 * audio_config.channels; i < audio_frame.samples.size(); 181 for (size_t i = 100 * audio_config.channels; i < audio_frame.samples.size();
179 ++i) { 182 ++i) {
180 EXPECT_NEAR(0x3412, audio_frame.samples[i], 400); 183 EXPECT_NEAR(0x3412, audio_frame.samples[i], 400);
181 if (0x3412 == audio_frame.samples[i]) count++; 184 if (0x3412 == audio_frame.samples[i]) count++;
182 } 185 }
183 } 186 }
184 187
185 } // namespace cast 188 } // namespace cast
186 } // namespace media 189 } // 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