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