Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet.h

Issue 1579213005: [rtp_rtcp] rtcp::Xr moved into own file and renamed to ExtendedReports on the way (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/rtp_rtcp.gypi ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map>
16 #include <string> 15 #include <string>
17 #include <vector> 16 #include <vector>
18 17
19 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/base/scoped_ptr.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h"
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
26 #include "webrtc/typedefs.h" 22 #include "webrtc/typedefs.h"
27 23
28 namespace webrtc { 24 namespace webrtc {
29 namespace rtcp { 25 namespace rtcp {
30 26
31 static const int kCommonFbFmtLength = 12; 27 static const int kCommonFbFmtLength = 12;
32 static const int kReportBlockLength = 24; 28 static const int kReportBlockLength = 24;
33 29
34 class RawPacket; 30 class RawPacket;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 size_t fci_length = 2 + (rpsi_.NumberOfValidBits / 8) + padding_bytes_; 295 size_t fci_length = 2 + (rpsi_.NumberOfValidBits / 8) + padding_bytes_;
300 return kCommonFbFmtLength + fci_length; 296 return kCommonFbFmtLength + fci_length;
301 } 297 }
302 298
303 uint8_t padding_bytes_; 299 uint8_t padding_bytes_;
304 RTCPUtility::RTCPPacketPSFBRPSI rpsi_; 300 RTCPUtility::RTCPPacketPSFBRPSI rpsi_;
305 301
306 RTC_DISALLOW_COPY_AND_ASSIGN(Rpsi); 302 RTC_DISALLOW_COPY_AND_ASSIGN(Rpsi);
307 }; 303 };
308 304
309 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR).
310 //
311 // Format for XR packets:
312 //
313 // 0 1 2 3
314 // 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
315 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
316 // |V=2|P|reserved | PT=XR=207 | length |
317 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
318 // | SSRC |
319 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
320 // : report blocks :
321 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
322
323 class Xr : public RtcpPacket {
324 public:
325 typedef std::vector<RTCPUtility::RTCPPacketXRDLRRReportBlockItem> DlrrBlock;
326 Xr() : RtcpPacket() {
327 memset(&xr_header_, 0, sizeof(xr_header_));
328 }
329
330 virtual ~Xr() {}
331
332 void From(uint32_t ssrc) {
333 xr_header_.OriginatorSSRC = ssrc;
334 }
335
336 // Max 50 items of each of {Rrtr, Dlrr, VoipMetric} allowed per Xr.
337 bool WithRrtr(Rrtr* rrtr);
338 bool WithDlrr(Dlrr* dlrr);
339 bool WithVoipMetric(VoipMetric* voip_metric);
340
341 protected:
342 bool Create(uint8_t* packet,
343 size_t* index,
344 size_t max_length,
345 RtcpPacket::PacketReadyCallback* callback) const override;
346
347 private:
348 static const int kMaxNumberOfRrtrBlocks = 50;
349 static const int kMaxNumberOfDlrrBlocks = 50;
350 static const int kMaxNumberOfVoipMetricBlocks = 50;
351
352 size_t BlockLength() const {
353 const size_t kXrHeaderLength = 8;
354 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength();
355 }
356
357 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); }
358
359 size_t DlrrLength() const;
360
361 size_t VoipMetricLength() const {
362 return VoipMetric::kLength * voip_metric_blocks_.size();
363 }
364
365 RTCPUtility::RTCPPacketXR xr_header_;
366 std::vector<Rrtr> rrtr_blocks_;
367 std::vector<Dlrr> dlrr_blocks_;
368 std::vector<VoipMetric> voip_metric_blocks_;
369
370 RTC_DISALLOW_COPY_AND_ASSIGN(Xr);
371 };
372
373 // Class holding a RTCP packet. 305 // Class holding a RTCP packet.
374 // 306 //
375 // Takes a built rtcp packet. 307 // Takes a built rtcp packet.
376 // RawPacket raw_packet(buffer, length); 308 // RawPacket raw_packet(buffer, length);
377 // 309 //
378 // To access the raw packet: 310 // To access the raw packet:
379 // raw_packet.Buffer(); - pointer to the raw packet 311 // raw_packet.Buffer(); - pointer to the raw packet
380 // raw_packet.BufferLength(); - the length of the raw packet 312 // raw_packet.BufferLength(); - the length of the raw packet
381 313
382 class RawPacket { 314 class RawPacket {
383 public: 315 public:
384 explicit RawPacket(size_t buffer_length); 316 explicit RawPacket(size_t buffer_length);
385 RawPacket(const uint8_t* packet, size_t packet_length); 317 RawPacket(const uint8_t* packet, size_t packet_length);
386 318
387 const uint8_t* Buffer() const; 319 const uint8_t* Buffer() const;
388 uint8_t* MutableBuffer(); 320 uint8_t* MutableBuffer();
389 size_t BufferLength() const; 321 size_t BufferLength() const;
390 size_t Length() const; 322 size_t Length() const;
391 void SetLength(size_t length); 323 void SetLength(size_t length);
392 324
393 private: 325 private:
394 const size_t buffer_length_; 326 const size_t buffer_length_;
395 size_t length_; 327 size_t length_;
396 rtc::scoped_ptr<uint8_t[]> buffer_; 328 rtc::scoped_ptr<uint8_t[]> buffer_;
397 }; 329 };
398 330
399 } // namespace rtcp 331 } // namespace rtcp
400 } // namespace webrtc 332 } // namespace webrtc
401 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ 333 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/rtp_rtcp.gypi ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698