OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 * | 9 * |
10 */ | 10 */ |
11 | 11 |
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ | 12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ |
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ | 13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ |
14 | 14 |
15 #include <string> | |
16 #include <vector> | 15 #include <vector> |
17 | 16 |
18 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
22 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
23 | 22 |
24 namespace webrtc { | 23 namespace webrtc { |
25 namespace rtcp { | 24 namespace rtcp { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return kSrHeaderLength + kSenderInfoLength + | 186 return kSrHeaderLength + kSenderInfoLength + |
188 report_blocks_.size() * kReportBlockLength; | 187 report_blocks_.size() * kReportBlockLength; |
189 } | 188 } |
190 | 189 |
191 RTCPUtility::RTCPPacketSR sr_; | 190 RTCPUtility::RTCPPacketSR sr_; |
192 std::vector<ReportBlock> report_blocks_; | 191 std::vector<ReportBlock> report_blocks_; |
193 | 192 |
194 RTC_DISALLOW_COPY_AND_ASSIGN(SenderReport); | 193 RTC_DISALLOW_COPY_AND_ASSIGN(SenderReport); |
195 }; | 194 }; |
196 | 195 |
197 // Source Description (SDES) (RFC 3550). | |
198 // | |
199 // 0 1 2 3 | |
200 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
201 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
202 // header |V=2|P| SC | PT=SDES=202 | length | | |
203 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | |
204 // chunk | SSRC/CSRC_1 | | |
205 // 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
206 // | SDES items | | |
207 // | ... | | |
208 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | |
209 // chunk | SSRC/CSRC_2 | | |
210 // 2 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
211 // | SDES items | | |
212 // | ... | | |
213 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | |
214 // | |
215 // Canonical End-Point Identifier SDES Item (CNAME) | |
216 // | |
217 // 0 1 2 3 | |
218 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |
219 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
220 // | CNAME=1 | length | user and domain name ... | |
221 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
222 | |
223 class Sdes : public RtcpPacket { | |
224 public: | |
225 Sdes() : RtcpPacket() {} | |
226 | |
227 virtual ~Sdes() {} | |
228 | |
229 bool WithCName(uint32_t ssrc, const std::string& cname); | |
230 | |
231 struct Chunk { | |
232 uint32_t ssrc; | |
233 std::string name; | |
234 int null_octets; | |
235 }; | |
236 | |
237 protected: | |
238 bool Create(uint8_t* packet, | |
239 size_t* index, | |
240 size_t max_length, | |
241 RtcpPacket::PacketReadyCallback* callback) const override; | |
242 | |
243 private: | |
244 static const int kMaxNumberOfChunks = 0x1f; | |
245 | |
246 size_t BlockLength() const; | |
247 | |
248 std::vector<Chunk> chunks_; | |
249 | |
250 RTC_DISALLOW_COPY_AND_ASSIGN(Sdes); | |
251 }; | |
252 | |
253 // Class holding a RTCP packet. | 196 // Class holding a RTCP packet. |
254 // | 197 // |
255 // Takes a built rtcp packet. | 198 // Takes a built rtcp packet. |
256 // RawPacket raw_packet(buffer, length); | 199 // RawPacket raw_packet(buffer, length); |
257 // | 200 // |
258 // To access the raw packet: | 201 // To access the raw packet: |
259 // raw_packet.Buffer(); - pointer to the raw packet | 202 // raw_packet.Buffer(); - pointer to the raw packet |
260 // raw_packet.BufferLength(); - the length of the raw packet | 203 // raw_packet.BufferLength(); - the length of the raw packet |
261 | 204 |
262 class RawPacket { | 205 class RawPacket { |
263 public: | 206 public: |
264 explicit RawPacket(size_t buffer_length); | 207 explicit RawPacket(size_t buffer_length); |
265 RawPacket(const uint8_t* packet, size_t packet_length); | 208 RawPacket(const uint8_t* packet, size_t packet_length); |
266 | 209 |
267 const uint8_t* Buffer() const; | 210 const uint8_t* Buffer() const; |
268 uint8_t* MutableBuffer(); | 211 uint8_t* MutableBuffer(); |
269 size_t BufferLength() const; | 212 size_t BufferLength() const; |
270 size_t Length() const; | 213 size_t Length() const; |
271 void SetLength(size_t length); | 214 void SetLength(size_t length); |
272 | 215 |
273 private: | 216 private: |
274 const size_t buffer_length_; | 217 const size_t buffer_length_; |
275 size_t length_; | 218 size_t length_; |
276 rtc::scoped_ptr<uint8_t[]> buffer_; | 219 rtc::scoped_ptr<uint8_t[]> buffer_; |
277 }; | 220 }; |
278 | 221 |
279 } // namespace rtcp | 222 } // namespace rtcp |
280 } // namespace webrtc | 223 } // namespace webrtc |
281 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ | 224 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ |
OLD | NEW |