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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 VieRemb* remb) | 155 VieRemb* remb) |
156 : transport_adapter_(config.rtcp_send_transport), | 156 : transport_adapter_(config.rtcp_send_transport), |
157 encoded_frame_proxy_(config.pre_decode_callback), | 157 encoded_frame_proxy_(config.pre_decode_callback), |
158 config_(config), | 158 config_(config), |
159 process_thread_(process_thread), | 159 process_thread_(process_thread), |
160 clock_(Clock::GetRealTimeClock()), | 160 clock_(Clock::GetRealTimeClock()), |
161 decode_thread_(DecodeThreadFunction, this, "DecodingThread"), | 161 decode_thread_(DecodeThreadFunction, this, "DecodingThread"), |
162 congestion_controller_(congestion_controller), | 162 congestion_controller_(congestion_controller), |
163 call_stats_(call_stats), | 163 call_stats_(call_stats), |
164 remb_(remb), | 164 remb_(remb), |
165 vcm_(VideoCodingModule::Create(clock_, | 165 video_receiver_(clock_, nullptr, this, this, this), |
166 nullptr, | |
167 nullptr, | |
168 this, | |
169 this, | |
170 this)), | |
171 incoming_video_stream_(0, config.disable_prerenderer_smoothing), | 166 incoming_video_stream_(0, config.disable_prerenderer_smoothing), |
172 stats_proxy_(config_, clock_), | 167 stats_proxy_(config_, clock_), |
173 vie_channel_(&transport_adapter_, | 168 vie_channel_(&transport_adapter_, |
174 process_thread, | 169 process_thread, |
175 vcm_.get(), | 170 &video_receiver_, |
176 congestion_controller_->GetRemoteBitrateEstimator( | 171 congestion_controller_->GetRemoteBitrateEstimator( |
177 UseSendSideBwe(config_)), | 172 UseSendSideBwe(config_)), |
178 call_stats_->rtcp_rtt_stats(), | 173 call_stats_->rtcp_rtt_stats(), |
179 congestion_controller_->pacer(), | 174 congestion_controller_->pacer(), |
180 congestion_controller_->packet_router()), | 175 congestion_controller_->packet_router()), |
181 vie_receiver_(vie_channel_.vie_receiver()), | 176 vie_receiver_(vie_channel_.vie_receiver()), |
182 vie_sync_(vcm_.get()), | 177 vie_sync_(&video_receiver_), |
183 rtp_rtcp_(vie_channel_.rtp_rtcp()) { | 178 rtp_rtcp_(vie_channel_.rtp_rtcp()) { |
184 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 179 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
185 | 180 |
186 RTC_DCHECK(process_thread_); | 181 RTC_DCHECK(process_thread_); |
187 RTC_DCHECK(congestion_controller_); | 182 RTC_DCHECK(congestion_controller_); |
188 RTC_DCHECK(call_stats_); | 183 RTC_DCHECK(call_stats_); |
189 RTC_DCHECK(remb_); | 184 RTC_DCHECK(remb_); |
190 RTC_CHECK(vie_channel_.Init() == 0); | 185 RTC_CHECK(vie_channel_.Init() == 0); |
191 | 186 |
192 // Register the channel to receive stats updates. | 187 // Register the channel to receive stats updates. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 265 |
271 RTC_DCHECK(!config_.decoders.empty()); | 266 RTC_DCHECK(!config_.decoders.empty()); |
272 std::set<int> decoder_payload_types; | 267 std::set<int> decoder_payload_types; |
273 for (const Decoder& decoder : config_.decoders) { | 268 for (const Decoder& decoder : config_.decoders) { |
274 RTC_CHECK(decoder.decoder); | 269 RTC_CHECK(decoder.decoder); |
275 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == | 270 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == |
276 decoder_payload_types.end()) | 271 decoder_payload_types.end()) |
277 << "Duplicate payload type (" << decoder.payload_type | 272 << "Duplicate payload type (" << decoder.payload_type |
278 << ") for different decoders."; | 273 << ") for different decoders."; |
279 decoder_payload_types.insert(decoder.payload_type); | 274 decoder_payload_types.insert(decoder.payload_type); |
280 vcm_->RegisterExternalDecoder(decoder.decoder, decoder.payload_type); | 275 video_receiver_.RegisterExternalDecoder(decoder.decoder, |
| 276 decoder.payload_type); |
281 | 277 |
282 VideoCodec codec = CreateDecoderVideoCodec(decoder); | 278 VideoCodec codec = CreateDecoderVideoCodec(decoder); |
283 | 279 |
284 RTC_CHECK(vie_receiver_->SetReceiveCodec(codec)); | 280 RTC_CHECK(vie_receiver_->SetReceiveCodec(codec)); |
285 RTC_CHECK_EQ(VCM_OK, | 281 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec( |
286 vcm_->RegisterReceiveCodec(&codec, num_cpu_cores, false)); | 282 &codec, num_cpu_cores, false)); |
287 } | 283 } |
288 | 284 |
289 vcm_->SetRenderDelay(config.render_delay_ms); | 285 video_receiver_.SetRenderDelay(config.render_delay_ms); |
290 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms); | 286 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms); |
291 incoming_video_stream_.SetExternalCallback(this); | 287 incoming_video_stream_.SetExternalCallback(this); |
292 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_); | 288 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_); |
293 vie_channel_.RegisterPreRenderCallback(this); | 289 vie_channel_.RegisterPreRenderCallback(this); |
294 | 290 |
295 process_thread_->RegisterModule(vcm_.get()); | 291 process_thread_->RegisterModule(&video_receiver_); |
296 process_thread_->RegisterModule(&vie_sync_); | 292 process_thread_->RegisterModule(&vie_sync_); |
297 } | 293 } |
298 | 294 |
299 VideoReceiveStream::~VideoReceiveStream() { | 295 VideoReceiveStream::~VideoReceiveStream() { |
300 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 296 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
301 Stop(); | 297 Stop(); |
302 | 298 |
303 process_thread_->DeRegisterModule(&vie_sync_); | 299 process_thread_->DeRegisterModule(&vie_sync_); |
304 process_thread_->DeRegisterModule(vcm_.get()); | 300 process_thread_->DeRegisterModule(&video_receiver_); |
305 | 301 |
306 // Deregister external decoders so that they are no longer running during | 302 // Deregister external decoders so that they are no longer running during |
307 // destruction. This effectively stops the VCM since the decoder thread is | 303 // destruction. This effectively stops the VCM since the decoder thread is |
308 // stopped, the VCM is deregistered and no asynchronous decoder threads are | 304 // stopped, the VCM is deregistered and no asynchronous decoder threads are |
309 // running. | 305 // running. |
310 for (const Decoder& decoder : config_.decoders) | 306 for (const Decoder& decoder : config_.decoders) |
311 vcm_->RegisterExternalDecoder(nullptr, decoder.payload_type); | 307 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); |
312 | 308 |
313 vie_channel_.RegisterPreRenderCallback(nullptr); | 309 vie_channel_.RegisterPreRenderCallback(nullptr); |
314 | 310 |
315 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); | 311 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); |
316 rtp_rtcp_->SetREMBStatus(false); | 312 rtp_rtcp_->SetREMBStatus(false); |
317 remb_->RemoveReceiveChannel(rtp_rtcp_); | 313 remb_->RemoveReceiveChannel(rtp_rtcp_); |
318 | 314 |
319 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) | 315 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) |
320 ->RemoveStream(vie_receiver_->GetRemoteSsrc()); | 316 ->RemoveStream(vie_receiver_->GetRemoteSsrc()); |
321 } | 317 } |
322 | 318 |
323 void VideoReceiveStream::Start() { | 319 void VideoReceiveStream::Start() { |
324 if (decode_thread_.IsRunning()) | 320 if (decode_thread_.IsRunning()) |
325 return; | 321 return; |
326 transport_adapter_.Enable(); | 322 transport_adapter_.Enable(); |
327 incoming_video_stream_.Start(); | 323 incoming_video_stream_.Start(); |
328 // Start the decode thread | 324 // Start the decode thread |
329 decode_thread_.Start(); | 325 decode_thread_.Start(); |
330 decode_thread_.SetPriority(rtc::kHighestPriority); | 326 decode_thread_.SetPriority(rtc::kHighestPriority); |
331 vie_receiver_->StartReceive(); | 327 vie_receiver_->StartReceive(); |
332 } | 328 } |
333 | 329 |
334 void VideoReceiveStream::Stop() { | 330 void VideoReceiveStream::Stop() { |
335 incoming_video_stream_.Stop(); | 331 incoming_video_stream_.Stop(); |
336 vie_receiver_->StopReceive(); | 332 vie_receiver_->StopReceive(); |
337 vcm_->TriggerDecoderShutdown(); | 333 video_receiver_.TriggerDecoderShutdown(); |
338 decode_thread_.Stop(); | 334 decode_thread_.Stop(); |
339 transport_adapter_.Disable(); | 335 transport_adapter_.Disable(); |
340 } | 336 } |
341 | 337 |
342 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, | 338 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, |
343 int audio_channel_id) { | 339 int audio_channel_id) { |
344 if (voice_engine && audio_channel_id != -1) { | 340 if (voice_engine && audio_channel_id != -1) { |
345 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); | 341 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); |
346 vie_sync_.ConfigureSync(audio_channel_id, voe_sync_interface, rtp_rtcp_, | 342 vie_sync_.ConfigureSync(audio_channel_id, voe_sync_interface, rtp_rtcp_, |
347 vie_receiver_->GetRtpReceiver()); | 343 vie_receiver_->GetRtpReceiver()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 : RtcpMode::kOff); | 420 : RtcpMode::kOff); |
425 } | 421 } |
426 | 422 |
427 bool VideoReceiveStream::DecodeThreadFunction(void* ptr) { | 423 bool VideoReceiveStream::DecodeThreadFunction(void* ptr) { |
428 static_cast<VideoReceiveStream*>(ptr)->Decode(); | 424 static_cast<VideoReceiveStream*>(ptr)->Decode(); |
429 return true; | 425 return true; |
430 } | 426 } |
431 | 427 |
432 void VideoReceiveStream::Decode() { | 428 void VideoReceiveStream::Decode() { |
433 static const int kMaxDecodeWaitTimeMs = 50; | 429 static const int kMaxDecodeWaitTimeMs = 50; |
434 vcm_->Decode(kMaxDecodeWaitTimeMs); | 430 video_receiver_.Decode(kMaxDecodeWaitTimeMs); |
435 } | 431 } |
436 | 432 |
437 void VideoReceiveStream::SendNack( | 433 void VideoReceiveStream::SendNack( |
438 const std::vector<uint16_t>& sequence_numbers) { | 434 const std::vector<uint16_t>& sequence_numbers) { |
439 rtp_rtcp_->SendNack(sequence_numbers); | 435 rtp_rtcp_->SendNack(sequence_numbers); |
440 } | 436 } |
441 | 437 |
442 void VideoReceiveStream::RequestKeyFrame() { | 438 void VideoReceiveStream::RequestKeyFrame() { |
443 rtp_rtcp_->RequestKeyFrame(); | 439 rtp_rtcp_->RequestKeyFrame(); |
444 } | 440 } |
445 | 441 |
446 } // namespace internal | 442 } // namespace internal |
447 } // namespace webrtc | 443 } // namespace webrtc |
OLD | NEW |