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

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc

Issue 1750353002: Change NetEq::GetAudio to use AudioFrame (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 4 years, 9 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/neteq/tools/neteq_performance_test.h" 11 #include "webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.h"
12 12
13 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" 13 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
14 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" 14 #include "webrtc/modules/audio_coding/neteq/include/neteq.h"
15 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" 15 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
16 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" 16 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
17 #include "webrtc/modules/include/module_common_types.h"
17 #include "webrtc/system_wrappers/include/clock.h" 18 #include "webrtc/system_wrappers/include/clock.h"
18 #include "webrtc/test/testsupport/fileutils.h" 19 #include "webrtc/test/testsupport/fileutils.h"
19 #include "webrtc/typedefs.h" 20 #include "webrtc/typedefs.h"
20 21
21 using webrtc::NetEq; 22 using webrtc::NetEq;
22 using webrtc::test::AudioLoop; 23 using webrtc::test::AudioLoop;
23 using webrtc::test::RtpGenerator; 24 using webrtc::test::RtpGenerator;
24 using webrtc::WebRtcRTPHeader; 25 using webrtc::WebRtcRTPHeader;
25 26
26 namespace webrtc { 27 namespace webrtc {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 &rtp_header); 97 &rtp_header);
97 input_samples = audio_loop.GetNextBlock(); 98 input_samples = audio_loop.GetNextBlock();
98 if (input_samples.empty()) 99 if (input_samples.empty())
99 return -1; 100 return -1;
100 payload_len = WebRtcPcm16b_Encode(input_samples.data(), 101 payload_len = WebRtcPcm16b_Encode(input_samples.data(),
101 input_samples.size(), input_payload); 102 input_samples.size(), input_payload);
102 assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t)); 103 assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t));
103 } 104 }
104 105
105 // Get output audio, but don't do anything with it. 106 // Get output audio, but don't do anything with it.
106 static const int kMaxChannels = 1; 107 AudioFrame out_frame;
107 static const size_t kMaxSamplesPerMs = 48000 / 1000; 108 int error = neteq->GetAudio(&out_frame, NULL);
108 static const int kOutputBlockSizeMs = 10;
109 static const size_t kOutDataLen =
110 kOutputBlockSizeMs * kMaxSamplesPerMs * kMaxChannels;
111 int16_t out_data[kOutDataLen];
112 size_t num_channels;
113 size_t samples_per_channel;
114 int error = neteq->GetAudio(kOutDataLen, out_data, &samples_per_channel,
115 &num_channels, NULL);
116 if (error != NetEq::kOK) 109 if (error != NetEq::kOK)
117 return -1; 110 return -1;
118 111
119 assert(samples_per_channel == static_cast<size_t>(kSampRateHz * 10 / 1000)); 112 assert(out_frame.samples_per_channel_ ==
113 static_cast<size_t>(kSampRateHz * 10 / 1000));
120 114
115 static const int kOutputBlockSizeMs = 10;
121 time_now_ms += kOutputBlockSizeMs; 116 time_now_ms += kOutputBlockSizeMs;
122 if (time_now_ms >= runtime_ms / 2 && !drift_flipped) { 117 if (time_now_ms >= runtime_ms / 2 && !drift_flipped) {
123 // Apply negative drift second half of simulation. 118 // Apply negative drift second half of simulation.
124 rtp_gen.set_drift_factor(-drift_factor); 119 rtp_gen.set_drift_factor(-drift_factor);
125 drift_flipped = true; 120 drift_flipped = true;
126 } 121 }
127 } 122 }
128 int64_t end_time_ms = clock->TimeInMilliseconds(); 123 int64_t end_time_ms = clock->TimeInMilliseconds();
129 delete neteq; 124 delete neteq;
130 return end_time_ms - start_time_ms; 125 return end_time_ms - start_time_ms;
131 } 126 }
132 127
133 } // namespace test 128 } // namespace test
134 } // namespace webrtc 129 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698