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

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

Issue 1973873003: Delete AndroidVideoCapturer::FrameFactory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix width/height typo. Tests. Formatting. 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
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 if (frame_factory_) { 207 if (frame_factory_) {
208 frame_factory_->SetApplyRotation(apply_rotation_); 208 frame_factory_->SetApplyRotation(apply_rotation_);
209 } 209 }
210 210
211 if (video_adapter()) { 211 if (video_adapter()) {
212 video_adapter()->OnResolutionRequest(wants.max_pixel_count, 212 video_adapter()->OnResolutionRequest(wants.max_pixel_count,
213 wants.max_pixel_count_step_up); 213 wants.max_pixel_count_step_up);
214 } 214 }
215 } 215 }
216 216
217 bool VideoCapturer::AdaptFrame(int width,
218 int height,
219 int* out_width,
220 int* out_height,
221 int* crop_width,
222 int* crop_height,
223 int* crop_x,
224 int* crop_y) {
225 if (!broadcaster_.frame_wanted()) {
226 return false;
227 }
228
229 if (enable_video_adapter_ && !IsScreencast()) {
230 if (!video_adapter_.AdaptFrameResolution(
231 width, height, crop_width, crop_height, out_width, out_height))
magjed_webrtc 2016/05/17 12:12:40 nit: Add {}
nisse-webrtc 2016/05/18 11:16:34 Done.
232 // VideoAdapter dropped the frame.
233 return false;
234 *crop_x = (width - *crop_width) / 2;
235 *crop_y = (height - *crop_height) / 2;
236 } else {
237 *out_width = width;
238 *out_height = height;
239 *crop_width = width;
240 *crop_height = height;
241 *crop_x = 0;
242 *crop_y = 0;
243 }
244 return true;
245 }
246
217 void VideoCapturer::OnFrameCaptured(VideoCapturer*, 247 void VideoCapturer::OnFrameCaptured(VideoCapturer*,
218 const CapturedFrame* captured_frame) { 248 const CapturedFrame* captured_frame) {
219 if (!broadcaster_.frame_wanted()) { 249 int out_width;
250 int out_height;
251 int crop_width;
252 int crop_height;
253 int crop_x;
254 int crop_y;
255
256 if (!AdaptFrame(captured_frame->width, captured_frame->height,
257 &out_width, &out_height,
258 &crop_width, &crop_height, &crop_x, &crop_y)) {
220 return; 259 return;
221 } 260 }
222 261
223 int cropped_width = captured_frame->width;
224 int cropped_height = captured_frame->height;
225 int out_width = captured_frame->width;
226 int out_height = captured_frame->height;
227 if (enable_video_adapter_ && !IsScreencast()) {
228 video_adapter_.AdaptFrameResolution(
229 captured_frame->width, captured_frame->height,
230 &cropped_width, &cropped_height,
231 &out_width, &out_height);
232 if (out_width == 0 || out_height == 0) {
233 // VideoAdapter dropped the frame.
234 return;
235 }
236 }
237
238 if (!frame_factory_) { 262 if (!frame_factory_) {
239 LOG(LS_ERROR) << "No video frame factory."; 263 LOG(LS_ERROR) << "No video frame factory.";
240 return; 264 return;
241 } 265 }
242 266
243 // TODO(nisse): Reorganize frame factory methods. 267 // TODO(nisse): Reorganize frame factory methods. crop_x and crop_y
268 // are ignored for now.
244 std::unique_ptr<VideoFrame> adapted_frame(frame_factory_->CreateAliasedFrame( 269 std::unique_ptr<VideoFrame> adapted_frame(frame_factory_->CreateAliasedFrame(
245 captured_frame, cropped_width, cropped_height, out_width, out_height)); 270 captured_frame, crop_width, crop_height, out_width, out_height));
246 271
247 if (!adapted_frame) { 272 if (!adapted_frame) {
248 // TODO(fbarchard): LOG more information about captured frame attributes. 273 // TODO(fbarchard): LOG more information about captured frame attributes.
249 LOG(LS_ERROR) << "Couldn't convert to I420! " 274 LOG(LS_ERROR) << "Couldn't convert to I420! "
250 << "From " << ToString(captured_frame) << " To " 275 << "From " << ToString(captured_frame) << " To "
251 << out_width << " x " << out_height; 276 << out_width << " x " << out_height;
252 return; 277 return;
253 } 278 }
254 279
255 OnFrame(this, adapted_frame.get()); 280 OnFrame(*adapted_frame, captured_frame->width, captured_frame->height);
256 UpdateInputSize(captured_frame);
257 } 281 }
258 282
259 void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) { 283 void VideoCapturer::OnFrame(const VideoFrame& frame,
260 broadcaster_.OnFrame(*frame); 284 int orig_width,
285 int orig_height) {
286 broadcaster_.OnFrame(frame);
287 UpdateInputSize(orig_width, orig_height);
261 } 288 }
262 289
263 void VideoCapturer::SetCaptureState(CaptureState state) { 290 void VideoCapturer::SetCaptureState(CaptureState state) {
264 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 291 RTC_DCHECK(thread_checker_.CalledOnValidThread());
265 if (state == capture_state_) { 292 if (state == capture_state_) {
266 // Don't trigger a state changed callback if the state hasn't changed. 293 // Don't trigger a state changed callback if the state hasn't changed.
267 return; 294 return;
268 } 295 }
269 capture_state_ = state; 296 capture_state_ = state;
270 SignalStateChange(this, capture_state_); 297 SignalStateChange(this, capture_state_);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 418
392 bool VideoCapturer::ShouldFilterFormat(const VideoFormat& format) const { 419 bool VideoCapturer::ShouldFilterFormat(const VideoFormat& format) const {
393 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 420 RTC_DCHECK(thread_checker_.CalledOnValidThread());
394 if (!enable_camera_list_) { 421 if (!enable_camera_list_) {
395 return false; 422 return false;
396 } 423 }
397 return format.width > max_format_->width || 424 return format.width > max_format_->width ||
398 format.height > max_format_->height; 425 format.height > max_format_->height;
399 } 426 }
400 427
401 void VideoCapturer::UpdateInputSize(const CapturedFrame* captured_frame) { 428 void VideoCapturer::UpdateInputSize(int width, int height) {
402 // Update stats protected from fetches from different thread. 429 // Update stats protected from fetches from different thread.
403 rtc::CritScope cs(&frame_stats_crit_); 430 rtc::CritScope cs(&frame_stats_crit_);
404 431
405 input_size_valid_ = true; 432 input_size_valid_ = true;
406 input_width_ = captured_frame->width; 433 input_width_ = width;
407 input_height_ = captured_frame->height; 434 input_height_ = height;
408 } 435 }
409 436
410 } // namespace cricket 437 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698