| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 rtp_rtcp->SetSendingStatus(false); | 88 rtp_rtcp->SetSendingStatus(false); |
| 89 rtp_rtcp->SetSendingMediaStatus(false); | 89 rtp_rtcp->SetSendingMediaStatus(false); |
| 90 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); | 90 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); |
| 91 modules.push_back(rtp_rtcp); | 91 modules.push_back(rtp_rtcp); |
| 92 } | 92 } |
| 93 return modules; | 93 return modules; |
| 94 } | 94 } |
| 95 | 95 |
| 96 // TODO(brandtr): Update this function when we support multistream protection. | 96 // TODO(brandtr): Update this function when we support multistream protection. |
| 97 std::unique_ptr<FlexfecSender> MaybeCreateFlexfecSender( | 97 std::unique_ptr<FlexfecSender> MaybeCreateFlexfecSender( |
| 98 const VideoSendStream::Config& config) { | 98 const VideoSendStream::Config& config, |
| 99 const std::map<uint32_t, RtpState>& suspended_ssrcs) { |
| 99 if (config.rtp.flexfec.payload_type < 0) { | 100 if (config.rtp.flexfec.payload_type < 0) { |
| 100 return nullptr; | 101 return nullptr; |
| 101 } | 102 } |
| 102 RTC_DCHECK_GE(config.rtp.flexfec.payload_type, 0); | 103 RTC_DCHECK_GE(config.rtp.flexfec.payload_type, 0); |
| 103 RTC_DCHECK_LE(config.rtp.flexfec.payload_type, 127); | 104 RTC_DCHECK_LE(config.rtp.flexfec.payload_type, 127); |
| 104 if (config.rtp.flexfec.ssrc == 0) { | 105 if (config.rtp.flexfec.ssrc == 0) { |
| 105 LOG(LS_WARNING) << "FlexFEC is enabled, but no FlexFEC SSRC given. " | 106 LOG(LS_WARNING) << "FlexFEC is enabled, but no FlexFEC SSRC given. " |
| 106 "Therefore disabling FlexFEC."; | 107 "Therefore disabling FlexFEC."; |
| 107 return nullptr; | 108 return nullptr; |
| 108 } | 109 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 121 | 122 |
| 122 if (config.rtp.flexfec.protected_media_ssrcs.size() > 1) { | 123 if (config.rtp.flexfec.protected_media_ssrcs.size() > 1) { |
| 123 LOG(LS_WARNING) | 124 LOG(LS_WARNING) |
| 124 << "The supplied FlexfecConfig contained multiple protected " | 125 << "The supplied FlexfecConfig contained multiple protected " |
| 125 "media streams, but our implementation currently only " | 126 "media streams, but our implementation currently only " |
| 126 "supports protecting a single media stream. " | 127 "supports protecting a single media stream. " |
| 127 "To avoid confusion, disabling FlexFEC completely."; | 128 "To avoid confusion, disabling FlexFEC completely."; |
| 128 return nullptr; | 129 return nullptr; |
| 129 } | 130 } |
| 130 | 131 |
| 132 const RtpState* rtp_state = nullptr; |
| 133 auto it = suspended_ssrcs.find(config.rtp.flexfec.ssrc); |
| 134 if (it != suspended_ssrcs.end()) { |
| 135 rtp_state = &it->second; |
| 136 } |
| 137 |
| 131 RTC_DCHECK_EQ(1U, config.rtp.flexfec.protected_media_ssrcs.size()); | 138 RTC_DCHECK_EQ(1U, config.rtp.flexfec.protected_media_ssrcs.size()); |
| 132 return std::unique_ptr<FlexfecSender>(new FlexfecSender( | 139 return std::unique_ptr<FlexfecSender>(new FlexfecSender( |
| 133 config.rtp.flexfec.payload_type, config.rtp.flexfec.ssrc, | 140 config.rtp.flexfec.payload_type, config.rtp.flexfec.ssrc, |
| 134 config.rtp.flexfec.protected_media_ssrcs[0], config.rtp.extensions, | 141 config.rtp.flexfec.protected_media_ssrcs[0], config.rtp.extensions, |
| 135 RTPSender::FecExtensionSizes(), Clock::GetRealTimeClock())); | 142 RTPSender::FecExtensionSizes(), rtp_state, Clock::GetRealTimeClock())); |
| 136 } | 143 } |
| 137 | 144 |
| 138 } // namespace | 145 } // namespace |
| 139 | 146 |
| 140 std::string | 147 std::string |
| 141 VideoSendStream::Config::EncoderSettings::ToString() const { | 148 VideoSendStream::Config::EncoderSettings::ToString() const { |
| 142 std::stringstream ss; | 149 std::stringstream ss; |
| 143 ss << "{payload_name: " << payload_name; | 150 ss << "{payload_name: " << payload_name; |
| 144 ss << ", payload_type: " << payload_type; | 151 ss << ", payload_type: " << payload_type; |
| 145 ss << ", encoder: " << (encoder ? "(VideoEncoder)" : "nullptr"); | 152 ss << ", encoder: " << (encoder ? "(VideoEncoder)" : "nullptr"); |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), | 762 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), |
| 756 stats_proxy_(stats_proxy), | 763 stats_proxy_(stats_proxy), |
| 757 config_(config), | 764 config_(config), |
| 758 suspended_ssrcs_(std::move(suspended_ssrcs)), | 765 suspended_ssrcs_(std::move(suspended_ssrcs)), |
| 759 module_process_thread_(nullptr), | 766 module_process_thread_(nullptr), |
| 760 worker_queue_(worker_queue), | 767 worker_queue_(worker_queue), |
| 761 check_encoder_activity_task_(nullptr), | 768 check_encoder_activity_task_(nullptr), |
| 762 call_stats_(call_stats), | 769 call_stats_(call_stats), |
| 763 transport_(transport), | 770 transport_(transport), |
| 764 bitrate_allocator_(bitrate_allocator), | 771 bitrate_allocator_(bitrate_allocator), |
| 765 flexfec_sender_(MaybeCreateFlexfecSender(*config_)), | 772 flexfec_sender_(MaybeCreateFlexfecSender(*config_, suspended_ssrcs_)), |
| 766 max_padding_bitrate_(0), | 773 max_padding_bitrate_(0), |
| 767 encoder_min_bitrate_bps_(0), | 774 encoder_min_bitrate_bps_(0), |
| 768 encoder_max_bitrate_bps_(initial_encoder_max_bitrate), | 775 encoder_max_bitrate_bps_(initial_encoder_max_bitrate), |
| 769 encoder_target_rate_bps_(0), | 776 encoder_target_rate_bps_(0), |
| 770 vie_encoder_(vie_encoder), | 777 vie_encoder_(vie_encoder), |
| 771 encoder_feedback_(Clock::GetRealTimeClock(), | 778 encoder_feedback_(Clock::GetRealTimeClock(), |
| 772 config_->rtp.ssrcs, | 779 config_->rtp.ssrcs, |
| 773 vie_encoder), | 780 vie_encoder), |
| 774 protection_bitrate_calculator_(Clock::GetRealTimeClock(), this), | 781 protection_bitrate_calculator_(Clock::GetRealTimeClock(), this), |
| 775 bandwidth_observer_(transport->send_side_cc() | 782 bandwidth_observer_(transport->send_side_cc() |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 1184 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 1178 rtp_rtcp->SetRtxSendPayloadType(config_->rtp.ulpfec.red_rtx_payload_type, | 1185 rtp_rtcp->SetRtxSendPayloadType(config_->rtp.ulpfec.red_rtx_payload_type, |
| 1179 config_->rtp.ulpfec.red_payload_type); | 1186 config_->rtp.ulpfec.red_payload_type); |
| 1180 } | 1187 } |
| 1181 } | 1188 } |
| 1182 } | 1189 } |
| 1183 | 1190 |
| 1184 std::map<uint32_t, RtpState> VideoSendStreamImpl::GetRtpStates() const { | 1191 std::map<uint32_t, RtpState> VideoSendStreamImpl::GetRtpStates() const { |
| 1185 RTC_DCHECK_RUN_ON(worker_queue_); | 1192 RTC_DCHECK_RUN_ON(worker_queue_); |
| 1186 std::map<uint32_t, RtpState> rtp_states; | 1193 std::map<uint32_t, RtpState> rtp_states; |
| 1194 |
| 1187 for (size_t i = 0; i < config_->rtp.ssrcs.size(); ++i) { | 1195 for (size_t i = 0; i < config_->rtp.ssrcs.size(); ++i) { |
| 1188 uint32_t ssrc = config_->rtp.ssrcs[i]; | 1196 uint32_t ssrc = config_->rtp.ssrcs[i]; |
| 1189 RTC_DCHECK_EQ(ssrc, rtp_rtcp_modules_[i]->SSRC()); | 1197 RTC_DCHECK_EQ(ssrc, rtp_rtcp_modules_[i]->SSRC()); |
| 1190 rtp_states[ssrc] = rtp_rtcp_modules_[i]->GetRtpState(); | 1198 rtp_states[ssrc] = rtp_rtcp_modules_[i]->GetRtpState(); |
| 1191 } | 1199 } |
| 1192 | 1200 |
| 1193 for (size_t i = 0; i < config_->rtp.rtx.ssrcs.size(); ++i) { | 1201 for (size_t i = 0; i < config_->rtp.rtx.ssrcs.size(); ++i) { |
| 1194 uint32_t ssrc = config_->rtp.rtx.ssrcs[i]; | 1202 uint32_t ssrc = config_->rtp.rtx.ssrcs[i]; |
| 1195 rtp_states[ssrc] = rtp_rtcp_modules_[i]->GetRtxState(); | 1203 rtp_states[ssrc] = rtp_rtcp_modules_[i]->GetRtxState(); |
| 1196 } | 1204 } |
| 1197 | 1205 |
| 1206 if (flexfec_sender_) { |
| 1207 uint32_t ssrc = config_->rtp.flexfec.ssrc; |
| 1208 rtp_states[ssrc] = flexfec_sender_->GetRtpState(); |
| 1209 } |
| 1210 |
| 1198 return rtp_states; | 1211 return rtp_states; |
| 1199 } | 1212 } |
| 1200 | 1213 |
| 1201 void VideoSendStreamImpl::SignalNetworkState(NetworkState state) { | 1214 void VideoSendStreamImpl::SignalNetworkState(NetworkState state) { |
| 1202 RTC_DCHECK_RUN_ON(worker_queue_); | 1215 RTC_DCHECK_RUN_ON(worker_queue_); |
| 1203 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 1216 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 1204 rtp_rtcp->SetRTCPStatus(state == kNetworkUp ? config_->rtp.rtcp_mode | 1217 rtp_rtcp->SetRTCPStatus(state == kNetworkUp ? config_->rtp.rtcp_mode |
| 1205 : RtcpMode::kOff); | 1218 : RtcpMode::kOff); |
| 1206 } | 1219 } |
| 1207 } | 1220 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 std::min(config_->rtp.max_packet_size, | 1336 std::min(config_->rtp.max_packet_size, |
| 1324 kPathMTU - transport_overhead_bytes_per_packet_); | 1337 kPathMTU - transport_overhead_bytes_per_packet_); |
| 1325 | 1338 |
| 1326 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 1339 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 1327 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size); | 1340 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size); |
| 1328 } | 1341 } |
| 1329 } | 1342 } |
| 1330 | 1343 |
| 1331 } // namespace internal | 1344 } // namespace internal |
| 1332 } // namespace webrtc | 1345 } // namespace webrtc |
| OLD | NEW |