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