xref: /aosp_15_r20/external/webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2016 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_SDES_H_
12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SDES_H_
13 
14 #include <string>
15 #include <vector>
16 
17 #include "absl/strings/string_view.h"
18 #include "modules/rtp_rtcp/source/rtcp_packet.h"
19 
20 namespace webrtc {
21 namespace rtcp {
22 class CommonHeader;
23 // Source Description (SDES) (RFC 3550).
24 class Sdes : public RtcpPacket {
25  public:
26   struct Chunk {
27     uint32_t ssrc;
28     std::string cname;
29   };
30   static constexpr uint8_t kPacketType = 202;
31   static constexpr size_t kMaxNumberOfChunks = 0x1f;
32 
33   Sdes();
34   ~Sdes() override;
35 
36   // Parse assumes header is already parsed and validated.
37   bool Parse(const CommonHeader& packet);
38 
39   bool AddCName(uint32_t ssrc, absl::string_view cname);
40 
chunks()41   const std::vector<Chunk>& chunks() const { return chunks_; }
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 
50  private:
51   std::vector<Chunk> chunks_;
52   size_t block_length_;
53 };
54 }  // namespace rtcp
55 }  // namespace webrtc
56 #endif  // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SDES_H_
57