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_(num_cpu_cores, | 166 vie_channel_(num_cpu_cores, |
164 &transport_adapter_, | 167 &transport_adapter_, |
165 process_thread, | 168 process_thread, |
166 nullptr, | 169 nullptr, |
167 vcm_.get(), | 170 vcm_.get(), |
168 nullptr, | 171 nullptr, |
169 nullptr, | 172 nullptr, |
170 nullptr, | 173 nullptr, |
171 congestion_controller_->GetRemoteBitrateEstimator( | 174 congestion_controller_->GetRemoteBitrateEstimator( |
172 UseSendSideBwe(config_)), | 175 UseSendSideBwe(config_)), |
173 call_stats_->rtcp_rtt_stats(), | 176 call_stats_->rtcp_rtt_stats(), |
174 congestion_controller_->pacer(), | 177 congestion_controller_->pacer(), |
175 congestion_controller_->packet_router(), | 178 congestion_controller_->packet_router(), |
176 1, | 179 1, |
177 false) { | 180 false) { |
178 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 181 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
179 | 182 |
183 RTC_DCHECK(congestion_controller_); | |
the sun
2016/02/08 10:39:23
nit: process_thread missing
stefan-webrtc
2016/02/08 13:30:54
Done.
| |
184 RTC_DCHECK(call_stats_); | |
185 RTC_DCHECK(remb_); | |
180 RTC_CHECK(vie_channel_.Init() == 0); | 186 RTC_CHECK(vie_channel_.Init() == 0); |
181 | 187 |
182 // Register the channel to receive stats updates. | 188 // Register the channel to receive stats updates. |
183 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver()); | 189 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver()); |
184 | 190 |
185 // TODO(pbos): This is not fine grained enough... | 191 // TODO(pbos): This is not fine grained enough... |
186 vie_channel_.SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, | 192 vie_channel_.SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, |
187 -1, -1); | 193 -1, -1); |
188 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) | 194 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) |
189 << "A stream should not be configured with RTCP disabled. This value is " | 195 << "A stream should not be configured with RTCP disabled. This value is " |
(...skipping 13 matching lines...) Expand all Loading... | |
203 RTC_DCHECK(it->second.payload_type != 0); | 209 RTC_DCHECK(it->second.payload_type != 0); |
204 | 210 |
205 vie_channel_.SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); | 211 vie_channel_.SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); |
206 vie_channel_.SetRtxReceivePayloadType(it->second.payload_type, it->first); | 212 vie_channel_.SetRtxReceivePayloadType(it->second.payload_type, it->first); |
207 } | 213 } |
208 // TODO(holmer): When Chrome no longer depends on this being false by default, | 214 // TODO(holmer): When Chrome no longer depends on this being false by default, |
209 // always use the mapping and remove this whole codepath. | 215 // always use the mapping and remove this whole codepath. |
210 vie_channel_.SetUseRtxPayloadMappingOnRestore( | 216 vie_channel_.SetUseRtxPayloadMappingOnRestore( |
211 config_.rtp.use_rtx_payload_mapping_on_restore); | 217 config_.rtp.use_rtx_payload_mapping_on_restore); |
212 | 218 |
213 congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb, | 219 RtpRtcp* rtp_module = vie_channel_.rtp_rtcp(); |
214 vie_channel_.rtp_rtcp()); | 220 if (config_.rtp.remb) { |
221 rtp_module->SetREMBStatus(true); | |
222 remb_->AddReceiveChannel(rtp_module); | |
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_EQ(0, vie_channel_.SetReceiveTimestampOffsetStatus(true, id)); | 232 RTC_CHECK_EQ(0, vie_channel_.SetReceiveTimestampOffsetStatus(true, id)); |
224 } else if (extension == RtpExtension::kAbsSendTime) { | 233 } else if (extension == RtpExtension::kAbsSendTime) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 } | 304 } |
296 | 305 |
297 VideoReceiveStream::~VideoReceiveStream() { | 306 VideoReceiveStream::~VideoReceiveStream() { |
298 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 307 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
299 incoming_video_stream_.Stop(); | 308 incoming_video_stream_.Stop(); |
300 process_thread_->DeRegisterModule(vcm_.get()); | 309 process_thread_->DeRegisterModule(vcm_.get()); |
301 vie_channel_.RegisterPreRenderCallback(nullptr); | 310 vie_channel_.RegisterPreRenderCallback(nullptr); |
302 vie_channel_.RegisterPreDecodeImageCallback(nullptr); | 311 vie_channel_.RegisterPreDecodeImageCallback(nullptr); |
303 | 312 |
304 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); | 313 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); |
305 congestion_controller_->SetChannelRembStatus(false, false, | 314 |
306 vie_channel_.rtp_rtcp()); | 315 RtpRtcp* rtp_module = vie_channel_.rtp_rtcp(); |
316 rtp_module->SetREMBStatus(false); | |
317 remb_->RemoveReceiveChannel(rtp_module); | |
307 | 318 |
308 uint32_t remote_ssrc = vie_channel_.GetRemoteSSRC(); | 319 uint32_t remote_ssrc = vie_channel_.GetRemoteSSRC(); |
309 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) | 320 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) |
310 ->RemoveStream(remote_ssrc); | 321 ->RemoveStream(remote_ssrc); |
311 } | 322 } |
312 | 323 |
313 void VideoReceiveStream::Start() { | 324 void VideoReceiveStream::Start() { |
314 transport_adapter_.Enable(); | 325 transport_adapter_.Enable(); |
315 incoming_video_stream_.Start(); | 326 incoming_video_stream_.Start(); |
316 vie_channel_.StartReceive(); | 327 vie_channel_.StartReceive(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 return 0; | 399 return 0; |
389 } | 400 } |
390 | 401 |
391 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 402 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
392 vie_channel_.SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode | 403 vie_channel_.SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode |
393 : RtcpMode::kOff); | 404 : RtcpMode::kOff); |
394 } | 405 } |
395 | 406 |
396 } // namespace internal | 407 } // namespace internal |
397 } // namespace webrtc | 408 } // namespace webrtc |
OLD | NEW |