Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: content/renderer/media/video_track_adapter.cc

Issue 1476523005: Verify returned frames from media::VideoFrame::Wrap*() methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: halliwell@ comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return; 194 return;
195 } 195 }
196 } 196 }
197 } 197 }
198 198
199 void VideoTrackAdapter::VideoFrameResolutionAdapter::DeliverFrame( 199 void VideoTrackAdapter::VideoFrameResolutionAdapter::DeliverFrame(
200 const scoped_refptr<media::VideoFrame>& frame, 200 const scoped_refptr<media::VideoFrame>& frame,
201 const base::TimeTicks& estimated_capture_time) { 201 const base::TimeTicks& estimated_capture_time) {
202 DCHECK(io_thread_checker_.CalledOnValidThread()); 202 DCHECK(io_thread_checker_.CalledOnValidThread());
203 203
204 if (!frame) {
205 DLOG(ERROR) << "Incoming frame is not valid.";
206 return;
207 }
208
204 double frame_rate; 209 double frame_rate;
205 if (!frame->metadata()->GetDouble(media::VideoFrameMetadata::FRAME_RATE, 210 if (!frame->metadata()->GetDouble(media::VideoFrameMetadata::FRAME_RATE,
206 &frame_rate)) { 211 &frame_rate)) {
207 frame_rate = MediaStreamVideoSource::kUnknownFrameRate; 212 frame_rate = MediaStreamVideoSource::kUnknownFrameRate;
208 } 213 }
209 214
210 if (MaybeDropFrame(frame, frame_rate)) 215 if (MaybeDropFrame(frame, frame_rate))
211 return; 216 return;
212 217
213 // TODO(perkj): Allow cropping / scaling of textures once 218 // TODO(perkj): Allow cropping / scaling of textures once
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 261
257 // Get the largest centered rectangle with the same aspect ratio of 262 // Get the largest centered rectangle with the same aspect ratio of
258 // |desired_size| that fits entirely inside of |frame->visible_rect()|. 263 // |desired_size| that fits entirely inside of |frame->visible_rect()|.
259 // This will be the rect we need to crop the original frame to. 264 // 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|. 265 // From this rect, the original frame can be scaled down to |desired_size|.
261 const gfx::Rect region_in_frame = 266 const gfx::Rect region_in_frame =
262 media::ComputeLetterboxRegion(frame->visible_rect(), desired_size); 267 media::ComputeLetterboxRegion(frame->visible_rect(), desired_size);
263 268
264 video_frame = 269 video_frame =
265 media::VideoFrame::WrapVideoFrame(frame, region_in_frame, desired_size); 270 media::VideoFrame::WrapVideoFrame(frame, region_in_frame, desired_size);
271 if (!video_frame)
272 return;
266 video_frame->AddDestructionObserver( 273 video_frame->AddDestructionObserver(
267 base::Bind(&ReleaseOriginalFrame, frame)); 274 base::Bind(&ReleaseOriginalFrame, frame));
268 275
269 DVLOG(3) << "desired size " << desired_size.ToString() 276 DVLOG(3) << "desired size " << desired_size.ToString()
270 << " output natural size " 277 << " output natural size "
271 << video_frame->natural_size().ToString() 278 << video_frame->natural_size().ToString()
272 << " output visible rect " 279 << " output visible rect "
273 << video_frame->visible_rect().ToString(); 280 << video_frame->visible_rect().ToString();
274 } 281 }
275 DoDeliverFrame(video_frame, estimated_capture_time); 282 DoDeliverFrame(video_frame, estimated_capture_time);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 514 }
508 515
509 io_task_runner_->PostDelayedTask( 516 io_task_runner_->PostDelayedTask(
510 FROM_HERE, base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this, 517 FROM_HERE, base::Bind(&VideoTrackAdapter::CheckFramesReceivedOnIO, this,
511 set_muted_state_callback, frame_counter_), 518 set_muted_state_callback, frame_counter_),
512 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals / 519 base::TimeDelta::FromSecondsD(kNormalFrameTimeoutInFrameIntervals /
513 source_frame_rate_)); 520 source_frame_rate_));
514 } 521 }
515 522
516 } // namespace content 523 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_impl.cc ('k') | content/renderer/media/webrtc/media_stream_remote_video_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698