| OLD | NEW |
| 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 Loading... |
| 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 |
| 229 void VideoCapturer::SetSupportedFormats( | 239 void VideoCapturer::SetSupportedFormats( |
| 230 const std::vector<VideoFormat>& formats) { | 240 const std::vector<VideoFormat>& formats) { |
| 231 supported_formats_ = formats; | 241 supported_formats_ = formats; |
| 232 UpdateFilteredSupportedFormats(); | 242 UpdateFilteredSupportedFormats(); |
| 233 } | 243 } |
| 234 | 244 |
| 235 bool VideoCapturer::GetBestCaptureFormat(const VideoFormat& format, | 245 bool VideoCapturer::GetBestCaptureFormat(const VideoFormat& format, |
| 236 VideoFormat* best_format) { | 246 VideoFormat* best_format) { |
| 237 // TODO(fbarchard): Directly support max_format. | 247 // TODO(fbarchard): Directly support max_format. |
| 238 UpdateFilteredSupportedFormats(); | 248 UpdateFilteredSupportedFormats(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 VideoFormat* last_captured_frame_format) { | 316 VideoFormat* last_captured_frame_format) { |
| 307 rtc::CritScope cs(&frame_stats_crit_); | 317 rtc::CritScope cs(&frame_stats_crit_); |
| 308 GetVariableSnapshot(adapt_frame_drops_data_, adapt_drops_stats); | 318 GetVariableSnapshot(adapt_frame_drops_data_, adapt_drops_stats); |
| 309 GetVariableSnapshot(frame_time_data_, frame_time_stats); | 319 GetVariableSnapshot(frame_time_data_, frame_time_stats); |
| 310 *last_captured_frame_format = last_captured_frame_format_; | 320 *last_captured_frame_format = last_captured_frame_format_; |
| 311 | 321 |
| 312 adapt_frame_drops_data_.Reset(); | 322 adapt_frame_drops_data_.Reset(); |
| 313 frame_time_data_.Reset(); | 323 frame_time_data_.Reset(); |
| 314 } | 324 } |
| 315 | 325 |
| 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 | |
| 335 void VideoCapturer::OnFrameCaptured(VideoCapturer*, | 326 void VideoCapturer::OnFrameCaptured(VideoCapturer*, |
| 336 const CapturedFrame* captured_frame) { | 327 const CapturedFrame* captured_frame) { |
| 337 if (muted_) { | 328 if (muted_) { |
| 338 if (black_frame_count_down_ == 0) { | 329 if (black_frame_count_down_ == 0) { |
| 339 thread_->Post(this, MSG_DO_PAUSE, NULL); | 330 thread_->Post(this, MSG_DO_PAUSE, NULL); |
| 340 } else { | 331 } else { |
| 341 --black_frame_count_down_; | 332 --black_frame_count_down_; |
| 342 } | 333 } |
| 343 } | 334 } |
| 344 | 335 |
| 345 if (!broadcaster_.frame_wanted()) { | 336 if (SignalVideoFrame.is_empty()) { |
| 346 return; | 337 return; |
| 347 } | 338 } |
| 348 | 339 |
| 349 // Use a temporary buffer to scale | 340 // Use a temporary buffer to scale |
| 350 rtc::scoped_ptr<uint8_t[]> scale_buffer; | 341 rtc::scoped_ptr<uint8_t[]> scale_buffer; |
| 351 | 342 |
| 352 if (IsScreencast()) { | 343 if (IsScreencast()) { |
| 353 int scaled_width, scaled_height; | 344 int scaled_width, scaled_height; |
| 354 int desired_screencast_fps = capture_format_.get() ? | 345 int desired_screencast_fps = capture_format_.get() ? |
| 355 VideoFormat::IntervalToFps(capture_format_->interval) : | 346 VideoFormat::IntervalToFps(capture_format_->interval) : |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 LOG(LS_ERROR) << "Couldn't convert to I420! " | 509 LOG(LS_ERROR) << "Couldn't convert to I420! " |
| 519 << "From " << ToString(captured_frame) << " To " | 510 << "From " << ToString(captured_frame) << " To " |
| 520 << cropped_width << " x " << cropped_height; | 511 << cropped_width << " x " << cropped_height; |
| 521 return; | 512 return; |
| 522 } | 513 } |
| 523 | 514 |
| 524 if (muted_) { | 515 if (muted_) { |
| 525 // TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead. | 516 // TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead. |
| 526 adapted_frame->SetToBlack(); | 517 adapted_frame->SetToBlack(); |
| 527 } | 518 } |
| 528 broadcaster_.OnFrame(*adapted_frame.get()); | 519 SignalVideoFrame(this, adapted_frame.get()); |
| 520 |
| 529 UpdateStats(captured_frame); | 521 UpdateStats(captured_frame); |
| 530 } | 522 } |
| 531 | 523 |
| 532 void VideoCapturer::SetCaptureState(CaptureState state) { | 524 void VideoCapturer::SetCaptureState(CaptureState state) { |
| 533 if (state == capture_state_) { | 525 if (state == capture_state_) { |
| 534 // Don't trigger a state changed callback if the state hasn't changed. | 526 // Don't trigger a state changed callback if the state hasn't changed. |
| 535 return; | 527 return; |
| 536 } | 528 } |
| 537 StateChangeParams* state_params = new StateChangeParams(state); | 529 StateChangeParams* state_params = new StateChangeParams(state); |
| 538 capture_state_ = state; | 530 capture_state_ = state; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 void VideoCapturer::GetVariableSnapshot( | 702 void VideoCapturer::GetVariableSnapshot( |
| 711 const rtc::RollingAccumulator<T>& data, | 703 const rtc::RollingAccumulator<T>& data, |
| 712 VariableInfo<T>* stats) { | 704 VariableInfo<T>* stats) { |
| 713 stats->max_val = data.ComputeMax(); | 705 stats->max_val = data.ComputeMax(); |
| 714 stats->mean = data.ComputeMean(); | 706 stats->mean = data.ComputeMean(); |
| 715 stats->min_val = data.ComputeMin(); | 707 stats->min_val = data.ComputeMin(); |
| 716 stats->variance = data.ComputeVariance(); | 708 stats->variance = data.ComputeVariance(); |
| 717 } | 709 } |
| 718 | 710 |
| 719 } // namespace cricket | 711 } // namespace cricket |
| OLD | NEW |