| 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 |
| 11 #include "webrtc/video/video_receive_stream.h" | 11 #include "webrtc/video/video_receive_stream.h" |
| 12 | 12 |
| 13 #include <stdlib.h> | 13 #include <stdlib.h> |
| 14 | 14 |
| 15 #include <set> | 15 #include <set> |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
| 19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
| 20 #include "webrtc/call/congestion_controller.h" | 20 #include "webrtc/call/congestion_controller.h" |
| 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 22 #include "webrtc/modules/utility/include/process_thread.h" | 22 #include "webrtc/modules/utility/include/process_thread.h" |
| 23 #include "webrtc/system_wrappers/include/clock.h" | 23 #include "webrtc/system_wrappers/include/clock.h" |
| 24 #include "webrtc/video/call_stats.h" | 24 #include "webrtc/video/call_stats.h" |
| 25 #include "webrtc/video/receive_statistics_proxy.h" | 25 #include "webrtc/video/receive_statistics_proxy.h" |
| 26 #include "webrtc/video/vie_remb.h" |
| 26 #include "webrtc/video_receive_stream.h" | 27 #include "webrtc/video_receive_stream.h" |
| 27 | 28 |
| 28 namespace webrtc { | 29 namespace webrtc { |
| 29 | 30 |
| 30 static bool UseSendSideBwe(const VideoReceiveStream::Config& config) { | 31 static bool UseSendSideBwe(const VideoReceiveStream::Config& config) { |
| 31 if (!config.rtp.transport_cc) | 32 if (!config.rtp.transport_cc) |
| 32 return false; | 33 return false; |
| 33 for (const auto& extension : config.rtp.extensions) { | 34 for (const auto& extension : config.rtp.extensions) { |
| 34 if (extension.name == RtpExtension::kTransportSequenceNumber) | 35 if (extension.name == RtpExtension::kTransportSequenceNumber) |
| 35 return true; | 36 return true; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return codec; | 141 return codec; |
| 141 } | 142 } |
| 142 } // namespace | 143 } // namespace |
| 143 | 144 |
| 144 VideoReceiveStream::VideoReceiveStream( | 145 VideoReceiveStream::VideoReceiveStream( |
| 145 int num_cpu_cores, | 146 int num_cpu_cores, |
| 146 CongestionController* congestion_controller, | 147 CongestionController* congestion_controller, |
| 147 const VideoReceiveStream::Config& config, | 148 const VideoReceiveStream::Config& config, |
| 148 webrtc::VoiceEngine* voice_engine, | 149 webrtc::VoiceEngine* voice_engine, |
| 149 ProcessThread* process_thread, | 150 ProcessThread* process_thread, |
| 150 CallStats* call_stats) | 151 CallStats* call_stats, |
| 152 VieRemb* remb) |
| 151 : transport_adapter_(config.rtcp_send_transport), | 153 : transport_adapter_(config.rtcp_send_transport), |
| 152 encoded_frame_proxy_(config.pre_decode_callback), | 154 encoded_frame_proxy_(config.pre_decode_callback), |
| 153 config_(config), | 155 config_(config), |
| 154 process_thread_(process_thread), | 156 process_thread_(process_thread), |
| 155 clock_(Clock::GetRealTimeClock()), | 157 clock_(Clock::GetRealTimeClock()), |
| 156 congestion_controller_(congestion_controller), | 158 congestion_controller_(congestion_controller), |
| 157 call_stats_(call_stats), | 159 call_stats_(call_stats), |
| 160 remb_(remb), |
| 158 vcm_(VideoCodingModule::Create(clock_, nullptr, nullptr)), | 161 vcm_(VideoCodingModule::Create(clock_, nullptr, nullptr)), |
| 159 incoming_video_stream_( | 162 incoming_video_stream_( |
| 160 0, | 163 0, |
| 161 config.renderer ? config.renderer->SmoothsRenderedFrames() : false), | 164 config.renderer ? config.renderer->SmoothsRenderedFrames() : false), |
| 162 stats_proxy_(config_.rtp.remote_ssrc, clock_), | 165 stats_proxy_(config_.rtp.remote_ssrc, clock_), |
| 163 vie_channel_(&transport_adapter_, | 166 vie_channel_(&transport_adapter_, |
| 164 process_thread, | 167 process_thread, |
| 165 nullptr, | 168 nullptr, |
| 166 vcm_.get(), | 169 vcm_.get(), |
| 167 nullptr, | 170 nullptr, |
| 168 nullptr, | 171 nullptr, |
| 169 nullptr, | 172 nullptr, |
| 170 congestion_controller_->GetRemoteBitrateEstimator( | 173 congestion_controller_->GetRemoteBitrateEstimator( |
| 171 UseSendSideBwe(config_)), | 174 UseSendSideBwe(config_)), |
| 172 call_stats_->rtcp_rtt_stats(), | 175 call_stats_->rtcp_rtt_stats(), |
| 173 congestion_controller_->pacer(), | 176 congestion_controller_->pacer(), |
| 174 congestion_controller_->packet_router(), | 177 congestion_controller_->packet_router(), |
| 175 1, | 178 1, |
| 176 false), | 179 false), |
| 177 vie_receiver_(vie_channel_.vie_receiver()), | 180 vie_receiver_(vie_channel_.vie_receiver()), |
| 178 rtp_rtcp_(vie_channel_.rtp_rtcp()) { | 181 rtp_rtcp_(vie_channel_.rtp_rtcp()) { |
| 179 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 182 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
| 180 | 183 |
| 184 RTC_DCHECK(process_thread_); |
| 185 RTC_DCHECK(congestion_controller_); |
| 186 RTC_DCHECK(call_stats_); |
| 187 RTC_DCHECK(remb_); |
| 181 RTC_CHECK(vie_channel_.Init() == 0); | 188 RTC_CHECK(vie_channel_.Init() == 0); |
| 182 | 189 |
| 183 // Register the channel to receive stats updates. | 190 // Register the channel to receive stats updates. |
| 184 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver()); | 191 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver()); |
| 185 | 192 |
| 186 // TODO(pbos): This is not fine grained enough... | 193 // TODO(pbos): This is not fine grained enough... |
| 187 vie_channel_.SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, -1, | 194 vie_channel_.SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, -1, |
| 188 -1); | 195 -1); |
| 189 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) | 196 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) |
| 190 << "A stream should not be configured with RTCP disabled. This value is " | 197 << "A stream should not be configured with RTCP disabled. This value is " |
| (...skipping 12 matching lines...) Expand all Loading... |
| 203 RTC_DCHECK(kv.second.payload_type != 0); | 210 RTC_DCHECK(kv.second.payload_type != 0); |
| 204 | 211 |
| 205 vie_receiver_->SetRtxSsrc(kv.second.ssrc); | 212 vie_receiver_->SetRtxSsrc(kv.second.ssrc); |
| 206 vie_receiver_->SetRtxPayloadType(kv.second.payload_type, kv.first); | 213 vie_receiver_->SetRtxPayloadType(kv.second.payload_type, kv.first); |
| 207 } | 214 } |
| 208 // TODO(holmer): When Chrome no longer depends on this being false by default, | 215 // TODO(holmer): When Chrome no longer depends on this being false by default, |
| 209 // always use the mapping and remove this whole codepath. | 216 // always use the mapping and remove this whole codepath. |
| 210 vie_receiver_->SetUseRtxPayloadMappingOnRestore( | 217 vie_receiver_->SetUseRtxPayloadMappingOnRestore( |
| 211 config_.rtp.use_rtx_payload_mapping_on_restore); | 218 config_.rtp.use_rtx_payload_mapping_on_restore); |
| 212 | 219 |
| 213 congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb, | 220 if (config_.rtp.remb) { |
| 214 rtp_rtcp_); | 221 rtp_rtcp_->SetREMBStatus(true); |
| 222 remb_->AddReceiveChannel(rtp_rtcp_); |
| 223 } |
| 215 | 224 |
| 216 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { | 225 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { |
| 217 const std::string& extension = config_.rtp.extensions[i].name; | 226 const std::string& extension = config_.rtp.extensions[i].name; |
| 218 int id = config_.rtp.extensions[i].id; | 227 int id = config_.rtp.extensions[i].id; |
| 219 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 228 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
| 220 RTC_DCHECK_GE(id, 1); | 229 RTC_DCHECK_GE(id, 1); |
| 221 RTC_DCHECK_LE(id, 14); | 230 RTC_DCHECK_LE(id, 14); |
| 222 if (extension == RtpExtension::kTOffset) { | 231 if (extension == RtpExtension::kTOffset) { |
| 223 RTC_CHECK(vie_receiver_->SetReceiveTimestampOffsetStatus(true, id)); | 232 RTC_CHECK(vie_receiver_->SetReceiveTimestampOffsetStatus(true, id)); |
| 224 } else if (extension == RtpExtension::kAbsSendTime) { | 233 } else if (extension == RtpExtension::kAbsSendTime) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 } | 306 } |
| 298 | 307 |
| 299 VideoReceiveStream::~VideoReceiveStream() { | 308 VideoReceiveStream::~VideoReceiveStream() { |
| 300 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 309 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
| 301 incoming_video_stream_.Stop(); | 310 incoming_video_stream_.Stop(); |
| 302 process_thread_->DeRegisterModule(vcm_.get()); | 311 process_thread_->DeRegisterModule(vcm_.get()); |
| 303 vie_channel_.RegisterPreRenderCallback(nullptr); | 312 vie_channel_.RegisterPreRenderCallback(nullptr); |
| 304 vcm_->RegisterPreDecodeImageCallback(nullptr); | 313 vcm_->RegisterPreDecodeImageCallback(nullptr); |
| 305 | 314 |
| 306 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); | 315 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); |
| 307 congestion_controller_->SetChannelRembStatus(false, false, rtp_rtcp_); | 316 rtp_rtcp_->SetREMBStatus(false); |
| 317 remb_->RemoveReceiveChannel(rtp_rtcp_); |
| 308 | 318 |
| 309 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) | 319 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) |
| 310 ->RemoveStream(vie_receiver_->GetRemoteSsrc()); | 320 ->RemoveStream(vie_receiver_->GetRemoteSsrc()); |
| 311 } | 321 } |
| 312 | 322 |
| 313 void VideoReceiveStream::Start() { | 323 void VideoReceiveStream::Start() { |
| 314 transport_adapter_.Enable(); | 324 transport_adapter_.Enable(); |
| 315 incoming_video_stream_.Start(); | 325 incoming_video_stream_.Start(); |
| 316 vie_channel_.StartReceive(); | 326 vie_channel_.StartReceive(); |
| 317 } | 327 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 return 0; | 398 return 0; |
| 389 } | 399 } |
| 390 | 400 |
| 391 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 401 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
| 392 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode | 402 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode |
| 393 : RtcpMode::kOff); | 403 : RtcpMode::kOff); |
| 394 } | 404 } |
| 395 | 405 |
| 396 } // namespace internal | 406 } // namespace internal |
| 397 } // namespace webrtc | 407 } // namespace webrtc |
| OLD | NEW |