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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 congestion_controller_->GetRetransmissionRateLimiter()), | 210 congestion_controller_->GetRetransmissionRateLimiter()), |
211 rtp_stream_sync_(&video_receiver_, &rtp_stream_receiver_) { | 211 rtp_stream_sync_(&video_receiver_, &rtp_stream_receiver_) { |
212 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 212 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
213 | 213 |
214 RTC_DCHECK(process_thread_); | 214 RTC_DCHECK(process_thread_); |
215 RTC_DCHECK(congestion_controller_); | 215 RTC_DCHECK(congestion_controller_); |
216 RTC_DCHECK(call_stats_); | 216 RTC_DCHECK(call_stats_); |
217 | 217 |
218 RTC_DCHECK(!config_.decoders.empty()); | 218 RTC_DCHECK(!config_.decoders.empty()); |
219 std::set<int> decoder_payload_types; | 219 std::set<int> decoder_payload_types; |
220 for (const Decoder& decoder : config_.decoders) { | 220 for (const Decoder& decoder : config_.decoders) { |
tommi
2016/10/07 19:45:40
should this loop be moved into Start()? As is, we
mflodman
2016/10/09 09:22:26
Yes, agree that should be done. Good catch Tommi!
| |
221 RTC_CHECK(decoder.decoder); | 221 RTC_CHECK(decoder.decoder); |
222 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == | 222 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == |
223 decoder_payload_types.end()) | 223 decoder_payload_types.end()) |
224 << "Duplicate payload type (" << decoder.payload_type | 224 << "Duplicate payload type (" << decoder.payload_type |
225 << ") for different decoders."; | 225 << ") for different decoders."; |
226 decoder_payload_types.insert(decoder.payload_type); | 226 decoder_payload_types.insert(decoder.payload_type); |
227 video_receiver_.RegisterExternalDecoder(decoder.decoder, | 227 video_receiver_.RegisterExternalDecoder(decoder.decoder, |
228 decoder.payload_type); | 228 decoder.payload_type); |
229 | 229 |
230 VideoCodec codec = CreateDecoderVideoCodec(decoder); | 230 VideoCodec codec = CreateDecoderVideoCodec(decoder); |
231 RTC_CHECK(rtp_stream_receiver_.SetReceiveCodec(codec)); | 231 RTC_CHECK(rtp_stream_receiver_.SetReceiveCodec(codec)); |
232 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec( | 232 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec( |
233 &codec, num_cpu_cores, false)); | 233 &codec, num_cpu_cores, false)); |
234 } | 234 } |
235 | 235 |
236 video_receiver_.SetRenderDelay(config.render_delay_ms); | 236 video_receiver_.SetRenderDelay(config.render_delay_ms); |
237 | 237 |
238 process_thread_->RegisterModule(&video_receiver_); | 238 process_thread_->RegisterModule(&video_receiver_); |
239 process_thread_->RegisterModule(&rtp_stream_sync_); | 239 process_thread_->RegisterModule(&rtp_stream_sync_); |
240 } | 240 } |
241 | 241 |
242 VideoReceiveStream::~VideoReceiveStream() { | 242 VideoReceiveStream::~VideoReceiveStream() { |
243 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 243 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
244 Stop(); | 244 Stop(); |
245 | 245 |
246 process_thread_->DeRegisterModule(&rtp_stream_sync_); | 246 process_thread_->DeRegisterModule(&rtp_stream_sync_); |
247 process_thread_->DeRegisterModule(&video_receiver_); | 247 process_thread_->DeRegisterModule(&video_receiver_); |
248 | 248 |
249 // Deregister external decoders so they are no longer running during | |
250 // destruction. This effectively stops the VCM since the decoder thread is | |
251 // stopped, the VCM is deregistered and no asynchronous decoder threads are | |
252 // running. | |
253 for (const Decoder& decoder : config_.decoders) | |
254 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); | |
255 | |
256 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) | 249 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) |
257 ->RemoveStream(rtp_stream_receiver_.GetRemoteSsrc()); | 250 ->RemoveStream(rtp_stream_receiver_.GetRemoteSsrc()); |
258 } | 251 } |
259 | 252 |
260 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 253 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
261 rtp_stream_receiver_.SignalNetworkState(state); | 254 rtp_stream_receiver_.SignalNetworkState(state); |
262 } | 255 } |
263 | 256 |
264 | 257 |
265 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 258 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 decode_thread_.SetPriority(rtc::kHighestPriority); | 293 decode_thread_.SetPriority(rtc::kHighestPriority); |
301 rtp_stream_receiver_.StartReceive(); | 294 rtp_stream_receiver_.StartReceive(); |
302 } | 295 } |
303 | 296 |
304 void VideoReceiveStream::Stop() { | 297 void VideoReceiveStream::Stop() { |
305 rtp_stream_receiver_.StopReceive(); | 298 rtp_stream_receiver_.StopReceive(); |
306 // TriggerDecoderShutdown will release any waiting decoder thread and make it | 299 // TriggerDecoderShutdown will release any waiting decoder thread and make it |
307 // stop immediately, instead of waiting for a timeout. Needs to be called | 300 // stop immediately, instead of waiting for a timeout. Needs to be called |
308 // before joining the decoder thread thread. | 301 // before joining the decoder thread thread. |
309 video_receiver_.TriggerDecoderShutdown(); | 302 video_receiver_.TriggerDecoderShutdown(); |
310 decode_thread_.Stop(); | 303 if (decode_thread_.IsRunning()) { |
304 decode_thread_.Stop(); | |
305 // Deregister external decoders so they are no longer running during | |
306 // destruction. This effectively stops the VCM since the decoder thread is | |
307 // stopped, the VCM is deregistered and no asynchronous decoder threads are | |
308 // running. | |
309 for (const Decoder& decoder : config_.decoders) | |
310 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); | |
311 } | |
311 call_stats_->DeregisterStatsObserver(video_stream_decoder_.get()); | 312 call_stats_->DeregisterStatsObserver(video_stream_decoder_.get()); |
312 video_stream_decoder_.reset(); | 313 video_stream_decoder_.reset(); |
313 incoming_video_stream_.reset(); | 314 incoming_video_stream_.reset(); |
314 transport_adapter_.Disable(); | 315 transport_adapter_.Disable(); |
315 } | 316 } |
316 | 317 |
317 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, | 318 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, |
318 int audio_channel_id) { | 319 int audio_channel_id) { |
319 if (voice_engine && audio_channel_id != -1) { | 320 if (voice_engine && audio_channel_id != -1) { |
320 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); | 321 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 RequestKeyFrame(); | 410 RequestKeyFrame(); |
410 } | 411 } |
411 } | 412 } |
412 | 413 |
413 void VideoReceiveStream::RequestKeyFrame() { | 414 void VideoReceiveStream::RequestKeyFrame() { |
414 rtp_stream_receiver_.RequestKeyFrame(); | 415 rtp_stream_receiver_.RequestKeyFrame(); |
415 } | 416 } |
416 | 417 |
417 } // namespace internal | 418 } // namespace internal |
418 } // namespace webrtc | 419 } // namespace webrtc |
OLD | NEW |