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

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

Issue 1496883002: rtcp::Rrtr block moved into own file and got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years 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_RTCP_PACKET_H_ 12 #ifndef WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_
13 #define WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ 13 #define WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_
14 14
15 #include <map> 15 #include <map>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/scoped_ptr.h" 19 #include "webrtc/base/scoped_ptr.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h" 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
23 #include "webrtc/typedefs.h" 24 #include "webrtc/typedefs.h"
24 25
25 namespace webrtc { 26 namespace webrtc {
26 namespace rtcp { 27 namespace rtcp {
27 28
28 static const int kCommonFbFmtLength = 12; 29 static const int kCommonFbFmtLength = 12;
29 static const int kReportBlockLength = 24; 30 static const int kReportBlockLength = 24;
30 31
31 class Dlrr; 32 class Dlrr;
32 class RawPacket; 33 class RawPacket;
33 class Rrtr;
34 class VoipMetric; 34 class VoipMetric;
35 35
36 // Class for building RTCP packets. 36 // Class for building RTCP packets.
37 // 37 //
38 // Example: 38 // Example:
39 // ReportBlock report_block; 39 // ReportBlock report_block;
40 // report_block.To(234) 40 // report_block.To(234)
41 // report_block.FractionLost(10); 41 // report_block.FractionLost(10);
42 // 42 //
43 // ReceiverReport rr; 43 // ReceiverReport rr;
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 private: 663 private:
664 static const int kMaxNumberOfRrtrBlocks = 50; 664 static const int kMaxNumberOfRrtrBlocks = 50;
665 static const int kMaxNumberOfDlrrBlocks = 50; 665 static const int kMaxNumberOfDlrrBlocks = 50;
666 static const int kMaxNumberOfVoipMetricBlocks = 50; 666 static const int kMaxNumberOfVoipMetricBlocks = 50;
667 667
668 size_t BlockLength() const { 668 size_t BlockLength() const {
669 const size_t kXrHeaderLength = 8; 669 const size_t kXrHeaderLength = 8;
670 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength(); 670 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength();
671 } 671 }
672 672
673 size_t RrtrLength() const { 673 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); }
674 const size_t kRrtrBlockLength = 12;
675 return kRrtrBlockLength * rrtr_blocks_.size();
676 }
677 674
678 size_t DlrrLength() const; 675 size_t DlrrLength() const;
679 676
680 size_t VoipMetricLength() const { 677 size_t VoipMetricLength() const {
681 const size_t kVoipMetricBlockLength = 36; 678 const size_t kVoipMetricBlockLength = 36;
682 return kVoipMetricBlockLength * voip_metric_blocks_.size(); 679 return kVoipMetricBlockLength * voip_metric_blocks_.size();
683 } 680 }
684 681
685 RTCPUtility::RTCPPacketXR xr_header_; 682 RTCPUtility::RTCPPacketXR xr_header_;
686 std::vector<RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem> rrtr_blocks_; 683 std::vector<Rrtr> rrtr_blocks_;
687 std::vector<DlrrBlock> dlrr_blocks_; 684 std::vector<DlrrBlock> dlrr_blocks_;
688 std::vector<RTCPUtility::RTCPPacketXRVOIPMetricItem> voip_metric_blocks_; 685 std::vector<RTCPUtility::RTCPPacketXRVOIPMetricItem> voip_metric_blocks_;
689 686
690 RTC_DISALLOW_COPY_AND_ASSIGN(Xr); 687 RTC_DISALLOW_COPY_AND_ASSIGN(Xr);
691 }; 688 };
692 689
693 // Receiver Reference Time Report Block (RFC 3611).
694 //
695 // 0 1 2 3
696 // 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
697 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
698 // | BT=4 | reserved | block length = 2 |
699 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
700 // | NTP timestamp, most significant word |
701 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
702 // | NTP timestamp, least significant word |
703 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
704
705 class Rrtr {
706 public:
707 Rrtr() {
708 memset(&rrtr_block_, 0, sizeof(rrtr_block_));
709 }
710 ~Rrtr() {}
711
712 void WithNtpSec(uint32_t sec) {
713 rrtr_block_.NTPMostSignificant = sec;
714 }
715 void WithNtpFrac(uint32_t frac) {
716 rrtr_block_.NTPLeastSignificant = frac;
717 }
718
719 private:
720 friend class Xr;
721 RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem rrtr_block_;
722
723 RTC_DISALLOW_COPY_AND_ASSIGN(Rrtr);
724 };
725
726 // DLRR Report Block (RFC 3611). 690 // DLRR Report Block (RFC 3611).
727 // 691 //
728 // 0 1 2 3 692 // 0 1 2 3
729 // 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 693 // 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
730 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 694 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
731 // | BT=5 | reserved | block length | 695 // | BT=5 | reserved | block length |
732 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 696 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
733 // | SSRC_1 (SSRC of first receiver) | sub- 697 // | SSRC_1 (SSRC of first receiver) | sub-
734 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block 698 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block
735 // | last RR (LRR) | 1 699 // | last RR (LRR) | 1
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 813
850 private: 814 private:
851 const size_t buffer_length_; 815 const size_t buffer_length_;
852 size_t length_; 816 size_t length_;
853 rtc::scoped_ptr<uint8_t[]> buffer_; 817 rtc::scoped_ptr<uint8_t[]> buffer_;
854 }; 818 };
855 819
856 } // namespace rtcp 820 } // namespace rtcp
857 } // namespace webrtc 821 } // namespace webrtc
858 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ 822 #endif // WEBRTC_MODULES_RTP_RTCP_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