OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 RTC_DCHECK(ok); | 647 RTC_DCHECK(ok); |
648 } | 648 } |
649 } | 649 } |
650 | 650 |
651 return return_value; | 651 return return_value; |
652 } | 652 } |
653 | 653 |
654 void VideoSendStream::ConfigureProtection() { | 654 void VideoSendStream::ConfigureProtection() { |
655 // Enable NACK, FEC or both. | 655 // Enable NACK, FEC or both. |
656 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; | 656 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; |
657 bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; | 657 bool enable_protection_fec = config_.rtp.fec.ulpfec_payload_type != -1; |
658 // Payload types without picture ID cannot determine that a stream is complete | 658 // Payload types without picture ID cannot determine that a stream is complete |
659 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is | 659 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is |
660 // a waste of bandwidth since FEC packets still have to be transmitted. Note | 660 // a waste of bandwidth since FEC packets still have to be transmitted. Note |
661 // that this is not the case with FLEXFEC. | 661 // that this is not the case with FLEXFEC. |
662 if (enable_protection_nack && | 662 if (enable_protection_nack && |
663 !PayloadTypeSupportsSkippingFecPackets( | 663 !PayloadTypeSupportsSkippingFecPackets( |
664 config_.encoder_settings.payload_name)) { | 664 config_.encoder_settings.payload_name)) { |
665 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" | 665 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" |
666 "NACK+FEC is a waste of bandwidth since FEC packets " | 666 "NACK+FEC is a waste of bandwidth since FEC packets " |
667 "also have to be retransmitted. Disabling FEC."; | 667 "also have to be retransmitted. Disabling FEC."; |
668 enable_protection_fec = false; | 668 enable_protection_fec = false; |
669 } | 669 } |
670 | 670 |
671 // Set to valid uint8_ts to be castable later without signed overflows. | 671 // Set to valid uint8_ts to be castable later without signed overflows. |
672 uint8_t payload_type_red = 0; | 672 uint8_t payload_type_red = 0; |
673 uint8_t payload_type_fec = 0; | 673 uint8_t payload_type_fec = 0; |
| 674 |
674 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. | 675 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. |
675 // Validate payload types. If either RED or FEC payload types are set then | 676 // Validate payload types. If either RED or FEC payload types are set then |
676 // both should be. If FEC is enabled then they both have to be set. | 677 // both should be. If FEC is enabled then they both have to be set. |
677 if (enable_protection_fec || config_.rtp.fec.red_payload_type != -1 || | 678 if (config_.rtp.fec.red_payload_type != -1) { |
678 config_.rtp.fec.ulpfec_payload_type != -1) { | |
679 RTC_DCHECK_GE(config_.rtp.fec.red_payload_type, 0); | 679 RTC_DCHECK_GE(config_.rtp.fec.red_payload_type, 0); |
| 680 RTC_DCHECK_LE(config_.rtp.fec.red_payload_type, 127); |
| 681 // TODO(holmer): We should only enable red if ulpfec is also enabled, but |
| 682 // but due to an incompatibility issue with previous versions the receiver |
| 683 // assumes rtx packets are containing red if it has been configured to |
| 684 // receive red. Remove this in a few versions once the incompatibility |
| 685 // issue is resolved (M53 timeframe). |
| 686 payload_type_red = static_cast<uint8_t>(config_.rtp.fec.red_payload_type); |
| 687 } |
| 688 if (config_.rtp.fec.ulpfec_payload_type != -1) { |
680 RTC_DCHECK_GE(config_.rtp.fec.ulpfec_payload_type, 0); | 689 RTC_DCHECK_GE(config_.rtp.fec.ulpfec_payload_type, 0); |
681 RTC_DCHECK_LE(config_.rtp.fec.red_payload_type, 127); | |
682 RTC_DCHECK_LE(config_.rtp.fec.ulpfec_payload_type, 127); | 690 RTC_DCHECK_LE(config_.rtp.fec.ulpfec_payload_type, 127); |
683 payload_type_red = static_cast<uint8_t>(config_.rtp.fec.red_payload_type); | |
684 payload_type_fec = | 691 payload_type_fec = |
685 static_cast<uint8_t>(config_.rtp.fec.ulpfec_payload_type); | 692 static_cast<uint8_t>(config_.rtp.fec.ulpfec_payload_type); |
686 } else { | |
687 // Payload types unset. | |
688 RTC_DCHECK_EQ(config_.rtp.fec.red_payload_type, -1); | |
689 RTC_DCHECK_EQ(config_.rtp.fec.ulpfec_payload_type, -1); | |
690 } | 693 } |
691 | 694 |
692 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 695 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
693 // Set NACK. | 696 // Set NACK. |
694 rtp_rtcp->SetStorePacketsStatus( | 697 rtp_rtcp->SetStorePacketsStatus( |
695 enable_protection_nack || congestion_controller_->pacer(), | 698 enable_protection_nack || congestion_controller_->pacer(), |
696 kMinSendSidePacketHistorySize); | 699 kMinSendSidePacketHistorySize); |
697 // Set FEC. | 700 // Set FEC. |
698 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 701 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
699 rtp_rtcp->SetGenericFECStatus(enable_protection_fec, payload_type_red, | 702 rtp_rtcp->SetGenericFECStatus(enable_protection_fec, payload_type_red, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 &module_nack_rate); | 804 &module_nack_rate); |
802 *sent_video_rate_bps += module_video_rate; | 805 *sent_video_rate_bps += module_video_rate; |
803 *sent_nack_rate_bps += module_nack_rate; | 806 *sent_nack_rate_bps += module_nack_rate; |
804 *sent_fec_rate_bps += module_fec_rate; | 807 *sent_fec_rate_bps += module_fec_rate; |
805 } | 808 } |
806 return 0; | 809 return 0; |
807 } | 810 } |
808 | 811 |
809 } // namespace internal | 812 } // namespace internal |
810 } // namespace webrtc | 813 } // namespace webrtc |
OLD | NEW |