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