• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2015 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 WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_RECEIVER_H_
12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_RECEIVER_H_
13 
14 #include <string>
15 
16 #include "webrtc/base/constructormagic.h"
17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
19 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h"
20 #include "webrtc/modules/remote_bitrate_estimator/test/metric_recorder.h"
21 
22 namespace webrtc {
23 namespace testing {
24 namespace bwe {
25 
26 class PacketReceiver : public PacketProcessor {
27  public:
28   PacketReceiver(PacketProcessorListener* listener,
29                  int flow_id,
30                  BandwidthEstimatorType bwe_type,
31                  bool plot_delay,
32                  bool plot_bwe);
33   PacketReceiver(PacketProcessorListener* listener,
34                  int flow_id,
35                  BandwidthEstimatorType bwe_type,
36                  bool plot_delay,
37                  bool plot_bwe,
38                  MetricRecorder* metric_recorder);
39   ~PacketReceiver();
40 
41   // Implements PacketProcessor.
42   void RunFor(int64_t time_ms, Packets* in_out) override;
43 
44   void LogStats();
45 
46   Stats<double> GetDelayStats() const;
47 
48   float GlobalPacketLoss();
49 
50  protected:
51   void UpdateMetrics(int64_t arrival_time_ms,
52                      int64_t send_time_ms,
53                      size_t payload_size);
54 
55   Stats<double> delay_stats_;
56   rtc::scoped_ptr<BweReceiver> bwe_receiver_;
57 
58  private:
59   void PlotDelay(int64_t arrival_time_ms, int64_t send_time_ms);
60   MetricRecorder* metric_recorder_;
61   bool plot_delay_;  // Used in case there isn't a metric recorder.
62   int64_t last_delay_plot_ms_;
63   std::string delay_prefix_;
64   BandwidthEstimatorType bwe_type_;
65 
66   RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketReceiver);
67 };
68 }  // namespace bwe
69 }  // namespace testing
70 }  // namespace webrtc
71 #endif  // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_RECEIVER_H_
72