| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 228     // This will be the rect we need to crop the original frame to. | 228     // This will be the rect we need to crop the original frame to. | 
| 229     // From this rect, the original frame can be scaled down to |desired_size|. | 229     // From this rect, the original frame can be scaled down to |desired_size|. | 
| 230     const gfx::Rect region_in_frame = | 230     const gfx::Rect region_in_frame = | 
| 231         media::ComputeLetterboxRegion(frame->visible_rect(), desired_size); | 231         media::ComputeLetterboxRegion(frame->visible_rect(), desired_size); | 
| 232 | 232 | 
| 233     video_frame = media::VideoFrame::WrapVideoFrame( | 233     video_frame = media::VideoFrame::WrapVideoFrame( | 
| 234         frame, frame->format(), region_in_frame, desired_size); | 234         frame, frame->format(), region_in_frame, desired_size); | 
| 235     if (!video_frame) | 235     if (!video_frame) | 
| 236       return; | 236       return; | 
| 237     video_frame->AddDestructionObserver( | 237     video_frame->AddDestructionObserver( | 
| 238         base::BindOnce(&ReleaseOriginalFrame, frame)); | 238         base::BindOnce(&VideoReleaseOriginalFrame, frame)); | 
| 239 | 239 | 
| 240     DVLOG(3) << "desired size  " << desired_size.ToString() | 240     DVLOG(3) << "desired size  " << desired_size.ToString() | 
| 241              << " output natural size " | 241              << " output natural size " | 
| 242              << video_frame->natural_size().ToString() | 242              << video_frame->natural_size().ToString() | 
| 243              << " output visible rect  " | 243              << " output visible rect  " | 
| 244              << video_frame->visible_rect().ToString(); | 244              << video_frame->visible_rect().ToString(); | 
| 245   } | 245   } | 
| 246   DoDeliverFrame(video_frame, estimated_capture_time); | 246   DoDeliverFrame(video_frame, estimated_capture_time); | 
| 247 } | 247 } | 
| 248 | 248 | 
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 569 | 569 | 
| 570   io_task_runner_->PostDelayedTask( | 570   io_task_runner_->PostDelayedTask( | 
| 571       FROM_HERE, | 571       FROM_HERE, | 
| 572       base::BindOnce(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, | 572       base::BindOnce(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, | 
| 573                      set_muted_state_callback, frame_counter_), | 573                      set_muted_state_callback, frame_counter_), | 
| 574       base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / | 574       base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / | 
| 575                                     source_frame_rate_)); | 575                                     source_frame_rate_)); | 
| 576 } | 576 } | 
| 577 | 577 | 
| 578 }  // namespace content | 578 }  // namespace content | 
| OLD | NEW | 
|---|