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

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: Address nit. Delete left-over include. 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/videocapturer.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | 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 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 // TODO(nisse): Switch to us unit.
220 int64_t capture_time_ns,
221 int* out_width,
222 int* out_height,
223 int* crop_width,
224 int* crop_height,
225 int* crop_x,
226 int* crop_y) {
227 if (!broadcaster_.frame_wanted()) {
228 return false;
229 }
230
231 if (enable_video_adapter_ && !IsScreencast()) {
232 if (!video_adapter_.AdaptFrameResolution(
233 width, height, capture_time_ns,
234 crop_width, crop_height, out_width, out_height)) {
235 // VideoAdapter dropped the frame.
236 return false;
237 }
238 *crop_x = (width - *crop_width) / 2;
239 *crop_y = (height - *crop_height) / 2;
240 } else {
241 *out_width = width;
242 *out_height = height;
243 *crop_width = width;
244 *crop_height = height;
245 *crop_x = 0;
246 *crop_y = 0;
247 }
248 return true;
249 }
250
217 void VideoCapturer::OnFrameCaptured(VideoCapturer*, 251 void VideoCapturer::OnFrameCaptured(VideoCapturer*,
218 const CapturedFrame* captured_frame) { 252 const CapturedFrame* captured_frame) {
219 if (!broadcaster_.frame_wanted()) { 253 int out_width;
254 int out_height;
255 int crop_width;
256 int crop_height;
257 int crop_x;
258 int crop_y;
259
260 if (!AdaptFrame(captured_frame->width, captured_frame->height,
261 captured_frame->time_stamp,
262 &out_width, &out_height,
263 &crop_width, &crop_height, &crop_x, &crop_y)) {
220 return; 264 return;
221 } 265 }
222 266
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 captured_frame->time_stamp,
231 &cropped_width, &cropped_height,
232 &out_width, &out_height);
233 if (out_width == 0 || out_height == 0) {
234 // VideoAdapter dropped the frame.
235 return;
236 }
237 }
238
239 if (!frame_factory_) { 267 if (!frame_factory_) {
240 LOG(LS_ERROR) << "No video frame factory."; 268 LOG(LS_ERROR) << "No video frame factory.";
241 return; 269 return;
242 } 270 }
243 271
244 // TODO(nisse): Reorganize frame factory methods. 272 // TODO(nisse): Reorganize frame factory methods. crop_x and crop_y
273 // are ignored for now.
245 std::unique_ptr<VideoFrame> adapted_frame(frame_factory_->CreateAliasedFrame( 274 std::unique_ptr<VideoFrame> adapted_frame(frame_factory_->CreateAliasedFrame(
246 captured_frame, cropped_width, cropped_height, out_width, out_height)); 275 captured_frame, crop_width, crop_height, out_width, out_height));
247 276
248 if (!adapted_frame) { 277 if (!adapted_frame) {
249 // TODO(fbarchard): LOG more information about captured frame attributes. 278 // TODO(fbarchard): LOG more information about captured frame attributes.
250 LOG(LS_ERROR) << "Couldn't convert to I420! " 279 LOG(LS_ERROR) << "Couldn't convert to I420! "
251 << "From " << ToString(captured_frame) << " To " 280 << "From " << ToString(captured_frame) << " To "
252 << out_width << " x " << out_height; 281 << out_width << " x " << out_height;
253 return; 282 return;
254 } 283 }
255 284
256 OnFrame(this, adapted_frame.get()); 285 OnFrame(*adapted_frame, captured_frame->width, captured_frame->height);
257 UpdateInputSize(captured_frame);
258 } 286 }
259 287
260 void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) { 288 void VideoCapturer::OnFrame(const VideoFrame& frame,
261 broadcaster_.OnFrame(*frame); 289 int orig_width,
290 int orig_height) {
291 broadcaster_.OnFrame(frame);
292 UpdateInputSize(orig_width, orig_height);
262 } 293 }
263 294
264 void VideoCapturer::SetCaptureState(CaptureState state) { 295 void VideoCapturer::SetCaptureState(CaptureState state) {
265 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 296 RTC_DCHECK(thread_checker_.CalledOnValidThread());
266 if (state == capture_state_) { 297 if (state == capture_state_) {
267 // Don't trigger a state changed callback if the state hasn't changed. 298 // Don't trigger a state changed callback if the state hasn't changed.
268 return; 299 return;
269 } 300 }
270 capture_state_ = state; 301 capture_state_ = state;
271 SignalStateChange(this, capture_state_); 302 SignalStateChange(this, capture_state_);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 423
393 bool VideoCapturer::ShouldFilterFormat(const VideoFormat& format) const { 424 bool VideoCapturer::ShouldFilterFormat(const VideoFormat& format) const {
394 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 425 RTC_DCHECK(thread_checker_.CalledOnValidThread());
395 if (!enable_camera_list_) { 426 if (!enable_camera_list_) {
396 return false; 427 return false;
397 } 428 }
398 return format.width > max_format_->width || 429 return format.width > max_format_->width ||
399 format.height > max_format_->height; 430 format.height > max_format_->height;
400 } 431 }
401 432
402 void VideoCapturer::UpdateInputSize(const CapturedFrame* captured_frame) { 433 void VideoCapturer::UpdateInputSize(int width, int height) {
403 // Update stats protected from fetches from different thread. 434 // Update stats protected from fetches from different thread.
404 rtc::CritScope cs(&frame_stats_crit_); 435 rtc::CritScope cs(&frame_stats_crit_);
405 436
406 input_size_valid_ = true; 437 input_size_valid_ = true;
407 input_width_ = captured_frame->width; 438 input_width_ = width;
408 input_height_ = captured_frame->height; 439 input_height_ = height;
409 } 440 }
410 441
411 } // namespace cricket 442 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/videocapturer.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698