• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_
12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 #include "modules/rtp_rtcp/source/rtcp_packet.h"
18 #include "rtc_base/buffer.h"
19 
20 namespace webrtc {
21 namespace rtcp {
22 class CommonHeader;
23 
24 class App : public RtcpPacket {
25  public:
26   static constexpr uint8_t kPacketType = 204;
27   App();
28   App(App&&) = default;
29   ~App() override;
30 
31   // Parse assumes header is already parsed and validated.
32   bool Parse(const CommonHeader& packet);
33 
34   void SetSubType(uint8_t subtype);
SetName(uint32_t name)35   void SetName(uint32_t name) { name_ = name; }
36   void SetData(const uint8_t* data, size_t data_length);
37 
sub_type()38   uint8_t sub_type() const { return sub_type_; }
name()39   uint32_t name() const { return name_; }
data_size()40   size_t data_size() const { return data_.size(); }
data()41   const uint8_t* data() const { return data_.data(); }
42 
43   size_t BlockLength() const override;
44 
45   bool Create(uint8_t* packet,
46               size_t* index,
47               size_t max_length,
48               PacketReadyCallback callback) const override;
49 
NameToInt(const char name[5])50   static inline constexpr uint32_t NameToInt(const char name[5]) {
51     return static_cast<uint32_t>(name[0]) << 24 |
52            static_cast<uint32_t>(name[1]) << 16 |
53            static_cast<uint32_t>(name[2]) << 8 | static_cast<uint32_t>(name[3]);
54   }
55 
56  private:
57   static constexpr size_t kAppBaseLength = 8;  // Ssrc and Name.
58   static constexpr size_t kMaxDataSize = 0xffff * 4 - kAppBaseLength;
59 
60   uint8_t sub_type_;
61   uint32_t name_;
62   rtc::Buffer data_;
63 };
64 
65 }  // namespace rtcp
66 }  // namespace webrtc
67 #endif  // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_APP_H_
68