| 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/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/metrics/histogram.h" |
| 14 #include "media/base/video_util.h" | 15 #include "media/base/video_util.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 // Amount of frame intervals to wait before considering the source as muted, for | 21 // Amount of frame intervals to wait before considering the source as muted, for |
| 21 // the first frame and under normal conditions, respectively. First frame might | 22 // the first frame and under normal conditions, respectively. First frame might |
| 22 // take longer to arrive due to source startup. | 23 // take longer to arrive due to source startup. |
| 23 const float kFirstFrameTimeoutInFrameIntervals = 100.0f; | 24 const float kFirstFrameTimeoutInFrameIntervals = 100.0f; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) | 309 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) |
| 309 : io_message_loop_(io_message_loop), | 310 : io_message_loop_(io_message_loop), |
| 310 renderer_task_runner_(base::MessageLoopProxy::current()), | 311 renderer_task_runner_(base::MessageLoopProxy::current()), |
| 311 frame_counter_(0), | 312 frame_counter_(0), |
| 312 source_frame_rate_(0.0f) { | 313 source_frame_rate_(0.0f) { |
| 313 DCHECK(io_message_loop_); | 314 DCHECK(io_message_loop_); |
| 314 } | 315 } |
| 315 | 316 |
| 316 VideoTrackAdapter::~VideoTrackAdapter() { | 317 VideoTrackAdapter::~VideoTrackAdapter() { |
| 317 DCHECK(adapters_.empty()); | 318 DCHECK(adapters_.empty()); |
| 319 UMA_HISTOGRAM_BOOLEAN("Media.VideoTrackAdapter.FramesReceived", |
| 320 frame_counter_ > 0); |
| 318 } | 321 } |
| 319 | 322 |
| 320 void VideoTrackAdapter::AddTrack( | 323 void VideoTrackAdapter::AddTrack( |
| 321 const MediaStreamVideoTrack* track, | 324 const MediaStreamVideoTrack* track, |
| 322 VideoCaptureDeliverFrameCB frame_callback, | 325 VideoCaptureDeliverFrameCB frame_callback, |
| 323 int max_width, | 326 int max_width, |
| 324 int max_height, | 327 int max_height, |
| 325 double min_aspect_ratio, | 328 double min_aspect_ratio, |
| 326 double max_aspect_ratio, | 329 double max_aspect_ratio, |
| 327 double max_frame_rate, | 330 double max_frame_rate, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 // Rearm the monitoring while there are active Tracks, i.e. as long as the | 436 // Rearm the monitoring while there are active Tracks, i.e. as long as the |
| 434 // owner MediaStreamSource is active. | 437 // owner MediaStreamSource is active. |
| 435 io_message_loop_->PostDelayedTask(FROM_HERE, | 438 io_message_loop_->PostDelayedTask(FROM_HERE, |
| 436 base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, | 439 base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, |
| 437 set_muted_state_callback, frame_counter_), | 440 set_muted_state_callback, frame_counter_), |
| 438 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / | 441 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / |
| 439 source_frame_rate_)); | 442 source_frame_rate_)); |
| 440 } | 443 } |
| 441 | 444 |
| 442 } // namespace content | 445 } // namespace content |
| OLD | NEW |