Line data Source code
1 : /*
2 : * Copyright (c) 2015 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_APP_H_
12 : #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_
13 :
14 : #include "webrtc/base/buffer.h"
15 : #include "webrtc/base/constructormagic.h"
16 : #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
17 :
18 : namespace webrtc {
19 : namespace rtcp {
20 : class CommonHeader;
21 :
22 : class App : public RtcpPacket {
23 : public:
24 : static constexpr uint8_t kPacketType = 204;
25 0 : App() : sub_type_(0), ssrc_(0), name_(0) {}
26 0 : ~App() override {}
27 :
28 : // Parse assumes header is already parsed and validated.
29 : bool Parse(const CommonHeader& packet);
30 :
31 0 : void SetSsrc(uint32_t ssrc) { ssrc_ = ssrc; }
32 : void SetSubType(uint8_t subtype);
33 0 : void SetName(uint32_t name) { name_ = name; }
34 : void SetData(const uint8_t* data, size_t data_length);
35 :
36 : uint8_t sub_type() const { return sub_type_; }
37 : uint32_t ssrc() const { return ssrc_; }
38 : uint32_t name() const { return name_; }
39 : size_t data_size() const { return data_.size(); }
40 : const uint8_t* data() const { return data_.data(); }
41 :
42 : protected:
43 : bool Create(uint8_t* packet,
44 : size_t* index,
45 : size_t max_length,
46 : RtcpPacket::PacketReadyCallback* callback) const override;
47 :
48 : private:
49 : static constexpr size_t kAppBaseLength = 8; // Ssrc and Name.
50 : static constexpr size_t kMaxDataSize = 0xffff * 4 - kAppBaseLength;
51 0 : size_t BlockLength() const override {
52 0 : return kHeaderLength + kAppBaseLength + data_.size();
53 : }
54 :
55 : uint8_t sub_type_;
56 : uint32_t ssrc_;
57 : uint32_t name_;
58 : rtc::Buffer data_;
59 :
60 : RTC_DISALLOW_COPY_AND_ASSIGN(App);
61 : };
62 :
63 : } // namespace rtcp
64 : } // namespace webrtc
65 : #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_
|