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

Side by Side Diff: webrtc/media/base/videocapturer.cc

Issue 1966273002: VideoAdapter: Add cropping based on OnOutputFormatRequest() (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove unused variable Created 4 years, 7 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
« no previous file with comments | « webrtc/media/base/videoadapter_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 wants.max_pixel_count_step_up); 213 wants.max_pixel_count_step_up);
214 } 214 }
215 } 215 }
216 216
217 void VideoCapturer::OnFrameCaptured(VideoCapturer*, 217 void VideoCapturer::OnFrameCaptured(VideoCapturer*,
218 const CapturedFrame* captured_frame) { 218 const CapturedFrame* captured_frame) {
219 if (!broadcaster_.frame_wanted()) { 219 if (!broadcaster_.frame_wanted()) {
220 return; 220 return;
221 } 221 }
222 222
223 int adapted_width = captured_frame->width; 223 int cropped_width = captured_frame->width;
224 int adapted_height = captured_frame->height; 224 int cropped_height = captured_frame->height;
225 int out_width = captured_frame->width;
226 int out_height = captured_frame->height;
225 if (enable_video_adapter_ && !IsScreencast()) { 227 if (enable_video_adapter_ && !IsScreencast()) {
226 const VideoFormat adapted_format = 228 video_adapter_.AdaptFrameResolution(
227 video_adapter_.AdaptFrameResolution(adapted_width, adapted_height); 229 captured_frame->width, captured_frame->height,
228 if (adapted_format.IsSize0x0()) { 230 &cropped_width, &cropped_height,
231 &out_width, &out_height);
232 if (out_width == 0 || out_height == 0) {
229 // VideoAdapter dropped the frame. 233 // VideoAdapter dropped the frame.
230 return; 234 return;
231 } 235 }
232 adapted_width = adapted_format.width;
233 adapted_height = adapted_format.height;
234 } 236 }
235 237
236 if (!frame_factory_) { 238 if (!frame_factory_) {
237 LOG(LS_ERROR) << "No video frame factory."; 239 LOG(LS_ERROR) << "No video frame factory.";
238 return; 240 return;
239 } 241 }
240 242
241 // TODO(nisse): Reorganize frame factory methods, deleting crop 243 // TODO(nisse): Reorganize frame factory methods.
242 // support there too.
243 std::unique_ptr<VideoFrame> adapted_frame(frame_factory_->CreateAliasedFrame( 244 std::unique_ptr<VideoFrame> adapted_frame(frame_factory_->CreateAliasedFrame(
244 captured_frame, captured_frame->width, captured_frame->height, 245 captured_frame, cropped_width, cropped_height, out_width, out_height));
245 adapted_width, adapted_height));
246 246
247 if (!adapted_frame) { 247 if (!adapted_frame) {
248 // TODO(fbarchard): LOG more information about captured frame attributes. 248 // TODO(fbarchard): LOG more information about captured frame attributes.
249 LOG(LS_ERROR) << "Couldn't convert to I420! " 249 LOG(LS_ERROR) << "Couldn't convert to I420! "
250 << "From " << ToString(captured_frame) << " To " 250 << "From " << ToString(captured_frame) << " To "
251 << adapted_width << " x " << adapted_height; 251 << out_width << " x " << out_height;
252 return; 252 return;
253 } 253 }
254 254
255 OnFrame(this, adapted_frame.get()); 255 OnFrame(this, adapted_frame.get());
256 UpdateInputSize(captured_frame); 256 UpdateInputSize(captured_frame);
257 } 257 }
258 258
259 void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) { 259 void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) {
260 broadcaster_.OnFrame(*frame); 260 broadcaster_.OnFrame(*frame);
261 } 261 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 void VideoCapturer::UpdateInputSize(const CapturedFrame* captured_frame) { 401 void VideoCapturer::UpdateInputSize(const CapturedFrame* captured_frame) {
402 // Update stats protected from fetches from different thread. 402 // Update stats protected from fetches from different thread.
403 rtc::CritScope cs(&frame_stats_crit_); 403 rtc::CritScope cs(&frame_stats_crit_);
404 404
405 input_size_valid_ = true; 405 input_size_valid_ = true;
406 input_width_ = captured_frame->width; 406 input_width_ = captured_frame->width;
407 input_height_ = captured_frame->height; 407 input_height_ = captured_frame->height;
408 } 408 }
409 409
410 } // namespace cricket 410 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/videoadapter_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698