blob: 19a97e0ed920a31a54ae25d37b6435de1b9065ff [file] [log] [blame]
danilchap0219c9b2015-11-18 05:56:53 -08001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_
12#define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_
danilchap0219c9b2015-11-18 05:56:53 -080013
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "modules/rtp_rtcp/source/rtcp_packet.h"
15#include "rtc_base/buffer.h"
danilchap0219c9b2015-11-18 05:56:53 -080016
17namespace webrtc {
18namespace rtcp {
danilchap2874ed52016-07-26 06:40:29 -070019class CommonHeader;
danilchap0219c9b2015-11-18 05:56:53 -080020
21class App : public RtcpPacket {
22 public:
danilchap2874ed52016-07-26 06:40:29 -070023 static constexpr uint8_t kPacketType = 204;
eladalon8fa21c42017-06-16 07:07:47 -070024 App();
25 ~App() override;
danilchap0219c9b2015-11-18 05:56:53 -080026
27 // Parse assumes header is already parsed and validated.
danilchap2874ed52016-07-26 06:40:29 -070028 bool Parse(const CommonHeader& packet);
danilchap0219c9b2015-11-18 05:56:53 -080029
danilchap822a16f2016-09-27 09:27:47 -070030 void SetSsrc(uint32_t ssrc) { ssrc_ = ssrc; }
31 void SetSubType(uint8_t subtype);
32 void SetName(uint32_t name) { name_ = name; }
33 void SetData(const uint8_t* data, size_t data_length);
danilchap0219c9b2015-11-18 05:56:53 -080034
35 uint8_t sub_type() const { return sub_type_; }
36 uint32_t ssrc() const { return ssrc_; }
37 uint32_t name() const { return name_; }
38 size_t data_size() const { return data_.size(); }
39 const uint8_t* data() const { return data_.data(); }
40
eladalon8fa21c42017-06-16 07:07:47 -070041 size_t BlockLength() const override;
42
danilchap0219c9b2015-11-18 05:56:53 -080043 bool Create(uint8_t* packet,
44 size_t* index,
45 size_t max_length,
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010046 PacketReadyCallback callback) const override;
danilchap0219c9b2015-11-18 05:56:53 -080047
48 private:
danilchap2874ed52016-07-26 06:40:29 -070049 static constexpr size_t kAppBaseLength = 8; // Ssrc and Name.
50 static constexpr size_t kMaxDataSize = 0xffff * 4 - kAppBaseLength;
danilchap0219c9b2015-11-18 05:56:53 -080051
52 uint8_t sub_type_;
53 uint32_t ssrc_;
54 uint32_t name_;
55 rtc::Buffer data_;
danilchap0219c9b2015-11-18 05:56:53 -080056};
57
58} // namespace rtcp
59} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020060#endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_