blob: dcde02d450ff39ed29feb8cd9bb39014f028060f [file] [log] [blame]
Yves Gerey3a65f392019-11-11 18:05:42 +01001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef MODULES_AUDIO_CODING_NETEQ_TEST_RESULT_SINK_H_
12#define MODULES_AUDIO_CODING_NETEQ_TEST_RESULT_SINK_H_
13
14#include <cstdio>
15#include <memory>
16#include <string>
17
18#include "api/neteq/neteq.h"
Yves Gerey3a65f392019-11-11 18:05:42 +010019#include "rtc_base/message_digest.h"
20
21namespace webrtc {
22
23class ResultSink {
24 public:
25 explicit ResultSink(const std::string& output_file);
26 ~ResultSink();
27
28 template <typename T>
29 void AddResult(const T* test_results, size_t length);
30
31 void AddResult(const NetEqNetworkStatistics& stats);
Yves Gerey3a65f392019-11-11 18:05:42 +010032
33 void VerifyChecksum(const std::string& ref_check_sum);
34
35 private:
36 FILE* output_fp_;
37 std::unique_ptr<rtc::MessageDigest> digest_;
38};
39
40template <typename T>
41void ResultSink::AddResult(const T* test_results, size_t length) {
42 if (output_fp_) {
43 ASSERT_EQ(length, fwrite(test_results, sizeof(T), length, output_fp_));
44 }
45 digest_->Update(test_results, sizeof(T) * length);
46}
47
48} // namespace webrtc
49#endif // MODULES_AUDIO_CODING_NETEQ_TEST_RESULT_SINK_H_