| 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 |
| 11 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" | 11 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" |
| 12 | 12 |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 | 14 |
| 15 #include <memory> | 15 #include <memory> |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" |
| 17 #include "webrtc/modules/include/module_common_types.h" | 18 #include "webrtc/modules/include/module_common_types.h" |
| 18 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 19 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 namespace test { | 22 namespace test { |
| 22 | 23 |
| 23 Packet::Packet(uint8_t* packet_memory, | 24 Packet::Packet(uint8_t* packet_memory, |
| 24 size_t allocated_bytes, | 25 size_t allocated_bytes, |
| 25 double time_ms, | 26 double time_ms, |
| 26 const RtpHeaderParser& parser) | 27 const RtpHeaderParser& parser) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 bool valid_header = parser.Parse( | 136 bool valid_header = parser.Parse( |
| 136 payload_memory_.get(), static_cast<int>(packet_length_bytes_), &header_); | 137 payload_memory_.get(), static_cast<int>(packet_length_bytes_), &header_); |
| 137 assert(valid_header); | 138 assert(valid_header); |
| 138 if (!valid_header) { | 139 if (!valid_header) { |
| 139 return false; | 140 return false; |
| 140 } | 141 } |
| 141 assert(header_.headerLength <= packet_length_bytes_); | 142 assert(header_.headerLength <= packet_length_bytes_); |
| 142 payload_ = &payload_memory_[header_.headerLength]; | 143 payload_ = &payload_memory_[header_.headerLength]; |
| 143 assert(packet_length_bytes_ >= header_.headerLength); | 144 assert(packet_length_bytes_ >= header_.headerLength); |
| 144 payload_length_bytes_ = packet_length_bytes_ - header_.headerLength; | 145 payload_length_bytes_ = packet_length_bytes_ - header_.headerLength; |
| 146 RTC_CHECK_GE(virtual_packet_length_bytes_, packet_length_bytes_); |
| 145 assert(virtual_packet_length_bytes_ >= header_.headerLength); | 147 assert(virtual_packet_length_bytes_ >= header_.headerLength); |
| 146 virtual_payload_length_bytes_ = | 148 virtual_payload_length_bytes_ = |
| 147 virtual_packet_length_bytes_ - header_.headerLength; | 149 virtual_packet_length_bytes_ - header_.headerLength; |
| 148 return true; | 150 return true; |
| 149 } | 151 } |
| 150 | 152 |
| 151 void Packet::CopyToHeader(RTPHeader* destination) const { | 153 void Packet::CopyToHeader(RTPHeader* destination) const { |
| 152 destination->markerBit = header_.markerBit; | 154 destination->markerBit = header_.markerBit; |
| 153 destination->payloadType = header_.payloadType; | 155 destination->payloadType = header_.payloadType; |
| 154 destination->sequenceNumber = header_.sequenceNumber; | 156 destination->sequenceNumber = header_.sequenceNumber; |
| 155 destination->timestamp = header_.timestamp; | 157 destination->timestamp = header_.timestamp; |
| 156 destination->ssrc = header_.ssrc; | 158 destination->ssrc = header_.ssrc; |
| 157 destination->numCSRCs = header_.numCSRCs; | 159 destination->numCSRCs = header_.numCSRCs; |
| 158 destination->paddingLength = header_.paddingLength; | 160 destination->paddingLength = header_.paddingLength; |
| 159 destination->headerLength = header_.headerLength; | 161 destination->headerLength = header_.headerLength; |
| 160 destination->payload_type_frequency = header_.payload_type_frequency; | 162 destination->payload_type_frequency = header_.payload_type_frequency; |
| 161 memcpy(&destination->arrOfCSRCs, | 163 memcpy(&destination->arrOfCSRCs, |
| 162 &header_.arrOfCSRCs, | 164 &header_.arrOfCSRCs, |
| 163 sizeof(header_.arrOfCSRCs)); | 165 sizeof(header_.arrOfCSRCs)); |
| 164 memcpy( | 166 memcpy( |
| 165 &destination->extension, &header_.extension, sizeof(header_.extension)); | 167 &destination->extension, &header_.extension, sizeof(header_.extension)); |
| 166 } | 168 } |
| 167 | 169 |
| 168 } // namespace test | 170 } // namespace test |
| 169 } // namespace webrtc | 171 } // namespace webrtc |
| OLD | NEW |