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 : #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_COMMON_HEADER_H_
11 : #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_COMMON_HEADER_H_
12 :
13 : #include "webrtc/base/basictypes.h"
14 :
15 : namespace webrtc {
16 : namespace rtcp {
17 : class CommonHeader {
18 : public:
19 0 : CommonHeader() {}
20 : CommonHeader(const CommonHeader&) = default;
21 : CommonHeader& operator =(const CommonHeader&) = default;
22 :
23 : bool Parse(const uint8_t* buffer, size_t size_bytes);
24 :
25 0 : uint8_t type() const { return packet_type_; }
26 : // Depending on packet type same header field can be used either as count or
27 : // as feedback message type (fmt). Caller expected to know how it is used.
28 0 : uint8_t fmt() const { return count_or_format_; }
29 0 : uint8_t count() const { return count_or_format_; }
30 0 : size_t payload_size_bytes() const { return payload_size_; }
31 0 : const uint8_t* payload() const { return payload_; }
32 : // Returns pointer to the next RTCP packet in compound packet.
33 0 : const uint8_t* NextPacket() const {
34 0 : return payload_ + payload_size_ + padding_size_;
35 : }
36 :
37 : private:
38 : uint8_t packet_type_ = 0;
39 : uint8_t count_or_format_ = 0;
40 : uint8_t padding_size_ = 0;
41 : uint32_t payload_size_ = 0;
42 : const uint8_t* payload_ = nullptr;
43 : };
44 : } // namespace rtcp
45 : } // namespace webrtc
46 : #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_COMMON_HEADER_H_
|