OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/video_track_adapter.h" | 5 #include "content/renderer/media/video_track_adapter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_to_current_loop.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/location.h" | 14 #include "base/location.h" |
14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
18 #include "media/base/bind_to_current_loop.h" | |
19 #include "media/base/video_util.h" | 19 #include "media/base/video_util.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Amount of frame intervals to wait before considering the source as muted, for | 25 // Amount of frame intervals to wait before considering the source as muted, for |
26 // the first frame and under normal conditions, respectively. First frame might | 26 // the first frame and under normal conditions, respectively. First frame might |
27 // take longer to arrive due to source startup. | 27 // take longer to arrive due to source startup. |
28 const float kFirstFrameTimeoutInFrameIntervals = 100.0f; | 28 const float kFirstFrameTimeoutInFrameIntervals = 100.0f; |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 FROM_HERE, | 421 FROM_HERE, |
422 base::Bind(&VideoTrackAdapter::RemoveTrackOnIO, this, track)); | 422 base::Bind(&VideoTrackAdapter::RemoveTrackOnIO, this, track)); |
423 } | 423 } |
424 | 424 |
425 void VideoTrackAdapter::StartFrameMonitoring( | 425 void VideoTrackAdapter::StartFrameMonitoring( |
426 double source_frame_rate, | 426 double source_frame_rate, |
427 const OnMutedCallback& on_muted_callback) { | 427 const OnMutedCallback& on_muted_callback) { |
428 DCHECK(thread_checker_.CalledOnValidThread()); | 428 DCHECK(thread_checker_.CalledOnValidThread()); |
429 | 429 |
430 VideoTrackAdapter::OnMutedCallback bound_on_muted_callback = | 430 VideoTrackAdapter::OnMutedCallback bound_on_muted_callback = |
431 media::BindToCurrentLoop(on_muted_callback); | 431 base::BindToCurrentLoop(on_muted_callback); |
432 | 432 |
433 io_message_loop_->PostTask( | 433 io_message_loop_->PostTask( |
434 FROM_HERE, | 434 FROM_HERE, |
435 base::Bind(&VideoTrackAdapter::StartFrameMonitoringOnIO, | 435 base::Bind(&VideoTrackAdapter::StartFrameMonitoringOnIO, |
436 this, bound_on_muted_callback, source_frame_rate)); | 436 this, bound_on_muted_callback, source_frame_rate)); |
437 } | 437 } |
438 | 438 |
439 void VideoTrackAdapter::StopFrameMonitoring() { | 439 void VideoTrackAdapter::StopFrameMonitoring() { |
440 DCHECK(thread_checker_.CalledOnValidThread()); | 440 DCHECK(thread_checker_.CalledOnValidThread()); |
441 io_message_loop_->PostTask( | 441 io_message_loop_->PostTask( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 } | 509 } |
510 | 510 |
511 io_message_loop_->PostDelayedTask(FROM_HERE, | 511 io_message_loop_->PostDelayedTask(FROM_HERE, |
512 base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, | 512 base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, |
513 set_muted_state_callback, frame_counter_), | 513 set_muted_state_callback, frame_counter_), |
514 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / | 514 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / |
515 source_frame_rate_)); | 515 source_frame_rate_)); |
516 } | 516 } |
517 | 517 |
518 } // namespace content | 518 } // namespace content |
OLD | NEW |