Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: webrtc/video/video_receive_stream.cc

Issue 2997853002: Change ThreadChecker to SequencedTaskChecker in VideoReceiveStream (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 this, // NackSender 198 this, // NackSender
199 this, // KeyFrameRequestSender 199 this, // KeyFrameRequestSender
200 this, // OnCompleteFrameCallback 200 this, // OnCompleteFrameCallback
201 timing_.get()), 201 timing_.get()),
202 rtp_stream_sync_(this) { 202 rtp_stream_sync_(this) {
203 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); 203 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString();
204 204
205 RTC_DCHECK(process_thread_); 205 RTC_DCHECK(process_thread_);
206 RTC_DCHECK(call_stats_); 206 RTC_DCHECK(call_stats_);
207 207
208 module_process_thread_checker_.DetachFromThread(); 208 module_process_sequence_checker_.Detach();
209 209
210 RTC_DCHECK(!config_.decoders.empty()); 210 RTC_DCHECK(!config_.decoders.empty());
211 std::set<int> decoder_payload_types; 211 std::set<int> decoder_payload_types;
212 for (const Decoder& decoder : config_.decoders) { 212 for (const Decoder& decoder : config_.decoders) {
213 RTC_CHECK(decoder.decoder); 213 RTC_CHECK(decoder.decoder);
214 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == 214 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) ==
215 decoder_payload_types.end()) 215 decoder_payload_types.end())
216 << "Duplicate payload type (" << decoder.payload_type 216 << "Duplicate payload type (" << decoder.payload_type
217 << ") for different decoders."; 217 << ") for different decoders.";
218 decoder_payload_types.insert(decoder.payload_type); 218 decoder_payload_types.insert(decoder.payload_type);
(...skipping 10 matching lines...) Expand all
229 // Register with RtpStreamReceiverController. 229 // Register with RtpStreamReceiverController.
230 media_receiver_ = receiver_controller->CreateReceiver( 230 media_receiver_ = receiver_controller->CreateReceiver(
231 config_.rtp.remote_ssrc, &rtp_video_stream_receiver_); 231 config_.rtp.remote_ssrc, &rtp_video_stream_receiver_);
232 if (config.rtp.rtx_ssrc) { 232 if (config.rtp.rtx_ssrc) {
233 rtx_receiver_ = receiver_controller->CreateReceiver( 233 rtx_receiver_ = receiver_controller->CreateReceiver(
234 config_.rtp.rtx_ssrc, &rtp_video_stream_receiver_); 234 config_.rtp.rtx_ssrc, &rtp_video_stream_receiver_);
235 } 235 }
236 } 236 }
237 237
238 VideoReceiveStream::~VideoReceiveStream() { 238 VideoReceiveStream::~VideoReceiveStream() {
239 RTC_DCHECK_RUN_ON(&worker_thread_checker_); 239 RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_);
240 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); 240 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString();
241 Stop(); 241 Stop();
242 242
243 process_thread_->DeRegisterModule(&rtp_stream_sync_); 243 process_thread_->DeRegisterModule(&rtp_stream_sync_);
244 } 244 }
245 245
246 void VideoReceiveStream::SignalNetworkState(NetworkState state) { 246 void VideoReceiveStream::SignalNetworkState(NetworkState state) {
247 RTC_DCHECK_RUN_ON(&worker_thread_checker_); 247 RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_);
248 rtp_video_stream_receiver_.SignalNetworkState(state); 248 rtp_video_stream_receiver_.SignalNetworkState(state);
249 } 249 }
250 250
251 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { 251 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
252 return rtp_video_stream_receiver_.DeliverRtcp(packet, length); 252 return rtp_video_stream_receiver_.DeliverRtcp(packet, length);
253 } 253 }
254 254
255 void VideoReceiveStream::SetSync(Syncable* audio_syncable) { 255 void VideoReceiveStream::SetSync(Syncable* audio_syncable) {
256 RTC_DCHECK_RUN_ON(&worker_thread_checker_); 256 RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_);
257 rtp_stream_sync_.ConfigureSync(audio_syncable); 257 rtp_stream_sync_.ConfigureSync(audio_syncable);
258 } 258 }
259 259
260 void VideoReceiveStream::Start() { 260 void VideoReceiveStream::Start() {
261 RTC_DCHECK_RUN_ON(&worker_thread_checker_); 261 RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_);
262 if (decode_thread_.IsRunning()) 262 if (decode_thread_.IsRunning())
263 return; 263 return;
264 264
265 bool protected_by_fec = config_.rtp.protected_by_flexfec || 265 bool protected_by_fec = config_.rtp.protected_by_flexfec ||
266 rtp_video_stream_receiver_.IsUlpfecEnabled(); 266 rtp_video_stream_receiver_.IsUlpfecEnabled();
267 267
268 frame_buffer_->Start(); 268 frame_buffer_->Start();
269 call_stats_->RegisterStatsObserver(&rtp_video_stream_receiver_); 269 call_stats_->RegisterStatsObserver(&rtp_video_stream_receiver_);
270 call_stats_->RegisterStatsObserver(this); 270 call_stats_->RegisterStatsObserver(this);
271 271
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 call_stats_->RegisterStatsObserver(video_stream_decoder_.get()); 306 call_stats_->RegisterStatsObserver(video_stream_decoder_.get());
307 307
308 process_thread_->RegisterModule(&video_receiver_, RTC_FROM_HERE); 308 process_thread_->RegisterModule(&video_receiver_, RTC_FROM_HERE);
309 309
310 // Start the decode thread 310 // Start the decode thread
311 decode_thread_.Start(); 311 decode_thread_.Start();
312 rtp_video_stream_receiver_.StartReceive(); 312 rtp_video_stream_receiver_.StartReceive();
313 } 313 }
314 314
315 void VideoReceiveStream::Stop() { 315 void VideoReceiveStream::Stop() {
316 RTC_DCHECK_RUN_ON(&worker_thread_checker_); 316 RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_);
317 rtp_video_stream_receiver_.StopReceive(); 317 rtp_video_stream_receiver_.StopReceive();
318 318
319 frame_buffer_->Stop(); 319 frame_buffer_->Stop();
320 call_stats_->DeregisterStatsObserver(this); 320 call_stats_->DeregisterStatsObserver(this);
321 call_stats_->DeregisterStatsObserver(&rtp_video_stream_receiver_); 321 call_stats_->DeregisterStatsObserver(&rtp_video_stream_receiver_);
322 process_thread_->DeRegisterModule(&video_receiver_); 322 process_thread_->DeRegisterModule(&video_receiver_);
323 323
324 if (decode_thread_.IsRunning()) { 324 if (decode_thread_.IsRunning()) {
325 // TriggerDecoderShutdown will release any waiting decoder thread and make 325 // TriggerDecoderShutdown will release any waiting decoder thread and make
326 // it stop immediately, instead of waiting for a timeout. Needs to be called 326 // it stop immediately, instead of waiting for a timeout. Needs to be called
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 int last_continuous_pid = frame_buffer_->InsertFrame(std::move(frame)); 443 int last_continuous_pid = frame_buffer_->InsertFrame(std::move(frame));
444 if (last_continuous_pid != -1) 444 if (last_continuous_pid != -1)
445 rtp_video_stream_receiver_.FrameContinuous(last_continuous_pid); 445 rtp_video_stream_receiver_.FrameContinuous(last_continuous_pid);
446 } 446 }
447 447
448 void VideoReceiveStream::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 448 void VideoReceiveStream::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
449 frame_buffer_->UpdateRtt(max_rtt_ms); 449 frame_buffer_->UpdateRtt(max_rtt_ms);
450 } 450 }
451 451
452 int VideoReceiveStream::id() const { 452 int VideoReceiveStream::id() const {
453 RTC_DCHECK_RUN_ON(&worker_thread_checker_); 453 RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_);
454 return config_.rtp.remote_ssrc; 454 return config_.rtp.remote_ssrc;
455 } 455 }
456 456
457 rtc::Optional<Syncable::Info> VideoReceiveStream::GetInfo() const { 457 rtc::Optional<Syncable::Info> VideoReceiveStream::GetInfo() const {
458 RTC_DCHECK_RUN_ON(&module_process_thread_checker_); 458 RTC_DCHECK_CALLED_SEQUENTIALLY(&module_process_sequence_checker_);
459 Syncable::Info info; 459 Syncable::Info info;
460 460
461 RtpReceiver* rtp_receiver = rtp_video_stream_receiver_.GetRtpReceiver(); 461 RtpReceiver* rtp_receiver = rtp_video_stream_receiver_.GetRtpReceiver();
462 RTC_DCHECK(rtp_receiver); 462 RTC_DCHECK(rtp_receiver);
463 if (!rtp_receiver->Timestamp(&info.latest_received_capture_timestamp)) 463 if (!rtp_receiver->Timestamp(&info.latest_received_capture_timestamp))
464 return rtc::Optional<Syncable::Info>(); 464 return rtc::Optional<Syncable::Info>();
465 if (!rtp_receiver->LastReceivedTimeMs(&info.latest_receive_time_ms)) 465 if (!rtp_receiver->LastReceivedTimeMs(&info.latest_receive_time_ms))
466 return rtc::Optional<Syncable::Info>(); 466 return rtc::Optional<Syncable::Info>();
467 467
468 RtpRtcp* rtp_rtcp = rtp_video_stream_receiver_.rtp_rtcp(); 468 RtpRtcp* rtp_rtcp = rtp_video_stream_receiver_.rtp_rtcp();
469 RTC_DCHECK(rtp_rtcp); 469 RTC_DCHECK(rtp_rtcp);
470 if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs, 470 if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs,
471 &info.capture_time_ntp_frac, 471 &info.capture_time_ntp_frac,
472 nullptr, 472 nullptr,
473 nullptr, 473 nullptr,
474 &info.capture_time_source_clock) != 0) { 474 &info.capture_time_source_clock) != 0) {
475 return rtc::Optional<Syncable::Info>(); 475 return rtc::Optional<Syncable::Info>();
476 } 476 }
477 477
478 info.current_delay_ms = video_receiver_.Delay(); 478 info.current_delay_ms = video_receiver_.Delay();
479 return rtc::Optional<Syncable::Info>(info); 479 return rtc::Optional<Syncable::Info>(info);
480 } 480 }
481 481
482 uint32_t VideoReceiveStream::GetPlayoutTimestamp() const { 482 uint32_t VideoReceiveStream::GetPlayoutTimestamp() const {
483 RTC_NOTREACHED(); 483 RTC_NOTREACHED();
484 return 0; 484 return 0;
485 } 485 }
486 486
487 void VideoReceiveStream::SetMinimumPlayoutDelay(int delay_ms) { 487 void VideoReceiveStream::SetMinimumPlayoutDelay(int delay_ms) {
488 RTC_DCHECK_RUN_ON(&module_process_thread_checker_); 488 RTC_DCHECK_CALLED_SEQUENTIALLY(&module_process_sequence_checker_);
489 video_receiver_.SetMinimumPlayoutDelay(delay_ms); 489 video_receiver_.SetMinimumPlayoutDelay(delay_ms);
490 } 490 }
491 491
492 void VideoReceiveStream::DecodeThreadFunction(void* ptr) { 492 void VideoReceiveStream::DecodeThreadFunction(void* ptr) {
493 while (static_cast<VideoReceiveStream*>(ptr)->Decode()) { 493 while (static_cast<VideoReceiveStream*>(ptr)->Decode()) {
494 } 494 }
495 } 495 }
496 496
497 bool VideoReceiveStream::Decode() { 497 bool VideoReceiveStream::Decode() {
498 TRACE_EVENT0("webrtc", "VideoReceiveStream::Decode"); 498 TRACE_EVENT0("webrtc", "VideoReceiveStream::Decode");
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 if (stream_is_active && !receiving_keyframe) { 543 if (stream_is_active && !receiving_keyframe) {
544 LOG(LS_WARNING) << "No decodable frame in " << wait_ms 544 LOG(LS_WARNING) << "No decodable frame in " << wait_ms
545 << " ms, requesting keyframe."; 545 << " ms, requesting keyframe.";
546 RequestKeyFrame(); 546 RequestKeyFrame();
547 } 547 }
548 } 548 }
549 return true; 549 return true;
550 } 550 }
551 } // namespace internal 551 } // namespace internal
552 } // namespace webrtc 552 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698