| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 using webrtc::RTCPUtility::PT_APP; | 23 using webrtc::RTCPUtility::PT_APP; |
| 24 using webrtc::RTCPUtility::PT_IJ; | 24 using webrtc::RTCPUtility::PT_IJ; |
| 25 using webrtc::RTCPUtility::PT_PSFB; | 25 using webrtc::RTCPUtility::PT_PSFB; |
| 26 using webrtc::RTCPUtility::PT_RTPFB; | 26 using webrtc::RTCPUtility::PT_RTPFB; |
| 27 using webrtc::RTCPUtility::PT_SDES; | 27 using webrtc::RTCPUtility::PT_SDES; |
| 28 using webrtc::RTCPUtility::PT_SR; | 28 using webrtc::RTCPUtility::PT_SR; |
| 29 using webrtc::RTCPUtility::PT_XR; | 29 using webrtc::RTCPUtility::PT_XR; |
| 30 | 30 |
| 31 using webrtc::RTCPUtility::RTCPPacketAPP; | 31 using webrtc::RTCPUtility::RTCPPacketAPP; |
| 32 using webrtc::RTCPUtility::RTCPPacketPSFBFIR; | |
| 33 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem; | |
| 34 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI; | 32 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI; |
| 35 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; | 33 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; |
| 36 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; | 34 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; |
| 37 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; | 35 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; |
| 38 using webrtc::RTCPUtility::RTCPPacketSR; | 36 using webrtc::RTCPUtility::RTCPPacketSR; |
| 39 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; | 37 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; |
| 40 using webrtc::RTCPUtility::RTCPPacketXR; | 38 using webrtc::RTCPUtility::RTCPPacketXR; |
| 41 | 39 |
| 42 namespace webrtc { | 40 namespace webrtc { |
| 43 namespace rtcp { | 41 namespace rtcp { |
| 44 namespace { | 42 namespace { |
| 45 // Unused SSRC of media source, set to 0. | |
| 46 const uint32_t kUnusedMediaSourceSsrc0 = 0; | |
| 47 | |
| 48 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) { | 43 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) { |
| 49 buffer[(*offset)++] = value; | 44 buffer[(*offset)++] = value; |
| 50 } | 45 } |
| 51 void AssignUWord16(uint8_t* buffer, size_t* offset, uint16_t value) { | 46 void AssignUWord16(uint8_t* buffer, size_t* offset, uint16_t value) { |
| 52 ByteWriter<uint16_t>::WriteBigEndian(buffer + *offset, value); | 47 ByteWriter<uint16_t>::WriteBigEndian(buffer + *offset, value); |
| 53 *offset += 2; | 48 *offset += 2; |
| 54 } | 49 } |
| 55 void AssignUWord24(uint8_t* buffer, size_t* offset, uint32_t value) { | |
| 56 ByteWriter<uint32_t, 3>::WriteBigEndian(buffer + *offset, value); | |
| 57 *offset += 3; | |
| 58 } | |
| 59 void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) { | 50 void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) { |
| 60 ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value); | 51 ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value); |
| 61 *offset += 4; | 52 *offset += 4; |
| 62 } | 53 } |
| 63 | 54 |
| 64 // Sender report (SR) (RFC 3550). | 55 // Sender report (SR) (RFC 3550). |
| 65 // 0 1 2 3 | 56 // 0 1 2 3 |
| 66 // 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 | 57 // 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 |
| 67 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 58 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 68 // |V=2|P| RC | PT=SR=200 | length | | 59 // |V=2|P| RC | PT=SR=200 | length | |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 AssignUWord32(buffer, pos, rpsi.SenderSSRC); | 171 AssignUWord32(buffer, pos, rpsi.SenderSSRC); |
| 181 AssignUWord32(buffer, pos, rpsi.MediaSSRC); | 172 AssignUWord32(buffer, pos, rpsi.MediaSSRC); |
| 182 AssignUWord8(buffer, pos, padding_bytes * 8); | 173 AssignUWord8(buffer, pos, padding_bytes * 8); |
| 183 AssignUWord8(buffer, pos, rpsi.PayloadType); | 174 AssignUWord8(buffer, pos, rpsi.PayloadType); |
| 184 memcpy(buffer + *pos, rpsi.NativeBitString, rpsi.NumberOfValidBits / 8); | 175 memcpy(buffer + *pos, rpsi.NativeBitString, rpsi.NumberOfValidBits / 8); |
| 185 *pos += rpsi.NumberOfValidBits / 8; | 176 *pos += rpsi.NumberOfValidBits / 8; |
| 186 memset(buffer + *pos, 0, padding_bytes); | 177 memset(buffer + *pos, 0, padding_bytes); |
| 187 *pos += padding_bytes; | 178 *pos += padding_bytes; |
| 188 } | 179 } |
| 189 | 180 |
| 190 // Full intra request (FIR) (RFC 5104). | |
| 191 // | |
| 192 // FCI: | |
| 193 // | |
| 194 // 0 1 2 3 | |
| 195 // 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 | |
| 196 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 197 // | SSRC | | |
| 198 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 199 // | Seq nr. | Reserved | | |
| 200 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |
| 201 | |
| 202 void CreateFir(const RTCPPacketPSFBFIR& fir, | |
| 203 const RTCPPacketPSFBFIRItem& fir_item, | |
| 204 uint8_t* buffer, | |
| 205 size_t* pos) { | |
| 206 AssignUWord32(buffer, pos, fir.SenderSSRC); | |
| 207 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0); | |
| 208 AssignUWord32(buffer, pos, fir_item.SSRC); | |
| 209 AssignUWord8(buffer, pos, fir_item.CommandSequenceNumber); | |
| 210 AssignUWord24(buffer, pos, 0); | |
| 211 } | |
| 212 | |
| 213 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR). | 181 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR). |
| 214 // | 182 // |
| 215 // Format for XR packets: | 183 // Format for XR packets: |
| 216 // | 184 // |
| 217 // 0 1 2 3 | 185 // 0 1 2 3 |
| 218 // 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 | 186 // 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 |
| 219 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 187 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 220 // |V=2|P|reserved | PT=XR=207 | length | | 188 // |V=2|P|reserved | PT=XR=207 | length | |
| 221 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 189 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 222 // | SSRC | | 190 // | SSRC | |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 rpsi_.NativeBitString[pos++] = static_cast<uint8_t>(picture_id & 0x7f); | 398 rpsi_.NativeBitString[pos++] = static_cast<uint8_t>(picture_id & 0x7f); |
| 431 rpsi_.NumberOfValidBits = pos * 8; | 399 rpsi_.NumberOfValidBits = pos * 8; |
| 432 | 400 |
| 433 // Calculate padding bytes (to reach next 32-bit boundary, 1, 2 or 3 bytes). | 401 // Calculate padding bytes (to reach next 32-bit boundary, 1, 2 or 3 bytes). |
| 434 padding_bytes_ = 4 - ((2 + required_bytes) % 4); | 402 padding_bytes_ = 4 - ((2 + required_bytes) % 4); |
| 435 if (padding_bytes_ == 4) { | 403 if (padding_bytes_ == 4) { |
| 436 padding_bytes_ = 0; | 404 padding_bytes_ = 0; |
| 437 } | 405 } |
| 438 } | 406 } |
| 439 | 407 |
| 440 bool Fir::Create(uint8_t* packet, | |
| 441 size_t* index, | |
| 442 size_t max_length, | |
| 443 RtcpPacket::PacketReadyCallback* callback) const { | |
| 444 while (*index + BlockLength() > max_length) { | |
| 445 if (!OnBufferFull(packet, index, callback)) | |
| 446 return false; | |
| 447 } | |
| 448 const uint8_t kFmt = 4; | |
| 449 CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index); | |
| 450 CreateFir(fir_, fir_item_, packet, index); | |
| 451 return true; | |
| 452 } | |
| 453 | |
| 454 bool Xr::Create(uint8_t* packet, | 408 bool Xr::Create(uint8_t* packet, |
| 455 size_t* index, | 409 size_t* index, |
| 456 size_t max_length, | 410 size_t max_length, |
| 457 RtcpPacket::PacketReadyCallback* callback) const { | 411 RtcpPacket::PacketReadyCallback* callback) const { |
| 458 while (*index + BlockLength() > max_length) { | 412 while (*index + BlockLength() > max_length) { |
| 459 if (!OnBufferFull(packet, index, callback)) | 413 if (!OnBufferFull(packet, index, callback)) |
| 460 return false; | 414 return false; |
| 461 } | 415 } |
| 462 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); | 416 CreateHeader(0U, PT_XR, HeaderLength(), packet, index); |
| 463 CreateXrHeader(xr_header_, packet, index); | 417 CreateXrHeader(xr_header_, packet, index); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 return length_; | 495 return length_; |
| 542 } | 496 } |
| 543 | 497 |
| 544 void RawPacket::SetLength(size_t length) { | 498 void RawPacket::SetLength(size_t length) { |
| 545 assert(length <= buffer_length_); | 499 assert(length <= buffer_length_); |
| 546 length_ = length; | 500 length_ = length; |
| 547 } | 501 } |
| 548 | 502 |
| 549 } // namespace rtcp | 503 } // namespace rtcp |
| 550 } // namespace webrtc | 504 } // namespace webrtc |
| OLD | NEW |