blob: 3400274568660a439d36eae7d8d9b3b59dd074fd [file] [log] [blame]
Sebastian Janssone1795f42019-07-24 09:38:031/*
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
19namespace webrtc {
20namespace rtcp {
21
22class CommonHeader;
23class 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.
33const RemoteEstimateSerializer* GetRemoteEstimateSerializer();
34
Sebastian Jansson97321b62019-07-24 12:01:1835// The RemoteEstimate packet provides network estimation results from the
36// receive side. This functionality is experimental and subject to change
37// without notice.
Sebastian Janssone1795f42019-07-24 09:38:0338class RemoteEstimate : public App {
39 public:
40 RemoteEstimate();
Sebastian Janssona72d5832019-07-25 07:50:4841 explicit RemoteEstimate(App&& app);
Sebastian Janssone1795f42019-07-24 09:38:0342 // 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
Sebastian Janssona72d5832019-07-25 07:50:4847 bool ParseData();
Sebastian Janssone1795f42019-07-24 09:38:0348 void SetEstimate(NetworkStateEstimate 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_