Ring Daemon 16.0.0
Loading...
Searching...
No Matches
video_device_monitor.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef VIDEO_DEVICE_MONITOR_H__
19#define VIDEO_DEVICE_MONITOR_H__
20
21#include "config/serializable.h"
22#include "noncopyable.h"
23
24#include <map>
25#include <string>
26#include <memory>
27
28#include "video_device.h"
29
30namespace YAML {
31class Emitter;
32class Node;
33} // namespace YAML
34
35namespace jami {
36namespace video {
37
38class VideoDeviceMonitorImpl;
39
41{
42public:
45
46 std::vector<std::string> getDeviceList() const;
47
48 libjami::VideoCapabilities getCapabilities(const std::string& name) const;
49 VideoSettings getSettings(const std::string& name);
50 void applySettings(const std::string& name, const VideoSettings& settings);
51
52 std::string getDefaultDevice() const;
53 std::string getMRLForDefaultDevice() const;
54 bool setDefaultDevice(const std::string& name);
55 void setDeviceOrientation(const std::string& id, int angle);
56
57 bool addDevice(const std::string& node,
58 const std::vector<std::map<std::string, std::string>>& devInfo = {});
59 void removeDevice(const std::string& node);
60 void removeDeviceViaInput(const std::string& path);
61
65 DeviceParams getDeviceParams(const std::string& name) const;
66
67 /*
68 * Interface to load from/store to the (YAML) configuration file.
69 */
70 void serialize(YAML::Emitter& out) const override;
71 virtual void unserialize(const YAML::Node& in) override;
72
73private:
75
76 mutable std::mutex lock_;
77 /*
78 * User preferred settings for a device,
79 * as loaded from (and stored to) the configuration file.
80 */
81 std::vector<VideoSettings> preferences_;
82
83 void overwritePreferences(const VideoSettings& settings);
84 std::vector<VideoSettings>::iterator findPreferencesById(const std::string& id);
85
86 /*
87 * Vector containing the video devices.
88 */
89 std::vector<VideoDevice> devices_;
90 std::string defaultDevice_ = "";
91
92 std::vector<VideoDevice>::iterator findDeviceById(const std::string& id);
93 std::vector<VideoDevice>::const_iterator findDeviceById(const std::string& id) const;
94
95 std::unique_ptr<VideoDeviceMonitorImpl> monitorImpl_;
96
97 constexpr static const char* CONFIG_LABEL = "video";
98};
99
100} // namespace video
101} // namespace jami
102
103#endif /* VIDEO_DEVICE_MONITOR_H__ */
bool addDevice(const std::string &node, const std::vector< std::map< std::string, std::string > > &devInfo={})
bool setDefaultDevice(const std::string &name)
libjami::VideoCapabilities getCapabilities(const std::string &name) const
DeviceParams getDeviceParams(const std::string &name) const
Params for libav.
void applySettings(const std::string &name, const VideoSettings &settings)
void removeDeviceViaInput(const std::string &path)
VideoSettings getSettings(const std::string &name)
void setDeviceOrientation(const std::string &id, int angle)
virtual void unserialize(const YAML::Node &in) override
std::vector< std::string > getDeviceList() const
void removeDevice(const std::string &node)
void serialize(YAML::Emitter &out) const override
void emitSignal(Args... args)
Definition ring_signal.h:64
std::map< std::string, std::map< std::string, std::vector< std::string > > > VideoCapabilities
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30
DeviceParams Parameters used by MediaDecoder and MediaEncoder to open a LibAV device/stream.