| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 int extension_block_pos = | 1449 int extension_block_pos = |
| 1450 rtp_header_extension_map_.GetLengthUntilBlockStartInBytes(type); | 1450 rtp_header_extension_map_.GetLengthUntilBlockStartInBytes(type); |
| 1451 if (extension_block_pos < 0) { | 1451 if (extension_block_pos < 0) { |
| 1452 LOG(LS_WARNING) << "Failed to find extension position for " << type | 1452 LOG(LS_WARNING) << "Failed to find extension position for " << type |
| 1453 << " as it is not registered."; | 1453 << " as it is not registered."; |
| 1454 return false; | 1454 return false; |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 HeaderExtension header_extension(type); | 1457 HeaderExtension header_extension(type); |
| 1458 | 1458 |
| 1459 size_t block_pos = | 1459 size_t extension_pos = |
| 1460 kRtpHeaderLength + rtp_header.numCSRCs + extension_block_pos; | 1460 kRtpHeaderLength + rtp_header.numCSRCs * sizeof(uint32_t); |
| 1461 size_t block_pos = extension_pos + extension_block_pos; |
| 1461 if (rtp_packet_length < block_pos + header_extension.length || | 1462 if (rtp_packet_length < block_pos + header_extension.length || |
| 1462 rtp_header.headerLength < block_pos + header_extension.length) { | 1463 rtp_header.headerLength < block_pos + header_extension.length) { |
| 1463 LOG(LS_WARNING) << "Failed to find extension position for " << type | 1464 LOG(LS_WARNING) << "Failed to find extension position for " << type |
| 1464 << " as the length is invalid."; | 1465 << " as the length is invalid."; |
| 1465 return false; | 1466 return false; |
| 1466 } | 1467 } |
| 1467 | 1468 |
| 1468 // Verify that header contains extension. | 1469 // Verify that header contains extension. |
| 1469 if (!((rtp_packet[kRtpHeaderLength + rtp_header.numCSRCs] == 0xBE) && | 1470 if (!(rtp_packet[extension_pos] == 0xBE && |
| 1470 (rtp_packet[kRtpHeaderLength + rtp_header.numCSRCs + 1] == 0xDE))) { | 1471 rtp_packet[extension_pos + 1] == 0xDE)) { |
| 1471 LOG(LS_WARNING) << "Failed to find extension position for " << type | 1472 LOG(LS_WARNING) << "Failed to find extension position for " << type |
| 1472 << "as hdr extension not found."; | 1473 << "as hdr extension not found."; |
| 1473 return false; | 1474 return false; |
| 1474 } | 1475 } |
| 1475 | 1476 |
| 1476 *position = block_pos; | 1477 *position = block_pos; |
| 1477 return true; | 1478 return true; |
| 1478 } | 1479 } |
| 1479 | 1480 |
| 1480 RTPSender::ExtensionStatus RTPSender::VerifyExtension( | 1481 RTPSender::ExtensionStatus RTPSender::VerifyExtension( |
| 1481 RTPExtensionType extension_type, | 1482 RTPExtensionType extension_type, |
| 1482 uint8_t* rtp_packet, | 1483 uint8_t* rtp_packet, |
| 1483 size_t rtp_packet_length, | 1484 size_t rtp_packet_length, |
| 1484 const RTPHeader& rtp_header, | 1485 const RTPHeader& rtp_header, |
| 1485 size_t extension_length_bytes, | 1486 size_t extension_length_bytes, |
| 1486 size_t* extension_offset) const { | 1487 size_t* extension_offset) const { |
| 1487 // Get id. | 1488 // Get id. |
| 1488 uint8_t id = 0; | 1489 uint8_t id = 0; |
| 1489 if (rtp_header_extension_map_.GetId(extension_type, &id) != 0) | 1490 if (rtp_header_extension_map_.GetId(extension_type, &id) != 0) |
| 1490 return ExtensionStatus::kNotRegistered; | 1491 return ExtensionStatus::kNotRegistered; |
| 1491 | 1492 |
| 1492 size_t block_pos = 0; | 1493 size_t block_pos = 0; |
| 1493 if (!FindHeaderExtensionPosition(extension_type, rtp_packet, | 1494 if (!FindHeaderExtensionPosition(extension_type, rtp_packet, |
| 1494 rtp_packet_length, rtp_header, &block_pos)) | 1495 rtp_packet_length, rtp_header, &block_pos)) |
| 1495 return ExtensionStatus::kError; | 1496 return ExtensionStatus::kError; |
| 1496 | 1497 |
| 1497 // Verify that header contains extension. | |
| 1498 if (!((rtp_packet[kRtpHeaderLength + rtp_header.numCSRCs] == 0xBE) && | |
| 1499 (rtp_packet[kRtpHeaderLength + rtp_header.numCSRCs + 1] == 0xDE))) { | |
| 1500 LOG(LS_WARNING) | |
| 1501 << "Failed to update absolute send time, hdr extension not found."; | |
| 1502 return ExtensionStatus::kError; | |
| 1503 } | |
| 1504 | |
| 1505 // Verify first byte in block. | 1498 // Verify first byte in block. |
| 1506 const uint8_t first_block_byte = (id << 4) + (extension_length_bytes - 2); | 1499 const uint8_t first_block_byte = (id << 4) + (extension_length_bytes - 2); |
| 1507 if (rtp_packet[block_pos] != first_block_byte) | 1500 if (rtp_packet[block_pos] != first_block_byte) |
| 1508 return ExtensionStatus::kError; | 1501 return ExtensionStatus::kError; |
| 1509 | 1502 |
| 1510 *extension_offset = block_pos; | 1503 *extension_offset = block_pos; |
| 1511 return ExtensionStatus::kOk; | 1504 return ExtensionStatus::kOk; |
| 1512 } | 1505 } |
| 1513 | 1506 |
| 1514 void RTPSender::UpdateTransmissionTimeOffset(uint8_t* rtp_packet, | 1507 void RTPSender::UpdateTransmissionTimeOffset(uint8_t* rtp_packet, |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 CriticalSectionScoped lock(send_critsect_.get()); | 1899 CriticalSectionScoped lock(send_critsect_.get()); |
| 1907 | 1900 |
| 1908 RtpState state; | 1901 RtpState state; |
| 1909 state.sequence_number = sequence_number_rtx_; | 1902 state.sequence_number = sequence_number_rtx_; |
| 1910 state.start_timestamp = start_timestamp_; | 1903 state.start_timestamp = start_timestamp_; |
| 1911 | 1904 |
| 1912 return state; | 1905 return state; |
| 1913 } | 1906 } |
| 1914 | 1907 |
| 1915 } // namespace webrtc | 1908 } // namespace webrtc |
| OLD | NEW |