blob: 985ddd3eaf9beb4e0962f5cf74ac5a3e6c10ef58 [file] [log] [blame]
sprang233bd872015-09-08 20:25:161/*
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
Mirko Bonadei92ea95e2017-09-15 04:47:3111#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_
12#define MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_
sprang233bd872015-09-08 20:25:1613
14#include <map>
15#include <vector>
16
Mirko Bonadei92ea95e2017-09-15 04:47:3117#include "modules/include/module_common_types.h"
18#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
19#include "rtc_base/criticalsection.h"
sprang233bd872015-09-08 20:25:1620
21namespace webrtc {
22
23class Clock;
24class PacketRouter;
25namespace rtcp {
26class TransportFeedback;
27}
28
29// 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
31// transport feedback messages back too the send side.
32
33class RemoteEstimatorProxy : public RemoteBitrateEstimator {
34 public:
Danil Chapovalov599df852017-09-25 13:19:3535 RemoteEstimatorProxy(const Clock* clock,
36 TransportFeedbackSenderInterface* feedback_sender);
sprang233bd872015-09-08 20:25:1637 virtual ~RemoteEstimatorProxy();
38
sprang233bd872015-09-08 20:25:1639 void IncomingPacket(int64_t arrival_time_ms,
40 size_t payload_size,
pbos2169d8b2016-06-20 18:53:0241 const RTPHeader& header) override;
Stefan Holmer62a5ccd2016-02-16 16:07:2142 void RemoveStream(uint32_t ssrc) override {}
sprang233bd872015-09-08 20:25:1643 bool LatestEstimate(std::vector<unsigned int>* ssrcs,
44 unsigned int* bitrate_bps) const override;
stefan4fbd1452015-09-28 10:57:1445 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override {}
46 void SetMinBitrate(int min_bitrate_bps) override {}
sprang233bd872015-09-08 20:25:1647 int64_t TimeUntilNextProcess() override;
pbosa26ac922016-02-25 12:50:0148 void Process() override;
minyue8927b052016-11-07 15:51:2049 void OnBitrateChanged(int bitrate);
sprang233bd872015-09-08 20:25:1650
minyue8927b052016-11-07 15:51:2051 static const int kMinSendIntervalMs;
52 static const int kMaxSendIntervalMs;
53 static const int kDefaultSendIntervalMs;
sprang233bd872015-09-08 20:25:1654 static const int kBackWindowMs;
55
56 private:
57 void OnPacketArrival(uint16_t sequence_number, int64_t arrival_time)
danilchap56359be2017-09-07 14:53:4558 RTC_EXCLUSIVE_LOCKS_REQUIRED(&lock_);
stefan159a2fe2016-07-18 11:14:1159 bool BuildFeedbackPacket(rtcp::TransportFeedback* feedback_packet);
sprang233bd872015-09-08 20:25:1660
elad.alon61ce37e2017-03-09 15:09:3161 const Clock* const clock_;
Danil Chapovalov599df852017-09-25 13:19:3562 TransportFeedbackSenderInterface* const feedback_sender_;
sprang233bd872015-09-08 20:25:1663 int64_t last_process_time_ms_;
64
65 rtc::CriticalSection lock_;
66
danilchap56359be2017-09-07 14:53:4567 uint32_t media_ssrc_ RTC_GUARDED_BY(&lock_);
68 uint8_t feedback_sequence_ RTC_GUARDED_BY(&lock_);
69 SequenceNumberUnwrapper unwrapper_ RTC_GUARDED_BY(&lock_);
70 int64_t window_start_seq_ RTC_GUARDED_BY(&lock_);
sprang233bd872015-09-08 20:25:1671 // Map unwrapped seq -> time.
danilchap56359be2017-09-07 14:53:4572 std::map<int64_t, int64_t> packet_arrival_times_ RTC_GUARDED_BY(&lock_);
73 int64_t send_interval_ms_ RTC_GUARDED_BY(&lock_);
sprang233bd872015-09-08 20:25:1674};
75
76} // namespace webrtc
77
Mirko Bonadei92ea95e2017-09-15 04:47:3178#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_REMOTE_ESTIMATOR_PROXY_H_