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

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

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: 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 27 matching lines...) Expand all
38 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; 38 using webrtc::RTCPUtility::RTCPPacketReportBlockItem;
39 using webrtc::RTCPUtility::RTCPPacketRR; 39 using webrtc::RTCPUtility::RTCPPacketRR;
40 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; 40 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK;
41 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; 41 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem;
42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN; 42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN;
43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem; 43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem;
44 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; 44 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR;
45 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; 45 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem;
46 using webrtc::RTCPUtility::RTCPPacketSR; 46 using webrtc::RTCPUtility::RTCPPacketSR;
47 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; 47 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem;
48 using webrtc::RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem;
49 using webrtc::RTCPUtility::RTCPPacketXR; 48 using webrtc::RTCPUtility::RTCPPacketXR;
50 using webrtc::RTCPUtility::RTCPPacketXRVOIPMetricItem; 49 using webrtc::RTCPUtility::RTCPPacketXRVOIPMetricItem;
51 50
52 namespace webrtc { 51 namespace webrtc {
53 namespace rtcp { 52 namespace rtcp {
54 namespace { 53 namespace {
55 // Unused SSRC of media source, set to 0. 54 // Unused SSRC of media source, set to 0.
56 const uint32_t kUnusedMediaSourceSsrc0 = 0; 55 const uint32_t kUnusedMediaSourceSsrc0 = 0;
57 56
58 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) { 57 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 425
427 void CreateXrBlockHeader(uint8_t block_type, 426 void CreateXrBlockHeader(uint8_t block_type,
428 uint16_t block_length, 427 uint16_t block_length,
429 uint8_t* buffer, 428 uint8_t* buffer,
430 size_t* pos) { 429 size_t* pos) {
431 AssignUWord8(buffer, pos, block_type); 430 AssignUWord8(buffer, pos, block_type);
432 AssignUWord8(buffer, pos, 0); 431 AssignUWord8(buffer, pos, 0);
433 AssignUWord16(buffer, pos, block_length); 432 AssignUWord16(buffer, pos, block_length);
434 } 433 }
435 434
436 // Receiver Reference Time Report Block (RFC 3611).
437 //
438 // 0 1 2 3
439 // 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
440 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
441 // | BT=4 | reserved | block length = 2 |
442 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
443 // | NTP timestamp, most significant word |
444 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
445 // | NTP timestamp, least significant word |
446 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
447
448 void CreateRrtr(const std::vector<RTCPPacketXRReceiverReferenceTimeItem>& rrtrs,
449 uint8_t* buffer,
450 size_t* pos) {
451 const uint16_t kBlockLength = 2;
452 for (std::vector<RTCPPacketXRReceiverReferenceTimeItem>::const_iterator it =
453 rrtrs.begin(); it != rrtrs.end(); ++it) {
454 CreateXrBlockHeader(kBtReceiverReferenceTime, kBlockLength, buffer, pos);
455 AssignUWord32(buffer, pos, (*it).NTPMostSignificant);
456 AssignUWord32(buffer, pos, (*it).NTPLeastSignificant);
457 }
458 }
459
460 // DLRR Report Block (RFC 3611). 435 // DLRR Report Block (RFC 3611).
461 // 436 //
462 // 0 1 2 3 437 // 0 1 2 3
463 // 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 438 // 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
464 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 439 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
465 // | BT=5 | reserved | block length | 440 // | BT=5 | reserved | block length |
466 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 441 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
467 // | SSRC_1 (SSRC of first receiver) | sub- 442 // | SSRC_1 (SSRC of first receiver) | sub-
468 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block 443 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block
469 // | last RR (LRR) | 1 444 // | last RR (LRR) | 1
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 bool Xr::Create(uint8_t* packet, 919 bool Xr::Create(uint8_t* packet,
945 size_t* index, 920 size_t* index,
946 size_t max_length, 921 size_t max_length,
947 RtcpPacket::PacketReadyCallback* callback) const { 922 RtcpPacket::PacketReadyCallback* callback) const {
948 while (*index + BlockLength() > max_length) { 923 while (*index + BlockLength() > max_length) {
949 if (!OnBufferFull(packet, index, callback)) 924 if (!OnBufferFull(packet, index, callback))
950 return false; 925 return false;
951 } 926 }
952 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); 927 CreateHeader(0U, PT_XR, HeaderLength(), packet, index);
953 CreateXrHeader(xr_header_, packet, index); 928 CreateXrHeader(xr_header_, packet, index);
954 CreateRrtr(rrtr_blocks_, packet, index); 929 for (const Rrtr& block : rrtr_blocks_) {
930 block.Create(packet + *index);
931 *index += Rrtr::kLength;
932 }
955 CreateDlrr(dlrr_blocks_, packet, index); 933 CreateDlrr(dlrr_blocks_, packet, index);
956 CreateVoipMetric(voip_metric_blocks_, packet, index); 934 CreateVoipMetric(voip_metric_blocks_, packet, index);
957 return true; 935 return true;
958 } 936 }
959 937
960 bool Xr::WithRrtr(Rrtr* rrtr) { 938 bool Xr::WithRrtr(Rrtr* rrtr) {
961 assert(rrtr); 939 RTC_DCHECK(rrtr);
962 if (rrtr_blocks_.size() >= kMaxNumberOfRrtrBlocks) { 940 if (rrtr_blocks_.size() >= kMaxNumberOfRrtrBlocks) {
963 LOG(LS_WARNING) << "Max RRTR blocks reached."; 941 LOG(LS_WARNING) << "Max RRTR blocks reached.";
964 return false; 942 return false;
965 } 943 }
966 rrtr_blocks_.push_back(rrtr->rrtr_block_); 944 rrtr_blocks_.push_back(*rrtr);
967 return true; 945 return true;
968 } 946 }
969 947
970 bool Xr::WithDlrr(Dlrr* dlrr) { 948 bool Xr::WithDlrr(Dlrr* dlrr) {
971 assert(dlrr); 949 assert(dlrr);
972 if (dlrr_blocks_.size() >= kMaxNumberOfDlrrBlocks) { 950 if (dlrr_blocks_.size() >= kMaxNumberOfDlrrBlocks) {
973 LOG(LS_WARNING) << "Max DLRR blocks reached."; 951 LOG(LS_WARNING) << "Max DLRR blocks reached.";
974 return false; 952 return false;
975 } 953 }
976 dlrr_blocks_.push_back(dlrr->dlrr_block_); 954 dlrr_blocks_.push_back(dlrr->dlrr_block_);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 return length_; 1020 return length_;
1043 } 1021 }
1044 1022
1045 void RawPacket::SetLength(size_t length) { 1023 void RawPacket::SetLength(size_t length) {
1046 assert(length <= buffer_length_); 1024 assert(length <= buffer_length_);
1047 length_ = length; 1025 length_ = length;
1048 } 1026 }
1049 1027
1050 } // namespace rtcp 1028 } // namespace rtcp
1051 } // namespace webrtc 1029 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698