| 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 <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // Min delta time between two frames allowed without being dropped if a max | 36 // Min delta time between two frames allowed without being dropped if a max |
| 37 // frame rate is specified. | 37 // frame rate is specified. |
| 38 const double kMinTimeInMsBetweenFrames = 5; | 38 const double kMinTimeInMsBetweenFrames = 5; |
| 39 // If the delta between two frames is bigger than this, we will consider it to | 39 // If the delta between two frames is bigger than this, we will consider it to |
| 40 // be invalid and reset the fps calculation. | 40 // be invalid and reset the fps calculation. |
| 41 const double kMaxTimeInMsBetweenFrames = 1000; | 41 const double kMaxTimeInMsBetweenFrames = 1000; |
| 42 | 42 |
| 43 // Empty method used for keeping a reference to the original media::VideoFrame | 43 // Empty method used for keeping a reference to the original media::VideoFrame |
| 44 // in VideoFrameResolutionAdapter::DeliverFrame if cropping is needed. | 44 // in VideoFrameResolutionAdapter::DeliverFrame if cropping is needed. |
| 45 // The reference to |frame| is kept in the closure that calls this method. | 45 // The reference to |frame| is kept in the closure that calls this method. |
| 46 void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) { | 46 void VideoReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ResetCallbackOnMainRenderThread( | 49 void ResetCallbackOnMainRenderThread( |
| 50 std::unique_ptr<VideoCaptureDeliverFrameCB> callback) { | 50 std::unique_ptr<VideoCaptureDeliverFrameCB> callback) { |
| 51 // |callback| will be deleted when this exits. | 51 // |callback| will be deleted when this exits. |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // anonymous namespace | 54 } // anonymous namespace |
| 55 | 55 |
| 56 // VideoFrameResolutionAdapter is created on and lives on the IO-thread. It does | 56 // VideoFrameResolutionAdapter is created on and lives on the IO-thread. It does |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // This will be the rect we need to crop the original frame to. | 238 // This will be the rect we need to crop the original frame to. |
| 239 // From this rect, the original frame can be scaled down to |desired_size|. | 239 // From this rect, the original frame can be scaled down to |desired_size|. |
| 240 const gfx::Rect region_in_frame = | 240 const gfx::Rect region_in_frame = |
| 241 media::ComputeLetterboxRegion(frame->visible_rect(), desired_size); | 241 media::ComputeLetterboxRegion(frame->visible_rect(), desired_size); |
| 242 | 242 |
| 243 video_frame = media::VideoFrame::WrapVideoFrame( | 243 video_frame = media::VideoFrame::WrapVideoFrame( |
| 244 frame, frame->format(), region_in_frame, desired_size); | 244 frame, frame->format(), region_in_frame, desired_size); |
| 245 if (!video_frame) | 245 if (!video_frame) |
| 246 return; | 246 return; |
| 247 video_frame->AddDestructionObserver( | 247 video_frame->AddDestructionObserver( |
| 248 base::Bind(&ReleaseOriginalFrame, frame)); | 248 base::Bind(&VideoReleaseOriginalFrame, frame)); |
| 249 | 249 |
| 250 DVLOG(3) << "desired size " << desired_size.ToString() | 250 DVLOG(3) << "desired size " << desired_size.ToString() |
| 251 << " output natural size " | 251 << " output natural size " |
| 252 << video_frame->natural_size().ToString() | 252 << video_frame->natural_size().ToString() |
| 253 << " output visible rect " | 253 << " output visible rect " |
| 254 << video_frame->visible_rect().ToString(); | 254 << video_frame->visible_rect().ToString(); |
| 255 } | 255 } |
| 256 DoDeliverFrame(video_frame, estimated_capture_time); | 256 DoDeliverFrame(video_frame, estimated_capture_time); |
| 257 } | 257 } |
| 258 | 258 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 } | 557 } |
| 558 | 558 |
| 559 io_task_runner_->PostDelayedTask( | 559 io_task_runner_->PostDelayedTask( |
| 560 FROM_HERE, base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, | 560 FROM_HERE, base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, |
| 561 set_muted_state_callback, frame_counter_), | 561 set_muted_state_callback, frame_counter_), |
| 562 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / | 562 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / |
| 563 source_frame_rate_)); | 563 source_frame_rate_)); |
| 564 } | 564 } |
| 565 | 565 |
| 566 } // namespace content | 566 } // namespace content |
| OLD | NEW |