Anton Sukhanov | c136b06 | 2019-05-14 14:53:42 -0700 | [diff] [blame] | 1 | /* Copyright 2018 The WebRTC project authors. All Rights Reserved. |
| 2 | * |
| 3 | * Use of this source code is governed by a BSD-style license |
| 4 | * that can be found in the LICENSE file in the root of the source |
| 5 | * tree. An additional intellectual property rights grant can be found |
| 6 | * in the file PATENTS. All contributing project authors may |
| 7 | * be found in the AUTHORS file in the root of the source tree. |
| 8 | */ |
| 9 | |
| 10 | // This is EXPERIMENTAL interface for media and datagram transports. |
| 11 | |
| 12 | #ifndef API_CONGESTION_CONTROL_INTERFACE_H_ |
| 13 | #define API_CONGESTION_CONTROL_INTERFACE_H_ |
| 14 | |
| 15 | #include <memory> |
| 16 | #include <string> |
| 17 | #include <utility> |
| 18 | |
| 19 | #include "api/media_transport_interface.h" |
| 20 | #include "api/units/data_rate.h" |
| 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // Defines congestion control feedback interface for media and datagram |
| 25 | // transports. |
| 26 | class CongestionControlInterface { |
| 27 | public: |
| 28 | virtual ~CongestionControlInterface() = default; |
| 29 | |
| 30 | // Updates allocation limits. |
| 31 | virtual void SetAllocatedBitrateLimits( |
| 32 | const MediaTransportAllocatedBitrateLimits& limits) = 0; |
| 33 | |
| 34 | // Sets starting rate. |
| 35 | virtual void SetTargetBitrateLimits( |
| 36 | const MediaTransportTargetRateConstraints& target_rate_constraints) = 0; |
| 37 | |
| 38 | // Intended for receive side. AddRttObserver registers an observer to be |
| 39 | // called for each RTT measurement, typically once per ACK. Before media |
| 40 | // transport is destructed the observer must be unregistered. |
| 41 | // |
| 42 | // TODO(sukhanov): Looks like AddRttObserver and RemoveRttObserver were |
| 43 | // never implemented for media transport, so keeping noop implementation. |
| 44 | virtual void AddRttObserver(MediaTransportRttObserver* observer) {} |
| 45 | virtual void RemoveRttObserver(MediaTransportRttObserver* observer) {} |
| 46 | |
| 47 | // Adds a target bitrate observer. Before media transport is destructed |
| 48 | // the observer must be unregistered (by calling |
| 49 | // RemoveTargetTransferRateObserver). |
| 50 | // A newly registered observer will be called back with the latest recorded |
| 51 | // target rate, if available. |
| 52 | virtual void AddTargetTransferRateObserver( |
| 53 | TargetTransferRateObserver* observer) = 0; |
| 54 | |
| 55 | // Removes an existing |observer| from observers. If observer was never |
| 56 | // registered, an error is logged and method does nothing. |
| 57 | virtual void RemoveTargetTransferRateObserver( |
| 58 | TargetTransferRateObserver* observer) = 0; |
| 59 | |
| 60 | // Returns the last known target transfer rate as reported to the above |
| 61 | // observers. |
| 62 | virtual absl::optional<TargetTransferRate> GetLatestTargetTransferRate() = 0; |
| 63 | }; |
| 64 | |
| 65 | } // namespace webrtc |
| 66 | |
| 67 | #endif // API_CONGESTION_CONTROL_INTERFACE_H_ |