| 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 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "webrtc/call/congestion_controller.h" | 21 #include "webrtc/call/congestion_controller.h" |
| 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 24 #include "webrtc/modules/pacing/packet_router.h" | 24 #include "webrtc/modules/pacing/packet_router.h" |
| 25 #include "webrtc/modules/utility/include/process_thread.h" | 25 #include "webrtc/modules/utility/include/process_thread.h" |
| 26 #include "webrtc/video/call_stats.h" | 26 #include "webrtc/video/call_stats.h" |
| 27 #include "webrtc/video/encoder_state_feedback.h" | 27 #include "webrtc/video/encoder_state_feedback.h" |
| 28 #include "webrtc/video/video_capture_input.h" | 28 #include "webrtc/video/video_capture_input.h" |
| 29 #include "webrtc/video/vie_channel.h" | 29 #include "webrtc/video/vie_channel.h" |
| 30 #include "webrtc/video/vie_encoder.h" | 30 #include "webrtc/video/vie_encoder.h" |
| 31 #include "webrtc/video/vie_remb.h" |
| 31 #include "webrtc/video_send_stream.h" | 32 #include "webrtc/video_send_stream.h" |
| 32 | 33 |
| 33 namespace webrtc { | 34 namespace webrtc { |
| 34 | 35 |
| 35 class PacedSender; | 36 class PacedSender; |
| 36 class RtcpIntraFrameObserver; | 37 class RtcpIntraFrameObserver; |
| 37 class TransportFeedbackObserver; | 38 class TransportFeedbackObserver; |
| 38 | 39 |
| 39 std::string | 40 std::string |
| 40 VideoSendStream::Config::EncoderSettings::ToString() const { | 41 VideoSendStream::Config::EncoderSettings::ToString() const { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return options; | 119 return options; |
| 119 } | 120 } |
| 120 } // namespace | 121 } // namespace |
| 121 | 122 |
| 122 namespace internal { | 123 namespace internal { |
| 123 VideoSendStream::VideoSendStream( | 124 VideoSendStream::VideoSendStream( |
| 124 int num_cpu_cores, | 125 int num_cpu_cores, |
| 125 ProcessThread* module_process_thread, | 126 ProcessThread* module_process_thread, |
| 126 CallStats* call_stats, | 127 CallStats* call_stats, |
| 127 CongestionController* congestion_controller, | 128 CongestionController* congestion_controller, |
| 129 VieRemb* remb, |
| 128 BitrateAllocator* bitrate_allocator, | 130 BitrateAllocator* bitrate_allocator, |
| 129 const VideoSendStream::Config& config, | 131 const VideoSendStream::Config& config, |
| 130 const VideoEncoderConfig& encoder_config, | 132 const VideoEncoderConfig& encoder_config, |
| 131 const std::map<uint32_t, RtpState>& suspended_ssrcs) | 133 const std::map<uint32_t, RtpState>& suspended_ssrcs) |
| 132 : stats_proxy_(Clock::GetRealTimeClock(), | 134 : stats_proxy_(Clock::GetRealTimeClock(), |
| 133 config, | 135 config, |
| 134 encoder_config.content_type), | 136 encoder_config.content_type), |
| 135 transport_adapter_(config.send_transport), | 137 transport_adapter_(config.send_transport), |
| 136 encoded_frame_proxy_(config.post_encode_callback), | 138 encoded_frame_proxy_(config.post_encode_callback), |
| 137 config_(config), | 139 config_(config), |
| 138 suspended_ssrcs_(suspended_ssrcs), | 140 suspended_ssrcs_(suspended_ssrcs), |
| 139 module_process_thread_(module_process_thread), | 141 module_process_thread_(module_process_thread), |
| 140 call_stats_(call_stats), | 142 call_stats_(call_stats), |
| 141 congestion_controller_(congestion_controller), | 143 congestion_controller_(congestion_controller), |
| 144 remb_(remb), |
| 142 overuse_detector_( | 145 overuse_detector_( |
| 143 Clock::GetRealTimeClock(), | 146 Clock::GetRealTimeClock(), |
| 144 GetCpuOveruseOptions(config.encoder_settings.full_overuse_time), | 147 GetCpuOveruseOptions(config.encoder_settings.full_overuse_time), |
| 145 this, | 148 this, |
| 146 config.post_encode_callback, | 149 config.post_encode_callback, |
| 147 &stats_proxy_), | 150 &stats_proxy_), |
| 148 encoder_feedback_(new EncoderStateFeedback()), | 151 encoder_feedback_(new EncoderStateFeedback()), |
| 149 use_config_bitrate_(true) { | 152 use_config_bitrate_(true) { |
| 150 LOG(LS_INFO) << "VideoSendStream: " << config_.ToString(); | 153 LOG(LS_INFO) << "VideoSendStream: " << config_.ToString(); |
| 154 |
| 151 RTC_DCHECK(!config_.rtp.ssrcs.empty()); | 155 RTC_DCHECK(!config_.rtp.ssrcs.empty()); |
| 156 RTC_DCHECK(module_process_thread_); |
| 157 RTC_DCHECK(call_stats_); |
| 158 RTC_DCHECK(congestion_controller_); |
| 159 RTC_DCHECK(remb_); |
| 152 | 160 |
| 153 // Set up Call-wide sequence numbers, if configured for this send stream. | 161 // Set up Call-wide sequence numbers, if configured for this send stream. |
| 154 TransportFeedbackObserver* transport_feedback_observer = nullptr; | 162 TransportFeedbackObserver* transport_feedback_observer = nullptr; |
| 155 for (const RtpExtension& extension : config.rtp.extensions) { | 163 for (const RtpExtension& extension : config.rtp.extensions) { |
| 156 if (extension.name == RtpExtension::kTransportSequenceNumber) { | 164 if (extension.name == RtpExtension::kTransportSequenceNumber) { |
| 157 transport_feedback_observer = | 165 transport_feedback_observer = |
| 158 congestion_controller_->GetTransportFeedbackObserver(); | 166 congestion_controller_->GetTransportFeedbackObserver(); |
| 159 break; | 167 break; |
| 160 } | 168 } |
| 161 } | 169 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 RTC_CHECK_EQ(0, vie_channel_->SetSendAbsoluteSendTimeStatus(true, id)); | 207 RTC_CHECK_EQ(0, vie_channel_->SetSendAbsoluteSendTimeStatus(true, id)); |
| 200 } else if (extension == RtpExtension::kVideoRotation) { | 208 } else if (extension == RtpExtension::kVideoRotation) { |
| 201 RTC_CHECK_EQ(0, vie_channel_->SetSendVideoRotationStatus(true, id)); | 209 RTC_CHECK_EQ(0, vie_channel_->SetSendVideoRotationStatus(true, id)); |
| 202 } else if (extension == RtpExtension::kTransportSequenceNumber) { | 210 } else if (extension == RtpExtension::kTransportSequenceNumber) { |
| 203 RTC_CHECK_EQ(0, vie_channel_->SetSendTransportSequenceNumber(true, id)); | 211 RTC_CHECK_EQ(0, vie_channel_->SetSendTransportSequenceNumber(true, id)); |
| 204 } else { | 212 } else { |
| 205 RTC_NOTREACHED() << "Registering unsupported RTP extension."; | 213 RTC_NOTREACHED() << "Registering unsupported RTP extension."; |
| 206 } | 214 } |
| 207 } | 215 } |
| 208 | 216 |
| 209 congestion_controller_->SetChannelRembStatus(true, false, | 217 RtpRtcp* rtp_module = vie_channel_->rtp_rtcp(); |
| 210 vie_channel_->rtp_rtcp()); | 218 remb_->AddRembSender(rtp_module); |
| 219 rtp_module->SetREMBStatus(true); |
| 211 | 220 |
| 212 // Enable NACK, FEC or both. | 221 // Enable NACK, FEC or both. |
| 213 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; | 222 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; |
| 214 const bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; | 223 const bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; |
| 215 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. | 224 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. |
| 216 vie_channel_->SetProtectionMode(enable_protection_nack, enable_protection_fec, | 225 vie_channel_->SetProtectionMode(enable_protection_nack, enable_protection_fec, |
| 217 config_.rtp.fec.red_payload_type, | 226 config_.rtp.fec.red_payload_type, |
| 218 config_.rtp.fec.ulpfec_payload_type); | 227 config_.rtp.fec.ulpfec_payload_type); |
| 219 vie_encoder_->SetProtectionMethod(enable_protection_nack, | 228 vie_encoder_->SetProtectionMethod(enable_protection_nack, |
| 220 enable_protection_fec); | 229 enable_protection_fec); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 242 RTC_CHECK(ReconfigureVideoEncoder(encoder_config)); | 251 RTC_CHECK(ReconfigureVideoEncoder(encoder_config)); |
| 243 | 252 |
| 244 vie_channel_->RegisterSendSideDelayObserver(&stats_proxy_); | 253 vie_channel_->RegisterSendSideDelayObserver(&stats_proxy_); |
| 245 | 254 |
| 246 if (config_.post_encode_callback) | 255 if (config_.post_encode_callback) |
| 247 vie_encoder_->RegisterPostEncodeImageCallback(&encoded_frame_proxy_); | 256 vie_encoder_->RegisterPostEncodeImageCallback(&encoded_frame_proxy_); |
| 248 | 257 |
| 249 if (config_.suspend_below_min_bitrate) | 258 if (config_.suspend_below_min_bitrate) |
| 250 vie_encoder_->SuspendBelowMinBitrate(); | 259 vie_encoder_->SuspendBelowMinBitrate(); |
| 251 | 260 |
| 252 congestion_controller_->AddEncoder(vie_encoder_.get()); | |
| 253 encoder_feedback_->AddEncoder(ssrcs, vie_encoder_.get()); | 261 encoder_feedback_->AddEncoder(ssrcs, vie_encoder_.get()); |
| 254 | 262 |
| 255 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(&stats_proxy_); | 263 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(&stats_proxy_); |
| 256 vie_channel_->RegisterSendChannelRtpStatisticsCallback(&stats_proxy_); | 264 vie_channel_->RegisterSendChannelRtpStatisticsCallback(&stats_proxy_); |
| 257 vie_channel_->RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); | 265 vie_channel_->RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); |
| 258 vie_channel_->RegisterSendBitrateObserver(&stats_proxy_); | 266 vie_channel_->RegisterSendBitrateObserver(&stats_proxy_); |
| 259 vie_channel_->RegisterSendFrameCountObserver(&stats_proxy_); | 267 vie_channel_->RegisterSendFrameCountObserver(&stats_proxy_); |
| 260 | 268 |
| 261 module_process_thread_->RegisterModule(&overuse_detector_); | 269 module_process_thread_->RegisterModule(&overuse_detector_); |
| 262 } | 270 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 275 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(nullptr); | 283 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(nullptr); |
| 276 | 284 |
| 277 // Remove capture input (thread) so that it's not running after the current | 285 // Remove capture input (thread) so that it's not running after the current |
| 278 // channel is deleted. | 286 // channel is deleted. |
| 279 input_.reset(); | 287 input_.reset(); |
| 280 | 288 |
| 281 vie_encoder_->DeRegisterExternalEncoder( | 289 vie_encoder_->DeRegisterExternalEncoder( |
| 282 config_.encoder_settings.payload_type); | 290 config_.encoder_settings.payload_type); |
| 283 | 291 |
| 284 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); | 292 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); |
| 285 congestion_controller_->SetChannelRembStatus(false, false, | 293 |
| 286 vie_channel_->rtp_rtcp()); | 294 RtpRtcp* rtp_module = vie_channel_->rtp_rtcp(); |
| 295 rtp_module->SetREMBStatus(false); |
| 296 remb_->RemoveRembSender(rtp_module); |
| 287 | 297 |
| 288 // Remove the feedback, stop all encoding threads and processing. This must be | 298 // Remove the feedback, stop all encoding threads and processing. This must be |
| 289 // done before deleting the channel. | 299 // done before deleting the channel. |
| 290 congestion_controller_->RemoveEncoder(vie_encoder_.get()); | |
| 291 encoder_feedback_->RemoveEncoder(vie_encoder_.get()); | 300 encoder_feedback_->RemoveEncoder(vie_encoder_.get()); |
| 292 | 301 |
| 293 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); | 302 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); |
| 294 congestion_controller_->GetRemoteBitrateEstimator(false)->RemoveStream( | 303 congestion_controller_->GetRemoteBitrateEstimator(false)->RemoveStream( |
| 295 remote_ssrc); | 304 remote_ssrc); |
| 296 } | 305 } |
| 297 | 306 |
| 298 VideoCaptureInput* VideoSendStream::Input() { | 307 VideoCaptureInput* VideoSendStream::Input() { |
| 299 return input_.get(); | 308 return input_.get(); |
| 300 } | 309 } |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 vie_encoder_->SetSsrcs(used_ssrcs); | 612 vie_encoder_->SetSsrcs(used_ssrcs); |
| 604 | 613 |
| 605 // Restart the media flow | 614 // Restart the media flow |
| 606 vie_encoder_->Restart(); | 615 vie_encoder_->Restart(); |
| 607 | 616 |
| 608 return true; | 617 return true; |
| 609 } | 618 } |
| 610 | 619 |
| 611 } // namespace internal | 620 } // namespace internal |
| 612 } // namespace webrtc | 621 } // namespace webrtc |
| OLD | NEW |