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

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

Issue 1452733002: rtcp::VoipMetric block moved into own file and got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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
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
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; 43 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK;
44 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; 44 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem;
45 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN; 45 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN;
46 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem; 46 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem;
47 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; 47 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR;
48 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; 48 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem;
49 using webrtc::RTCPUtility::RTCPPacketSR; 49 using webrtc::RTCPUtility::RTCPPacketSR;
50 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; 50 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem;
51 using webrtc::RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem; 51 using webrtc::RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem;
52 using webrtc::RTCPUtility::RTCPPacketXR; 52 using webrtc::RTCPUtility::RTCPPacketXR;
53 using webrtc::RTCPUtility::RTCPPacketXRVOIPMetricItem;
54 53
55 namespace webrtc { 54 namespace webrtc {
56 namespace rtcp { 55 namespace rtcp {
57 namespace { 56 namespace {
58 // Unused SSRC of media source, set to 0. 57 // Unused SSRC of media source, set to 0.
59 const uint32_t kUnusedMediaSourceSsrc0 = 0; 58 const uint32_t kUnusedMediaSourceSsrc0 = 0;
60 59
61 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) { 60 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) {
62 buffer[(*offset)++] = value; 61 buffer[(*offset)++] = value;
63 } 62 }
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 uint16_t block_length = 3 * (*it).size(); 561 uint16_t block_length = 3 * (*it).size();
563 CreateXrBlockHeader(kBtDlrr, block_length, buffer, pos); 562 CreateXrBlockHeader(kBtDlrr, block_length, buffer, pos);
564 for (Xr::DlrrBlock::const_iterator it_block = (*it).begin(); 563 for (Xr::DlrrBlock::const_iterator it_block = (*it).begin();
565 it_block != (*it).end(); ++it_block) { 564 it_block != (*it).end(); ++it_block) {
566 AssignUWord32(buffer, pos, (*it_block).SSRC); 565 AssignUWord32(buffer, pos, (*it_block).SSRC);
567 AssignUWord32(buffer, pos, (*it_block).LastRR); 566 AssignUWord32(buffer, pos, (*it_block).LastRR);
568 AssignUWord32(buffer, pos, (*it_block).DelayLastRR); 567 AssignUWord32(buffer, pos, (*it_block).DelayLastRR);
569 } 568 }
570 } 569 }
571 } 570 }
572
573 // VoIP Metrics Report Block (RFC 3611).
574 //
575 // 0 1 2 3
576 // 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
577 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
578 // | BT=7 | reserved | block length = 8 |
579 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
580 // | SSRC of source |
581 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
582 // | loss rate | discard rate | burst density | gap density |
583 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
584 // | burst duration | gap duration |
585 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
586 // | round trip delay | end system delay |
587 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
588 // | signal level | noise level | RERL | Gmin |
589 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
590 // | R factor | ext. R factor | MOS-LQ | MOS-CQ |
591 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
592 // | RX config | reserved | JB nominal |
593 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
594 // | JB maximum | JB abs max |
595 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
596
597 void CreateVoipMetric(const std::vector<RTCPPacketXRVOIPMetricItem>& metrics,
598 uint8_t* buffer,
599 size_t* pos) {
600 const uint16_t kBlockLength = 8;
601 for (std::vector<RTCPPacketXRVOIPMetricItem>::const_iterator it =
602 metrics.begin(); it != metrics.end(); ++it) {
603 CreateXrBlockHeader(kBtVoipMetric, kBlockLength, buffer, pos);
604 AssignUWord32(buffer, pos, (*it).SSRC);
605 AssignUWord8(buffer, pos, (*it).lossRate);
606 AssignUWord8(buffer, pos, (*it).discardRate);
607 AssignUWord8(buffer, pos, (*it).burstDensity);
608 AssignUWord8(buffer, pos, (*it).gapDensity);
609 AssignUWord16(buffer, pos, (*it).burstDuration);
610 AssignUWord16(buffer, pos, (*it).gapDuration);
611 AssignUWord16(buffer, pos, (*it).roundTripDelay);
612 AssignUWord16(buffer, pos, (*it).endSystemDelay);
613 AssignUWord8(buffer, pos, (*it).signalLevel);
614 AssignUWord8(buffer, pos, (*it).noiseLevel);
615 AssignUWord8(buffer, pos, (*it).RERL);
616 AssignUWord8(buffer, pos, (*it).Gmin);
617 AssignUWord8(buffer, pos, (*it).Rfactor);
618 AssignUWord8(buffer, pos, (*it).extRfactor);
619 AssignUWord8(buffer, pos, (*it).MOSLQ);
620 AssignUWord8(buffer, pos, (*it).MOSCQ);
621 AssignUWord8(buffer, pos, (*it).RXconfig);
622 AssignUWord8(buffer, pos, 0);
623 AssignUWord16(buffer, pos, (*it).JBnominal);
624 AssignUWord16(buffer, pos, (*it).JBmax);
625 AssignUWord16(buffer, pos, (*it).JBabsMax);
626 }
627 }
628 } // namespace 571 } // namespace
629 572
630 void RtcpPacket::Append(RtcpPacket* packet) { 573 void RtcpPacket::Append(RtcpPacket* packet) {
631 assert(packet); 574 assert(packet);
632 appended_packets_.push_back(packet); 575 appended_packets_.push_back(packet);
633 } 576 }
634 577
635 rtc::scoped_ptr<RawPacket> RtcpPacket::Build() const { 578 rtc::scoped_ptr<RawPacket> RtcpPacket::Build() const {
636 size_t length = 0; 579 size_t length = 0;
637 rtc::scoped_ptr<RawPacket> packet(new RawPacket(IP_PACKET_SIZE)); 580 rtc::scoped_ptr<RawPacket> packet(new RawPacket(IP_PACKET_SIZE));
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 size_t max_length, 1016 size_t max_length,
1074 RtcpPacket::PacketReadyCallback* callback) const { 1017 RtcpPacket::PacketReadyCallback* callback) const {
1075 while (*index + BlockLength() > max_length) { 1018 while (*index + BlockLength() > max_length) {
1076 if (!OnBufferFull(packet, index, callback)) 1019 if (!OnBufferFull(packet, index, callback))
1077 return false; 1020 return false;
1078 } 1021 }
1079 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); 1022 CreateHeader(0U, PT_XR, HeaderLength(), packet, index);
1080 CreateXrHeader(xr_header_, packet, index); 1023 CreateXrHeader(xr_header_, packet, index);
1081 CreateRrtr(rrtr_blocks_, packet, index); 1024 CreateRrtr(rrtr_blocks_, packet, index);
1082 CreateDlrr(dlrr_blocks_, packet, index); 1025 CreateDlrr(dlrr_blocks_, packet, index);
1083 CreateVoipMetric(voip_metric_blocks_, packet, index); 1026 for (const VoipMetric& block : voip_metric_blocks_) {
1027 block.Create(packet + *index);
1028 *index += VoipMetric::kLength;
1029 }
1084 return true; 1030 return true;
1085 } 1031 }
1086 1032
1087 bool Xr::WithRrtr(Rrtr* rrtr) { 1033 bool Xr::WithRrtr(Rrtr* rrtr) {
1088 assert(rrtr); 1034 assert(rrtr);
1089 if (rrtr_blocks_.size() >= kMaxNumberOfRrtrBlocks) { 1035 if (rrtr_blocks_.size() >= kMaxNumberOfRrtrBlocks) {
1090 LOG(LS_WARNING) << "Max RRTR blocks reached."; 1036 LOG(LS_WARNING) << "Max RRTR blocks reached.";
1091 return false; 1037 return false;
1092 } 1038 }
1093 rrtr_blocks_.push_back(rrtr->rrtr_block_); 1039 rrtr_blocks_.push_back(rrtr->rrtr_block_);
1094 return true; 1040 return true;
1095 } 1041 }
1096 1042
1097 bool Xr::WithDlrr(Dlrr* dlrr) { 1043 bool Xr::WithDlrr(Dlrr* dlrr) {
1098 assert(dlrr); 1044 assert(dlrr);
1099 if (dlrr_blocks_.size() >= kMaxNumberOfDlrrBlocks) { 1045 if (dlrr_blocks_.size() >= kMaxNumberOfDlrrBlocks) {
1100 LOG(LS_WARNING) << "Max DLRR blocks reached."; 1046 LOG(LS_WARNING) << "Max DLRR blocks reached.";
1101 return false; 1047 return false;
1102 } 1048 }
1103 dlrr_blocks_.push_back(dlrr->dlrr_block_); 1049 dlrr_blocks_.push_back(dlrr->dlrr_block_);
1104 return true; 1050 return true;
1105 } 1051 }
1106 1052
1107 bool Xr::WithVoipMetric(VoipMetric* voip_metric) { 1053 bool Xr::WithVoipMetric(VoipMetric* voip_metric) {
1108 assert(voip_metric); 1054 assert(voip_metric);
1109 if (voip_metric_blocks_.size() >= kMaxNumberOfVoipMetricBlocks) { 1055 if (voip_metric_blocks_.size() >= kMaxNumberOfVoipMetricBlocks) {
1110 LOG(LS_WARNING) << "Max Voip Metric blocks reached."; 1056 LOG(LS_WARNING) << "Max Voip Metric blocks reached.";
1111 return false; 1057 return false;
1112 } 1058 }
1113 voip_metric_blocks_.push_back(voip_metric->metric_); 1059 voip_metric_blocks_.push_back(*voip_metric);
1114 return true; 1060 return true;
1115 } 1061 }
1116 1062
1117 size_t Xr::DlrrLength() const { 1063 size_t Xr::DlrrLength() const {
1118 const size_t kBlockHeaderLen = 4; 1064 const size_t kBlockHeaderLen = 4;
1119 const size_t kSubBlockLen = 12; 1065 const size_t kSubBlockLen = 12;
1120 size_t length = 0; 1066 size_t length = 0;
1121 for (std::vector<DlrrBlock>::const_iterator it = dlrr_blocks_.begin(); 1067 for (std::vector<DlrrBlock>::const_iterator it = dlrr_blocks_.begin();
1122 it != dlrr_blocks_.end(); ++it) { 1068 it != dlrr_blocks_.end(); ++it) {
1123 if (!(*it).empty()) { 1069 if (!(*it).empty()) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 return length_; 1115 return length_;
1170 } 1116 }
1171 1117
1172 void RawPacket::SetLength(size_t length) { 1118 void RawPacket::SetLength(size_t length) {
1173 assert(length <= buffer_length_); 1119 assert(length <= buffer_length_);
1174 length_ = length; 1120 length_ = length;
1175 } 1121 }
1176 1122
1177 } // namespace rtcp 1123 } // namespace rtcp
1178 } // namespace webrtc 1124 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698