| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 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 | 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 | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| 11 #ifndef WEBRTC_MODULES_PACING_INCLUDE_PACED_SENDER_H_ | 11 #ifndef WEBRTC_MODULES_PACING_INCLUDE_PACED_SENDER_H_ | 
| 12 #define WEBRTC_MODULES_PACING_INCLUDE_PACED_SENDER_H_ | 12 #define WEBRTC_MODULES_PACING_INCLUDE_PACED_SENDER_H_ | 
| 13 | 13 | 
| 14 #include <list> | 14 #include <list> | 
| 15 #include <set> | 15 #include <set> | 
| 16 | 16 | 
| 17 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" | 
| 18 #include "webrtc/base/thread_annotations.h" | 18 #include "webrtc/base/thread_annotations.h" | 
| 19 #include "webrtc/modules/interface/module.h" | 19 #include "webrtc/modules/interface/module.h" | 
|  | 20 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" | 
| 20 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" | 
| 21 | 22 | 
| 22 namespace webrtc { | 23 namespace webrtc { | 
| 23 class BitrateProber; | 24 class BitrateProber; | 
| 24 class Clock; | 25 class Clock; | 
| 25 class CriticalSectionWrapper; | 26 class CriticalSectionWrapper; | 
| 26 | 27 | 
| 27 namespace paced_sender { | 28 namespace paced_sender { | 
| 28 class IntervalBudget; | 29 class IntervalBudget; | 
| 29 struct Packet; | 30 struct Packet; | 
| 30 class PacketQueue; | 31 class PacketQueue; | 
| 31 }  // namespace paced_sender | 32 }  // namespace paced_sender | 
| 32 | 33 | 
| 33 class PacedSender : public Module { | 34 class PacedSender : public Module, public RtpPacketSender { | 
| 34  public: | 35  public: | 
| 35   enum Priority { |  | 
| 36     kHighPriority = 0,  // Pass through; will be sent immediately. |  | 
| 37     kNormalPriority = 2,  // Put in back of the line. |  | 
| 38     kLowPriority = 3,  // Put in back of the low priority line. |  | 
| 39   }; |  | 
| 40   // Low priority packets are mixed with the normal priority packets |  | 
| 41   // while we are paused. |  | 
| 42 |  | 
| 43   class Callback { | 36   class Callback { | 
| 44    public: | 37    public: | 
| 45     // Note: packets sent as a result of a callback should not pass by this | 38     // Note: packets sent as a result of a callback should not pass by this | 
| 46     // module again. | 39     // module again. | 
| 47     // Called when it's time to send a queued packet. | 40     // Called when it's time to send a queued packet. | 
| 48     // Returns false if packet cannot be sent. | 41     // Returns false if packet cannot be sent. | 
| 49     virtual bool TimeToSendPacket(uint32_t ssrc, | 42     virtual bool TimeToSendPacket(uint32_t ssrc, | 
| 50                                   uint16_t sequence_number, | 43                                   uint16_t sequence_number, | 
| 51                                   int64_t capture_time_ms, | 44                                   int64_t capture_time_ms, | 
| 52                                   bool retransmission) = 0; | 45                                   bool retransmission) = 0; | 
| 53     // Called when it's a good time to send a padding data. | 46     // Called when it's a good time to send a padding data. | 
| 54     // Returns the number of bytes sent. | 47     // Returns the number of bytes sent. | 
| 55     virtual size_t TimeToSendPadding(size_t bytes) = 0; | 48     virtual size_t TimeToSendPadding(size_t bytes) = 0; | 
| 56 | 49 | 
| 57    protected: | 50    protected: | 
| 58     virtual ~Callback() {} | 51     virtual ~Callback() {} | 
| 59   }; | 52   }; | 
| 60 | 53 | 
| 61   static const int64_t kDefaultMaxQueueLengthMs = 2000; | 54   static const int64_t kDefaultMaxQueueLengthMs = 2000; | 
| 62   // Pace in kbits/s until we receive first estimate. | 55   // Pace in kbits/s until we receive first estimate. | 
| 63   static const int kDefaultInitialPaceKbps = 2000; | 56   static const int kDefaultInitialPaceKbps = 2000; | 
| 64   // Pacing-rate relative to our target send rate. | 57   // Pacing-rate relative to our target send rate. | 
| 65   // Multiplicative factor that is applied to the target bitrate to calculate | 58   // Multiplicative factor that is applied to the target bitrate to calculate | 
| 66   // the number of bytes that can be transmitted per interval. | 59   // the number of bytes that can be transmitted per interval. | 
| 67   // Increasing this factor will result in lower delays in cases of bitrate | 60   // Increasing this factor will result in lower delays in cases of bitrate | 
| 68   // overshoots from the encoder. | 61   // overshoots from the encoder. | 
| 69   static const float kDefaultPaceMultiplier; | 62   static const float kDefaultPaceMultiplier; | 
| 70 | 63 | 
|  | 64   static const size_t kMinProbePacketSize = 200; | 
|  | 65 | 
| 71   PacedSender(Clock* clock, | 66   PacedSender(Clock* clock, | 
| 72               Callback* callback, | 67               Callback* callback, | 
| 73               int bitrate_kbps, | 68               int bitrate_kbps, | 
| 74               int max_bitrate_kbps, | 69               int max_bitrate_kbps, | 
| 75               int min_bitrate_kbps); | 70               int min_bitrate_kbps); | 
| 76 | 71 | 
| 77   virtual ~PacedSender(); | 72   virtual ~PacedSender(); | 
| 78 | 73 | 
| 79   // Enable/disable pacing. | 74   // Enable/disable pacing. | 
| 80   void SetStatus(bool enable); | 75   void SetStatus(bool enable); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 96   // We will pace out bursts of packets at a bitrate of |max_bitrate_kbps|. | 91   // We will pace out bursts of packets at a bitrate of |max_bitrate_kbps|. | 
| 97   // |bitrate_kbps| is our estimate of what we are allowed to send on average. | 92   // |bitrate_kbps| is our estimate of what we are allowed to send on average. | 
| 98   // Padding packets will be utilized to reach |min_bitrate| unless enough media | 93   // Padding packets will be utilized to reach |min_bitrate| unless enough media | 
| 99   // packets are available. | 94   // packets are available. | 
| 100   void UpdateBitrate(int bitrate_kbps, | 95   void UpdateBitrate(int bitrate_kbps, | 
| 101                      int max_bitrate_kbps, | 96                      int max_bitrate_kbps, | 
| 102                      int min_bitrate_kbps); | 97                      int min_bitrate_kbps); | 
| 103 | 98 | 
| 104   // Returns true if we send the packet now, else it will add the packet | 99   // Returns true if we send the packet now, else it will add the packet | 
| 105   // information to the queue and call TimeToSendPacket when it's time to send. | 100   // information to the queue and call TimeToSendPacket when it's time to send. | 
| 106   virtual bool SendPacket(Priority priority, | 101   bool SendPacket(RtpPacketSender::Priority priority, | 
| 107                           uint32_t ssrc, | 102                   uint32_t ssrc, | 
| 108                           uint16_t sequence_number, | 103                   uint16_t sequence_number, | 
| 109                           int64_t capture_time_ms, | 104                   int64_t capture_time_ms, | 
| 110                           size_t bytes, | 105                   size_t bytes, | 
| 111                           bool retransmission); | 106                   bool retransmission) override; | 
| 112 | 107 | 
| 113   // Returns the time since the oldest queued packet was enqueued. | 108   // Returns the time since the oldest queued packet was enqueued. | 
| 114   virtual int64_t QueueInMs() const; | 109   virtual int64_t QueueInMs() const; | 
| 115 | 110 | 
| 116   virtual size_t QueueSizePackets() const; | 111   virtual size_t QueueSizePackets() const; | 
| 117 | 112 | 
| 118   // Returns the number of milliseconds it will take to send the current | 113   // Returns the number of milliseconds it will take to send the current | 
| 119   // packets in the queue, given the current size and bitrate, ignoring prio. | 114   // packets in the queue, given the current size and bitrate, ignoring prio. | 
| 120   virtual int64_t ExpectedQueueTimeMs() const; | 115   virtual int64_t ExpectedQueueTimeMs() const; | 
| 121 | 116 | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 155   rtc::scoped_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); | 150   rtc::scoped_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); | 
| 156   int bitrate_bps_ GUARDED_BY(critsect_); | 151   int bitrate_bps_ GUARDED_BY(critsect_); | 
| 157 | 152 | 
| 158   int64_t time_last_update_us_ GUARDED_BY(critsect_); | 153   int64_t time_last_update_us_ GUARDED_BY(critsect_); | 
| 159 | 154 | 
| 160   rtc::scoped_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); | 155   rtc::scoped_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); | 
| 161   uint64_t packet_counter_; | 156   uint64_t packet_counter_; | 
| 162 }; | 157 }; | 
| 163 }  // namespace webrtc | 158 }  // namespace webrtc | 
| 164 #endif  // WEBRTC_MODULES_PACING_INCLUDE_PACED_SENDER_H_ | 159 #endif  // WEBRTC_MODULES_PACING_INCLUDE_PACED_SENDER_H_ | 
| OLD | NEW | 
|---|