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 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 double min_aspect_ratio, | 117 double min_aspect_ratio, |
118 double max_aspect_ratio, | 118 double max_aspect_ratio, |
119 double max_frame_rate) | 119 double max_frame_rate) |
120 : renderer_task_runner_(render_message_loop), | 120 : renderer_task_runner_(render_message_loop), |
121 max_frame_size_(max_size), | 121 max_frame_size_(max_size), |
122 min_aspect_ratio_(min_aspect_ratio), | 122 min_aspect_ratio_(min_aspect_ratio), |
123 max_aspect_ratio_(max_aspect_ratio), | 123 max_aspect_ratio_(max_aspect_ratio), |
124 frame_rate_(MediaStreamVideoSource::kDefaultFrameRate), | 124 frame_rate_(MediaStreamVideoSource::kDefaultFrameRate), |
125 max_frame_rate_(max_frame_rate), | 125 max_frame_rate_(max_frame_rate), |
126 keep_frame_counter_(0.0f) { | 126 keep_frame_counter_(0.0f) { |
127 DCHECK(renderer_task_runner_); | 127 DCHECK(renderer_task_runner_.get()); |
128 DCHECK(io_thread_checker_.CalledOnValidThread()); | 128 DCHECK(io_thread_checker_.CalledOnValidThread()); |
129 DCHECK_GE(max_aspect_ratio_, min_aspect_ratio_); | 129 DCHECK_GE(max_aspect_ratio_, min_aspect_ratio_); |
130 CHECK_NE(0, max_aspect_ratio_); | 130 CHECK_NE(0, max_aspect_ratio_); |
131 DVLOG(3) << "VideoFrameResolutionAdapter(" | 131 DVLOG(3) << "VideoFrameResolutionAdapter(" |
132 << "{ max_width =" << max_frame_size_.width() << "}, " | 132 << "{ max_width =" << max_frame_size_.width() << "}, " |
133 << "{ max_height =" << max_frame_size_.height() << "}, " | 133 << "{ max_height =" << max_frame_size_.height() << "}, " |
134 << "{ min_aspect_ratio =" << min_aspect_ratio << "}, " | 134 << "{ min_aspect_ratio =" << min_aspect_ratio << "}, " |
135 << "{ max_aspect_ratio_ =" << max_aspect_ratio_ << "}" | 135 << "{ max_aspect_ratio_ =" << max_aspect_ratio_ << "}" |
136 << "{ max_frame_rate_ =" << max_frame_rate_ << "}) "; | 136 << "{ max_frame_rate_ =" << max_frame_rate_ << "}) "; |
137 } | 137 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 DCHECK(io_thread_checker_.CalledOnValidThread()); | 304 DCHECK(io_thread_checker_.CalledOnValidThread()); |
305 return callbacks_.empty(); | 305 return callbacks_.empty(); |
306 } | 306 } |
307 | 307 |
308 VideoTrackAdapter::VideoTrackAdapter( | 308 VideoTrackAdapter::VideoTrackAdapter( |
309 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) | 309 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) |
310 : io_message_loop_(io_message_loop), | 310 : io_message_loop_(io_message_loop), |
311 renderer_task_runner_(base::MessageLoopProxy::current()), | 311 renderer_task_runner_(base::MessageLoopProxy::current()), |
312 frame_counter_(0), | 312 frame_counter_(0), |
313 source_frame_rate_(0.0f) { | 313 source_frame_rate_(0.0f) { |
314 DCHECK(io_message_loop_); | 314 DCHECK(io_message_loop_.get()); |
315 } | 315 } |
316 | 316 |
317 VideoTrackAdapter::~VideoTrackAdapter() { | 317 VideoTrackAdapter::~VideoTrackAdapter() { |
318 DCHECK(adapters_.empty()); | 318 DCHECK(adapters_.empty()); |
319 UMA_HISTOGRAM_BOOLEAN("Media.VideoTrackAdapter.FramesReceived", | 319 UMA_HISTOGRAM_BOOLEAN("Media.VideoTrackAdapter.FramesReceived", |
320 frame_counter_ > 0); | 320 frame_counter_ > 0); |
321 } | 321 } |
322 | 322 |
323 void VideoTrackAdapter::AddTrack( | 323 void VideoTrackAdapter::AddTrack( |
324 const MediaStreamVideoTrack* track, | 324 const MediaStreamVideoTrack* track, |
(...skipping 29 matching lines...) Expand all Loading... |
354 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 354 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
355 scoped_refptr<VideoFrameResolutionAdapter> adapter; | 355 scoped_refptr<VideoFrameResolutionAdapter> adapter; |
356 for (FrameAdapters::const_iterator it = adapters_.begin(); | 356 for (FrameAdapters::const_iterator it = adapters_.begin(); |
357 it != adapters_.end(); ++it) { | 357 it != adapters_.end(); ++it) { |
358 if ((*it)->ConstraintsMatch(max_frame_size, min_aspect_ratio, | 358 if ((*it)->ConstraintsMatch(max_frame_size, min_aspect_ratio, |
359 max_aspect_ratio, max_frame_rate)) { | 359 max_aspect_ratio, max_frame_rate)) { |
360 adapter = it->get(); | 360 adapter = it->get(); |
361 break; | 361 break; |
362 } | 362 } |
363 } | 363 } |
364 if (!adapter) { | 364 if (!adapter.get()) { |
365 adapter = new VideoFrameResolutionAdapter(renderer_task_runner_, | 365 adapter = new VideoFrameResolutionAdapter(renderer_task_runner_, |
366 max_frame_size, | 366 max_frame_size, |
367 min_aspect_ratio, | 367 min_aspect_ratio, |
368 max_aspect_ratio, | 368 max_aspect_ratio, |
369 max_frame_rate); | 369 max_frame_rate); |
370 adapters_.push_back(adapter); | 370 adapters_.push_back(adapter); |
371 } | 371 } |
372 | 372 |
373 adapter->AddCallback(track, frame_callback); | 373 adapter->AddCallback(track, frame_callback); |
374 } | 374 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 // 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 |
437 // owner MediaStreamSource is active. | 437 // owner MediaStreamSource is active. |
438 io_message_loop_->PostDelayedTask(FROM_HERE, | 438 io_message_loop_->PostDelayedTask(FROM_HERE, |
439 base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, | 439 base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, |
440 set_muted_state_callback, frame_counter_), | 440 set_muted_state_callback, frame_counter_), |
441 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / | 441 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / |
442 source_frame_rate_)); | 442 source_frame_rate_)); |
443 } | 443 } |
444 | 444 |
445 } // namespace content | 445 } // namespace content |
OLD | NEW |