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/system_wrappers/include/clock.h" | 23 #include "webrtc/system_wrappers/include/clock.h" |
23 #include "webrtc/video/call_stats.h" | 24 #include "webrtc/video/call_stats.h" |
24 #include "webrtc/video/receive_statistics_proxy.h" | 25 #include "webrtc/video/receive_statistics_proxy.h" |
25 #include "webrtc/video_receive_stream.h" | 26 #include "webrtc/video_receive_stream.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
28 | 29 |
29 static bool UseSendSideBwe(const std::vector<RtpExtension>& extensions) { | 30 static bool UseSendSideBwe(const std::vector<RtpExtension>& extensions) { |
30 for (const auto& extension : extensions) { | 31 for (const auto& extension : extensions) { |
31 if (extension.name == RtpExtension::kTransportSequenceNumber) | 32 if (extension.name == RtpExtension::kTransportSequenceNumber) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 VideoReceiveStream::VideoReceiveStream( | 142 VideoReceiveStream::VideoReceiveStream( |
142 int num_cpu_cores, | 143 int num_cpu_cores, |
143 CongestionController* congestion_controller, | 144 CongestionController* congestion_controller, |
144 const VideoReceiveStream::Config& config, | 145 const VideoReceiveStream::Config& config, |
145 webrtc::VoiceEngine* voice_engine, | 146 webrtc::VoiceEngine* voice_engine, |
146 ProcessThread* process_thread, | 147 ProcessThread* process_thread, |
147 CallStats* call_stats) | 148 CallStats* call_stats) |
148 : transport_adapter_(config.rtcp_send_transport), | 149 : transport_adapter_(config.rtcp_send_transport), |
149 encoded_frame_proxy_(config.pre_decode_callback), | 150 encoded_frame_proxy_(config.pre_decode_callback), |
150 config_(config), | 151 config_(config), |
| 152 process_thread_(process_thread), |
151 clock_(Clock::GetRealTimeClock()), | 153 clock_(Clock::GetRealTimeClock()), |
152 congestion_controller_(congestion_controller), | 154 congestion_controller_(congestion_controller), |
153 call_stats_(call_stats) { | 155 call_stats_(call_stats), |
| 156 vcm_(VideoCodingModule::Create(clock_, nullptr, nullptr)) { |
154 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 157 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
155 | 158 |
156 bool send_side_bwe = | 159 bool send_side_bwe = |
157 config.rtp.transport_cc && UseSendSideBwe(config_.rtp.extensions); | 160 config.rtp.transport_cc && UseSendSideBwe(config_.rtp.extensions); |
158 | 161 |
159 RemoteBitrateEstimator* bitrate_estimator = | 162 RemoteBitrateEstimator* bitrate_estimator = |
160 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe); | 163 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe); |
161 | 164 |
162 vie_channel_.reset(new ViEChannel( | 165 vie_channel_.reset(new ViEChannel( |
163 num_cpu_cores, &transport_adapter_, process_thread, nullptr, | 166 num_cpu_cores, &transport_adapter_, process_thread, nullptr, vcm_.get(), |
164 nullptr, nullptr, bitrate_estimator, call_stats_->rtcp_rtt_stats(), | 167 nullptr, nullptr, nullptr, bitrate_estimator, |
165 congestion_controller_->pacer(), congestion_controller_->packet_router(), | 168 call_stats_->rtcp_rtt_stats(), congestion_controller_->pacer(), |
166 1, false)); | 169 congestion_controller_->packet_router(), 1, false)); |
167 | 170 |
168 RTC_CHECK(vie_channel_->Init() == 0); | 171 RTC_CHECK(vie_channel_->Init() == 0); |
169 | 172 |
170 // Register the channel to receive stats updates. | 173 // Register the channel to receive stats updates. |
171 call_stats_->RegisterStatsObserver(vie_channel_->GetStatsObserver()); | 174 call_stats_->RegisterStatsObserver(vie_channel_->GetStatsObserver()); |
172 | 175 |
173 // TODO(pbos): This is not fine grained enough... | 176 // TODO(pbos): This is not fine grained enough... |
174 vie_channel_->SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, | 177 vie_channel_->SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, |
175 -1, -1); | 178 -1, -1); |
176 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) | 179 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 280 |
278 incoming_video_stream_.reset(new IncomingVideoStream( | 281 incoming_video_stream_.reset(new IncomingVideoStream( |
279 0, config.renderer ? config.renderer->SmoothsRenderedFrames() : false)); | 282 0, config.renderer ? config.renderer->SmoothsRenderedFrames() : false)); |
280 incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms); | 283 incoming_video_stream_->SetExpectedRenderDelay(config.render_delay_ms); |
281 vie_channel_->SetExpectedRenderDelay(config.render_delay_ms); | 284 vie_channel_->SetExpectedRenderDelay(config.render_delay_ms); |
282 incoming_video_stream_->SetExternalCallback(this); | 285 incoming_video_stream_->SetExternalCallback(this); |
283 vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get()); | 286 vie_channel_->SetIncomingVideoStream(incoming_video_stream_.get()); |
284 | 287 |
285 vie_channel_->RegisterPreDecodeImageCallback(this); | 288 vie_channel_->RegisterPreDecodeImageCallback(this); |
286 vie_channel_->RegisterPreRenderCallback(this); | 289 vie_channel_->RegisterPreRenderCallback(this); |
| 290 |
| 291 process_thread_->RegisterModule(vcm_.get()); |
287 } | 292 } |
288 | 293 |
289 VideoReceiveStream::~VideoReceiveStream() { | 294 VideoReceiveStream::~VideoReceiveStream() { |
290 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 295 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
291 incoming_video_stream_->Stop(); | 296 incoming_video_stream_->Stop(); |
| 297 process_thread_->DeRegisterModule(vcm_.get()); |
292 vie_channel_->RegisterPreRenderCallback(nullptr); | 298 vie_channel_->RegisterPreRenderCallback(nullptr); |
293 vie_channel_->RegisterPreDecodeImageCallback(nullptr); | 299 vie_channel_->RegisterPreDecodeImageCallback(nullptr); |
294 | 300 |
295 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); | 301 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); |
296 congestion_controller_->SetChannelRembStatus(false, false, | 302 congestion_controller_->SetChannelRembStatus(false, false, |
297 vie_channel_->rtp_rtcp()); | 303 vie_channel_->rtp_rtcp()); |
298 | 304 |
299 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); | 305 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); |
300 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); | 306 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); |
301 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe)-> | 307 congestion_controller_->GetRemoteBitrateEstimator(send_side_bwe)-> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 return 0; | 386 return 0; |
381 } | 387 } |
382 | 388 |
383 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 389 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
384 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode | 390 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode |
385 : RtcpMode::kOff); | 391 : RtcpMode::kOff); |
386 } | 392 } |
387 | 393 |
388 } // namespace internal | 394 } // namespace internal |
389 } // namespace webrtc | 395 } // namespace webrtc |
OLD | NEW |