| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return ss.str(); | 176 return ss.str(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void VideoCapturer::set_frame_factory(VideoFrameFactory* frame_factory) { | 179 void VideoCapturer::set_frame_factory(VideoFrameFactory* frame_factory) { |
| 180 frame_factory_.reset(frame_factory); | 180 frame_factory_.reset(frame_factory); |
| 181 if (frame_factory) { | 181 if (frame_factory) { |
| 182 frame_factory->SetApplyRotation(apply_rotation_); | 182 frame_factory->SetApplyRotation(apply_rotation_); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void VideoCapturer::GetStats(VideoFormat* last_captured_frame_format) { | |
| 187 rtc::CritScope cs(&frame_stats_crit_); | |
| 188 *last_captured_frame_format = last_captured_frame_format_; | |
| 189 } | |
| 190 | |
| 191 void VideoCapturer::RemoveSink( | 186 void VideoCapturer::RemoveSink( |
| 192 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { | 187 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) { |
| 193 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 188 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 194 broadcaster_.RemoveSink(sink); | 189 broadcaster_.RemoveSink(sink); |
| 195 OnSinkWantsChanged(broadcaster_.wants()); | 190 OnSinkWantsChanged(broadcaster_.wants()); |
| 196 } | 191 } |
| 197 | 192 |
| 198 void VideoCapturer::AddOrUpdateSink( | 193 void VideoCapturer::AddOrUpdateSink( |
| 199 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | 194 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
| 200 const rtc::VideoSinkWants& wants) { | 195 const rtc::VideoSinkWants& wants) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 383 |
| 389 if (!adapted_frame) { | 384 if (!adapted_frame) { |
| 390 // TODO(fbarchard): LOG more information about captured frame attributes. | 385 // TODO(fbarchard): LOG more information about captured frame attributes. |
| 391 LOG(LS_ERROR) << "Couldn't convert to I420! " | 386 LOG(LS_ERROR) << "Couldn't convert to I420! " |
| 392 << "From " << ToString(captured_frame) << " To " | 387 << "From " << ToString(captured_frame) << " To " |
| 393 << cropped_width << " x " << cropped_height; | 388 << cropped_width << " x " << cropped_height; |
| 394 return; | 389 return; |
| 395 } | 390 } |
| 396 | 391 |
| 397 SignalVideoFrame(this, adapted_frame.get()); | 392 SignalVideoFrame(this, adapted_frame.get()); |
| 398 UpdateStats(captured_frame); | |
| 399 } | 393 } |
| 400 | 394 |
| 401 void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) { | 395 void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) { |
| 402 broadcaster_.OnFrame(*frame); | 396 broadcaster_.OnFrame(*frame); |
| 403 } | 397 } |
| 404 | 398 |
| 405 void VideoCapturer::SetCaptureState(CaptureState state) { | 399 void VideoCapturer::SetCaptureState(CaptureState state) { |
| 406 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 400 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 407 if (state == capture_state_) { | 401 if (state == capture_state_) { |
| 408 // Don't trigger a state changed callback if the state hasn't changed. | 402 // Don't trigger a state changed callback if the state hasn't changed. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 527 |
| 534 bool VideoCapturer::ShouldFilterFormat(const VideoFormat& format) const { | 528 bool VideoCapturer::ShouldFilterFormat(const VideoFormat& format) const { |
| 535 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 529 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 536 if (!enable_camera_list_) { | 530 if (!enable_camera_list_) { |
| 537 return false; | 531 return false; |
| 538 } | 532 } |
| 539 return format.width > max_format_->width || | 533 return format.width > max_format_->width || |
| 540 format.height > max_format_->height; | 534 format.height > max_format_->height; |
| 541 } | 535 } |
| 542 | 536 |
| 543 void VideoCapturer::UpdateStats(const CapturedFrame* captured_frame) { | |
| 544 // Update stats protected from fetches from different thread. | |
| 545 rtc::CritScope cs(&frame_stats_crit_); | |
| 546 | |
| 547 last_captured_frame_format_.width = captured_frame->width; | |
| 548 last_captured_frame_format_.height = captured_frame->height; | |
| 549 // TODO(ronghuawu): Useful to report interval as well? | |
| 550 last_captured_frame_format_.interval = 0; | |
| 551 last_captured_frame_format_.fourcc = captured_frame->fourcc; | |
| 552 } | |
| 553 | |
| 554 } // namespace cricket | 537 } // namespace cricket |
| OLD | NEW |