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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 packets_.back().last_fragment = true; | 238 packets_.back().last_fragment = true; |
239 return fragment_index; | 239 return fragment_index; |
240 } | 240 } |
241 | 241 |
242 void RtpPacketizerH264::PacketizeSingleNalu(size_t fragment_index) { | 242 void RtpPacketizerH264::PacketizeSingleNalu(size_t fragment_index) { |
243 // Add a single NALU to the queue, no aggregation. | 243 // Add a single NALU to the queue, no aggregation. |
244 size_t payload_size_left = max_payload_len_; | 244 size_t payload_size_left = max_payload_len_; |
245 const Fragment* fragment = &input_fragments_[fragment_index]; | 245 const Fragment* fragment = &input_fragments_[fragment_index]; |
246 RTC_CHECK_GE(payload_size_left, fragment->length) | 246 RTC_CHECK_GE(payload_size_left, fragment->length) |
247 << "Payload size left " << payload_size_left << ", fragment length " | 247 << "Payload size left " << payload_size_left << ", fragment length " |
248 << fragment->length << ", packetization mode " | 248 << fragment->length << ", packetization mode " << packetization_mode_; |
249 << (packetization_mode_ == H264PacketizationMode::SingleNalUnit | |
250 ? "SingleNalUnit" | |
251 : "NonInterleaved"); | |
252 RTC_CHECK_GT(fragment->length, 0u); | 249 RTC_CHECK_GT(fragment->length, 0u); |
253 packets_.push(PacketUnit(*fragment, true /* first */, true /* last */, | 250 packets_.push(PacketUnit(*fragment, true /* first */, true /* last */, |
254 false /* aggregated */, fragment->buffer[0])); | 251 false /* aggregated */, fragment->buffer[0])); |
255 } | 252 } |
256 | 253 |
257 bool RtpPacketizerH264::NextPacket(RtpPacketToSend* rtp_packet, | 254 bool RtpPacketizerH264::NextPacket(RtpPacketToSend* rtp_packet, |
258 bool* last_packet) { | 255 bool* last_packet) { |
259 RTC_DCHECK(rtp_packet); | 256 RTC_DCHECK(rtp_packet); |
260 RTC_DCHECK(last_packet); | 257 RTC_DCHECK(last_packet); |
261 if (packets_.empty()) { | 258 if (packets_.empty()) { |
262 *last_packet = true; | 259 *last_packet = true; |
263 return false; | 260 return false; |
264 } | 261 } |
265 | 262 |
266 PacketUnit packet = packets_.front(); | 263 PacketUnit packet = packets_.front(); |
267 if (packet.first_fragment && packet.last_fragment) { | 264 if (packet.first_fragment && packet.last_fragment) { |
268 // Single NAL unit packet. | 265 // Single NAL unit packet. |
269 size_t bytes_to_send = packet.source_fragment.length; | 266 size_t bytes_to_send = packet.source_fragment.length; |
270 uint8_t* buffer = rtp_packet->AllocatePayload(bytes_to_send); | 267 uint8_t* buffer = rtp_packet->AllocatePayload(bytes_to_send); |
271 memcpy(buffer, packet.source_fragment.buffer, bytes_to_send); | 268 memcpy(buffer, packet.source_fragment.buffer, bytes_to_send); |
272 packets_.pop(); | 269 packets_.pop(); |
273 input_fragments_.pop_front(); | 270 input_fragments_.pop_front(); |
274 } else if (packet.aggregated) { | 271 } else if (packet.aggregated) { |
275 RTC_CHECK(packetization_mode_ == H264PacketizationMode::NonInterleaved); | 272 RTC_CHECK_EQ(H264PacketizationMode::NonInterleaved, packetization_mode_); |
276 NextAggregatePacket(rtp_packet); | 273 NextAggregatePacket(rtp_packet); |
277 } else { | 274 } else { |
278 RTC_CHECK(packetization_mode_ == H264PacketizationMode::NonInterleaved); | 275 RTC_CHECK_EQ(H264PacketizationMode::NonInterleaved, packetization_mode_); |
279 NextFragmentPacket(rtp_packet); | 276 NextFragmentPacket(rtp_packet); |
280 } | 277 } |
281 RTC_DCHECK_LE(rtp_packet->payload_size(), max_payload_len_); | 278 RTC_DCHECK_LE(rtp_packet->payload_size(), max_payload_len_); |
282 *last_packet = packets_.empty(); | 279 *last_packet = packets_.empty(); |
283 rtp_packet->SetMarker(*last_packet); | 280 rtp_packet->SetMarker(*last_packet); |
284 return true; | 281 return true; |
285 } | 282 } |
286 | 283 |
287 void RtpPacketizerH264::NextAggregatePacket(RtpPacketToSend* rtp_packet) { | 284 void RtpPacketizerH264::NextAggregatePacket(RtpPacketToSend* rtp_packet) { |
288 uint8_t* buffer = rtp_packet->AllocatePayload(max_payload_len_); | 285 uint8_t* buffer = rtp_packet->AllocatePayload(max_payload_len_); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 h264->packetization_type = kH264FuA; | 615 h264->packetization_type = kH264FuA; |
619 h264->nalu_type = original_nal_type; | 616 h264->nalu_type = original_nal_type; |
620 if (first_fragment) { | 617 if (first_fragment) { |
621 h264->nalus[h264->nalus_length] = nalu; | 618 h264->nalus[h264->nalus_length] = nalu; |
622 h264->nalus_length = 1; | 619 h264->nalus_length = 1; |
623 } | 620 } |
624 return true; | 621 return true; |
625 } | 622 } |
626 | 623 |
627 } // namespace webrtc | 624 } // namespace webrtc |
OLD | NEW |