Line data Source code
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 : // This class estimates the incoming available bandwidth.
12 :
13 : #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_REMOTE_BITRATE_ESTIMATOR_H_
14 : #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_REMOTE_BITRATE_ESTIMATOR_H_
15 :
16 : #include <map>
17 : #include <vector>
18 :
19 : #include "webrtc/common_types.h"
20 : #include "webrtc/modules/include/module.h"
21 : #include "webrtc/modules/include/module_common_types.h"
22 : #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
23 : #include "webrtc/typedefs.h"
24 :
25 : namespace webrtc {
26 :
27 : class Clock;
28 :
29 : // RemoteBitrateObserver is used to signal changes in bitrate estimates for
30 : // the incoming streams.
31 0 : class RemoteBitrateObserver {
32 : public:
33 : // Called when a receive channel group has a new bitrate estimate for the
34 : // incoming streams.
35 : virtual void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
36 : uint32_t bitrate) = 0;
37 0 : virtual void OnProbeBitrate(uint32_t bitrate) {}
38 :
39 0 : virtual ~RemoteBitrateObserver() {}
40 : };
41 :
42 : // TODO(holmer): Remove when all implementations have been updated.
43 : struct ReceiveBandwidthEstimatorStats {};
44 :
45 0 : class RemoteBitrateEstimator : public CallStatsObserver, public Module {
46 : public:
47 0 : virtual ~RemoteBitrateEstimator() {}
48 :
49 0 : virtual void IncomingPacketFeedbackVector(
50 : const std::vector<PacketInfo>& packet_feedback_vector) {
51 0 : assert(false);
52 : }
53 :
54 : // Called for each incoming packet. Updates the incoming payload bitrate
55 : // estimate and the over-use detector. If an over-use is detected the
56 : // remote bitrate estimate will be updated. Note that |payload_size| is the
57 : // packet size excluding headers.
58 : // Note that |arrival_time_ms| can be of an arbitrary time base.
59 : virtual void IncomingPacket(int64_t arrival_time_ms,
60 : size_t payload_size,
61 : const RTPHeader& header) = 0;
62 :
63 : // Removes all data for |ssrc|.
64 : virtual void RemoveStream(uint32_t ssrc) = 0;
65 :
66 : // Returns true if a valid estimate exists and sets |bitrate_bps| to the
67 : // estimated payload bitrate in bits per second. |ssrcs| is the list of ssrcs
68 : // currently being received and of which the bitrate estimate is based upon.
69 : virtual bool LatestEstimate(std::vector<uint32_t>* ssrcs,
70 : uint32_t* bitrate_bps) const = 0;
71 :
72 : // TODO(holmer): Remove when all implementations have been updated.
73 0 : virtual bool GetStats(ReceiveBandwidthEstimatorStats* output) const {
74 0 : return false;
75 : }
76 :
77 : virtual void SetMinBitrate(int min_bitrate_bps) = 0;
78 :
79 : protected:
80 : static const int64_t kProcessIntervalMs = 500;
81 : static const int64_t kStreamTimeOutMs = 2000;
82 : };
83 :
84 : } // namespace webrtc
85 :
86 : #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_REMOTE_BITRATE_ESTIMATOR_H_
|