OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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/include/neteq.h" | 11 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" |
12 | 12 |
13 #include <math.h> | 13 #include <math.h> |
14 #include <stdlib.h> | 14 #include <stdlib.h> |
15 #include <string.h> // memset | 15 #include <string.h> // memset |
16 | 16 |
17 #include <algorithm> | 17 #include <algorithm> |
18 #include <memory> | 18 #include <memory> |
19 #include <set> | 19 #include <set> |
20 #include <string> | 20 #include <string> |
21 #include <vector> | 21 #include <vector> |
22 | 22 |
23 #include "gflags/gflags.h" | 23 #include "gflags/gflags.h" |
24 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | 24 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
25 #include "webrtc/base/ignore_wundef.h" | 25 #include "webrtc/base/ignore_wundef.h" |
26 #include "webrtc/base/sha1digest.h" | 26 #include "webrtc/base/sha1digest.h" |
27 #include "webrtc/base/stringencode.h" | 27 #include "webrtc/base/stringencode.h" |
| 28 #include "webrtc/base/protobuf_utils.h" |
28 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" | 29 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" |
29 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" | 30 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
30 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" | 31 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
31 #include "webrtc/modules/include/module_common_types.h" | 32 #include "webrtc/modules/include/module_common_types.h" |
32 #include "webrtc/test/gtest.h" | 33 #include "webrtc/test/gtest.h" |
33 #include "webrtc/test/testsupport/fileutils.h" | 34 #include "webrtc/test/testsupport/fileutils.h" |
34 #include "webrtc/typedefs.h" | 35 #include "webrtc/typedefs.h" |
35 | 36 |
36 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | 37 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
37 RTC_PUSH_IGNORING_WUNDEF() | 38 RTC_PUSH_IGNORING_WUNDEF() |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 ASSERT_EQ(length, fwrite(&test_results, sizeof(T), length, output_fp_)); | 188 ASSERT_EQ(length, fwrite(&test_results, sizeof(T), length, output_fp_)); |
188 } | 189 } |
189 digest_->Update(&test_results, sizeof(T) * length); | 190 digest_->Update(&test_results, sizeof(T) * length); |
190 } | 191 } |
191 | 192 |
192 void ResultSink::AddResult(const NetEqNetworkStatistics& stats_raw) { | 193 void ResultSink::AddResult(const NetEqNetworkStatistics& stats_raw) { |
193 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | 194 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
194 neteq_unittest::NetEqNetworkStatistics stats; | 195 neteq_unittest::NetEqNetworkStatistics stats; |
195 Convert(stats_raw, &stats); | 196 Convert(stats_raw, &stats); |
196 | 197 |
197 std::string stats_string; | 198 ProtoString stats_string; |
198 ASSERT_TRUE(stats.SerializeToString(&stats_string)); | 199 ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
199 AddMessage(output_fp_, digest_.get(), stats_string); | 200 AddMessage(output_fp_, digest_.get(), stats_string); |
200 #else | 201 #else |
201 FAIL() << "Writing to reference file requires Proto Buffer."; | 202 FAIL() << "Writing to reference file requires Proto Buffer."; |
202 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT | 203 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
203 } | 204 } |
204 | 205 |
205 void ResultSink::AddResult(const RtcpStatistics& stats_raw) { | 206 void ResultSink::AddResult(const RtcpStatistics& stats_raw) { |
206 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | 207 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
207 neteq_unittest::RtcpStatistics stats; | 208 neteq_unittest::RtcpStatistics stats; |
208 Convert(stats_raw, &stats); | 209 Convert(stats_raw, &stats); |
209 | 210 |
210 std::string stats_string; | 211 ProtoString stats_string; |
211 ASSERT_TRUE(stats.SerializeToString(&stats_string)); | 212 ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
212 AddMessage(output_fp_, digest_.get(), stats_string); | 213 AddMessage(output_fp_, digest_.get(), stats_string); |
213 #else | 214 #else |
214 FAIL() << "Writing to reference file requires Proto Buffer."; | 215 FAIL() << "Writing to reference file requires Proto Buffer."; |
215 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT | 216 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
216 } | 217 } |
217 | 218 |
218 void ResultSink::VerifyChecksum(const std::string& checksum) { | 219 void ResultSink::VerifyChecksum(const std::string& checksum) { |
219 std::vector<char> buffer; | 220 std::vector<char> buffer; |
220 buffer.resize(digest_->Size()); | 221 buffer.resize(digest_->Size()); |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 if (muted) { | 1583 if (muted) { |
1583 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); | 1584 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); |
1584 } else { | 1585 } else { |
1585 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); | 1586 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); |
1586 } | 1587 } |
1587 } | 1588 } |
1588 EXPECT_FALSE(muted); | 1589 EXPECT_FALSE(muted); |
1589 } | 1590 } |
1590 | 1591 |
1591 } // namespace webrtc | 1592 } // namespace webrtc |
OLD | NEW |