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