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

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

Issue 1655793003: Make cricket::VideoCapturer implement VideoSourceInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added dummy capturerenderadapter.cc 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
« no previous file with comments | « webrtc/media/base/videocapturer.h ('k') | webrtc/media/base/videocapturer_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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 black_frame_count_down_ = kNumBlackFramesOnMute; 219 black_frame_count_down_ = kNumBlackFramesOnMute;
220 // Following frames will be overritten with black, then the camera will be 220 // Following frames will be overritten with black, then the camera will be
221 // paused. 221 // paused.
222 return true; 222 return true;
223 } 223 }
224 // Start the camera. 224 // Start the camera.
225 thread_->Clear(this, MSG_DO_PAUSE); 225 thread_->Clear(this, MSG_DO_PAUSE);
226 return Pause(false); 226 return Pause(false);
227 } 227 }
228 228
229 // Note that the last caller decides whether rotation should be applied if there
230 // are multiple send streams using the same camera.
231 bool VideoCapturer::SetApplyRotation(bool enable) {
232 apply_rotation_ = enable;
233 if (frame_factory_) {
234 frame_factory_->SetApplyRotation(apply_rotation_);
235 }
236 return true;
237 }
238
239 void VideoCapturer::SetSupportedFormats( 229 void VideoCapturer::SetSupportedFormats(
240 const std::vector<VideoFormat>& formats) { 230 const std::vector<VideoFormat>& formats) {
241 supported_formats_ = formats; 231 supported_formats_ = formats;
242 UpdateFilteredSupportedFormats(); 232 UpdateFilteredSupportedFormats();
243 } 233 }
244 234
245 bool VideoCapturer::GetBestCaptureFormat(const VideoFormat& format, 235 bool VideoCapturer::GetBestCaptureFormat(const VideoFormat& format,
246 VideoFormat* best_format) { 236 VideoFormat* best_format) {
247 // TODO(fbarchard): Directly support max_format. 237 // TODO(fbarchard): Directly support max_format.
248 UpdateFilteredSupportedFormats(); 238 UpdateFilteredSupportedFormats();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 VideoFormat* last_captured_frame_format) { 306 VideoFormat* last_captured_frame_format) {
317 rtc::CritScope cs(&frame_stats_crit_); 307 rtc::CritScope cs(&frame_stats_crit_);
318 GetVariableSnapshot(adapt_frame_drops_data_, adapt_drops_stats); 308 GetVariableSnapshot(adapt_frame_drops_data_, adapt_drops_stats);
319 GetVariableSnapshot(frame_time_data_, frame_time_stats); 309 GetVariableSnapshot(frame_time_data_, frame_time_stats);
320 *last_captured_frame_format = last_captured_frame_format_; 310 *last_captured_frame_format = last_captured_frame_format_;
321 311
322 adapt_frame_drops_data_.Reset(); 312 adapt_frame_drops_data_.Reset();
323 frame_time_data_.Reset(); 313 frame_time_data_.Reset();
324 } 314 }
325 315
316 void VideoCapturer::RemoveSink(
317 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) {
318 broadcaster_.RemoveSink(sink);
319 }
320
321 void VideoCapturer::AddOrUpdateSink(
322 rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
323 const rtc::VideoSinkWants& wants) {
324 broadcaster_.AddOrUpdateSink(sink, wants);
325 OnSinkWantsChanged(broadcaster_.wants());
326 }
327
328 void VideoCapturer::OnSinkWantsChanged(const rtc::VideoSinkWants& wants) {
329 apply_rotation_ = wants.rotation_applied;
330 if (frame_factory_) {
331 frame_factory_->SetApplyRotation(apply_rotation_);
332 }
333 }
334
326 void VideoCapturer::OnFrameCaptured(VideoCapturer*, 335 void VideoCapturer::OnFrameCaptured(VideoCapturer*,
327 const CapturedFrame* captured_frame) { 336 const CapturedFrame* captured_frame) {
328 if (muted_) { 337 if (muted_) {
329 if (black_frame_count_down_ == 0) { 338 if (black_frame_count_down_ == 0) {
330 thread_->Post(this, MSG_DO_PAUSE, NULL); 339 thread_->Post(this, MSG_DO_PAUSE, NULL);
331 } else { 340 } else {
332 --black_frame_count_down_; 341 --black_frame_count_down_;
333 } 342 }
334 } 343 }
335 344
336 if (SignalVideoFrame.is_empty()) { 345 if (!broadcaster_.frame_wanted()) {
337 return; 346 return;
338 } 347 }
339 348
340 // Use a temporary buffer to scale 349 // Use a temporary buffer to scale
341 rtc::scoped_ptr<uint8_t[]> scale_buffer; 350 rtc::scoped_ptr<uint8_t[]> scale_buffer;
342 351
343 if (IsScreencast()) { 352 if (IsScreencast()) {
344 int scaled_width, scaled_height; 353 int scaled_width, scaled_height;
345 int desired_screencast_fps = capture_format_.get() ? 354 int desired_screencast_fps = capture_format_.get() ?
346 VideoFormat::IntervalToFps(capture_format_->interval) : 355 VideoFormat::IntervalToFps(capture_format_->interval) :
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 LOG(LS_ERROR) << "Couldn't convert to I420! " 518 LOG(LS_ERROR) << "Couldn't convert to I420! "
510 << "From " << ToString(captured_frame) << " To " 519 << "From " << ToString(captured_frame) << " To "
511 << cropped_width << " x " << cropped_height; 520 << cropped_width << " x " << cropped_height;
512 return; 521 return;
513 } 522 }
514 523
515 if (muted_) { 524 if (muted_) {
516 // TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead. 525 // TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead.
517 adapted_frame->SetToBlack(); 526 adapted_frame->SetToBlack();
518 } 527 }
519 SignalVideoFrame(this, adapted_frame.get()); 528 broadcaster_.OnFrame(*adapted_frame.get());
520
521 UpdateStats(captured_frame); 529 UpdateStats(captured_frame);
522 } 530 }
523 531
524 void VideoCapturer::SetCaptureState(CaptureState state) { 532 void VideoCapturer::SetCaptureState(CaptureState state) {
525 if (state == capture_state_) { 533 if (state == capture_state_) {
526 // Don't trigger a state changed callback if the state hasn't changed. 534 // Don't trigger a state changed callback if the state hasn't changed.
527 return; 535 return;
528 } 536 }
529 StateChangeParams* state_params = new StateChangeParams(state); 537 StateChangeParams* state_params = new StateChangeParams(state);
530 capture_state_ = state; 538 capture_state_ = state;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 void VideoCapturer::GetVariableSnapshot( 710 void VideoCapturer::GetVariableSnapshot(
703 const rtc::RollingAccumulator<T>& data, 711 const rtc::RollingAccumulator<T>& data,
704 VariableInfo<T>* stats) { 712 VariableInfo<T>* stats) {
705 stats->max_val = data.ComputeMax(); 713 stats->max_val = data.ComputeMax();
706 stats->mean = data.ComputeMean(); 714 stats->mean = data.ComputeMean();
707 stats->min_val = data.ComputeMin(); 715 stats->min_val = data.ComputeMin();
708 stats->variance = data.ComputeVariance(); 716 stats->variance = data.ComputeVariance();
709 } 717 }
710 718
711 } // namespace cricket 719 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/videocapturer.h ('k') | webrtc/media/base/videocapturer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698