| 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 #include "webrtc/video/video_send_stream.h" | 10 #include "webrtc/video/video_send_stream.h" |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 // that this is not the case with FLEXFEC. | 929 // that this is not the case with FLEXFEC. |
| 930 if (enable_protection_nack && | 930 if (enable_protection_nack && |
| 931 !PayloadTypeSupportsSkippingFecPackets( | 931 !PayloadTypeSupportsSkippingFecPackets( |
| 932 config_->encoder_settings.payload_name)) { | 932 config_->encoder_settings.payload_name)) { |
| 933 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" | 933 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" |
| 934 "NACK+FEC is a waste of bandwidth since FEC packets " | 934 "NACK+FEC is a waste of bandwidth since FEC packets " |
| 935 "also have to be retransmitted. Disabling FEC."; | 935 "also have to be retransmitted. Disabling FEC."; |
| 936 enable_protection_fec = false; | 936 enable_protection_fec = false; |
| 937 } | 937 } |
| 938 | 938 |
| 939 // Set to valid uint8_ts to be castable later without signed overflows. | 939 // TODO(brandtr): Remove the workaround described below. |
| 940 uint8_t payload_type_red = 0; | 940 // |
| 941 uint8_t payload_type_fec = 0; | 941 // In theory, we should enable RED if and only if ULPFEC is also enabled, |
| 942 // and vice versa. (We only support ULPFEC over RED, not multiplexed in any |
| 943 // other way.) However, due to the RED/RTX workaround introduced here: |
| 944 // https://codereview.webrtc.org/1649493004, we need to send media over RED |
| 945 // (even if ULPFEC is disabled), whenever RED has been negotiated in the SDP. |
| 946 // This is due to the associated payload type is hardcoded to be RED in the |
| 947 // receiver, whenever RED appears in the SDP. If we would not send media over |
| 948 // RED in this case, the RTX receiver would recover retransmitted packets |
| 949 // using the wrong payload type. |
| 942 | 950 |
| 943 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. | 951 // Verify validity of provided payload types. |
| 944 // Validate payload types. If either RED or FEC payload types are set then | |
| 945 // both should be. If FEC is enabled then they both have to be set. | |
| 946 if (config_->rtp.ulpfec.red_payload_type != -1) { | 952 if (config_->rtp.ulpfec.red_payload_type != -1) { |
| 947 RTC_DCHECK_GE(config_->rtp.ulpfec.red_payload_type, 0); | 953 RTC_DCHECK_GE(config_->rtp.ulpfec.red_payload_type, 0); |
| 948 RTC_DCHECK_LE(config_->rtp.ulpfec.red_payload_type, 127); | 954 RTC_DCHECK_LE(config_->rtp.ulpfec.red_payload_type, 127); |
| 949 // TODO(holmer): We should only enable red if ulpfec is also enabled, but | |
| 950 // but due to an incompatibility issue with previous versions the receiver | |
| 951 // assumes rtx packets are containing red if it has been configured to | |
| 952 // receive red. Remove this in a few versions once the incompatibility | |
| 953 // issue is resolved (M53 timeframe). | |
| 954 payload_type_red = | |
| 955 static_cast<uint8_t>(config_->rtp.ulpfec.red_payload_type); | |
| 956 } | 955 } |
| 957 if (config_->rtp.ulpfec.ulpfec_payload_type != -1) { | 956 if (config_->rtp.ulpfec.ulpfec_payload_type != -1) { |
| 958 RTC_DCHECK_GE(config_->rtp.ulpfec.ulpfec_payload_type, 0); | 957 RTC_DCHECK_GE(config_->rtp.ulpfec.ulpfec_payload_type, 0); |
| 959 RTC_DCHECK_LE(config_->rtp.ulpfec.ulpfec_payload_type, 127); | 958 RTC_DCHECK_LE(config_->rtp.ulpfec.ulpfec_payload_type, 127); |
| 960 payload_type_fec = | |
| 961 static_cast<uint8_t>(config_->rtp.ulpfec.ulpfec_payload_type); | |
| 962 } | 959 } |
| 963 | 960 |
| 964 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 961 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 965 // Set NACK. | 962 // Set NACK. |
| 966 rtp_rtcp->SetStorePacketsStatus( | 963 rtp_rtcp->SetStorePacketsStatus( |
| 967 enable_protection_nack || congestion_controller_->pacer(), | 964 enable_protection_nack || congestion_controller_->pacer(), |
| 968 kMinSendSidePacketHistorySize); | 965 kMinSendSidePacketHistorySize); |
| 969 // Set FEC. | 966 // Set FEC. |
| 970 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 967 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 971 rtp_rtcp->SetGenericFECStatus(enable_protection_fec, payload_type_red, | 968 rtp_rtcp->SetUlpfecConfig(enable_protection_fec, |
| 972 payload_type_fec); | 969 config_->rtp.ulpfec.red_payload_type, |
| 970 config_->rtp.ulpfec.ulpfec_payload_type); |
| 973 } | 971 } |
| 974 } | 972 } |
| 975 | 973 |
| 976 protection_bitrate_calculator_.SetProtectionMethod(enable_protection_fec, | 974 protection_bitrate_calculator_.SetProtectionMethod(enable_protection_fec, |
| 977 enable_protection_nack); | 975 enable_protection_nack); |
| 978 } | 976 } |
| 979 | 977 |
| 980 void VideoSendStreamImpl::ConfigureSsrcs() { | 978 void VideoSendStreamImpl::ConfigureSsrcs() { |
| 981 RTC_DCHECK_RUN_ON(worker_queue_); | 979 RTC_DCHECK_RUN_ON(worker_queue_); |
| 982 // Configure regular SSRCs. | 980 // Configure regular SSRCs. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 &module_nack_rate); | 1105 &module_nack_rate); |
| 1108 *sent_video_rate_bps += module_video_rate; | 1106 *sent_video_rate_bps += module_video_rate; |
| 1109 *sent_nack_rate_bps += module_nack_rate; | 1107 *sent_nack_rate_bps += module_nack_rate; |
| 1110 *sent_fec_rate_bps += module_fec_rate; | 1108 *sent_fec_rate_bps += module_fec_rate; |
| 1111 } | 1109 } |
| 1112 return 0; | 1110 return 0; |
| 1113 } | 1111 } |
| 1114 | 1112 |
| 1115 } // namespace internal | 1113 } // namespace internal |
| 1116 } // namespace webrtc | 1114 } // namespace webrtc |
| OLD | NEW |