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

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

Issue 2809153002: Change from WebRtcRTPHeader to RTPHeader in NetEq tests and tools (Closed)
Patch Set: Fixing neteq_rtp_fuzzer Created 3 years, 8 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/api/audio_codecs/builtin_audio_decoder_factory.h" 13 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
14 #include "webrtc/base/checks.h" 14 #include "webrtc/base/checks.h"
15 #include "webrtc/common_types.h"
15 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" 16 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h"
16 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" 17 #include "webrtc/modules/audio_coding/neteq/include/neteq.h"
17 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" 18 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
18 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" 19 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
19 #include "webrtc/modules/include/module_common_types.h" 20 #include "webrtc/modules/include/module_common_types.h"
20 #include "webrtc/system_wrappers/include/clock.h" 21 #include "webrtc/system_wrappers/include/clock.h"
21 #include "webrtc/test/testsupport/fileutils.h" 22 #include "webrtc/test/testsupport/fileutils.h"
22 #include "webrtc/typedefs.h" 23 #include "webrtc/typedefs.h"
23 24
24 using webrtc::NetEq; 25 using webrtc::NetEq;
25 using webrtc::test::AudioLoop; 26 using webrtc::test::AudioLoop;
26 using webrtc::test::RtpGenerator; 27 using webrtc::test::RtpGenerator;
27 using webrtc::WebRtcRTPHeader;
28 28
29 namespace webrtc { 29 namespace webrtc {
30 namespace test { 30 namespace test {
31 31
32 int64_t NetEqPerformanceTest::Run(int runtime_ms, 32 int64_t NetEqPerformanceTest::Run(int runtime_ms,
33 int lossrate, 33 int lossrate,
34 double drift_factor) { 34 double drift_factor) {
35 const std::string kInputFileName = 35 const std::string kInputFileName =
36 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); 36 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
37 const int kSampRateHz = 32000; 37 const int kSampRateHz = 32000;
(...skipping 14 matching lines...) Expand all
52 AudioLoop audio_loop; 52 AudioLoop audio_loop;
53 const size_t kMaxLoopLengthSamples = kSampRateHz * 10; // 10 second loop. 53 const size_t kMaxLoopLengthSamples = kSampRateHz * 10; // 10 second loop.
54 const size_t kInputBlockSizeSamples = 60 * kSampRateHz / 1000; // 60 ms. 54 const size_t kInputBlockSizeSamples = 60 * kSampRateHz / 1000; // 60 ms.
55 if (!audio_loop.Init(kInputFileName, kMaxLoopLengthSamples, 55 if (!audio_loop.Init(kInputFileName, kMaxLoopLengthSamples,
56 kInputBlockSizeSamples)) 56 kInputBlockSizeSamples))
57 return -1; 57 return -1;
58 58
59 int32_t time_now_ms = 0; 59 int32_t time_now_ms = 0;
60 60
61 // Get first input packet. 61 // Get first input packet.
62 WebRtcRTPHeader rtp_header; 62 RTPHeader rtp_header;
63 RtpGenerator rtp_gen(kSampRateHz / 1000); 63 RtpGenerator rtp_gen(kSampRateHz / 1000);
64 // Start with positive drift first half of simulation. 64 // Start with positive drift first half of simulation.
65 rtp_gen.set_drift_factor(drift_factor); 65 rtp_gen.set_drift_factor(drift_factor);
66 bool drift_flipped = false; 66 bool drift_flipped = false;
67 int32_t packet_input_time_ms = 67 int32_t packet_input_time_ms =
68 rtp_gen.GetRtpHeader(kPayloadType, kInputBlockSizeSamples, &rtp_header); 68 rtp_gen.GetRtpHeader(kPayloadType, kInputBlockSizeSamples, &rtp_header);
69 auto input_samples = audio_loop.GetNextBlock(); 69 auto input_samples = audio_loop.GetNextBlock();
70 if (input_samples.empty()) 70 if (input_samples.empty())
71 exit(1); 71 exit(1);
72 uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)]; 72 uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)];
73 size_t payload_len = WebRtcPcm16b_Encode(input_samples.data(), 73 size_t payload_len = WebRtcPcm16b_Encode(input_samples.data(),
74 input_samples.size(), input_payload); 74 input_samples.size(), input_payload);
75 RTC_CHECK_EQ(sizeof(input_payload), payload_len); 75 RTC_CHECK_EQ(sizeof(input_payload), payload_len);
76 76
77 // Main loop. 77 // Main loop.
78 webrtc::Clock* clock = webrtc::Clock::GetRealTimeClock(); 78 webrtc::Clock* clock = webrtc::Clock::GetRealTimeClock();
79 int64_t start_time_ms = clock->TimeInMilliseconds(); 79 int64_t start_time_ms = clock->TimeInMilliseconds();
80 AudioFrame out_frame; 80 AudioFrame out_frame;
81 while (time_now_ms < runtime_ms) { 81 while (time_now_ms < runtime_ms) {
82 while (packet_input_time_ms <= time_now_ms) { 82 while (packet_input_time_ms <= time_now_ms) {
83 // Drop every N packets, where N = FLAGS_lossrate. 83 // Drop every N packets, where N = FLAGS_lossrate.
84 bool lost = false; 84 bool lost = false;
85 if (lossrate > 0) { 85 if (lossrate > 0) {
86 lost = ((rtp_header.header.sequenceNumber - 1) % lossrate) == 0; 86 lost = ((rtp_header.sequenceNumber - 1) % lossrate) == 0;
87 } 87 }
88 if (!lost) { 88 if (!lost) {
89 // Insert packet. 89 // Insert packet.
90 int error = 90 int error =
91 neteq->InsertPacket(rtp_header.header, input_payload, 91 neteq->InsertPacket(rtp_header, input_payload,
92 packet_input_time_ms * kSampRateHz / 1000); 92 packet_input_time_ms * kSampRateHz / 1000);
93 if (error != NetEq::kOK) 93 if (error != NetEq::kOK)
94 return -1; 94 return -1;
95 } 95 }
96 96
97 // Get next packet. 97 // Get next packet.
98 packet_input_time_ms = rtp_gen.GetRtpHeader(kPayloadType, 98 packet_input_time_ms = rtp_gen.GetRtpHeader(kPayloadType,
99 kInputBlockSizeSamples, 99 kInputBlockSizeSamples,
100 &rtp_header); 100 &rtp_header);
101 input_samples = audio_loop.GetNextBlock(); 101 input_samples = audio_loop.GetNextBlock();
(...skipping 22 matching lines...) Expand all
124 drift_flipped = true; 124 drift_flipped = true;
125 } 125 }
126 } 126 }
127 int64_t end_time_ms = clock->TimeInMilliseconds(); 127 int64_t end_time_ms = clock->TimeInMilliseconds();
128 delete neteq; 128 delete neteq;
129 return end_time_ms - start_time_ms; 129 return end_time_ms - start_time_ms;
130 } 130 }
131 131
132 } // namespace test 132 } // namespace test
133 } // namespace webrtc 133 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698