Ring Daemon
Loading...
Searching...
No Matches
videomanager.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 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#pragma once
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <memory> // for weak/shared_ptr
24#include <map>
25#include <mutex>
26#include <string>
27
29#ifdef ENABLE_VIDEO
32#endif
33#include "media/media_player.h"
34
35namespace jami {
36
38{
39public:
40 // Client-managed video inputs and players
41 std::map<std::string, std::shared_ptr<MediaPlayer>> mediaPlayers;
43
44 // Client-managed audio preview
45 std::shared_ptr<AudioInput> audioPreview;
46
47#ifdef ENABLE_VIDEO
48 std::map<std::string, std::shared_ptr<video::VideoInput>> clientVideoInputs;
49 void setDeviceOrientation(const std::string& deviceId, int angle);
50 // device monitor
52 std::shared_ptr<video::VideoInput> getVideoInput(std::string_view id) const
53 {
54 auto input = videoInputs.find(id);
55 return input == videoInputs.end() ? nullptr : input->second.lock();
56 }
57 std::mutex videoMutex;
58 std::map<std::string, std::weak_ptr<video::VideoInput>, std::less<>> videoInputs;
59#endif
60
64 std::map<std::string, std::weak_ptr<AudioInput>, std::less<>> audioInputs;
65 std::mutex audioMutex;
66 bool hasRunningPlayers();
67};
68
69#ifdef ENABLE_VIDEO
71std::shared_ptr<video::VideoInput> getVideoInput(const std::string& resource,
73 const std::string& sink = "");
74#endif
75std::shared_ptr<AudioInput> getAudioInput(const std::string& device);
76std::string createMediaPlayer(const std::string& path);
77std::shared_ptr<MediaPlayer> getMediaPlayer(const std::string& id);
78bool pausePlayer(const std::string& id, bool pause);
79bool closeMediaPlayer(const std::string& id);
80bool mutePlayerAudio(const std::string& id, bool mute);
81bool playerSeekToTime(const std::string& id, int time);
82int64_t getPlayerPosition(const std::string& id);
83int64_t getPlayerDuration(const std::string& id);
84void setAutoRestart(const std::string& id, bool restart);
85
86} // namespace jami
std::shared_ptr< MediaPlayer > getMediaPlayer(const std::string &id)
bool closeMediaPlayer(const std::string &id)
void emitSignal(Args... args)
Definition jami_signal.h:64
std::shared_ptr< AudioInput > getAudioInput(const std::string &device)
int64_t getPlayerDuration(const std::string &id)
void setAutoRestart(const std::string &id, bool restart)
bool playerSeekToTime(const std::string &id, int time)
int64_t getPlayerPosition(const std::string &id)
bool pausePlayer(const std::string &id, bool pause)
std::string createMediaPlayer(const std::string &path)
bool mutePlayerAudio(const std::string &id, bool mute)
std::mutex mediaPlayersMutex
std::mutex audioMutex
std::map< std::string, std::weak_ptr< AudioInput >, std::less<> > audioInputs
Cache of the active Audio/Video input(s).
std::map< std::string, std::shared_ptr< MediaPlayer > > mediaPlayers
std::shared_ptr< AudioInput > audioPreview