remote_estimate.h (2119B)
1 /* 2 * Copyright (c) 2019 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 #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMOTE_ESTIMATE_H_ 11 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMOTE_ESTIMATE_H_ 12 13 #include <cstdint> 14 15 #include "api/array_view.h" 16 #include "api/transport/network_types.h" 17 #include "api/units/time_delta.h" 18 #include "modules/rtp_rtcp/source/rtcp_packet/app.h" 19 #include "rtc_base/buffer.h" 20 21 namespace webrtc { 22 namespace rtcp { 23 24 class CommonHeader; 25 class RemoteEstimateSerializer { 26 public: 27 virtual bool Parse(ArrayView<const uint8_t> src, 28 NetworkStateEstimate* target) const = 0; 29 virtual Buffer Serialize(const NetworkStateEstimate& src) const = 0; 30 virtual ~RemoteEstimateSerializer() = default; 31 }; 32 33 // Using a static global implementation to avoid incurring initialization 34 // overhead of the serializer every time RemoteEstimate is created. 35 const RemoteEstimateSerializer* GetRemoteEstimateSerializer(); 36 37 // The RemoteEstimate packet provides network estimation results from the 38 // receive side. This functionality is experimental and subject to change 39 // without notice. 40 class RemoteEstimate : public App { 41 public: 42 RemoteEstimate(); 43 explicit RemoteEstimate(App&& app); 44 // Note, sub type must be unique among all app messages with "goog" name. 45 static constexpr uint8_t kSubType = 13; 46 static constexpr uint32_t kName = NameToInt("goog"); 47 static TimeDelta GetTimestampPeriod(); 48 49 bool ParseData(); 50 void SetEstimate(NetworkStateEstimate estimate); 51 NetworkStateEstimate estimate() const { return estimate_; } 52 53 private: 54 NetworkStateEstimate estimate_; 55 const RemoteEstimateSerializer* const serializer_; 56 }; 57 58 } // namespace rtcp 59 } // namespace webrtc 60 61 #endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMOTE_ESTIMATE_H_