| 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_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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 private: | 710 private: |
| 711 static const int kMaxNumberOfRrtrBlocks = 50; | 711 static const int kMaxNumberOfRrtrBlocks = 50; |
| 712 static const int kMaxNumberOfDlrrBlocks = 50; | 712 static const int kMaxNumberOfDlrrBlocks = 50; |
| 713 static const int kMaxNumberOfVoipMetricBlocks = 50; | 713 static const int kMaxNumberOfVoipMetricBlocks = 50; |
| 714 | 714 |
| 715 size_t BlockLength() const { | 715 size_t BlockLength() const { |
| 716 const size_t kXrHeaderLength = 8; | 716 const size_t kXrHeaderLength = 8; |
| 717 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength(); | 717 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength(); |
| 718 } | 718 } |
| 719 | 719 |
| 720 size_t RrtrLength() const { | 720 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); } |
| 721 const size_t kRrtrBlockLength = 12; | |
| 722 return kRrtrBlockLength * rrtr_blocks_.size(); | |
| 723 } | |
| 724 | 721 |
| 725 size_t DlrrLength() const; | 722 size_t DlrrLength() const; |
| 726 | 723 |
| 727 size_t VoipMetricLength() const { | 724 size_t VoipMetricLength() const { |
| 728 const size_t kVoipMetricBlockLength = 36; | 725 const size_t kVoipMetricBlockLength = 36; |
| 729 return kVoipMetricBlockLength * voip_metric_blocks_.size(); | 726 return kVoipMetricBlockLength * voip_metric_blocks_.size(); |
| 730 } | 727 } |
| 731 | 728 |
| 732 RTCPUtility::RTCPPacketXR xr_header_; | 729 RTCPUtility::RTCPPacketXR xr_header_; |
| 733 std::vector<RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem> rrtr_blocks_; | 730 std::vector<Rrtr> rrtr_blocks_; |
| 734 std::vector<DlrrBlock> dlrr_blocks_; | 731 std::vector<DlrrBlock> dlrr_blocks_; |
| 735 std::vector<RTCPUtility::RTCPPacketXRVOIPMetricItem> voip_metric_blocks_; | 732 std::vector<RTCPUtility::RTCPPacketXRVOIPMetricItem> voip_metric_blocks_; |
| 736 | 733 |
| 737 RTC_DISALLOW_COPY_AND_ASSIGN(Xr); | 734 RTC_DISALLOW_COPY_AND_ASSIGN(Xr); |
| 738 }; | 735 }; |
| 739 | 736 |
| 740 // Receiver Reference Time Report Block (RFC 3611). | |
| 741 // | |
| 742 // 0 1 2 3 | |
| 743 // 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 | |
| 744 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 745 // | BT=4 | reserved | block length = 2 | | |
| 746 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 747 // | NTP timestamp, most significant word | | |
| 748 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 749 // | NTP timestamp, least significant word | | |
| 750 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 751 | |
| 752 class Rrtr { | |
| 753 public: | |
| 754 Rrtr() { | |
| 755 memset(&rrtr_block_, 0, sizeof(rrtr_block_)); | |
| 756 } | |
| 757 ~Rrtr() {} | |
| 758 | |
| 759 void WithNtpSec(uint32_t sec) { | |
| 760 rrtr_block_.NTPMostSignificant = sec; | |
| 761 } | |
| 762 void WithNtpFrac(uint32_t frac) { | |
| 763 rrtr_block_.NTPLeastSignificant = frac; | |
| 764 } | |
| 765 | |
| 766 private: | |
| 767 friend class Xr; | |
| 768 RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem rrtr_block_; | |
| 769 | |
| 770 RTC_DISALLOW_COPY_AND_ASSIGN(Rrtr); | |
| 771 }; | |
| 772 | |
| 773 // DLRR Report Block (RFC 3611). | 737 // DLRR Report Block (RFC 3611). |
| 774 // | 738 // |
| 775 // 0 1 2 3 | 739 // 0 1 2 3 |
| 776 // 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 | 740 // 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 |
| 777 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 741 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 778 // | BT=5 | reserved | block length | | 742 // | BT=5 | reserved | block length | |
| 779 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 743 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
| 780 // | SSRC_1 (SSRC of first receiver) | sub- | 744 // | SSRC_1 (SSRC of first receiver) | sub- |
| 781 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block | 745 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block |
| 782 // | last RR (LRR) | 1 | 746 // | last RR (LRR) | 1 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 860 |
| 897 private: | 861 private: |
| 898 const size_t buffer_length_; | 862 const size_t buffer_length_; |
| 899 size_t length_; | 863 size_t length_; |
| 900 rtc::scoped_ptr<uint8_t[]> buffer_; | 864 rtc::scoped_ptr<uint8_t[]> buffer_; |
| 901 }; | 865 }; |
| 902 | 866 |
| 903 } // namespace rtcp | 867 } // namespace rtcp |
| 904 } // namespace webrtc | 868 } // namespace webrtc |
| 905 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ | 869 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ |
| OLD | NEW |