duvc-ctl 2.0.0
USB Video Class Camera Control Library
Loading...
Searching...
No Matches
factory.cpp
Go to the documentation of this file.
1
6#include <duvc-ctl/detail/directshow_impl.h>
8#include <memory>
9
10#ifdef _WIN32
12#endif
13
14namespace duvc {
15
16#ifdef _WIN32
17
22public:
24 try {
25 detail::DirectShowEnumerator enumerator;
26 auto devices = enumerator.enumerate_devices();
27 return Ok(std::move(devices));
28 } catch (const std::exception &e) {
30 }
31 }
32
33 Result<bool> is_device_connected(const Device &device) override {
34 try {
35 detail::DirectShowEnumerator enumerator;
36 return Ok(enumerator.is_device_available(device));
37 } catch (const std::exception &e) {
38 return Err<bool>(ErrorCode::SystemError, e.what());
39 }
40 }
41
43 create_connection(const Device &device) override {
44 try {
45 auto connection = detail::create_directshow_connection(device);
46 if (!connection) {
48 ErrorCode::DeviceNotFound, "Failed to create device connection");
49 }
50 return Ok(std::move(connection));
51 } catch (const std::exception &e) {
53 e.what());
54 }
55 }
56};
57
58#endif // _WIN32
59
60std::unique_ptr<IPlatformInterface> create_platform_interface() {
61#ifdef _WIN32
62 return std::make_unique<WindowsPlatformInterface>();
63#else
64 // Return null for unsupported platforms
65 return nullptr;
66#endif
67}
68
69} // namespace duvc
Abstract interface for platform-specific camera operations.
Definition interface.h:18
Result type that can contain either a value or an error.
Definition result.h:75
Windows DirectShow platform implementation.
Definition factory.cpp:21
Result< std::unique_ptr< IDeviceConnection > > create_connection(const Device &device) override
Create device connection.
Definition factory.cpp:43
Result< std::vector< Device > > list_devices() override
Enumerate available devices.
Definition factory.cpp:23
Result< bool > is_device_connected(const Device &device) override
Check if device is connected.
Definition factory.cpp:33
DirectShow-specific declarations and helpers.
Abstract platform interface for camera control.
Definition core.h:13
@ SystemError
System/platform error.
@ DeviceNotFound
Device not found or disconnected.
std::unique_ptr< IPlatformInterface > create_platform_interface()
Get platform-specific interface implementation.
Definition factory.cpp:60
Result< void > Ok()
Helper to create successful void Result.
Definition result.h:222
Represents a camera device.
Definition types.h:131