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

Side by Side Diff: webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc

Issue 1203803004: Adding a new ChangeLogger class to handle UMA logging of bitrates (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 13 matching lines...) Expand all
24 const int kDataLengthSamples = 80; 24 const int kDataLengthSamples = 80;
25 const int kPacketSizeSamples = 2 * kDataLengthSamples; 25 const int kPacketSizeSamples = 2 * kDataLengthSamples;
26 const int16_t kZeroData[kDataLengthSamples] = {0}; 26 const int16_t kZeroData[kDataLengthSamples] = {0};
27 const CodecInst kDefaultCodecInst = 27 const CodecInst kDefaultCodecInst =
28 {0, "pcmu", 8000, kPacketSizeSamples, 1, 64000}; 28 {0, "pcmu", 8000, kPacketSizeSamples, 1, 64000};
29 const int kCngPt = 13; 29 const int kCngPt = 13;
30 } // namespace 30 } // namespace
31 31
32 class CodecOwnerTest : public ::testing::Test { 32 class CodecOwnerTest : public ::testing::Test {
33 protected: 33 protected:
34 CodecOwnerTest() : timestamp_(0) {} 34 CodecOwnerTest() : codec_owner_(nullptr), timestamp_(0) {}
35 35
36 void CreateCodec() { 36 void CreateCodec() {
37 codec_owner_.SetEncoders(kDefaultCodecInst, kCngPt, VADNormal, -1); 37 codec_owner_.SetEncoders(kDefaultCodecInst, kCngPt, VADNormal, -1);
38 } 38 }
39 39
40 void EncodeAndVerify(size_t expected_out_length, 40 void EncodeAndVerify(size_t expected_out_length,
41 uint32_t expected_timestamp, 41 uint32_t expected_timestamp,
42 int expected_payload_type, 42 int expected_payload_type,
43 int expected_send_even_if_empty) { 43 int expected_send_even_if_empty) {
44 uint8_t out[kPacketSizeSamples]; 44 uint8_t out[kPacketSizeSamples];
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Verify NoEncoding. 93 // Verify NoEncoding.
94 expected_timestamp += 2 * kDataLengthSamples; 94 expected_timestamp += 2 * kDataLengthSamples;
95 { 95 {
96 SCOPED_TRACE("Fourth encoding"); 96 SCOPED_TRACE("Fourth encoding");
97 EncodeAndVerify(0, expected_timestamp, kCngPt, 1); 97 EncodeAndVerify(0, expected_timestamp, kCngPt, 1);
98 } 98 }
99 } 99 }
100 100
101 TEST_F(CodecOwnerTest, ExternalEncoder) { 101 TEST_F(CodecOwnerTest, ExternalEncoder) {
102 MockAudioEncoderMutable external_encoder; 102 MockAudioEncoderMutable external_encoder;
103 EXPECT_CALL(external_encoder, GetTargetBitrate())
104 .WillRepeatedly(Return(-1)); // Flag adaptive bitrate (doesn't matter).
105 codec_owner_.SetEncoders(&external_encoder, -1, VADNormal, -1); 103 codec_owner_.SetEncoders(&external_encoder, -1, VADNormal, -1);
106 const int kSampleRateHz = 8000; 104 const int kSampleRateHz = 8000;
107 const int kPacketSizeSamples = kSampleRateHz / 100; 105 const int kPacketSizeSamples = kSampleRateHz / 100;
108 int16_t audio[kPacketSizeSamples] = {0}; 106 int16_t audio[kPacketSizeSamples] = {0};
109 uint8_t encoded[kPacketSizeSamples]; 107 uint8_t encoded[kPacketSizeSamples];
110 AudioEncoder::EncodedInfo info; 108 AudioEncoder::EncodedInfo info;
111 EXPECT_CALL(external_encoder, SampleRateHz()) 109 EXPECT_CALL(external_encoder, SampleRateHz())
112 .WillRepeatedly(Return(kSampleRateHz)); 110 .WillRepeatedly(Return(kSampleRateHz));
113 111
114 { 112 {
(...skipping 28 matching lines...) Expand all
143 // Change back to external encoder again. 141 // Change back to external encoder again.
144 codec_owner_.SetEncoders(&external_encoder, -1, VADNormal, -1); 142 codec_owner_.SetEncoders(&external_encoder, -1, VADNormal, -1);
145 info = codec_owner_.Encoder()->Encode(2, audio, arraysize(audio), 143 info = codec_owner_.Encoder()->Encode(2, audio, arraysize(audio),
146 arraysize(encoded), encoded); 144 arraysize(encoded), encoded);
147 EXPECT_EQ(2u, info.encoded_timestamp); 145 EXPECT_EQ(2u, info.encoded_timestamp);
148 external_encoder.Reset(); // Dummy call to mark the sequence of expectations. 146 external_encoder.Reset(); // Dummy call to mark the sequence of expectations.
149 } 147 }
150 148
151 } // namespace acm2 149 } // namespace acm2
152 } // namespace webrtc 150 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698