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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 return false; | 297 return false; |
298 | 298 |
299 // Create header that will be reused in all packets. | 299 // Create header that will be reused in all packets. |
300 std::unique_ptr<RtpPacketToSend> rtp_header = rtp_sender_->AllocatePacket(); | 300 std::unique_ptr<RtpPacketToSend> rtp_header = rtp_sender_->AllocatePacket(); |
301 rtp_header->SetPayloadType(payload_type); | 301 rtp_header->SetPayloadType(payload_type); |
302 rtp_header->SetTimestamp(rtp_timestamp); | 302 rtp_header->SetTimestamp(rtp_timestamp); |
303 rtp_header->set_capture_time_ms(capture_time_ms); | 303 rtp_header->set_capture_time_ms(capture_time_ms); |
304 auto last_packet = rtc::MakeUnique<RtpPacketToSend>(*rtp_header); | 304 auto last_packet = rtc::MakeUnique<RtpPacketToSend>(*rtp_header); |
305 | 305 |
306 size_t fec_packet_overhead; | 306 size_t fec_packet_overhead; |
307 bool is_timing_frame = false; | |
307 bool red_enabled; | 308 bool red_enabled; |
308 int32_t retransmission_settings; | 309 int32_t retransmission_settings; |
309 { | 310 { |
310 rtc::CritScope cs(&crit_); | 311 rtc::CritScope cs(&crit_); |
311 // According to | 312 // According to |
312 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 313 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
313 // ts_126114v120700p.pdf Section 7.4.5: | 314 // ts_126114v120700p.pdf Section 7.4.5: |
314 // The MTSI client shall add the payload bytes as defined in this clause | 315 // The MTSI client shall add the payload bytes as defined in this clause |
315 // onto the last RTP packet in each group of packets which make up a key | 316 // onto the last RTP packet in each group of packets which make up a key |
316 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 | 317 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
317 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP | 318 // (HEVC)). The MTSI client may also add the payload bytes onto the last RTP |
318 // packet in each group of packets which make up another type of frame | 319 // packet in each group of packets which make up another type of frame |
319 // (e.g. a P-Frame) only if the current value is different from the previous | 320 // (e.g. a P-Frame) only if the current value is different from the previous |
320 // value sent. | 321 // value sent. |
321 if (video_header) { | 322 if (video_header) { |
322 // Set rotation when key frame or when changed (to follow standard). | 323 // Set rotation when key frame or when changed (to follow standard). |
323 // Or when different from 0 (to follow current receiver implementation). | 324 // Or when different from 0 (to follow current receiver implementation). |
324 VideoRotation current_rotation = video_header->rotation; | 325 VideoRotation current_rotation = video_header->rotation; |
325 if (frame_type == kVideoFrameKey || current_rotation != last_rotation_ || | 326 if (frame_type == kVideoFrameKey || current_rotation != last_rotation_ || |
326 current_rotation != kVideoRotation_0) | 327 current_rotation != kVideoRotation_0) |
327 last_packet->SetExtension<VideoOrientation>(current_rotation); | 328 last_packet->SetExtension<VideoOrientation>(current_rotation); |
328 last_rotation_ = current_rotation; | 329 last_rotation_ = current_rotation; |
329 // Report content type only for key frames. | 330 // Report content type only for key frames. |
330 if (frame_type == kVideoFrameKey && | 331 if (frame_type == kVideoFrameKey && |
331 video_header->content_type != VideoContentType::UNSPECIFIED) { | 332 video_header->content_type != VideoContentType::UNSPECIFIED) { |
332 last_packet->SetExtension<VideoContentTypeExtension>( | 333 last_packet->SetExtension<VideoContentTypeExtension>( |
333 video_header->content_type); | 334 video_header->content_type); |
334 } | 335 } |
336 if (video_header->video_timing.is_timing_frame) { | |
337 last_packet->SetExtension<VideoTimingExtension>( | |
338 video_header->video_timing); | |
339 is_timing_frame = true; | |
340 } | |
335 } | 341 } |
336 | 342 |
337 // FEC settings. | 343 // FEC settings. |
338 const FecProtectionParams& fec_params = | 344 const FecProtectionParams& fec_params = |
339 frame_type == kVideoFrameKey ? key_fec_params_ : delta_fec_params_; | 345 frame_type == kVideoFrameKey ? key_fec_params_ : delta_fec_params_; |
340 if (flexfec_enabled()) | 346 if (flexfec_enabled()) |
341 flexfec_sender_->SetFecParameters(fec_params); | 347 flexfec_sender_->SetFecParameters(fec_params); |
342 if (ulpfec_enabled()) | 348 if (ulpfec_enabled()) |
343 ulpfec_generator_.SetFecParameters(fec_params); | 349 ulpfec_generator_.SetFecParameters(fec_params); |
344 | 350 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 auto packet = last ? std::move(last_packet) | 387 auto packet = last ? std::move(last_packet) |
382 : rtc::MakeUnique<RtpPacketToSend>(*rtp_header); | 388 : rtc::MakeUnique<RtpPacketToSend>(*rtp_header); |
383 if (!packetizer->NextPacket(packet.get())) | 389 if (!packetizer->NextPacket(packet.get())) |
384 return false; | 390 return false; |
385 RTC_DCHECK_LE(packet->payload_size(), | 391 RTC_DCHECK_LE(packet->payload_size(), |
386 last ? max_data_payload_length - last_packet_reduction_len | 392 last ? max_data_payload_length - last_packet_reduction_len |
387 : max_data_payload_length); | 393 : max_data_payload_length); |
388 if (!rtp_sender_->AssignSequenceNumber(packet.get())) | 394 if (!rtp_sender_->AssignSequenceNumber(packet.get())) |
389 return false; | 395 return false; |
390 | 396 |
397 // Put packetization finish timestamp into extension; | |
åsapersson
2017/06/12 14:33:42
nit end with.
ilnik
2017/06/13 08:43:13
Done.
| |
398 if (last && is_timing_frame) { | |
åsapersson
2017/06/12 14:33:42
Can HasExtension be used instead of is_timing_fram
ilnik
2017/06/13 08:43:13
Yes, but they are set together at lines 337-339 ex
| |
399 packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds()); | |
400 } | |
401 | |
391 const bool protect_packet = | 402 const bool protect_packet = |
392 (packetizer->GetProtectionType() == kProtectedPacket); | 403 (packetizer->GetProtectionType() == kProtectedPacket); |
393 if (flexfec_enabled()) { | 404 if (flexfec_enabled()) { |
394 // TODO(brandtr): Remove the FlexFEC code path when FlexfecSender | 405 // TODO(brandtr): Remove the FlexFEC code path when FlexfecSender |
395 // is wired up to PacedSender instead. | 406 // is wired up to PacedSender instead. |
396 SendVideoPacketWithFlexfec(std::move(packet), storage, protect_packet); | 407 SendVideoPacketWithFlexfec(std::move(packet), storage, protect_packet); |
397 } else if (red_enabled) { | 408 } else if (red_enabled) { |
398 SendVideoPacketAsRedMaybeWithUlpfec(std::move(packet), storage, | 409 SendVideoPacketAsRedMaybeWithUlpfec(std::move(packet), storage, |
399 protect_packet); | 410 protect_packet); |
400 } else { | 411 } else { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 rtc::CritScope cs(&crit_); | 443 rtc::CritScope cs(&crit_); |
433 return retransmission_settings_; | 444 return retransmission_settings_; |
434 } | 445 } |
435 | 446 |
436 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { | 447 void RTPSenderVideo::SetSelectiveRetransmissions(uint8_t settings) { |
437 rtc::CritScope cs(&crit_); | 448 rtc::CritScope cs(&crit_); |
438 retransmission_settings_ = settings; | 449 retransmission_settings_ = settings; |
439 } | 450 } |
440 | 451 |
441 } // namespace webrtc | 452 } // namespace webrtc |
OLD | NEW |