OpenShot Library | libopenshot  1.0.0
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 
21 namespace openshot
22 {
24  {
29  };
30 
32  {
34  std::string device = "/dev/video0";
35  int width = 1280;
36  int height = 720;
38  std::map<std::string, std::string> options;
39  };
40 
42  {
43  public:
44  explicit CameraCaptureReader(const CameraCaptureSettings& settings);
45  ~CameraCaptureReader() override;
46 
47  void Close() override;
48  CacheBase* GetCache() override { return NULL; };
49  std::shared_ptr<openshot::Frame> GetFrame(int64_t number) override;
50  bool IsOpen() override { return reader && reader->IsOpen(); };
51  std::string Name() override { return "CameraCaptureReader"; };
52  std::string Json() const override;
53  void SetJson(const std::string value) override;
54  Json::Value JsonValue() const override;
55  void SetJsonValue(const Json::Value root) override;
56  void Open() override;
57 
59  CameraCaptureSettings GetSettings() const { return settings; };
60  static bool IsBackendSupported(CameraCaptureBackend backend);
63 
64  private:
65  void ValidateSettings() const;
66  ScreenCaptureSettings ToDeviceSettings() const;
67  void RebuildReader();
68 
69  CameraCaptureSettings settings;
70  std::unique_ptr<ScreenCaptureReader> reader;
71  };
72 }
73 
74 #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)
CameraCaptureReader(const CameraCaptureSettings &settings)
std::string Json() const override
Generate JSON string of this object.
openshot::CaptureReaderStats GetStats() const
std::shared_ptr< openshot::Frame > GetFrame(int64_t number) override
CacheBase * GetCache() override
Get the cache object used by this reader (note: not all readers use cache)
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
std::map< std::string, std::string > options