danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 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 | |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 14 | #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 15 | #include "webrtc/rtc_base/buffer.h" |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | namespace rtcp { |
danilchap | 2874ed5 | 2016-07-26 06:40:29 -0700 | [diff] [blame] | 19 | class CommonHeader; |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 20 | |
| 21 | class App : public RtcpPacket { |
| 22 | public: |
danilchap | 2874ed5 | 2016-07-26 06:40:29 -0700 | [diff] [blame] | 23 | static constexpr uint8_t kPacketType = 204; |
eladalon | 8fa21c4 | 2017-06-16 07:07:47 -0700 | [diff] [blame] | 24 | App(); |
| 25 | ~App() override; |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 26 | |
| 27 | // Parse assumes header is already parsed and validated. |
danilchap | 2874ed5 | 2016-07-26 06:40:29 -0700 | [diff] [blame] | 28 | bool Parse(const CommonHeader& packet); |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 29 | |
danilchap | 822a16f | 2016-09-27 09:27:47 -0700 | [diff] [blame] | 30 | 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); |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 34 | |
| 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 | |
eladalon | 8fa21c4 | 2017-06-16 07:07:47 -0700 | [diff] [blame] | 41 | size_t BlockLength() const override; |
| 42 | |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 43 | bool Create(uint8_t* packet, |
| 44 | size_t* index, |
| 45 | size_t max_length, |
| 46 | RtcpPacket::PacketReadyCallback* callback) const override; |
| 47 | |
| 48 | private: |
danilchap | 2874ed5 | 2016-07-26 06:40:29 -0700 | [diff] [blame] | 49 | static constexpr size_t kAppBaseLength = 8; // Ssrc and Name. |
| 50 | static constexpr size_t kMaxDataSize = 0xffff * 4 - kAppBaseLength; |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 51 | |
| 52 | uint8_t sub_type_; |
| 53 | uint32_t ssrc_; |
| 54 | uint32_t name_; |
| 55 | rtc::Buffer data_; |
danilchap | 0219c9b | 2015-11-18 05:56:53 -0800 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | } // namespace rtcp |
| 59 | } // namespace webrtc |
| 60 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_ |