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 return; |
265 video_frame->AddDestructionObserver( | 267 video_frame->AddDestructionObserver( |
266 base::Bind(&ReleaseOriginalFrame, frame)); | 268 base::Bind(&ReleaseOriginalFrame, frame)); |
267 | 269 |
268 DVLOG(3) << "desired size " << desired_size.ToString() | 270 DVLOG(3) << "desired size " << desired_size.ToString() |
269 << " output natural size " | 271 << " output natural size " |
270 << video_frame->natural_size().ToString() | 272 << video_frame->natural_size().ToString() |
271 << " output visible rect " | 273 << " output visible rect " |
272 << video_frame->visible_rect().ToString(); | 274 << video_frame->visible_rect().ToString(); |
273 } | 275 } |
274 DoDeliverFrame(video_frame, estimated_capture_time); | 276 DoDeliverFrame(video_frame, estimated_capture_time); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 } | 508 } |
507 | 509 |
508 io_task_runner_->PostDelayedTask( | 510 io_task_runner_->PostDelayedTask( |
509 FROM_HERE, base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, | 511 FROM_HERE, base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, |
510 set_muted_state_callback, frame_counter_), | 512 set_muted_state_callback, frame_counter_), |
511 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / | 513 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / |
512 source_frame_rate_)); | 514 source_frame_rate_)); |
513 } | 515 } |
514 | 516 |
515 } // namespace content | 517 } // namespace content |
OLD | NEW |