OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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/test/vcm_capturer.h" | 11 #include "webrtc/test/vcm_capturer.h" |
12 | 12 |
13 #include "webrtc/modules/video_capture/video_capture_factory.h" | 13 #include "webrtc/modules/video_capture/video_capture_factory.h" |
14 #include "webrtc/video_send_stream.h" | 14 #include "webrtc/video_send_stream.h" |
15 | 15 |
16 namespace webrtc { | 16 namespace webrtc { |
17 namespace test { | 17 namespace test { |
18 | 18 |
19 VcmCapturer::VcmCapturer() : started_(false), sink_(nullptr), vcm_(NULL) {} | 19 VcmCapturer::VcmCapturer() : started_(false), sink_(nullptr), vcm_(NULL) {} |
20 | 20 |
21 bool VcmCapturer::Init(size_t width, size_t height, size_t target_fps) { | 21 bool VcmCapturer::Init(size_t width, size_t height, size_t target_fps) { |
22 VideoCaptureModule::DeviceInfo* device_info = | 22 VideoCaptureModule::DeviceInfo* device_info = |
23 VideoCaptureFactory::CreateDeviceInfo(42); // Any ID (42) will do. | 23 VideoCaptureFactory::CreateDeviceInfo(); |
24 | 24 |
25 char device_name[256]; | 25 char device_name[256]; |
26 char unique_name[256]; | 26 char unique_name[256]; |
27 if (device_info->GetDeviceName(0, device_name, sizeof(device_name), | 27 if (device_info->GetDeviceName(0, device_name, sizeof(device_name), |
28 unique_name, sizeof(unique_name)) != | 28 unique_name, sizeof(unique_name)) != |
29 0) { | 29 0) { |
30 Destroy(); | 30 Destroy(); |
31 return false; | 31 return false; |
32 } | 32 } |
33 | 33 |
34 vcm_ = webrtc::VideoCaptureFactory::Create(0, unique_name); | 34 vcm_ = webrtc::VideoCaptureFactory::Create(unique_name); |
35 vcm_->RegisterCaptureDataCallback(*this); | 35 vcm_->RegisterCaptureDataCallback(this); |
36 | 36 |
37 device_info->GetCapability(vcm_->CurrentDeviceName(), 0, capability_); | 37 device_info->GetCapability(vcm_->CurrentDeviceName(), 0, capability_); |
38 delete device_info; | 38 delete device_info; |
39 | 39 |
40 capability_.width = static_cast<int32_t>(width); | 40 capability_.width = static_cast<int32_t>(width); |
41 capability_.height = static_cast<int32_t>(height); | 41 capability_.height = static_cast<int32_t>(height); |
42 capability_.maxFPS = static_cast<int32_t>(target_fps); | 42 capability_.maxFPS = static_cast<int32_t>(target_fps); |
43 capability_.rawType = kVideoI420; | 43 capability_.rawType = kVideoI420; |
44 | 44 |
45 if (vcm_->StartCapture(capability_) != 0) { | 45 if (vcm_->StartCapture(capability_) != 0) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return; | 93 return; |
94 | 94 |
95 vcm_->StopCapture(); | 95 vcm_->StopCapture(); |
96 vcm_->DeRegisterCaptureDataCallback(); | 96 vcm_->DeRegisterCaptureDataCallback(); |
97 // Release reference to VCM. | 97 // Release reference to VCM. |
98 vcm_ = nullptr; | 98 vcm_ = nullptr; |
99 } | 99 } |
100 | 100 |
101 VcmCapturer::~VcmCapturer() { Destroy(); } | 101 VcmCapturer::~VcmCapturer() { Destroy(); } |
102 | 102 |
103 void VcmCapturer::OnIncomingCapturedFrame(const int32_t id, | 103 void VcmCapturer::OnFrame(const VideoFrame& frame) { |
104 const VideoFrame& frame) { | |
105 rtc::CritScope lock(&crit_); | 104 rtc::CritScope lock(&crit_); |
106 if (started_ && sink_) | 105 if (started_ && sink_) |
107 sink_->OnFrame(frame); | 106 sink_->OnFrame(frame); |
108 } | 107 } |
109 | 108 |
110 void VcmCapturer::OnCaptureDelayChanged(const int32_t id, const int32_t delay) { | |
111 } | |
112 } // test | 109 } // test |
113 } // webrtc | 110 } // webrtc |
OLD | NEW |