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

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

Issue 1655793003: Make cricket::VideoCapturer implement VideoSourceInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed Android Created 4 years, 10 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 * libjingle 2 * libjingle
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 black_frame_count_down_ = kNumBlackFramesOnMute; 236 black_frame_count_down_ = kNumBlackFramesOnMute;
237 // Following frames will be overritten with black, then the camera will be 237 // Following frames will be overritten with black, then the camera will be
238 // paused. 238 // paused.
239 return true; 239 return true;
240 } 240 }
241 // Start the camera. 241 // Start the camera.
242 thread_->Clear(this, MSG_DO_PAUSE); 242 thread_->Clear(this, MSG_DO_PAUSE);
243 return Pause(false); 243 return Pause(false);
244 } 244 }
245 245
246 // Note that the last caller decides whether rotation should be applied if there 246 void VideoCapturer::OnSinkCapabilitiesChanged(
247 // are multiple send streams using the same camera. 247 const rtc::VideoSinkCapabilities& capabilities) {
248 bool VideoCapturer::SetApplyRotation(bool enable) { 248 apply_rotation_ = !capabilities.can_apply_rotation;
pthatcher1 2016/02/03 15:38:35 I like this a lot.
perkj_webrtc 2016/02/08 14:32:00 Acknowledged.
249 apply_rotation_ = enable;
250 if (frame_factory_) { 249 if (frame_factory_) {
251 frame_factory_->SetApplyRotation(apply_rotation_); 250 frame_factory_->SetApplyRotation(apply_rotation_);
252 } 251 }
253 return true;
254 } 252 }
255 253
256 void VideoCapturer::SetSupportedFormats( 254 void VideoCapturer::SetSupportedFormats(
257 const std::vector<VideoFormat>& formats) { 255 const std::vector<VideoFormat>& formats) {
258 supported_formats_ = formats; 256 supported_formats_ = formats;
259 UpdateFilteredSupportedFormats(); 257 UpdateFilteredSupportedFormats();
260 } 258 }
261 259
262 bool VideoCapturer::GetBestCaptureFormat(const VideoFormat& format, 260 bool VideoCapturer::GetBestCaptureFormat(const VideoFormat& format,
263 VideoFormat* best_format) { 261 VideoFormat* best_format) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 void VideoCapturer::OnFrameCaptured(VideoCapturer*, 341 void VideoCapturer::OnFrameCaptured(VideoCapturer*,
344 const CapturedFrame* captured_frame) { 342 const CapturedFrame* captured_frame) {
345 if (muted_) { 343 if (muted_) {
346 if (black_frame_count_down_ == 0) { 344 if (black_frame_count_down_ == 0) {
347 thread_->Post(this, MSG_DO_PAUSE, NULL); 345 thread_->Post(this, MSG_DO_PAUSE, NULL);
348 } else { 346 } else {
349 --black_frame_count_down_; 347 --black_frame_count_down_;
350 } 348 }
351 } 349 }
352 350
353 if (SignalVideoFrame.is_empty()) { 351 if (!HasSinks()) {
pthatcher1 2016/02/03 15:38:35 We could make this more generic as something like
perkj_webrtc 2016/02/08 14:32:00 Done.
354 return; 352 return;
355 } 353 }
356 354
357 // Use a temporary buffer to scale 355 // Use a temporary buffer to scale
358 rtc::scoped_ptr<uint8_t[]> scale_buffer; 356 rtc::scoped_ptr<uint8_t[]> scale_buffer;
359 357
360 if (IsScreencast()) { 358 if (IsScreencast()) {
361 int scaled_width, scaled_height; 359 int scaled_width, scaled_height;
362 int desired_screencast_fps = capture_format_.get() ? 360 int desired_screencast_fps = capture_format_.get() ?
363 VideoFormat::IntervalToFps(capture_format_->interval) : 361 VideoFormat::IntervalToFps(capture_format_->interval) :
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 LOG(LS_ERROR) << "Couldn't convert to I420! " 524 LOG(LS_ERROR) << "Couldn't convert to I420! "
527 << "From " << ToString(captured_frame) << " To " 525 << "From " << ToString(captured_frame) << " To "
528 << cropped_width << " x " << cropped_height; 526 << cropped_width << " x " << cropped_height;
529 return; 527 return;
530 } 528 }
531 529
532 if (muted_) { 530 if (muted_) {
533 // TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead. 531 // TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead.
534 adapted_frame->SetToBlack(); 532 adapted_frame->SetToBlack();
535 } 533 }
536 SignalVideoFrame(this, adapted_frame.get()); 534 DeliverFrameToSinks(*adapted_frame.get());
537
538 UpdateStats(captured_frame); 535 UpdateStats(captured_frame);
539 } 536 }
540 537
541 void VideoCapturer::SetCaptureState(CaptureState state) { 538 void VideoCapturer::SetCaptureState(CaptureState state) {
542 if (state == capture_state_) { 539 if (state == capture_state_) {
543 // Don't trigger a state changed callback if the state hasn't changed. 540 // Don't trigger a state changed callback if the state hasn't changed.
544 return; 541 return;
545 } 542 }
546 StateChangeParams* state_params = new StateChangeParams(state); 543 StateChangeParams* state_params = new StateChangeParams(state);
547 capture_state_ = state; 544 capture_state_ = state;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 void VideoCapturer::GetVariableSnapshot( 716 void VideoCapturer::GetVariableSnapshot(
720 const rtc::RollingAccumulator<T>& data, 717 const rtc::RollingAccumulator<T>& data,
721 VariableInfo<T>* stats) { 718 VariableInfo<T>* stats) {
722 stats->max_val = data.ComputeMax(); 719 stats->max_val = data.ComputeMax();
723 stats->mean = data.ComputeMean(); 720 stats->mean = data.ComputeMean();
724 stats->min_val = data.ComputeMin(); 721 stats->min_val = data.ComputeMin();
725 stats->variance = data.ComputeVariance(); 722 stats->variance = data.ComputeVariance();
726 } 723 }
727 724
728 } // namespace cricket 725 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698