Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: webrtc/video/video_send_stream.cc

Issue 2460533002: Simplify {,Set}UlpfecConfig interface. (Closed)
Patch Set: git cl format. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/rtp_stream_receiver.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 927 }
928 } 928 }
929 929
930 return result; 930 return result;
931 } 931 }
932 932
933 void VideoSendStreamImpl::ConfigureProtection() { 933 void VideoSendStreamImpl::ConfigureProtection() {
934 RTC_DCHECK_RUN_ON(worker_queue_); 934 RTC_DCHECK_RUN_ON(worker_queue_);
935 // Enable NACK, FEC or both. 935 // Enable NACK, FEC or both.
936 const bool enable_protection_nack = config_->rtp.nack.rtp_history_ms > 0; 936 const bool enable_protection_nack = config_->rtp.nack.rtp_history_ms > 0;
937 bool enable_protection_fec = config_->rtp.ulpfec.ulpfec_payload_type != -1; 937 const int red_payload_type = config_->rtp.ulpfec.red_payload_type;
938 int ulpfec_payload_type = config_->rtp.ulpfec.ulpfec_payload_type;
938 // Payload types without picture ID cannot determine that a stream is complete 939 // Payload types without picture ID cannot determine that a stream is complete
939 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is 940 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is
940 // a waste of bandwidth since FEC packets still have to be transmitted. Note 941 // a waste of bandwidth since FEC packets still have to be transmitted. Note
941 // that this is not the case with FLEXFEC. 942 // that this is not the case with FLEXFEC.
942 if (enable_protection_nack && 943 if (enable_protection_nack &&
943 !PayloadTypeSupportsSkippingFecPackets( 944 !PayloadTypeSupportsSkippingFecPackets(
944 config_->encoder_settings.payload_name)) { 945 config_->encoder_settings.payload_name)) {
945 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" 946 LOG(LS_WARNING) << "Transmitting payload type without picture ID using"
946 "NACK+FEC is a waste of bandwidth since FEC packets " 947 "NACK+FEC is a waste of bandwidth since FEC packets "
947 "also have to be retransmitted. Disabling FEC."; 948 "also have to be retransmitted. Disabling FEC.";
948 enable_protection_fec = false; 949 ulpfec_payload_type = -1;
949 } 950 }
950 951
951 // TODO(brandtr): Remove the workaround described below. 952 // TODO(brandtr): Remove the workaround described below.
952 // 953 //
953 // In theory, we should enable RED if and only if ULPFEC is also enabled, 954 // 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 // 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 // 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 // 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 // (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 // 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 // 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 // RED in this case, the RTX receiver would recover retransmitted packets
961 // using the wrong payload type. 962 // using the wrong payload type.
962 963
963 // Verify validity of provided payload types. 964 // Verify validity of provided payload types.
964 if (config_->rtp.ulpfec.red_payload_type != -1) { 965 if (red_payload_type != -1) {
965 RTC_DCHECK_GE(config_->rtp.ulpfec.red_payload_type, 0); 966 RTC_DCHECK_GE(red_payload_type, 0);
966 RTC_DCHECK_LE(config_->rtp.ulpfec.red_payload_type, 127); 967 RTC_DCHECK_LE(red_payload_type, 127);
967 } 968 }
968 if (config_->rtp.ulpfec.ulpfec_payload_type != -1) { 969 if (ulpfec_payload_type != -1) {
969 RTC_DCHECK_GE(config_->rtp.ulpfec.ulpfec_payload_type, 0); 970 RTC_DCHECK_GE(ulpfec_payload_type, 0);
970 RTC_DCHECK_LE(config_->rtp.ulpfec.ulpfec_payload_type, 127); 971 RTC_DCHECK_LE(ulpfec_payload_type, 127);
971 } 972 }
972 973
973 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 974 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
974 // Set NACK. 975 // Set NACK.
975 rtp_rtcp->SetStorePacketsStatus( 976 rtp_rtcp->SetStorePacketsStatus(
976 enable_protection_nack || congestion_controller_->pacer(), 977 enable_protection_nack || congestion_controller_->pacer(),
977 kMinSendSidePacketHistorySize); 978 kMinSendSidePacketHistorySize);
978 // Set FEC. 979 // Set FEC.
979 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 980 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
980 rtp_rtcp->SetUlpfecConfig(enable_protection_fec, 981 rtp_rtcp->SetUlpfecConfig(red_payload_type, ulpfec_payload_type);
981 config_->rtp.ulpfec.red_payload_type,
982 config_->rtp.ulpfec.ulpfec_payload_type);
983 } 982 }
984 } 983 }
985 984
985 const bool enable_protection_fec = (ulpfec_payload_type != -1);
986 protection_bitrate_calculator_.SetProtectionMethod(enable_protection_fec, 986 protection_bitrate_calculator_.SetProtectionMethod(enable_protection_fec,
987 enable_protection_nack); 987 enable_protection_nack);
988 } 988 }
989 989
990 void VideoSendStreamImpl::ConfigureSsrcs() { 990 void VideoSendStreamImpl::ConfigureSsrcs() {
991 RTC_DCHECK_RUN_ON(worker_queue_); 991 RTC_DCHECK_RUN_ON(worker_queue_);
992 // Configure regular SSRCs. 992 // Configure regular SSRCs.
993 for (size_t i = 0; i < config_->rtp.ssrcs.size(); ++i) { 993 for (size_t i = 0; i < config_->rtp.ssrcs.size(); ++i) {
994 uint32_t ssrc = config_->rtp.ssrcs[i]; 994 uint32_t ssrc = config_->rtp.ssrcs[i];
995 RtpRtcp* const rtp_rtcp = rtp_rtcp_modules_[i]; 995 RtpRtcp* const rtp_rtcp = rtp_rtcp_modules_[i];
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 &module_nack_rate); 1117 &module_nack_rate);
1118 *sent_video_rate_bps += module_video_rate; 1118 *sent_video_rate_bps += module_video_rate;
1119 *sent_nack_rate_bps += module_nack_rate; 1119 *sent_nack_rate_bps += module_nack_rate;
1120 *sent_fec_rate_bps += module_fec_rate; 1120 *sent_fec_rate_bps += module_fec_rate;
1121 } 1121 }
1122 return 0; 1122 return 0;
1123 } 1123 }
1124 1124
1125 } // namespace internal 1125 } // namespace internal
1126 } // namespace webrtc 1126 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_stream_receiver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698