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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 bool ok = file_writers_[layer]->WriteFrame( | 912 bool ok = file_writers_[layer]->WriteFrame( |
913 encoded_image, codec_specific_info->codecType); | 913 encoded_image, codec_specific_info->codecType); |
914 RTC_DCHECK(ok); | 914 RTC_DCHECK(ok); |
915 } | 915 } |
916 } | 916 } |
917 | 917 |
918 return result; | 918 return result; |
919 } | 919 } |
920 | 920 |
921 void VideoSendStreamImpl::ConfigureProtection() { | 921 void VideoSendStreamImpl::ConfigureProtection() { |
922 RTC_DCHECK_RUN_ON(worker_queue_); | 922 RTC_DCHECK_RUN_ON(worker_queue_); |
brandtr
2016/10/27 11:06:24
This function will see further changes in future C
| |
923 // Enable NACK, FEC or both. | 923 // Enable NACK, FEC or both. |
924 const bool enable_protection_nack = config_->rtp.nack.rtp_history_ms > 0; | 924 const bool enable_protection_nack = config_->rtp.nack.rtp_history_ms > 0; |
925 bool enable_protection_fec = config_->rtp.ulpfec.ulpfec_payload_type != -1; | 925 const int red_payload_type = config_->rtp.ulpfec.red_payload_type; |
926 int ulpfec_payload_type = config_->rtp.ulpfec.ulpfec_payload_type; | |
926 // Payload types without picture ID cannot determine that a stream is complete | 927 // Payload types without picture ID cannot determine that a stream is complete |
927 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is | 928 // without retransmitting FEC, so using FEC + NACK for H.264 (for instance) is |
928 // a waste of bandwidth since FEC packets still have to be transmitted. Note | 929 // a waste of bandwidth since FEC packets still have to be transmitted. Note |
929 // that this is not the case with FLEXFEC. | 930 // that this is not the case with FLEXFEC. |
930 if (enable_protection_nack && | 931 if (enable_protection_nack && |
931 !PayloadTypeSupportsSkippingFecPackets( | 932 !PayloadTypeSupportsSkippingFecPackets( |
932 config_->encoder_settings.payload_name)) { | 933 config_->encoder_settings.payload_name)) { |
933 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" | 934 LOG(LS_WARNING) << "Transmitting payload type without picture ID using" |
934 "NACK+FEC is a waste of bandwidth since FEC packets " | 935 "NACK+FEC is a waste of bandwidth since FEC packets " |
935 "also have to be retransmitted. Disabling FEC."; | 936 "also have to be retransmitted. Disabling FEC."; |
936 enable_protection_fec = false; | 937 ulpfec_payload_type = -1; |
937 } | 938 } |
938 | 939 |
939 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. | 940 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. |
940 // Validate payload types. If either RED or FEC payload types are set then | 941 // Validate payload types. If either RED or FEC payload types are set then |
941 // both should be. If FEC is enabled then they both have to be set. | 942 // both should be. If FEC is enabled then they both have to be set. |
942 if (config_->rtp.ulpfec.red_payload_type != -1) { | 943 if (red_payload_type != -1) { |
943 RTC_DCHECK_GE(config_->rtp.ulpfec.red_payload_type, 0); | 944 RTC_DCHECK_GE(red_payload_type, 0); |
944 RTC_DCHECK_LE(config_->rtp.ulpfec.red_payload_type, 127); | 945 RTC_DCHECK_LE(red_payload_type, 127); |
945 // TODO(holmer): We should only enable red if ulpfec is also enabled, but | 946 // TODO(holmer): We should only enable red if ulpfec is also enabled, but |
946 // but due to an incompatibility issue with previous versions the receiver | 947 // but due to an incompatibility issue with previous versions the receiver |
947 // assumes rtx packets are containing red if it has been configured to | 948 // assumes rtx packets are containing red if it has been configured to |
948 // receive red. Remove this in a few versions once the incompatibility | 949 // receive red. Remove this in a few versions once the incompatibility |
949 // issue is resolved (M53 timeframe). | 950 // issue is resolved (M53 timeframe). |
950 } | 951 } |
951 if (config_->rtp.ulpfec.ulpfec_payload_type != -1) { | 952 if (ulpfec_payload_type != -1) { |
952 RTC_DCHECK_GE(config_->rtp.ulpfec.ulpfec_payload_type, 0); | 953 RTC_DCHECK_GE(ulpfec_payload_type, 0); |
953 RTC_DCHECK_LE(config_->rtp.ulpfec.ulpfec_payload_type, 127); | 954 RTC_DCHECK_LE(ulpfec_payload_type, 127); |
954 } | 955 } |
955 | 956 |
956 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 957 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
957 // Set NACK. | 958 // Set NACK. |
958 rtp_rtcp->SetStorePacketsStatus( | 959 rtp_rtcp->SetStorePacketsStatus( |
959 enable_protection_nack || congestion_controller_->pacer(), | 960 enable_protection_nack || congestion_controller_->pacer(), |
960 kMinSendSidePacketHistorySize); | 961 kMinSendSidePacketHistorySize); |
961 // Set FEC. | 962 // Set FEC. |
962 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 963 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
963 rtp_rtcp->SetUlpfecConfig(enable_protection_fec, | 964 rtp_rtcp->SetUlpfecConfig(red_payload_type, ulpfec_payload_type); |
964 config_->rtp.ulpfec.red_payload_type, | |
965 config_->rtp.ulpfec.ulpfec_payload_type); | |
966 } | 965 } |
967 } | 966 } |
968 | 967 |
968 const bool enable_protection_fec = (ulpfec_payload_type != -1); | |
969 protection_bitrate_calculator_.SetProtectionMethod(enable_protection_fec, | 969 protection_bitrate_calculator_.SetProtectionMethod(enable_protection_fec, |
970 enable_protection_nack); | 970 enable_protection_nack); |
971 } | 971 } |
972 | 972 |
973 void VideoSendStreamImpl::ConfigureSsrcs() { | 973 void VideoSendStreamImpl::ConfigureSsrcs() { |
974 RTC_DCHECK_RUN_ON(worker_queue_); | 974 RTC_DCHECK_RUN_ON(worker_queue_); |
975 // Configure regular SSRCs. | 975 // Configure regular SSRCs. |
976 for (size_t i = 0; i < config_->rtp.ssrcs.size(); ++i) { | 976 for (size_t i = 0; i < config_->rtp.ssrcs.size(); ++i) { |
977 uint32_t ssrc = config_->rtp.ssrcs[i]; | 977 uint32_t ssrc = config_->rtp.ssrcs[i]; |
978 RtpRtcp* const rtp_rtcp = rtp_rtcp_modules_[i]; | 978 RtpRtcp* const rtp_rtcp = rtp_rtcp_modules_[i]; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1100 &module_nack_rate); | 1100 &module_nack_rate); |
1101 *sent_video_rate_bps += module_video_rate; | 1101 *sent_video_rate_bps += module_video_rate; |
1102 *sent_nack_rate_bps += module_nack_rate; | 1102 *sent_nack_rate_bps += module_nack_rate; |
1103 *sent_fec_rate_bps += module_fec_rate; | 1103 *sent_fec_rate_bps += module_fec_rate; |
1104 } | 1104 } |
1105 return 0; | 1105 return 0; |
1106 } | 1106 } |
1107 | 1107 |
1108 } // namespace internal | 1108 } // namespace internal |
1109 } // namespace webrtc | 1109 } // namespace webrtc |
OLD | NEW |