Chromium Code Reviews| 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/video/call_stats.h" | 25 #include "webrtc/video/call_stats.h" |
| 26 #include "webrtc/video/encoder_state_feedback.h" | 26 #include "webrtc/video/encoder_state_feedback.h" |
| 27 #include "webrtc/video/payload_router.h" | 27 #include "webrtc/video/payload_router.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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 ss << '}'; | 107 ss << '}'; |
| 107 return ss.str(); | 108 return ss.str(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 namespace internal { | 111 namespace internal { |
| 111 VideoSendStream::VideoSendStream( | 112 VideoSendStream::VideoSendStream( |
| 112 int num_cpu_cores, | 113 int num_cpu_cores, |
| 113 ProcessThread* module_process_thread, | 114 ProcessThread* module_process_thread, |
| 114 CallStats* call_stats, | 115 CallStats* call_stats, |
| 115 CongestionController* congestion_controller, | 116 CongestionController* congestion_controller, |
| 117 VieRemb* remb, | |
| 116 BitrateAllocator* bitrate_allocator, | 118 BitrateAllocator* bitrate_allocator, |
| 117 const VideoSendStream::Config& config, | 119 const VideoSendStream::Config& config, |
| 118 const VideoEncoderConfig& encoder_config, | 120 const VideoEncoderConfig& encoder_config, |
| 119 const std::map<uint32_t, RtpState>& suspended_ssrcs) | 121 const std::map<uint32_t, RtpState>& suspended_ssrcs) |
| 120 : stats_proxy_(Clock::GetRealTimeClock(), | 122 : stats_proxy_(Clock::GetRealTimeClock(), |
| 121 config, | 123 config, |
| 122 encoder_config.content_type), | 124 encoder_config.content_type), |
| 123 transport_adapter_(config.send_transport), | 125 transport_adapter_(config.send_transport), |
| 124 encoded_frame_proxy_(config.post_encode_callback), | 126 encoded_frame_proxy_(config.post_encode_callback), |
| 125 config_(config), | 127 config_(config), |
| 126 suspended_ssrcs_(suspended_ssrcs), | 128 suspended_ssrcs_(suspended_ssrcs), |
| 127 module_process_thread_(module_process_thread), | 129 module_process_thread_(module_process_thread), |
| 128 call_stats_(call_stats), | 130 call_stats_(call_stats), |
| 129 congestion_controller_(congestion_controller), | 131 congestion_controller_(congestion_controller), |
| 132 remb_(remb), | |
| 130 encoder_feedback_(new EncoderStateFeedback()), | 133 encoder_feedback_(new EncoderStateFeedback()), |
| 131 use_config_bitrate_(true) { | 134 use_config_bitrate_(true) { |
|
the sun
2016/02/05 15:12:37
Same as in receive stream, RTC_DCHECK(remb); and t
stefan-webrtc
2016/02/07 18:29:27
Done.
| |
| 132 LOG(LS_INFO) << "VideoSendStream: " << config_.ToString(); | 135 LOG(LS_INFO) << "VideoSendStream: " << config_.ToString(); |
| 133 RTC_DCHECK(!config_.rtp.ssrcs.empty()); | 136 RTC_DCHECK(!config_.rtp.ssrcs.empty()); |
| 134 | 137 |
| 135 // Set up Call-wide sequence numbers, if configured for this send stream. | 138 // Set up Call-wide sequence numbers, if configured for this send stream. |
| 136 TransportFeedbackObserver* transport_feedback_observer = nullptr; | 139 TransportFeedbackObserver* transport_feedback_observer = nullptr; |
| 137 for (const RtpExtension& extension : config.rtp.extensions) { | 140 for (const RtpExtension& extension : config.rtp.extensions) { |
| 138 if (extension.name == RtpExtension::kTransportSequenceNumber) { | 141 if (extension.name == RtpExtension::kTransportSequenceNumber) { |
| 139 transport_feedback_observer = | 142 transport_feedback_observer = |
| 140 congestion_controller_->GetTransportFeedbackObserver(); | 143 congestion_controller_->GetTransportFeedbackObserver(); |
| 141 break; | 144 break; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 RTC_CHECK_EQ(0, vie_channel_->SetSendAbsoluteSendTimeStatus(true, id)); | 185 RTC_CHECK_EQ(0, vie_channel_->SetSendAbsoluteSendTimeStatus(true, id)); |
| 183 } else if (extension == RtpExtension::kVideoRotation) { | 186 } else if (extension == RtpExtension::kVideoRotation) { |
| 184 RTC_CHECK_EQ(0, vie_channel_->SetSendVideoRotationStatus(true, id)); | 187 RTC_CHECK_EQ(0, vie_channel_->SetSendVideoRotationStatus(true, id)); |
| 185 } else if (extension == RtpExtension::kTransportSequenceNumber) { | 188 } else if (extension == RtpExtension::kTransportSequenceNumber) { |
| 186 RTC_CHECK_EQ(0, vie_channel_->SetSendTransportSequenceNumber(true, id)); | 189 RTC_CHECK_EQ(0, vie_channel_->SetSendTransportSequenceNumber(true, id)); |
| 187 } else { | 190 } else { |
| 188 RTC_NOTREACHED() << "Registering unsupported RTP extension."; | 191 RTC_NOTREACHED() << "Registering unsupported RTP extension."; |
| 189 } | 192 } |
| 190 } | 193 } |
| 191 | 194 |
| 192 congestion_controller_->SetChannelRembStatus(true, false, | 195 RtpRtcp* rtp_module = vie_channel_->rtp_rtcp(); |
| 193 vie_channel_->rtp_rtcp()); | 196 remb_->AddRembSender(rtp_module); |
| 197 rtp_module->SetREMBStatus(true); | |
| 194 | 198 |
| 195 // Enable NACK, FEC or both. | 199 // Enable NACK, FEC or both. |
| 196 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; | 200 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; |
| 197 const bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; | 201 const bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; |
| 198 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. | 202 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. |
| 199 vie_channel_->SetProtectionMode(enable_protection_nack, enable_protection_fec, | 203 vie_channel_->SetProtectionMode(enable_protection_nack, enable_protection_fec, |
| 200 config_.rtp.fec.red_payload_type, | 204 config_.rtp.fec.red_payload_type, |
| 201 config_.rtp.fec.ulpfec_payload_type); | 205 config_.rtp.fec.ulpfec_payload_type); |
| 202 vie_encoder_->SetProtectionMethod(enable_protection_nack, | 206 vie_encoder_->SetProtectionMethod(enable_protection_nack, |
| 203 enable_protection_fec); | 207 enable_protection_fec); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 225 RTC_CHECK(ReconfigureVideoEncoder(encoder_config)); | 229 RTC_CHECK(ReconfigureVideoEncoder(encoder_config)); |
| 226 | 230 |
| 227 vie_channel_->RegisterSendSideDelayObserver(&stats_proxy_); | 231 vie_channel_->RegisterSendSideDelayObserver(&stats_proxy_); |
| 228 | 232 |
| 229 if (config_.post_encode_callback) | 233 if (config_.post_encode_callback) |
| 230 vie_encoder_->RegisterPostEncodeImageCallback(&encoded_frame_proxy_); | 234 vie_encoder_->RegisterPostEncodeImageCallback(&encoded_frame_proxy_); |
| 231 | 235 |
| 232 if (config_.suspend_below_min_bitrate) | 236 if (config_.suspend_below_min_bitrate) |
| 233 vie_encoder_->SuspendBelowMinBitrate(); | 237 vie_encoder_->SuspendBelowMinBitrate(); |
| 234 | 238 |
| 235 congestion_controller_->AddEncoder(vie_encoder_.get()); | |
| 236 encoder_feedback_->AddEncoder(ssrcs, vie_encoder_.get()); | 239 encoder_feedback_->AddEncoder(ssrcs, vie_encoder_.get()); |
| 237 | 240 |
| 238 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(&stats_proxy_); | 241 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(&stats_proxy_); |
| 239 vie_channel_->RegisterSendChannelRtpStatisticsCallback(&stats_proxy_); | 242 vie_channel_->RegisterSendChannelRtpStatisticsCallback(&stats_proxy_); |
| 240 vie_channel_->RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); | 243 vie_channel_->RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); |
| 241 vie_channel_->RegisterSendBitrateObserver(&stats_proxy_); | 244 vie_channel_->RegisterSendBitrateObserver(&stats_proxy_); |
| 242 vie_channel_->RegisterSendFrameCountObserver(&stats_proxy_); | 245 vie_channel_->RegisterSendFrameCountObserver(&stats_proxy_); |
| 243 } | 246 } |
| 244 | 247 |
| 245 VideoSendStream::~VideoSendStream() { | 248 VideoSendStream::~VideoSendStream() { |
| 246 LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString(); | 249 LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString(); |
| 247 vie_channel_->RegisterSendFrameCountObserver(nullptr); | 250 vie_channel_->RegisterSendFrameCountObserver(nullptr); |
| 248 vie_channel_->RegisterSendBitrateObserver(nullptr); | 251 vie_channel_->RegisterSendBitrateObserver(nullptr); |
| 249 vie_channel_->RegisterRtcpPacketTypeCounterObserver(nullptr); | 252 vie_channel_->RegisterRtcpPacketTypeCounterObserver(nullptr); |
| 250 vie_channel_->RegisterSendChannelRtpStatisticsCallback(nullptr); | 253 vie_channel_->RegisterSendChannelRtpStatisticsCallback(nullptr); |
| 251 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(nullptr); | 254 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(nullptr); |
| 252 | 255 |
| 253 // Remove capture input (thread) so that it's not running after the current | 256 // Remove capture input (thread) so that it's not running after the current |
| 254 // channel is deleted. | 257 // channel is deleted. |
| 255 input_.reset(); | 258 input_.reset(); |
| 256 | 259 |
| 257 vie_encoder_->DeRegisterExternalEncoder( | 260 vie_encoder_->DeRegisterExternalEncoder( |
| 258 config_.encoder_settings.payload_type); | 261 config_.encoder_settings.payload_type); |
| 259 | 262 |
| 260 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); | 263 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); |
| 261 congestion_controller_->SetChannelRembStatus(false, false, | 264 |
| 262 vie_channel_->rtp_rtcp()); | 265 RtpRtcp* rtp_module = vie_channel_->rtp_rtcp(); |
| 266 rtp_module->SetREMBStatus(false); | |
| 267 remb_->RemoveRembSender(rtp_module); | |
| 263 | 268 |
| 264 // Remove the feedback, stop all encoding threads and processing. This must be | 269 // Remove the feedback, stop all encoding threads and processing. This must be |
| 265 // done before deleting the channel. | 270 // done before deleting the channel. |
| 266 congestion_controller_->RemoveEncoder(vie_encoder_.get()); | |
| 267 encoder_feedback_->RemoveEncoder(vie_encoder_.get()); | 271 encoder_feedback_->RemoveEncoder(vie_encoder_.get()); |
| 268 vie_encoder_->StopThreadsAndRemoveSharedMembers(); | 272 vie_encoder_->StopThreadsAndRemoveSharedMembers(); |
| 269 | 273 |
| 270 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); | 274 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); |
| 271 congestion_controller_->GetRemoteBitrateEstimator(false)->RemoveStream( | 275 congestion_controller_->GetRemoteBitrateEstimator(false)->RemoveStream( |
| 272 remote_ssrc); | 276 remote_ssrc); |
| 273 } | 277 } |
| 274 | 278 |
| 275 VideoCaptureInput* VideoSendStream::Input() { | 279 VideoCaptureInput* VideoSendStream::Input() { |
| 276 return input_.get(); | 280 return input_.get(); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 vie_encoder_->SetSsrcs(used_ssrcs); | 584 vie_encoder_->SetSsrcs(used_ssrcs); |
| 581 | 585 |
| 582 // Restart the media flow | 586 // Restart the media flow |
| 583 vie_encoder_->Restart(); | 587 vie_encoder_->Restart(); |
| 584 | 588 |
| 585 return true; | 589 return true; |
| 586 } | 590 } |
| 587 | 591 |
| 588 } // namespace internal | 592 } // namespace internal |
| 589 } // namespace webrtc | 593 } // namespace webrtc |
| OLD | NEW |