| 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/voip_metric.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 Rrtr; |
| 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; |
| 44 // rr.From(123); | 44 // rr.From(123); |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 } | 878 } |
| 879 | 879 |
| 880 size_t RrtrLength() const { | 880 size_t RrtrLength() const { |
| 881 const size_t kRrtrBlockLength = 12; | 881 const size_t kRrtrBlockLength = 12; |
| 882 return kRrtrBlockLength * rrtr_blocks_.size(); | 882 return kRrtrBlockLength * rrtr_blocks_.size(); |
| 883 } | 883 } |
| 884 | 884 |
| 885 size_t DlrrLength() const; | 885 size_t DlrrLength() const; |
| 886 | 886 |
| 887 size_t VoipMetricLength() const { | 887 size_t VoipMetricLength() const { |
| 888 const size_t kVoipMetricBlockLength = 36; | 888 return VoipMetric::kLength * voip_metric_blocks_.size(); |
| 889 return kVoipMetricBlockLength * voip_metric_blocks_.size(); | |
| 890 } | 889 } |
| 891 | 890 |
| 892 RTCPUtility::RTCPPacketXR xr_header_; | 891 RTCPUtility::RTCPPacketXR xr_header_; |
| 893 std::vector<RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem> rrtr_blocks_; | 892 std::vector<RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem> rrtr_blocks_; |
| 894 std::vector<DlrrBlock> dlrr_blocks_; | 893 std::vector<DlrrBlock> dlrr_blocks_; |
| 895 std::vector<RTCPUtility::RTCPPacketXRVOIPMetricItem> voip_metric_blocks_; | 894 std::vector<VoipMetric> voip_metric_blocks_; |
| 896 | 895 |
| 897 RTC_DISALLOW_COPY_AND_ASSIGN(Xr); | 896 RTC_DISALLOW_COPY_AND_ASSIGN(Xr); |
| 898 }; | 897 }; |
| 899 | 898 |
| 900 // Receiver Reference Time Report Block (RFC 3611). | 899 // Receiver Reference Time Report Block (RFC 3611). |
| 901 // | 900 // |
| 902 // 0 1 2 3 | 901 // 0 1 2 3 |
| 903 // 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 | 902 // 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 |
| 904 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 903 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 905 // | BT=4 | reserved | block length = 2 | | 904 // | BT=4 | reserved | block length = 2 | |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 | 956 |
| 958 private: | 957 private: |
| 959 friend class Xr; | 958 friend class Xr; |
| 960 static const int kMaxNumberOfDlrrItems = 100; | 959 static const int kMaxNumberOfDlrrItems = 100; |
| 961 | 960 |
| 962 std::vector<RTCPUtility::RTCPPacketXRDLRRReportBlockItem> dlrr_block_; | 961 std::vector<RTCPUtility::RTCPPacketXRDLRRReportBlockItem> dlrr_block_; |
| 963 | 962 |
| 964 RTC_DISALLOW_COPY_AND_ASSIGN(Dlrr); | 963 RTC_DISALLOW_COPY_AND_ASSIGN(Dlrr); |
| 965 }; | 964 }; |
| 966 | 965 |
| 967 // VoIP Metrics Report Block (RFC 3611). | |
| 968 // | |
| 969 // 0 1 2 3 | |
| 970 // 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 | |
| 971 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 972 // | BT=7 | reserved | block length = 8 | | |
| 973 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 974 // | SSRC of source | | |
| 975 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 976 // | loss rate | discard rate | burst density | gap density | | |
| 977 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 978 // | burst duration | gap duration | | |
| 979 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 980 // | round trip delay | end system delay | | |
| 981 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 982 // | signal level | noise level | RERL | Gmin | | |
| 983 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 984 // | R factor | ext. R factor | MOS-LQ | MOS-CQ | | |
| 985 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 986 // | RX config | reserved | JB nominal | | |
| 987 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 988 // | JB maximum | JB abs max | | |
| 989 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 990 | |
| 991 class VoipMetric { | |
| 992 public: | |
| 993 VoipMetric() { | |
| 994 memset(&metric_, 0, sizeof(metric_)); | |
| 995 } | |
| 996 ~VoipMetric() {} | |
| 997 | |
| 998 void To(uint32_t ssrc) { metric_.SSRC = ssrc; } | |
| 999 void LossRate(uint8_t loss_rate) { metric_.lossRate = loss_rate; } | |
| 1000 void DiscardRate(uint8_t discard_rate) { metric_.discardRate = discard_rate; } | |
| 1001 void BurstDensity(uint8_t burst_density) { | |
| 1002 metric_.burstDensity = burst_density; | |
| 1003 } | |
| 1004 void GapDensity(uint8_t gap_density) { metric_.gapDensity = gap_density; } | |
| 1005 void BurstDuration(uint16_t burst_duration) { | |
| 1006 metric_.burstDuration = burst_duration; | |
| 1007 } | |
| 1008 void GapDuration(uint16_t gap_duration) { | |
| 1009 metric_.gapDuration = gap_duration; | |
| 1010 } | |
| 1011 void RoundTripDelay(uint16_t round_trip_delay) { | |
| 1012 metric_.roundTripDelay = round_trip_delay; | |
| 1013 } | |
| 1014 void EndSystemDelay(uint16_t end_system_delay) { | |
| 1015 metric_.endSystemDelay = end_system_delay; | |
| 1016 } | |
| 1017 void SignalLevel(uint8_t signal_level) { metric_.signalLevel = signal_level; } | |
| 1018 void NoiseLevel(uint8_t noise_level) { metric_.noiseLevel = noise_level; } | |
| 1019 void Rerl(uint8_t rerl) { metric_.RERL = rerl; } | |
| 1020 void Gmin(uint8_t gmin) { metric_.Gmin = gmin; } | |
| 1021 void Rfactor(uint8_t rfactor) { metric_.Rfactor = rfactor; } | |
| 1022 void ExtRfactor(uint8_t extrfactor) { metric_.extRfactor = extrfactor; } | |
| 1023 void MosLq(uint8_t moslq) { metric_.MOSLQ = moslq; } | |
| 1024 void MosCq(uint8_t moscq) { metric_.MOSCQ = moscq; } | |
| 1025 void RxConfig(uint8_t rxconfig) { metric_.RXconfig = rxconfig; } | |
| 1026 void JbNominal(uint16_t jbnominal) { metric_.JBnominal = jbnominal; } | |
| 1027 void JbMax(uint16_t jbmax) { metric_.JBmax = jbmax; } | |
| 1028 void JbAbsMax(uint16_t jbabsmax) { metric_.JBabsMax = jbabsmax; } | |
| 1029 | |
| 1030 private: | |
| 1031 friend class Xr; | |
| 1032 RTCPUtility::RTCPPacketXRVOIPMetricItem metric_; | |
| 1033 | |
| 1034 RTC_DISALLOW_COPY_AND_ASSIGN(VoipMetric); | |
| 1035 }; | |
| 1036 | |
| 1037 // Class holding a RTCP packet. | 966 // Class holding a RTCP packet. |
| 1038 // | 967 // |
| 1039 // Takes a built rtcp packet. | 968 // Takes a built rtcp packet. |
| 1040 // RawPacket raw_packet(buffer, length); | 969 // RawPacket raw_packet(buffer, length); |
| 1041 // | 970 // |
| 1042 // To access the raw packet: | 971 // To access the raw packet: |
| 1043 // raw_packet.Buffer(); - pointer to the raw packet | 972 // raw_packet.Buffer(); - pointer to the raw packet |
| 1044 // raw_packet.BufferLength(); - the length of the raw packet | 973 // raw_packet.BufferLength(); - the length of the raw packet |
| 1045 | 974 |
| 1046 class RawPacket { | 975 class RawPacket { |
| 1047 public: | 976 public: |
| 1048 explicit RawPacket(size_t buffer_length); | 977 explicit RawPacket(size_t buffer_length); |
| 1049 RawPacket(const uint8_t* packet, size_t packet_length); | 978 RawPacket(const uint8_t* packet, size_t packet_length); |
| 1050 | 979 |
| 1051 const uint8_t* Buffer() const; | 980 const uint8_t* Buffer() const; |
| 1052 uint8_t* MutableBuffer(); | 981 uint8_t* MutableBuffer(); |
| 1053 size_t BufferLength() const; | 982 size_t BufferLength() const; |
| 1054 size_t Length() const; | 983 size_t Length() const; |
| 1055 void SetLength(size_t length); | 984 void SetLength(size_t length); |
| 1056 | 985 |
| 1057 private: | 986 private: |
| 1058 const size_t buffer_length_; | 987 const size_t buffer_length_; |
| 1059 size_t length_; | 988 size_t length_; |
| 1060 rtc::scoped_ptr<uint8_t[]> buffer_; | 989 rtc::scoped_ptr<uint8_t[]> buffer_; |
| 1061 }; | 990 }; |
| 1062 | 991 |
| 1063 } // namespace rtcp | 992 } // namespace rtcp |
| 1064 } // namespace webrtc | 993 } // namespace webrtc |
| 1065 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ | 994 #endif // WEBRTC_MODULES_RTP_RTCP_RTCP_PACKET_H_ |
| OLD | NEW |