Line data Source code
1 : /*
2 : * Copyright (c) 2016 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 : #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SENDER_REPORT_H_
12 : #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SENDER_REPORT_H_
13 :
14 : #include <vector>
15 :
16 : #include "webrtc/base/constructormagic.h"
17 : #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
18 : #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h"
19 : #include "webrtc/system_wrappers/include/ntp_time.h"
20 :
21 : namespace webrtc {
22 : namespace rtcp {
23 : class CommonHeader;
24 :
25 : class SenderReport : public RtcpPacket {
26 : public:
27 : static constexpr uint8_t kPacketType = 200;
28 :
29 : SenderReport();
30 0 : ~SenderReport() override {}
31 :
32 : // Parse assumes header is already parsed and validated.
33 : bool Parse(const CommonHeader& packet);
34 :
35 0 : void SetSenderSsrc(uint32_t ssrc) { sender_ssrc_ = ssrc; }
36 0 : void SetNtp(NtpTime ntp) { ntp_ = ntp; }
37 0 : void SetRtpTimestamp(uint32_t rtp_timestamp) {
38 0 : rtp_timestamp_ = rtp_timestamp;
39 0 : }
40 0 : void SetPacketCount(uint32_t packet_count) {
41 0 : sender_packet_count_ = packet_count;
42 0 : }
43 0 : void SetOctetCount(uint32_t octet_count) {
44 0 : sender_octet_count_ = octet_count;
45 0 : }
46 : bool AddReportBlock(const ReportBlock& block);
47 : void ClearReportBlocks() { report_blocks_.clear(); }
48 :
49 0 : uint32_t sender_ssrc() const { return sender_ssrc_; }
50 0 : NtpTime ntp() const { return ntp_; }
51 0 : uint32_t rtp_timestamp() const { return rtp_timestamp_; }
52 0 : uint32_t sender_packet_count() const { return sender_packet_count_; }
53 0 : uint32_t sender_octet_count() const { return sender_octet_count_; }
54 :
55 0 : const std::vector<ReportBlock>& report_blocks() const {
56 0 : return report_blocks_;
57 : }
58 :
59 : protected:
60 : bool Create(uint8_t* packet,
61 : size_t* index,
62 : size_t max_length,
63 : RtcpPacket::PacketReadyCallback* callback) const override;
64 :
65 : private:
66 : static const size_t kMaxNumberOfReportBlocks = 0x1f;
67 : const size_t kSenderBaseLength = 24;
68 :
69 0 : size_t BlockLength() const override {
70 0 : return kHeaderLength + kSenderBaseLength +
71 0 : report_blocks_.size() * ReportBlock::kLength;
72 : }
73 :
74 : uint32_t sender_ssrc_;
75 : NtpTime ntp_;
76 : uint32_t rtp_timestamp_;
77 : uint32_t sender_packet_count_;
78 : uint32_t sender_octet_count_;
79 : std::vector<ReportBlock> report_blocks_;
80 :
81 : RTC_DISALLOW_COPY_AND_ASSIGN(SenderReport);
82 : };
83 :
84 : } // namespace rtcp
85 : } // namespace webrtc
86 : #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SENDER_REPORT_H_
|