OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 #include "webrtc/media/engine/webrtcvideocapturer.h" | 11 #include "webrtc/media/engine/webrtcvideocapturer.h" |
12 | 12 |
13 #include "webrtc/base/arraysize.h" | 13 #include "webrtc/base/arraysize.h" |
14 #include "webrtc/base/bind.h" | 14 #include "webrtc/base/bind.h" |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/criticalsection.h" | 16 #include "webrtc/base/criticalsection.h" |
17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
18 #include "webrtc/base/safe_conversions.h" | 18 #include "webrtc/base/safe_conversions.h" |
19 #include "webrtc/base/thread.h" | 19 #include "webrtc/base/thread.h" |
20 #include "webrtc/base/timeutils.h" | 20 #include "webrtc/base/timeutils.h" |
21 #include "webrtc/media/engine/webrtcvideoframe.h" | 21 #include "webrtc/media/engine/webrtcvideoframe.h" |
22 #include "webrtc/media/engine/webrtcvideoframefactory.h" | |
23 | 22 |
24 #include "webrtc/base/win32.h" // Need this to #include the impl files. | 23 #include "webrtc/base/win32.h" // Need this to #include the impl files. |
25 #include "webrtc/modules/video_capture/video_capture_factory.h" | 24 #include "webrtc/modules/video_capture/video_capture_factory.h" |
26 #include "webrtc/system_wrappers/include/field_trial.h" | 25 #include "webrtc/system_wrappers/include/field_trial.h" |
27 | 26 |
28 namespace cricket { | 27 namespace cricket { |
29 | 28 |
30 struct kVideoFourCCEntry { | 29 struct kVideoFourCCEntry { |
31 uint32_t fourcc; | 30 uint32_t fourcc; |
32 webrtc::RawVideoType webrtc_type; | 31 webrtc::RawVideoType webrtc_type; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 105 |
107 /////////////////////////////////////////////////////////////////////////// | 106 /////////////////////////////////////////////////////////////////////////// |
108 // Implementation of class WebRtcVideoCapturer | 107 // Implementation of class WebRtcVideoCapturer |
109 /////////////////////////////////////////////////////////////////////////// | 108 /////////////////////////////////////////////////////////////////////////// |
110 | 109 |
111 WebRtcVideoCapturer::WebRtcVideoCapturer() | 110 WebRtcVideoCapturer::WebRtcVideoCapturer() |
112 : factory_(new WebRtcVcmFactory), | 111 : factory_(new WebRtcVcmFactory), |
113 module_(nullptr), | 112 module_(nullptr), |
114 captured_frames_(0), | 113 captured_frames_(0), |
115 start_thread_(nullptr), | 114 start_thread_(nullptr), |
116 async_invoker_(nullptr) { | 115 async_invoker_(nullptr) {} |
117 set_frame_factory(new WebRtcVideoFrameFactory()); | |
118 } | |
119 | 116 |
120 WebRtcVideoCapturer::WebRtcVideoCapturer(WebRtcVcmFactoryInterface* factory) | 117 WebRtcVideoCapturer::WebRtcVideoCapturer(WebRtcVcmFactoryInterface* factory) |
121 : factory_(factory), | 118 : factory_(factory), |
122 module_(nullptr), | 119 module_(nullptr), |
123 captured_frames_(0), | 120 captured_frames_(0), |
124 start_thread_(nullptr), | 121 start_thread_(nullptr), |
125 async_invoker_(nullptr) { | 122 async_invoker_(nullptr) {} |
126 set_frame_factory(new WebRtcVideoFrameFactory()); | |
127 } | |
128 | 123 |
129 WebRtcVideoCapturer::~WebRtcVideoCapturer() {} | 124 WebRtcVideoCapturer::~WebRtcVideoCapturer() {} |
130 | 125 |
131 bool WebRtcVideoCapturer::Init(const Device& device) { | 126 bool WebRtcVideoCapturer::Init(const Device& device) { |
132 RTC_DCHECK(!start_thread_); | 127 RTC_DCHECK(!start_thread_); |
133 if (module_) { | 128 if (module_) { |
134 LOG(LS_ERROR) << "The capturer is already initialized"; | 129 LOG(LS_ERROR) << "The capturer is already initialized"; |
135 return false; | 130 return false; |
136 } | 131 } |
137 | 132 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 ++captured_frames_; | 348 ++captured_frames_; |
354 // Log the size and pixel aspect ratio of the first captured frame. | 349 // Log the size and pixel aspect ratio of the first captured frame. |
355 if (1 == captured_frames_) { | 350 if (1 == captured_frames_) { |
356 LOG(LS_INFO) << "Captured frame size " | 351 LOG(LS_INFO) << "Captured frame size " |
357 << sample.width() << "x" << sample.height() | 352 << sample.width() << "x" << sample.height() |
358 << ". Expected format " << GetCaptureFormat()->ToString(); | 353 << ". Expected format " << GetCaptureFormat()->ToString(); |
359 } | 354 } |
360 | 355 |
361 OnFrame(cricket::WebRtcVideoFrame( | 356 OnFrame(cricket::WebRtcVideoFrame( |
362 sample.video_frame_buffer(), sample.rotation(), | 357 sample.video_frame_buffer(), sample.rotation(), |
363 sample.render_time_ms() * rtc::kNumMicrosecsPerMillisec, 0), | 358 sample.render_time_ms() * rtc::kNumMicrosecsPerMillisec), |
364 sample.width(), sample.height()); | 359 sample.width(), sample.height()); |
365 } | 360 } |
366 | 361 |
367 void WebRtcVideoCapturer::OnCaptureDelayChanged(const int32_t id, | 362 void WebRtcVideoCapturer::OnCaptureDelayChanged(const int32_t id, |
368 const int32_t delay) { | 363 const int32_t delay) { |
369 LOG(LS_INFO) << "Capture delay changed to " << delay << " ms"; | 364 LOG(LS_INFO) << "Capture delay changed to " << delay << " ms"; |
370 } | 365 } |
371 | 366 |
372 } // namespace cricket | 367 } // namespace cricket |
OLD | NEW |