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