blob: ff5f52dbf88902ce02802aa6a9a9c6ec6cc5bbc8 [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
Yves Gerey988cc082018-10-23 12:03:01 +020014#include <stddef.h>
15#include <stdint.h>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/rtp_rtcp/source/rtcp_packet.h"
18#include "rtc_base/buffer.h"
danilchap0219c9b2015-11-18 05:56:53 -080019
20namespace webrtc {
21namespace rtcp {
danilchap2874ed52016-07-26 06:40:29 -070022class CommonHeader;
danilchap0219c9b2015-11-18 05:56:53 -080023
24class App : public RtcpPacket {
25 public:
danilchap2874ed52016-07-26 06:40:29 -070026 static constexpr uint8_t kPacketType = 204;
eladalon8fa21c42017-06-16 07:07:47 -070027 App();
28 ~App() override;
danilchap0219c9b2015-11-18 05:56:53 -080029
30 // Parse assumes header is already parsed and validated.
danilchap2874ed52016-07-26 06:40:29 -070031 bool Parse(const CommonHeader& packet);
danilchap0219c9b2015-11-18 05:56:53 -080032
danilchap822a16f2016-09-27 09:27:47 -070033 void SetSsrc(uint32_t ssrc) { ssrc_ = ssrc; }
34 void SetSubType(uint8_t subtype);
35 void SetName(uint32_t name) { name_ = name; }
36 void SetData(const uint8_t* data, size_t data_length);
danilchap0219c9b2015-11-18 05:56:53 -080037
38 uint8_t sub_type() const { return sub_type_; }
39 uint32_t ssrc() const { return ssrc_; }
40 uint32_t name() const { return name_; }
41 size_t data_size() const { return data_.size(); }
42 const uint8_t* data() const { return data_.data(); }
43
eladalon8fa21c42017-06-16 07:07:47 -070044 size_t BlockLength() const override;
45
danilchap0219c9b2015-11-18 05:56:53 -080046 bool Create(uint8_t* packet,
47 size_t* index,
48 size_t max_length,
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010049 PacketReadyCallback callback) const override;
danilchap0219c9b2015-11-18 05:56:53 -080050
Sebastian Janssone1795f42019-07-24 11:38:03 +020051 static inline constexpr uint32_t NameToInt(const char name[5]) {
52 return static_cast<uint32_t>(name[0]) << 24 |
53 static_cast<uint32_t>(name[1]) << 16 |
54 static_cast<uint32_t>(name[2]) << 8 | static_cast<uint32_t>(name[3]);
55 }
56
danilchap0219c9b2015-11-18 05:56:53 -080057 private:
danilchap2874ed52016-07-26 06:40:29 -070058 static constexpr size_t kAppBaseLength = 8; // Ssrc and Name.
59 static constexpr size_t kMaxDataSize = 0xffff * 4 - kAppBaseLength;
danilchap0219c9b2015-11-18 05:56:53 -080060
61 uint8_t sub_type_;
62 uint32_t ssrc_;
63 uint32_t name_;
64 rtc::Buffer data_;
danilchap0219c9b2015-11-18 05:56:53 -080065};
66
67} // namespace rtcp
68} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020069#endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_