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

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

Powered by Google App Engine
This is Rietveld 408576698