Ring Daemon 16.0.0
Loading...
Searching...
No Matches
videomanager.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#pragma once
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <memory> // for weak/shared_ptr
24#include <vector>
25#include <map>
26#include <mutex>
27#include <string>
28
30#ifdef ENABLE_VIDEO
34#endif
35#include "media/media_player.h"
36
37namespace jami {
38
40{
41public:
42 // Client-managed video inputs and players
43 std::map<std::string, std::shared_ptr<MediaPlayer>> mediaPlayers;
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(
72 const std::string& resource,
74 const std::string& sink = "");
75#endif
76std::shared_ptr<AudioInput> getAudioInput(const std::string& device);
77std::string createMediaPlayer(const std::string& path);
78std::shared_ptr<MediaPlayer> getMediaPlayer(const std::string& id);
79bool pausePlayer(const std::string& id, bool pause);
80bool closeMediaPlayer(const std::string& id);
81bool mutePlayerAudio(const std::string& id, bool mute);
82bool playerSeekToTime(const std::string& id, int time);
83int64_t getPlayerPosition(const std::string& id);
84int64_t getPlayerDuration(const std::string& id);
85void setAutoRestart(const std::string& id, bool restart);
86
87} // namespace jami
std::shared_ptr< MediaPlayer > getMediaPlayer(const std::string &id)
bool closeMediaPlayer(const std::string &id)
void emitSignal(Args... args)
Definition ring_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 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