Ring Daemon 16.0.0
Loading...
Searching...
No Matches
iosvideo/video_device_monitor_impl.cpp
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#include <mutex>
19#include <thread>
20
21#include "../video_device_monitor.h"
22#include "logger.h"
23#include "noncopyable.h"
24
25namespace jami {
26namespace video {
27
28class VideoDeviceMonitorImpl
29{
30public:
31 /*
32 * This is the only restriction to the pImpl design:
33 * as the Linux implementation has a thread, it needs a way to notify
34 * devices addition and deletion.
35 *
36 * This class should maybe inherit from VideoDeviceMonitor instead of
37 * being its pImpl.
38 */
41
42 void start();
43
44private:
46
47 VideoDeviceMonitor* monitor_;
48
49 void run();
50
51 mutable std::mutex mutex_;
52 bool probing_;
53 std::thread thread_;
54};
55
57 : monitor_(monitor)
58 , mutex_()
59 , thread_()
60{}
61
62void
64{
65 probing_ = true;
66 thread_ = std::thread(&VideoDeviceMonitorImpl::run, this);
67}
68
70{
71 probing_ = false;
72 if (thread_.joinable())
73 thread_.join();
74}
75
76void
77VideoDeviceMonitorImpl::run()
78{}
79
81 : preferences_()
82 , devices_()
83 , monitorImpl_(new VideoDeviceMonitorImpl(this))
84{
85 monitorImpl_->start();
86}
87
89
90} // namespace video
91} // namespace jami
VideoDeviceMonitorImpl(VideoDeviceMonitor *monitor)
void emitSignal(Args... args)
Definition ring_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30