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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 remb_(remb), | 164 remb_(remb), |
165 video_receiver_(clock_, nullptr, this, this, this), | 165 video_receiver_(clock_, nullptr, this, this, this), |
166 incoming_video_stream_(config.disable_prerenderer_smoothing), | 166 incoming_video_stream_(config.disable_prerenderer_smoothing), |
167 stats_proxy_(config_, clock_), | 167 stats_proxy_(config_, clock_), |
168 rtp_stream_receiver_(&video_receiver_, | 168 rtp_stream_receiver_(&video_receiver_, |
169 congestion_controller_->GetRemoteBitrateEstimator( | 169 congestion_controller_->GetRemoteBitrateEstimator( |
170 UseSendSideBwe(config_)), | 170 UseSendSideBwe(config_)), |
171 &transport_adapter_, | 171 &transport_adapter_, |
172 call_stats_->rtcp_rtt_stats(), | 172 call_stats_->rtcp_rtt_stats(), |
173 congestion_controller_->pacer(), | 173 congestion_controller_->pacer(), |
174 congestion_controller_->packet_router()), | 174 congestion_controller_->packet_router(), |
175 vie_channel_(&video_receiver_, | 175 config, |
176 &rtp_stream_receiver_), | 176 &stats_proxy_), |
| 177 video_stream_decoder_(&video_receiver_, |
| 178 &rtp_stream_receiver_, |
| 179 &rtp_stream_receiver_, |
| 180 config.rtp.nack.rtp_history_ms > 0, |
| 181 &stats_proxy_, |
| 182 &incoming_video_stream_, |
| 183 this), |
177 vie_sync_(&video_receiver_), | 184 vie_sync_(&video_receiver_), |
178 rtp_rtcp_(vie_channel_.rtp_rtcp()) { | 185 rtp_rtcp_(rtp_stream_receiver_.rtp_rtcp()) { |
179 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 186 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
180 | 187 |
181 RTC_DCHECK(process_thread_); | 188 RTC_DCHECK(process_thread_); |
182 RTC_DCHECK(congestion_controller_); | 189 RTC_DCHECK(congestion_controller_); |
183 RTC_DCHECK(call_stats_); | 190 RTC_DCHECK(call_stats_); |
184 RTC_DCHECK(remb_); | 191 RTC_DCHECK(remb_); |
185 RTC_CHECK(vie_channel_.Init() == 0); | |
186 | |
187 // Register the channel to receive stats updates. | |
188 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver()); | |
189 | |
190 // TODO(pbos): This is not fine grained enough... | |
191 vie_channel_.SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, -1, | |
192 -1); | |
193 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) | 192 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) |
194 << "A stream should not be configured with RTCP disabled. This value is " | 193 << "A stream should not be configured with RTCP disabled. This value is " |
195 "reserved for internal usage."; | 194 "reserved for internal usage."; |
196 rtp_rtcp_->SetRTCPStatus(config_.rtp.rtcp_mode); | 195 |
| 196 // Register the channel to receive stats updates. |
| 197 call_stats_->RegisterStatsObserver(&video_stream_decoder_); |
197 | 198 |
198 RTC_DCHECK(config_.rtp.remote_ssrc != 0); | 199 RTC_DCHECK(config_.rtp.remote_ssrc != 0); |
199 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? | 200 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? |
200 RTC_DCHECK(config_.rtp.local_ssrc != 0); | 201 RTC_DCHECK(config_.rtp.local_ssrc != 0); |
201 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); | 202 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); |
202 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc); | 203 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc); |
203 | 204 |
204 // TODO(pbos): Support multiple RTX, per video payload. | 205 // TODO(pbos): Support multiple RTX, per video payload. |
205 for (const auto& kv : config_.rtp.rtx) { | 206 for (const auto& kv : config_.rtp.rtx) { |
206 RTC_DCHECK(kv.second.ssrc != 0); | 207 RTC_DCHECK(kv.second.ssrc != 0); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 if (config_.rtp.fec.red_rtx_payload_type != -1) { | 249 if (config_.rtp.fec.red_rtx_payload_type != -1) { |
249 rtp_stream_receiver_.SetRtxPayloadType( | 250 rtp_stream_receiver_.SetRtxPayloadType( |
250 config_.rtp.fec.red_rtx_payload_type, | 251 config_.rtp.fec.red_rtx_payload_type, |
251 config_.rtp.fec.red_payload_type); | 252 config_.rtp.fec.red_payload_type); |
252 } | 253 } |
253 } | 254 } |
254 | 255 |
255 if (config.rtp.rtcp_xr.receiver_reference_time_report) | 256 if (config.rtp.rtcp_xr.receiver_reference_time_report) |
256 rtp_rtcp_->SetRtcpXrRrtrStatus(true); | 257 rtp_rtcp_->SetRtcpXrRrtrStatus(true); |
257 | 258 |
258 vie_channel_.RegisterReceiveStatisticsProxy(&stats_proxy_); | |
259 rtp_stream_receiver_.GetReceiveStatistics()->RegisterRtpStatisticsCallback( | |
260 &stats_proxy_); | |
261 rtp_stream_receiver_.GetReceiveStatistics()->RegisterRtcpStatisticsCallback( | |
262 &stats_proxy_); | |
263 // Stats callback for CNAME changes. | 259 // Stats callback for CNAME changes. |
264 rtp_rtcp_->RegisterRtcpStatisticsCallback(&stats_proxy_); | 260 rtp_rtcp_->RegisterRtcpStatisticsCallback(&stats_proxy_); |
265 vie_channel_.RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); | |
266 | 261 |
267 RTC_DCHECK(!config_.decoders.empty()); | 262 RTC_DCHECK(!config_.decoders.empty()); |
268 std::set<int> decoder_payload_types; | 263 std::set<int> decoder_payload_types; |
269 for (const Decoder& decoder : config_.decoders) { | 264 for (const Decoder& decoder : config_.decoders) { |
270 RTC_CHECK(decoder.decoder); | 265 RTC_CHECK(decoder.decoder); |
271 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == | 266 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == |
272 decoder_payload_types.end()) | 267 decoder_payload_types.end()) |
273 << "Duplicate payload type (" << decoder.payload_type | 268 << "Duplicate payload type (" << decoder.payload_type |
274 << ") for different decoders."; | 269 << ") for different decoders."; |
275 decoder_payload_types.insert(decoder.payload_type); | 270 decoder_payload_types.insert(decoder.payload_type); |
276 video_receiver_.RegisterExternalDecoder(decoder.decoder, | 271 video_receiver_.RegisterExternalDecoder(decoder.decoder, |
277 decoder.payload_type); | 272 decoder.payload_type); |
278 | 273 |
279 VideoCodec codec = CreateDecoderVideoCodec(decoder); | 274 VideoCodec codec = CreateDecoderVideoCodec(decoder); |
280 | 275 |
281 RTC_CHECK(rtp_stream_receiver_.SetReceiveCodec(codec)); | 276 RTC_CHECK(rtp_stream_receiver_.SetReceiveCodec(codec)); |
282 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec( | 277 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec( |
283 &codec, num_cpu_cores, false)); | 278 &codec, num_cpu_cores, false)); |
284 } | 279 } |
285 | 280 |
286 video_receiver_.SetRenderDelay(config.render_delay_ms); | 281 video_receiver_.SetRenderDelay(config.render_delay_ms); |
287 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms); | 282 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms); |
288 incoming_video_stream_.SetExternalCallback(this); | 283 incoming_video_stream_.SetExternalCallback(this); |
289 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_); | |
290 vie_channel_.RegisterPreRenderCallback(this); | |
291 | 284 |
292 process_thread_->RegisterModule(rtp_stream_receiver_.GetReceiveStatistics()); | 285 process_thread_->RegisterModule(rtp_stream_receiver_.GetReceiveStatistics()); |
293 process_thread_->RegisterModule(rtp_stream_receiver_.rtp_rtcp()); | 286 process_thread_->RegisterModule(rtp_stream_receiver_.rtp_rtcp()); |
294 process_thread_->RegisterModule(&video_receiver_); | 287 process_thread_->RegisterModule(&video_receiver_); |
295 process_thread_->RegisterModule(&vie_sync_); | 288 process_thread_->RegisterModule(&vie_sync_); |
296 } | 289 } |
297 | 290 |
298 VideoReceiveStream::~VideoReceiveStream() { | 291 VideoReceiveStream::~VideoReceiveStream() { |
299 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 292 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
300 Stop(); | 293 Stop(); |
301 | 294 |
302 process_thread_->DeRegisterModule(&vie_sync_); | 295 process_thread_->DeRegisterModule(&vie_sync_); |
303 process_thread_->DeRegisterModule(&video_receiver_); | 296 process_thread_->DeRegisterModule(&video_receiver_); |
304 process_thread_->DeRegisterModule(rtp_stream_receiver_.rtp_rtcp()); | 297 process_thread_->DeRegisterModule(rtp_stream_receiver_.rtp_rtcp()); |
305 process_thread_->DeRegisterModule( | 298 process_thread_->DeRegisterModule( |
306 rtp_stream_receiver_.GetReceiveStatistics()); | 299 rtp_stream_receiver_.GetReceiveStatistics()); |
307 | 300 |
308 // Deregister external decoders so that they are no longer running during | 301 // Deregister external decoders so they are no longer running during |
309 // destruction. This effectively stops the VCM since the decoder thread is | 302 // destruction. This effectively stops the VCM since the decoder thread is |
310 // stopped, the VCM is deregistered and no asynchronous decoder threads are | 303 // stopped, the VCM is deregistered and no asynchronous decoder threads are |
311 // running. | 304 // running. |
312 for (const Decoder& decoder : config_.decoders) | 305 for (const Decoder& decoder : config_.decoders) |
313 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); | 306 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); |
314 | 307 |
315 vie_channel_.RegisterPreRenderCallback(nullptr); | 308 call_stats_->DeregisterStatsObserver(&video_stream_decoder_); |
316 | |
317 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); | |
318 rtp_rtcp_->SetREMBStatus(false); | 309 rtp_rtcp_->SetREMBStatus(false); |
319 remb_->RemoveReceiveChannel(rtp_rtcp_); | 310 remb_->RemoveReceiveChannel(rtp_rtcp_); |
320 | 311 |
321 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) | 312 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) |
322 ->RemoveStream(rtp_stream_receiver_.GetRemoteSsrc()); | 313 ->RemoveStream(rtp_stream_receiver_.GetRemoteSsrc()); |
323 } | 314 } |
324 | 315 |
325 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 316 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
326 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode | 317 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode |
327 : RtcpMode::kOff); | 318 : RtcpMode::kOff); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 const std::vector<uint16_t>& sequence_numbers) { | 429 const std::vector<uint16_t>& sequence_numbers) { |
439 rtp_rtcp_->SendNack(sequence_numbers); | 430 rtp_rtcp_->SendNack(sequence_numbers); |
440 } | 431 } |
441 | 432 |
442 void VideoReceiveStream::RequestKeyFrame() { | 433 void VideoReceiveStream::RequestKeyFrame() { |
443 rtp_rtcp_->RequestKeyFrame(); | 434 rtp_rtcp_->RequestKeyFrame(); |
444 } | 435 } |
445 | 436 |
446 } // namespace internal | 437 } // namespace internal |
447 } // namespace webrtc | 438 } // namespace webrtc |
OLD | NEW |