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

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
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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 size_t BlockLength() const { 398 size_t BlockLength() const {
403 return (remb_item_.NumberOfSSRCs + 5) * 4; 399 return (remb_item_.NumberOfSSRCs + 5) * 4;
404 } 400 }
405 401
406 RTCPUtility::RTCPPacketPSFBAPP remb_; 402 RTCPUtility::RTCPPacketPSFBAPP remb_;
407 RTCPUtility::RTCPPacketPSFBREMBItem remb_item_; 403 RTCPUtility::RTCPPacketPSFBREMBItem remb_item_;
408 404
409 RTC_DISALLOW_COPY_AND_ASSIGN(Remb); 405 RTC_DISALLOW_COPY_AND_ASSIGN(Remb);
410 }; 406 };
411 407
412 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR).
413 //
414 // Format for XR packets:
415 //
416 // 0 1 2 3
417 // 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
418 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
419 // |V=2|P|reserved | PT=XR=207 | length |
420 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
421 // | SSRC |
422 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
423 // : report blocks :
424 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
425
426 class Xr : public RtcpPacket {
427 public:
428 typedef std::vector<RTCPUtility::RTCPPacketXRDLRRReportBlockItem> DlrrBlock;
429 Xr() : RtcpPacket() {
430 memset(&xr_header_, 0, sizeof(xr_header_));
431 }
432
433 virtual ~Xr() {}
434
435 void From(uint32_t ssrc) {
436 xr_header_.OriginatorSSRC = ssrc;
437 }
438
439 // Max 50 items of each of {Rrtr, Dlrr, VoipMetric} allowed per Xr.
440 bool WithRrtr(Rrtr* rrtr);
441 bool WithDlrr(Dlrr* dlrr);
442 bool WithVoipMetric(VoipMetric* voip_metric);
443
444 protected:
445 bool Create(uint8_t* packet,
446 size_t* index,
447 size_t max_length,
448 RtcpPacket::PacketReadyCallback* callback) const override;
449
450 private:
451 static const int kMaxNumberOfRrtrBlocks = 50;
452 static const int kMaxNumberOfDlrrBlocks = 50;
453 static const int kMaxNumberOfVoipMetricBlocks = 50;
454
455 size_t BlockLength() const {
456 const size_t kXrHeaderLength = 8;
457 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength();
458 }
459
460 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); }
461
462 size_t DlrrLength() const;
463
464 size_t VoipMetricLength() const {
465 return VoipMetric::kLength * voip_metric_blocks_.size();
466 }
467
468 RTCPUtility::RTCPPacketXR xr_header_;
469 std::vector<Rrtr> rrtr_blocks_;
470 std::vector<Dlrr> dlrr_blocks_;
471 std::vector<VoipMetric> voip_metric_blocks_;
472
473 RTC_DISALLOW_COPY_AND_ASSIGN(Xr);
474 };
475
476 // Class holding a RTCP packet. 408 // Class holding a RTCP packet.
477 // 409 //
478 // Takes a built rtcp packet. 410 // Takes a built rtcp packet.
479 // RawPacket raw_packet(buffer, length); 411 // RawPacket raw_packet(buffer, length);
480 // 412 //
481 // To access the raw packet: 413 // To access the raw packet:
482 // raw_packet.Buffer(); - pointer to the raw packet 414 // raw_packet.Buffer(); - pointer to the raw packet
483 // raw_packet.BufferLength(); - the length of the raw packet 415 // raw_packet.BufferLength(); - the length of the raw packet
484 416
485 class RawPacket { 417 class RawPacket {
486 public: 418 public:
487 explicit RawPacket(size_t buffer_length); 419 explicit RawPacket(size_t buffer_length);
488 RawPacket(const uint8_t* packet, size_t packet_length); 420 RawPacket(const uint8_t* packet, size_t packet_length);
489 421
490 const uint8_t* Buffer() const; 422 const uint8_t* Buffer() const;
491 uint8_t* MutableBuffer(); 423 uint8_t* MutableBuffer();
492 size_t BufferLength() const; 424 size_t BufferLength() const;
493 size_t Length() const; 425 size_t Length() const;
494 void SetLength(size_t length); 426 void SetLength(size_t length);
495 427
496 private: 428 private:
497 const size_t buffer_length_; 429 const size_t buffer_length_;
498 size_t length_; 430 size_t length_;
499 rtc::scoped_ptr<uint8_t[]> buffer_; 431 rtc::scoped_ptr<uint8_t[]> buffer_;
500 }; 432 };
501 433
502 } // namespace rtcp 434 } // namespace rtcp
503 } // namespace webrtc 435 } // namespace webrtc
504 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_ 436 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698