Loading...
Searching...
No Matches
WebCameraInput.hpp
1#pragma once
2#include <Media/Libav.hpp>
3
4#if defined(__EMSCRIPTEN__) && SCORE_HAS_LIBAV
5#include <Video/ExternalInput.hpp>
6#include <Video/FrameQueue.hpp>
7
8#include <score_plugin_media_export.h>
9
10#include <string>
11#include <vector>
12
13namespace Video
14{
15struct WebCameraDevice
16{
17 std::string id;
18 std::string label;
19};
20
22SCORE_PLUGIN_MEDIA_EXPORT void webCameraScan() noexcept;
23
26SCORE_PLUGIN_MEDIA_EXPORT int webCameraScanGeneration() noexcept;
27
30SCORE_PLUGIN_MEDIA_EXPORT std::vector<WebCameraDevice> webCameraDevices() noexcept;
31
39class SCORE_PLUGIN_MEDIA_EXPORT WebCameraInput final : public ExternalInput
40{
41public:
42 WebCameraInput() noexcept;
43 ~WebCameraInput() noexcept override;
44
45 bool load(const std::string& deviceId, int w, int h, double fps) noexcept;
46
47 bool start() noexcept override;
48 void stop() noexcept override;
49
50 AVFrame* dequeue_frame() noexcept override;
51 void release_frame(AVFrame* frame) noexcept override;
52
53private:
54 void fetch() noexcept;
55
56 FrameQueue m_frames;
57 std::string m_deviceId;
58 int m_requestedWidth{};
59 int m_requestedHeight{};
60 double m_requestedFps{};
61 int m_handle{};
62 bool m_reportedError{};
63};
64}
65#endif
STL namespace.