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 |
11 // Implementation file of class VideoCapturer. | 11 // Implementation file of class VideoCapturer. |
12 | 12 |
13 #include "webrtc/media/base/videocapturer.h" | 13 #include "webrtc/media/base/videocapturer.h" |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
16 | 16 |
| 17 #include "webrtc/api/video/i420_buffer.h" |
| 18 #include "webrtc/api/video/video_frame.h" |
17 #include "webrtc/base/common.h" | 19 #include "webrtc/base/common.h" |
18 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
19 #include "webrtc/base/systeminfo.h" | 21 #include "webrtc/base/systeminfo.h" |
20 #include "webrtc/video_frame.h" | |
21 | 22 |
22 namespace cricket { | 23 namespace cricket { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 static const int64_t kMaxDistance = ~(static_cast<int64_t>(1) << 63); | 27 static const int64_t kMaxDistance = ~(static_cast<int64_t>(1) << 63); |
27 #ifdef WEBRTC_LINUX | 28 #ifdef WEBRTC_LINUX |
28 static const int kYU12Penalty = 16; // Needs to be higher than MJPG index. | 29 static const int kYU12Penalty = 16; // Needs to be higher than MJPG index. |
29 #endif | 30 #endif |
30 | 31 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 if (buffer->native_handle()) { | 209 if (buffer->native_handle()) { |
209 // Sources producing native frames must handle apply_rotation | 210 // Sources producing native frames must handle apply_rotation |
210 // themselves. But even if they do, we may occasionally end up | 211 // themselves. But even if they do, we may occasionally end up |
211 // in this case, for frames in flight at the time | 212 // in this case, for frames in flight at the time |
212 // applied_rotation is set to true. In that case, we just drop | 213 // applied_rotation is set to true. In that case, we just drop |
213 // the frame. | 214 // the frame. |
214 LOG(LS_WARNING) << "Native frame requiring rotation. Discarding."; | 215 LOG(LS_WARNING) << "Native frame requiring rotation. Discarding."; |
215 return; | 216 return; |
216 } | 217 } |
217 broadcaster_.OnFrame(webrtc::VideoFrame( | 218 broadcaster_.OnFrame(webrtc::VideoFrame( |
218 webrtc::I420Buffer::Rotate(buffer, frame.rotation()), | 219 webrtc::I420Buffer::Rotate(*buffer, frame.rotation()), |
219 webrtc::kVideoRotation_0, frame.timestamp_us())); | 220 webrtc::kVideoRotation_0, frame.timestamp_us())); |
220 } else { | 221 } else { |
221 broadcaster_.OnFrame(frame); | 222 broadcaster_.OnFrame(frame); |
222 } | 223 } |
223 UpdateInputSize(orig_width, orig_height); | 224 UpdateInputSize(orig_width, orig_height); |
224 } | 225 } |
225 | 226 |
226 void VideoCapturer::SetCaptureState(CaptureState state) { | 227 void VideoCapturer::SetCaptureState(CaptureState state) { |
227 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 228 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
228 if (state == capture_state_) { | 229 if (state == capture_state_) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 void VideoCapturer::UpdateInputSize(int width, int height) { | 365 void VideoCapturer::UpdateInputSize(int width, int height) { |
365 // Update stats protected from fetches from different thread. | 366 // Update stats protected from fetches from different thread. |
366 rtc::CritScope cs(&frame_stats_crit_); | 367 rtc::CritScope cs(&frame_stats_crit_); |
367 | 368 |
368 input_size_valid_ = true; | 369 input_size_valid_ = true; |
369 input_width_ = width; | 370 input_width_ = width; |
370 input_height_ = height; | 371 input_height_ = height; |
371 } | 372 } |
372 | 373 |
373 } // namespace cricket | 374 } // namespace cricket |
OLD | NEW |