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" | |
29 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" | 28 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" |
30 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" | 29 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
31 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" | 30 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
32 #include "webrtc/modules/include/module_common_types.h" | 31 #include "webrtc/modules/include/module_common_types.h" |
33 #include "webrtc/test/gtest.h" | 32 #include "webrtc/test/gtest.h" |
34 #include "webrtc/test/testsupport/fileutils.h" | 33 #include "webrtc/test/testsupport/fileutils.h" |
35 #include "webrtc/typedefs.h" | 34 #include "webrtc/typedefs.h" |
36 | 35 |
37 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | 36 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
38 RTC_PUSH_IGNORING_WUNDEF() | 37 RTC_PUSH_IGNORING_WUNDEF() |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 ASSERT_EQ(length, fwrite(&test_results, sizeof(T), length, output_fp_)); | 187 ASSERT_EQ(length, fwrite(&test_results, sizeof(T), length, output_fp_)); |
189 } | 188 } |
190 digest_->Update(&test_results, sizeof(T) * length); | 189 digest_->Update(&test_results, sizeof(T) * length); |
191 } | 190 } |
192 | 191 |
193 void ResultSink::AddResult(const NetEqNetworkStatistics& stats_raw) { | 192 void ResultSink::AddResult(const NetEqNetworkStatistics& stats_raw) { |
194 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | 193 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
195 neteq_unittest::NetEqNetworkStatistics stats; | 194 neteq_unittest::NetEqNetworkStatistics stats; |
196 Convert(stats_raw, &stats); | 195 Convert(stats_raw, &stats); |
197 | 196 |
198 ProtoString stats_string; | 197 std::string stats_string; |
199 ASSERT_TRUE(stats.SerializeToString(&stats_string)); | 198 ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
200 AddMessage(output_fp_, digest_.get(), stats_string); | 199 AddMessage(output_fp_, digest_.get(), stats_string); |
201 #else | 200 #else |
202 FAIL() << "Writing to reference file requires Proto Buffer."; | 201 FAIL() << "Writing to reference file requires Proto Buffer."; |
203 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT | 202 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
204 } | 203 } |
205 | 204 |
206 void ResultSink::AddResult(const RtcpStatistics& stats_raw) { | 205 void ResultSink::AddResult(const RtcpStatistics& stats_raw) { |
207 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | 206 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
208 neteq_unittest::RtcpStatistics stats; | 207 neteq_unittest::RtcpStatistics stats; |
209 Convert(stats_raw, &stats); | 208 Convert(stats_raw, &stats); |
210 | 209 |
211 ProtoString stats_string; | 210 std::string stats_string; |
212 ASSERT_TRUE(stats.SerializeToString(&stats_string)); | 211 ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
213 AddMessage(output_fp_, digest_.get(), stats_string); | 212 AddMessage(output_fp_, digest_.get(), stats_string); |
214 #else | 213 #else |
215 FAIL() << "Writing to reference file requires Proto Buffer."; | 214 FAIL() << "Writing to reference file requires Proto Buffer."; |
216 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT | 215 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
217 } | 216 } |
218 | 217 |
219 void ResultSink::VerifyChecksum(const std::string& checksum) { | 218 void ResultSink::VerifyChecksum(const std::string& checksum) { |
220 std::vector<char> buffer; | 219 std::vector<char> buffer; |
221 buffer.resize(digest_->Size()); | 220 buffer.resize(digest_->Size()); |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 if (muted) { | 1582 if (muted) { |
1584 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); | 1583 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); |
1585 } else { | 1584 } else { |
1586 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); | 1585 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); |
1587 } | 1586 } |
1588 } | 1587 } |
1589 EXPECT_FALSE(muted); | 1588 EXPECT_FALSE(muted); |
1590 } | 1589 } |
1591 | 1590 |
1592 } // namespace webrtc | 1591 } // namespace webrtc |
OLD | NEW |