remb.h revision c81591d63f5e441bd26025a5e986bb2ebfd9fdfd
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_ESTIMATORS_REMB_H_ 12#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_REMB_H_ 13 14#include <string> 15#include <vector> 16 17#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" 18 19namespace webrtc { 20 21class BitrateObserver; 22class BitrateController; 23class ReceiveStatistics; 24class StreamStatistician; 25 26namespace testing { 27namespace bwe { 28 29class RembBweSender : public BweSender { 30 public: 31 RembBweSender(int kbps, BitrateObserver* observer, Clock* clock); 32 virtual ~RembBweSender(); 33 34 int GetFeedbackIntervalMs() const override; 35 void GiveFeedback(const FeedbackPacket& feedback) override; 36 void OnPacketsSent(const Packets& packets) override {} 37 int64_t TimeUntilNextProcess() override; 38 int Process() override; 39 40 protected: 41 rtc::scoped_ptr<BitrateController> bitrate_controller_; 42 rtc::scoped_ptr<RtcpBandwidthObserver> feedback_observer_; 43 44 private: 45 Clock* clock_; 46 47 DISALLOW_IMPLICIT_CONSTRUCTORS(RembBweSender); 48}; 49 50class RembReceiver : public BweReceiver, public RemoteBitrateObserver { 51 public: 52 static const uint32_t kRemoteBitrateEstimatorMinBitrateBps = 30000; 53 54 RembReceiver(int flow_id, bool plot); 55 virtual ~RembReceiver(); 56 57 void ReceivePacket(int64_t arrival_time_ms, 58 const MediaPacket& media_packet) override; 59 FeedbackPacket* GetFeedback(int64_t now_ms) override; 60 // Implements RemoteBitrateObserver. 61 void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, 62 unsigned int bitrate) override; 63 64 private: 65 static RTCPReportBlock BuildReportBlock(StreamStatistician* statistician); 66 bool LatestEstimate(uint32_t* estimate_bps); 67 68 std::string estimate_log_prefix_; 69 bool plot_estimate_; 70 SimulatedClock clock_; 71 rtc::scoped_ptr<ReceiveStatistics> recv_stats_; 72 int64_t latest_estimate_bps_; 73 int64_t last_feedback_ms_; 74 rtc::scoped_ptr<RemoteBitrateEstimator> estimator_; 75 76 DISALLOW_IMPLICIT_CONSTRUCTORS(RembReceiver); 77}; 78 79} // namespace bwe 80} // namespace testing 81} // namespace webrtc 82 83#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_REMB_H_ 84