| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 255 |
| 256 // Get the largest centered rectangle with the same aspect ratio of | 256 // Get the largest centered rectangle with the same aspect ratio of |
| 257 // |desired_size| that fits entirely inside of |frame->visible_rect()|. | 257 // |desired_size| that fits entirely inside of |frame->visible_rect()|. |
| 258 // This will be the rect we need to crop the original frame to. | 258 // This will be the rect we need to crop the original frame to. |
| 259 // From this rect, the original frame can be scaled down to |desired_size|. | 259 // From this rect, the original frame can be scaled down to |desired_size|. |
| 260 const gfx::Rect region_in_frame = | 260 const gfx::Rect region_in_frame = |
| 261 media::ComputeLetterboxRegion(frame->visible_rect(), desired_size); | 261 media::ComputeLetterboxRegion(frame->visible_rect(), desired_size); |
| 262 | 262 |
| 263 video_frame = | 263 video_frame = |
| 264 media::VideoFrame::WrapVideoFrame(frame, region_in_frame, desired_size); | 264 media::VideoFrame::WrapVideoFrame(frame, region_in_frame, desired_size); |
| 265 if (!video_frame) { |
| 266 DLOG(ERROR) << "Couldn't create video frame"; |
| 267 return; |
| 268 } |
| 265 video_frame->AddDestructionObserver( | 269 video_frame->AddDestructionObserver( |
| 266 base::Bind(&ReleaseOriginalFrame, frame)); | 270 base::Bind(&ReleaseOriginalFrame, frame)); |
| 267 | 271 |
| 268 DVLOG(3) << "desired size " << desired_size.ToString() | 272 DVLOG(3) << "desired size " << desired_size.ToString() |
| 269 << " output natural size " | 273 << " output natural size " |
| 270 << video_frame->natural_size().ToString() | 274 << video_frame->natural_size().ToString() |
| 271 << " output visible rect " | 275 << " output visible rect " |
| 272 << video_frame->visible_rect().ToString(); | 276 << video_frame->visible_rect().ToString(); |
| 273 } | 277 } |
| 274 DoDeliverFrame(video_frame, estimated_capture_time); | 278 DoDeliverFrame(video_frame, estimated_capture_time); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 } | 510 } |
| 507 | 511 |
| 508 io_task_runner_->PostDelayedTask( | 512 io_task_runner_->PostDelayedTask( |
| 509 FROM_HERE, base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, | 513 FROM_HERE, base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, |
| 510 set_muted_state_callback, frame_counter_), | 514 set_muted_state_callback, frame_counter_), |
| 511 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / | 515 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / |
| 512 source_frame_rate_)); | 516 source_frame_rate_)); |
| 513 } | 517 } |
| 514 | 518 |
| 515 } // namespace content | 519 } // namespace content |
| OLD | NEW |