| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_ | 11 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_ |
| 12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_ | 12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> |
| 15 #include <vector> | 16 #include <vector> |
| 16 | 17 |
| 17 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
| 19 #include "webrtc/base/ratetracker.h" |
| 18 #include "webrtc/modules/include/module_common_types.h" | 20 #include "webrtc/modules/include/module_common_types.h" |
| 19 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 21 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
| 20 | 22 |
| 21 namespace webrtc { | 23 namespace webrtc { |
| 22 | 24 |
| 23 class Clock; | 25 class Clock; |
| 24 class PacketRouter; | 26 class PacketRouter; |
| 25 namespace rtcp { | 27 namespace rtcp { |
| 26 class TransportFeedback; | 28 class TransportFeedback; |
| 27 } | 29 } |
| 28 | 30 |
| 29 // Class used when send-side BWE is enabled: This proxy is instantiated on the | 31 // Class used when send-side BWE is enabled: This proxy is instantiated on the |
| 30 // receive side. It buffers a number of receive timestamps and then sends | 32 // receive side. It buffers a number of receive timestamps and then sends |
| 31 // transport feedback messages back too the send side. | 33 // transport feedback messages back too the send side. |
| 32 | 34 |
| 33 class RemoteEstimatorProxy : public RemoteBitrateEstimator { | 35 class RemoteEstimatorProxy : public RemoteBitrateEstimator { |
| 34 public: | 36 public: |
| 35 RemoteEstimatorProxy(Clock* clock, PacketRouter* packet_router); | 37 RemoteEstimatorProxy( |
| 38 Clock* clock, |
| 39 PacketRouter* packet_router, |
| 40 std::unique_ptr<rtc::RateTracker> recieved_bitrate_tracker); |
| 36 virtual ~RemoteEstimatorProxy(); | 41 virtual ~RemoteEstimatorProxy(); |
| 37 | 42 |
| 38 void IncomingPacketFeedbackVector( | 43 void IncomingPacketFeedbackVector( |
| 39 const std::vector<PacketInfo>& packet_feedback_vector) override; | 44 const std::vector<PacketInfo>& packet_feedback_vector) override; |
| 40 void IncomingPacket(int64_t arrival_time_ms, | 45 void IncomingPacket(int64_t arrival_time_ms, |
| 41 size_t payload_size, | 46 size_t payload_size, |
| 42 const RTPHeader& header) override; | 47 const RTPHeader& header) override; |
| 43 void RemoveStream(uint32_t ssrc) override {} | 48 void RemoveStream(uint32_t ssrc) override {} |
| 44 bool LatestEstimate(std::vector<unsigned int>* ssrcs, | 49 bool LatestEstimate(std::vector<unsigned int>* ssrcs, |
| 45 unsigned int* bitrate_bps) const override; | 50 unsigned int* bitrate_bps) const override; |
| 46 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override {} | 51 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override {} |
| 47 void SetMinBitrate(int min_bitrate_bps) override {} | 52 void SetMinBitrate(int min_bitrate_bps) override {} |
| 48 int64_t TimeUntilNextProcess() override; | 53 int64_t TimeUntilNextProcess() override; |
| 49 void Process() override; | 54 void Process() override; |
| 50 | 55 |
| 51 static const int kDefaultProcessIntervalMs; | 56 static const int kHighBitrateProcessIntervalMs; |
| 57 static const int kLowBitrateProcessIntervalMs; |
| 58 static const int kSwitchToLowBitrateProcessIntervalBps; |
| 59 static const int kSwitchToHighBitrateProcessIntervalBps; |
| 60 static const int kMinPacketCountRecievedBitrate; |
| 52 static const int kBackWindowMs; | 61 static const int kBackWindowMs; |
| 53 | 62 |
| 54 private: | 63 private: |
| 55 void OnPacketArrival(uint16_t sequence_number, int64_t arrival_time) | 64 void OnPacketArrival(uint16_t sequence_number, int64_t arrival_time) |
| 56 EXCLUSIVE_LOCKS_REQUIRED(&lock_); | 65 EXCLUSIVE_LOCKS_REQUIRED(&lock_); |
| 57 bool BuildFeedbackPacket(rtcp::TransportFeedback* feedback_packet); | 66 bool BuildFeedbackPacket(rtcp::TransportFeedback* feedback_packet); |
| 58 | 67 |
| 59 Clock* const clock_; | 68 Clock* const clock_; |
| 60 PacketRouter* const packet_router_; | 69 PacketRouter* const packet_router_; |
| 61 int64_t last_process_time_ms_; | 70 int64_t last_process_time_ms_; |
| 62 | 71 |
| 63 rtc::CriticalSection lock_; | 72 rtc::CriticalSection lock_; |
| 64 | 73 |
| 65 uint32_t media_ssrc_ GUARDED_BY(&lock_); | 74 uint32_t media_ssrc_ GUARDED_BY(&lock_); |
| 66 uint8_t feedback_sequence_ GUARDED_BY(&lock_); | 75 uint8_t feedback_sequence_ GUARDED_BY(&lock_); |
| 67 SequenceNumberUnwrapper unwrapper_ GUARDED_BY(&lock_); | 76 SequenceNumberUnwrapper unwrapper_ GUARDED_BY(&lock_); |
| 68 int64_t window_start_seq_ GUARDED_BY(&lock_); | 77 int64_t window_start_seq_ GUARDED_BY(&lock_); |
| 69 // Map unwrapped seq -> time. | 78 // Map unwrapped seq -> time. |
| 70 std::map<int64_t, int64_t> packet_arrival_times_ GUARDED_BY(&lock_); | 79 std::map<int64_t, int64_t> packet_arrival_times_ GUARDED_BY(&lock_); |
| 80 int process_interval_ms_; |
| 81 std::unique_ptr<rtc::RateTracker> received_bitrate_tracker_bps_ |
| 82 GUARDED_BY(&lock_); |
| 71 }; | 83 }; |
| 72 | 84 |
| 73 } // namespace webrtc | 85 } // namespace webrtc |
| 74 | 86 |
| 75 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_ | 87 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_ |
| OLD | NEW |