| 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 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 using webrtc::RTCPUtility::RTCPPacketPSFBSLIItem; | 36 using webrtc::RTCPUtility::RTCPPacketPSFBSLIItem; |
| 37 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; | 37 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; |
| 38 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; | 38 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; |
| 39 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; | 39 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; |
| 40 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN; | 40 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN; |
| 41 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem; | 41 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem; |
| 42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; | 42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; |
| 43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; | 43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; |
| 44 using webrtc::RTCPUtility::RTCPPacketSR; | 44 using webrtc::RTCPUtility::RTCPPacketSR; |
| 45 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; | 45 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; |
| 46 using webrtc::RTCPUtility::RTCPPacketXRReceiverReferenceTimeItem; | |
| 47 using webrtc::RTCPUtility::RTCPPacketXR; | 46 using webrtc::RTCPUtility::RTCPPacketXR; |
| 48 using webrtc::RTCPUtility::RTCPPacketXRVOIPMetricItem; | 47 using webrtc::RTCPUtility::RTCPPacketXRVOIPMetricItem; |
| 49 | 48 |
| 50 namespace webrtc { | 49 namespace webrtc { |
| 51 namespace rtcp { | 50 namespace rtcp { |
| 52 namespace { | 51 namespace { |
| 53 // Unused SSRC of media source, set to 0. | 52 // Unused SSRC of media source, set to 0. |
| 54 const uint32_t kUnusedMediaSourceSsrc0 = 0; | 53 const uint32_t kUnusedMediaSourceSsrc0 = 0; |
| 55 | 54 |
| 56 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) { | 55 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 408 |
| 410 void CreateXrBlockHeader(uint8_t block_type, | 409 void CreateXrBlockHeader(uint8_t block_type, |
| 411 uint16_t block_length, | 410 uint16_t block_length, |
| 412 uint8_t* buffer, | 411 uint8_t* buffer, |
| 413 size_t* pos) { | 412 size_t* pos) { |
| 414 AssignUWord8(buffer, pos, block_type); | 413 AssignUWord8(buffer, pos, block_type); |
| 415 AssignUWord8(buffer, pos, 0); | 414 AssignUWord8(buffer, pos, 0); |
| 416 AssignUWord16(buffer, pos, block_length); | 415 AssignUWord16(buffer, pos, block_length); |
| 417 } | 416 } |
| 418 | 417 |
| 419 // Receiver Reference Time Report Block (RFC 3611). | |
| 420 // | |
| 421 // 0 1 2 3 | |
| 422 // 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 | |
| 423 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 424 // | BT=4 | reserved | block length = 2 | | |
| 425 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 426 // | NTP timestamp, most significant word | | |
| 427 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 428 // | NTP timestamp, least significant word | | |
| 429 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 430 | |
| 431 void CreateRrtr(const std::vector<RTCPPacketXRReceiverReferenceTimeItem>& rrtrs, | |
| 432 uint8_t* buffer, | |
| 433 size_t* pos) { | |
| 434 const uint16_t kBlockLength = 2; | |
| 435 for (std::vector<RTCPPacketXRReceiverReferenceTimeItem>::const_iterator it = | |
| 436 rrtrs.begin(); it != rrtrs.end(); ++it) { | |
| 437 CreateXrBlockHeader(kBtReceiverReferenceTime, kBlockLength, buffer, pos); | |
| 438 AssignUWord32(buffer, pos, (*it).NTPMostSignificant); | |
| 439 AssignUWord32(buffer, pos, (*it).NTPLeastSignificant); | |
| 440 } | |
| 441 } | |
| 442 | |
| 443 // DLRR Report Block (RFC 3611). | 418 // DLRR Report Block (RFC 3611). |
| 444 // | 419 // |
| 445 // 0 1 2 3 | 420 // 0 1 2 3 |
| 446 // 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 | 421 // 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 |
| 447 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 422 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 448 // | BT=5 | reserved | block length | | 423 // | BT=5 | reserved | block length | |
| 449 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 424 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
| 450 // | SSRC_1 (SSRC of first receiver) | sub- | 425 // | SSRC_1 (SSRC of first receiver) | sub- |
| 451 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block | 426 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ block |
| 452 // | last RR (LRR) | 1 | 427 // | last RR (LRR) | 1 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 bool Xr::Create(uint8_t* packet, | 878 bool Xr::Create(uint8_t* packet, |
| 904 size_t* index, | 879 size_t* index, |
| 905 size_t max_length, | 880 size_t max_length, |
| 906 RtcpPacket::PacketReadyCallback* callback) const { | 881 RtcpPacket::PacketReadyCallback* callback) const { |
| 907 while (*index + BlockLength() > max_length) { | 882 while (*index + BlockLength() > max_length) { |
| 908 if (!OnBufferFull(packet, index, callback)) | 883 if (!OnBufferFull(packet, index, callback)) |
| 909 return false; | 884 return false; |
| 910 } | 885 } |
| 911 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); | 886 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); |
| 912 CreateXrHeader(xr_header_, packet, index); | 887 CreateXrHeader(xr_header_, packet, index); |
| 913 CreateRrtr(rrtr_blocks_, packet, index); | 888 for (const Rrtr& block : rrtr_blocks_) { |
| 889 block.Create(packet + *index); |
| 890 *index += Rrtr::kLength; |
| 891 } |
| 914 CreateDlrr(dlrr_blocks_, packet, index); | 892 CreateDlrr(dlrr_blocks_, packet, index); |
| 915 CreateVoipMetric(voip_metric_blocks_, packet, index); | 893 CreateVoipMetric(voip_metric_blocks_, packet, index); |
| 916 return true; | 894 return true; |
| 917 } | 895 } |
| 918 | 896 |
| 919 bool Xr::WithRrtr(Rrtr* rrtr) { | 897 bool Xr::WithRrtr(Rrtr* rrtr) { |
| 920 assert(rrtr); | 898 RTC_DCHECK(rrtr); |
| 921 if (rrtr_blocks_.size() >= kMaxNumberOfRrtrBlocks) { | 899 if (rrtr_blocks_.size() >= kMaxNumberOfRrtrBlocks) { |
| 922 LOG(LS_WARNING) << "Max RRTR blocks reached."; | 900 LOG(LS_WARNING) << "Max RRTR blocks reached."; |
| 923 return false; | 901 return false; |
| 924 } | 902 } |
| 925 rrtr_blocks_.push_back(rrtr->rrtr_block_); | 903 rrtr_blocks_.push_back(*rrtr); |
| 926 return true; | 904 return true; |
| 927 } | 905 } |
| 928 | 906 |
| 929 bool Xr::WithDlrr(Dlrr* dlrr) { | 907 bool Xr::WithDlrr(Dlrr* dlrr) { |
| 930 assert(dlrr); | 908 assert(dlrr); |
| 931 if (dlrr_blocks_.size() >= kMaxNumberOfDlrrBlocks) { | 909 if (dlrr_blocks_.size() >= kMaxNumberOfDlrrBlocks) { |
| 932 LOG(LS_WARNING) << "Max DLRR blocks reached."; | 910 LOG(LS_WARNING) << "Max DLRR blocks reached."; |
| 933 return false; | 911 return false; |
| 934 } | 912 } |
| 935 dlrr_blocks_.push_back(dlrr->dlrr_block_); | 913 dlrr_blocks_.push_back(dlrr->dlrr_block_); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 return length_; | 979 return length_; |
| 1002 } | 980 } |
| 1003 | 981 |
| 1004 void RawPacket::SetLength(size_t length) { | 982 void RawPacket::SetLength(size_t length) { |
| 1005 assert(length <= buffer_length_); | 983 assert(length <= buffer_length_); |
| 1006 length_ = length; | 984 length_ = length; |
| 1007 } | 985 } |
| 1008 | 986 |
| 1009 } // namespace rtcp | 987 } // namespace rtcp |
| 1010 } // namespace webrtc | 988 } // namespace webrtc |
| OLD | NEW |