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

Side by Side Diff: webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.cc

Issue 2365653004: AudioCodingModule: Specify decoders using SdpAudioFormat (Closed)
Patch Set: rebase Created 4 years, 2 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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
11 #include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h" 11 #include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <stdio.h> 14 #include <stdio.h>
15 15
16 #include <memory> 16 #include <memory>
17 17
18 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
18 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" 19 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
19 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" 20 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h"
20 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" 21 #include "webrtc/modules/audio_coding/neteq/tools/packet.h"
21 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" 22 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h"
22 #include "webrtc/test/gtest.h" 23 #include "webrtc/test/gtest.h"
23 24
24 namespace webrtc { 25 namespace webrtc {
25 namespace test { 26 namespace test {
26 27
27 namespace { 28 namespace {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } else if (STR_CASE_CMP(plname, "L16") == 0 && plfreq == 32000) { 91 } else if (STR_CASE_CMP(plname, "L16") == 0 && plfreq == 32000) {
91 *pltype = 95; 92 *pltype = 95;
92 } else if (STR_CASE_CMP(plname, "G722") == 0) { 93 } else if (STR_CASE_CMP(plname, "G722") == 0) {
93 *pltype = 9; 94 *pltype = 9;
94 } else { 95 } else {
95 // Don't use any other codecs. 96 // Don't use any other codecs.
96 return false; 97 return false;
97 } 98 }
98 return true; 99 return true;
99 } 100 }
101
102 AudioCodingModule::Config MakeAcmConfig(
103 Clock* clock,
104 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory) {
105 AudioCodingModule::Config config;
106 config.id = 0;
107 config.clock = clock;
108 config.decoder_factory = std::move(decoder_factory);
109 return config;
110 }
111
100 } // namespace 112 } // namespace
101 113
102 AcmReceiveTestOldApi::AcmReceiveTestOldApi( 114 AcmReceiveTestOldApi::AcmReceiveTestOldApi(
103 PacketSource* packet_source, 115 PacketSource* packet_source,
104 AudioSink* audio_sink, 116 AudioSink* audio_sink,
105 int output_freq_hz, 117 int output_freq_hz,
106 NumOutputChannels exptected_output_channels) 118 NumOutputChannels exptected_output_channels,
119 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory)
107 : clock_(0), 120 : clock_(0),
108 acm_(webrtc::AudioCodingModule::Create(0, &clock_)), 121 acm_(webrtc::AudioCodingModule::Create(
122 MakeAcmConfig(&clock_, std::move(decoder_factory)))),
109 packet_source_(packet_source), 123 packet_source_(packet_source),
110 audio_sink_(audio_sink), 124 audio_sink_(audio_sink),
111 output_freq_hz_(output_freq_hz), 125 output_freq_hz_(output_freq_hz),
112 exptected_output_channels_(exptected_output_channels) { 126 exptected_output_channels_(exptected_output_channels) {}
113 }
114 127
115 AcmReceiveTestOldApi::~AcmReceiveTestOldApi() = default; 128 AcmReceiveTestOldApi::~AcmReceiveTestOldApi() = default;
116 129
117 void AcmReceiveTestOldApi::RegisterDefaultCodecs() { 130 void AcmReceiveTestOldApi::RegisterDefaultCodecs() {
118 CodecInst my_codec_param; 131 CodecInst my_codec_param;
119 for (int n = 0; n < acm_->NumberOfCodecs(); n++) { 132 for (int n = 0; n < acm_->NumberOfCodecs(); n++) {
120 ASSERT_EQ(0, acm_->Codec(n, &my_codec_param)) << "Failed to get codec."; 133 ASSERT_EQ(0, acm_->Codec(n, &my_codec_param)) << "Failed to get codec.";
121 if (ModifyAndUseThisCodec(&my_codec_param)) { 134 if (ModifyAndUseThisCodec(&my_codec_param)) {
122 ASSERT_EQ(0, acm_->RegisterReceiveCodec(my_codec_param)) 135 ASSERT_EQ(0, acm_->RegisterReceiveCodec(my_codec_param))
123 << "Couldn't register receive codec.\n"; 136 << "Couldn't register receive codec.\n";
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 AcmReceiveTestToggleOutputFreqOldApi::AcmReceiveTestToggleOutputFreqOldApi( 215 AcmReceiveTestToggleOutputFreqOldApi::AcmReceiveTestToggleOutputFreqOldApi(
203 PacketSource* packet_source, 216 PacketSource* packet_source,
204 AudioSink* audio_sink, 217 AudioSink* audio_sink,
205 int output_freq_hz_1, 218 int output_freq_hz_1,
206 int output_freq_hz_2, 219 int output_freq_hz_2,
207 int toggle_period_ms, 220 int toggle_period_ms,
208 NumOutputChannels exptected_output_channels) 221 NumOutputChannels exptected_output_channels)
209 : AcmReceiveTestOldApi(packet_source, 222 : AcmReceiveTestOldApi(packet_source,
210 audio_sink, 223 audio_sink,
211 output_freq_hz_1, 224 output_freq_hz_1,
212 exptected_output_channels), 225 exptected_output_channels,
226 CreateBuiltinAudioDecoderFactory()),
213 output_freq_hz_1_(output_freq_hz_1), 227 output_freq_hz_1_(output_freq_hz_1),
214 output_freq_hz_2_(output_freq_hz_2), 228 output_freq_hz_2_(output_freq_hz_2),
215 toggle_period_ms_(toggle_period_ms), 229 toggle_period_ms_(toggle_period_ms),
216 last_toggle_time_ms_(clock_.TimeInMilliseconds()) { 230 last_toggle_time_ms_(clock_.TimeInMilliseconds()) {}
217 }
218 231
219 void AcmReceiveTestToggleOutputFreqOldApi::AfterGetAudio() { 232 void AcmReceiveTestToggleOutputFreqOldApi::AfterGetAudio() {
220 if (clock_.TimeInMilliseconds() >= last_toggle_time_ms_ + toggle_period_ms_) { 233 if (clock_.TimeInMilliseconds() >= last_toggle_time_ms_ + toggle_period_ms_) {
221 output_freq_hz_ = (output_freq_hz_ == output_freq_hz_1_) 234 output_freq_hz_ = (output_freq_hz_ == output_freq_hz_1_)
222 ? output_freq_hz_2_ 235 ? output_freq_hz_2_
223 : output_freq_hz_1_; 236 : output_freq_hz_1_;
224 last_toggle_time_ms_ = clock_.TimeInMilliseconds(); 237 last_toggle_time_ms_ = clock_.TimeInMilliseconds();
225 } 238 }
226 } 239 }
227 240
228 } // namespace test 241 } // namespace test
229 } // namespace webrtc 242 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698