OpenShot Library | libopenshot 1.1.1
CameraCaptureReader.h
Go to the documentation of this file.
1
9// Copyright (c) 2008-2026 OpenShot Studios, LLC
10//
11// SPDX-License-Identifier: LGPL-3.0-or-later
12
13#ifndef OPENSHOT_CAMERACAPTUREREADER_H
14#define OPENSHOT_CAMERACAPTUREREADER_H
15
16#include "AudioDevices.h"
17#include "ScreenCaptureReader.h"
18
19#include <memory>
20#include <vector>
21
22namespace openshot
23{
25 {
30 };
31
34 {
35 int width = 0;
36 int height = 0;
38 std::string input_format;
39 };
40
42 {
44 std::string device = "/dev/video0";
45 int width = 1280;
46 int height = 720;
48 std::map<std::string, std::string> options;
49 };
50
52 {
53 public:
54 explicit CameraCaptureReader(const CameraCaptureSettings& settings);
55 ~CameraCaptureReader() override;
56
57 void Close() override;
59 void RequestClose();
60 CacheBase* GetCache() override { return NULL; };
61 std::shared_ptr<openshot::Frame> GetFrame(int64_t number) override;
62 bool IsOpen() override { return reader && reader->IsOpen(); };
63 std::string Name() override { return "CameraCaptureReader"; };
64 std::string Json() const override;
65 void SetJson(const std::string value) override;
66 Json::Value JsonValue() const override;
67 void SetJsonValue(const Json::Value root) override;
68 void Open() override;
69
71 CameraCaptureSettings GetSettings() const { return settings; };
72 static bool IsBackendSupported(CameraCaptureBackend backend);
75
79 static std::vector<CameraCaptureMode> GetDeviceModes(
80 const std::string& device, CameraCaptureBackend backend = CAMERA_CAPTURE_AUTO);
81
82 private:
83 void ValidateSettings() const;
84 ScreenCaptureSettings ToDeviceSettings() const;
85 void RebuildReader();
86
87 CameraCaptureSettings settings;
88 std::unique_ptr<ScreenCaptureReader> reader;
89 };
90}
91
92#endif
Header file for Audio Device Info struct.
Header file for live screen capture readers.
All cache managers in libopenshot are based on this CacheBase class.
Definition: CacheBase.h:35
void Open() override
Open the reader (and start consuming resources, such as images or video files)
Json::Value JsonValue() const override
Generate Json::Value for this object.
void Close() override
Close the reader (and any resources it was consuming)
static bool IsBackendSupported(CameraCaptureBackend backend)
static AudioDeviceList GetDeviceNames(CameraCaptureBackend backend=CAMERA_CAPTURE_AUTO)
void RequestClose()
Request cancellation without releasing camera resources on the caller's thread.
CameraCaptureReader(const CameraCaptureSettings &settings)
std::string Json() const override
Generate JSON string of this object.
CacheBase * GetCache() override
Get the cache object used by this reader (note: not all readers use cache)
openshot::CaptureReaderStats GetStats() const
std::shared_ptr< openshot::Frame > GetFrame(int64_t number) override
static std::vector< CameraCaptureMode > GetDeviceModes(const std::string &device, CameraCaptureBackend backend=CAMERA_CAPTURE_AUTO)
std::string Name() override
Return the type name of the class.
static CameraCaptureBackend DefaultBackend()
bool IsOpen() override
Determine if reader is open or closed.
void SetJson(const std::string value) override
Load JSON string into this object.
CameraCaptureSettings GetSettings() const
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
This class represents a fraction.
Definition: Fraction.h:30
This abstract class is the base class, used by all readers in libopenshot.
Definition: ReaderBase.h:76
This namespace is the default namespace for all code in the openshot library.
Definition: AnimatedCurve.h:24
@ CAMERA_CAPTURE_WINDOWS_DSHOW
@ CAMERA_CAPTURE_MAC_AVFOUNDATION
std::vector< std::pair< std::string, std::string > > AudioDeviceList
Definition: AudioDevices.h:42
A supported capture combination, with an FFmpeg input format name.
std::map< std::string, std::string > options