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

Side by Side Diff: content/renderer/media/webrtc/webrtc_video_capturer_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/webrtc/webrtc_video_capturer_adapter.h" 5 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/aligned_memory.h" 8 #include "base/memory/aligned_memory.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h" 10 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // Create a centered cropped visible rect that preservers aspect ratio for 88 // Create a centered cropped visible rect that preservers aspect ratio for
89 // cropped natural size. 89 // cropped natural size.
90 gfx::Rect visible_rect = frame_->visible_rect(); 90 gfx::Rect visible_rect = frame_->visible_rect();
91 visible_rect.ClampToCenteredSize(gfx::Size( 91 visible_rect.ClampToCenteredSize(gfx::Size(
92 visible_rect.width() * cropped_input_width / input_frame->width, 92 visible_rect.width() * cropped_input_width / input_frame->width,
93 visible_rect.height() * cropped_input_height / input_frame->height)); 93 visible_rect.height() * cropped_input_height / input_frame->height));
94 94
95 const gfx::Size output_size(output_width, output_height); 95 const gfx::Size output_size(output_width, output_height);
96 scoped_refptr<media::VideoFrame> video_frame = 96 scoped_refptr<media::VideoFrame> video_frame =
97 media::VideoFrame::WrapVideoFrame(frame_, visible_rect, output_size); 97 media::VideoFrame::WrapVideoFrame(frame_, visible_rect, output_size);
98 if (!video_frame)
99 return nullptr;
98 video_frame->AddDestructionObserver( 100 video_frame->AddDestructionObserver(
99 base::Bind(&ReleaseOriginalFrame, frame_)); 101 base::Bind(&ReleaseOriginalFrame, frame_));
100 102
101 // If no scaling is needed, return a wrapped version of |frame_| directly. 103 // If no scaling is needed, return a wrapped version of |frame_| directly.
102 if (video_frame->natural_size() == video_frame->visible_rect().size()) { 104 if (video_frame->natural_size() == video_frame->visible_rect().size()) {
103 return new cricket::WebRtcVideoFrame( 105 return new cricket::WebRtcVideoFrame(
104 new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(video_frame), 106 new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(video_frame),
105 timestamp_ns, webrtc::kVideoRotation_0); 107 timestamp_ns, webrtc::kVideoRotation_0);
106 } 108 }
107 109
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 reinterpret_cast<MediaVideoFrameFactory*>(frame_factory()); 232 reinterpret_cast<MediaVideoFrameFactory*>(frame_factory());
231 media_video_frame_factory->SetFrame(frame); 233 media_video_frame_factory->SetFrame(frame);
232 234
233 // This signals to libJingle that a new VideoFrame is available. 235 // This signals to libJingle that a new VideoFrame is available.
234 SignalFrameCaptured(this, media_video_frame_factory->GetCapturedFrame()); 236 SignalFrameCaptured(this, media_video_frame_factory->GetCapturedFrame());
235 237
236 media_video_frame_factory->ReleaseFrame(); // Release the frame ASAP. 238 media_video_frame_factory->ReleaseFrame(); // Release the frame ASAP.
237 } 239 }
238 240
239 } // namespace content 241 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698