Home | History | Annotate | Download | only in call
      1 /*
      2  *  Copyright (c) 2012 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_CALL_CONGESTION_CONTROLLER_H_
     12 #define WEBRTC_CALL_CONGESTION_CONTROLLER_H_
     13 
     14 #include <vector>
     15 
     16 #include "webrtc/base/criticalsection.h"
     17 #include "webrtc/base/scoped_ptr.h"
     18 #include "webrtc/base/socket.h"
     19 #include "webrtc/stream.h"
     20 
     21 namespace webrtc {
     22 
     23 class BitrateController;
     24 class BitrateObserver;
     25 class CallStats;
     26 class Config;
     27 class PacedSender;
     28 class PacketRouter;
     29 class ProcessThread;
     30 class RemoteBitrateEstimator;
     31 class RemoteEstimatorProxy;
     32 class RtpRtcp;
     33 class SendStatisticsProxy;
     34 class TransportFeedbackAdapter;
     35 class TransportFeedbackObserver;
     36 class ViEEncoder;
     37 class VieRemb;
     38 
     39 class CongestionController {
     40  public:
     41   CongestionController(ProcessThread* process_thread, CallStats* call_stats,
     42                        BitrateObserver* bitrate_observer);
     43   virtual ~CongestionController();
     44   virtual void AddEncoder(ViEEncoder* encoder);
     45   virtual void RemoveEncoder(ViEEncoder* encoder);
     46   virtual void SetBweBitrates(int min_bitrate_bps,
     47                               int start_bitrate_bps,
     48                               int max_bitrate_bps);
     49 
     50   virtual void SetChannelRembStatus(bool sender,
     51                                     bool receiver,
     52                                     RtpRtcp* rtp_module);
     53 
     54   virtual void SignalNetworkState(NetworkState state);
     55 
     56   virtual BitrateController* GetBitrateController() const;
     57   virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
     58       bool send_side_bwe) const;
     59   virtual int64_t GetPacerQueuingDelayMs() const;
     60   virtual PacedSender* pacer() const { return pacer_.get(); }
     61   virtual PacketRouter* packet_router() const { return packet_router_.get(); }
     62   virtual TransportFeedbackObserver* GetTransportFeedbackObserver();
     63 
     64   virtual void UpdatePacerBitrate(int bitrate_kbps,
     65                                   int max_bitrate_kbps,
     66                                   int min_bitrate_kbps);
     67 
     68   virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
     69 
     70  private:
     71   rtc::scoped_ptr<VieRemb> remb_;
     72   rtc::scoped_ptr<PacketRouter> packet_router_;
     73   rtc::scoped_ptr<PacedSender> pacer_;
     74   rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_;
     75   rtc::scoped_ptr<RemoteEstimatorProxy> remote_estimator_proxy_;
     76 
     77   mutable rtc::CriticalSection encoder_crit_;
     78   std::vector<ViEEncoder*> encoders_ GUARDED_BY(encoder_crit_);
     79 
     80   // Registered at construct time and assumed to outlive this class.
     81   ProcessThread* const process_thread_;
     82   CallStats* const call_stats_;
     83 
     84   rtc::scoped_ptr<ProcessThread> pacer_thread_;
     85 
     86   rtc::scoped_ptr<BitrateController> bitrate_controller_;
     87   rtc::scoped_ptr<TransportFeedbackAdapter> transport_feedback_adapter_;
     88   int min_bitrate_bps_;
     89 
     90   RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController);
     91 };
     92 
     93 }  // namespace webrtc
     94 
     95 #endif  // WEBRTC_CALL_CONGESTION_CONTROLLER_H_
     96