blob: 357b635b08929b9431821eb2d2ab56507dc0d27f [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"
19#include "modules/rtp_rtcp/include/rtcp_statistics.h"
20#include "rtc_base/message_digest.h"
21
22namespace webrtc {
23
24class ResultSink {
25 public:
26 explicit ResultSink(const std::string& output_file);
27 ~ResultSink();
28
29 template <typename T>
30 void AddResult(const T* test_results, size_t length);
31
32 void AddResult(const NetEqNetworkStatistics& stats);
33 void AddResult(const RtcpStatistics& stats);
34
35 void VerifyChecksum(const std::string& ref_check_sum);
36
37 private:
38 FILE* output_fp_;
39 std::unique_ptr<rtc::MessageDigest> digest_;
40};
41
42template <typename T>
43void ResultSink::AddResult(const T* test_results, size_t length) {
44 if (output_fp_) {
45 ASSERT_EQ(length, fwrite(test_results, sizeof(T), length, output_fp_));
46 }
47 digest_->Update(test_results, sizeof(T) * length);
48}
49
50} // namespace webrtc
51#endif // MODULES_AUDIO_CODING_NETEQ_TEST_RESULT_SINK_H_