Ring Daemon 16.0.0
Loading...
Searching...
No Matches
callservicesmanager.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#include "mediahandler.h"
20#include "streamdata.h"
21
22#include "noncopyable.h"
23
24#include <list>
25#include <map>
26#include <tuple>
27
28namespace jami {
29
30class PluginManager;
31
32using CallMediaHandlerPtr = std::unique_ptr<CallMediaHandler>;
33using AVSubjectSPtr = std::weak_ptr<Observable<AVFrame*>>;
34
44{
45public:
53
55
57
66
71 void clearAVSubject(const std::string& callId);
72
77 std::vector<std::string> getCallMediaHandlers();
78
90 void toggleCallMediaHandler(const std::string& mediaHandlerId,
91 const std::string& callId,
92 const bool toggle);
93
99 std::map<std::string, std::string> getCallMediaHandlerDetails(
100 const std::string& mediaHandlerIdStr);
101
107 std::vector<std::string> getCallMediaHandlerStatus(const std::string& callId);
108
116 bool setPreference(const std::string& key,
117 const std::string& value,
118 const std::string& rootPath);
119
124 void clearCallHandlerMaps(const std::string& callId);
125
126private:
131 void registerComponentsLifeCycleManagers(PluginManager& pluginManager);
132
140 void notifyAVSubject(CallMediaHandlerPtr& callMediaHandlerPtr,
141 const StreamData& data,
143
145 const std::string& callId,
146 const bool toggle);
147
154 bool isVideoType(const CallMediaHandlerPtr& mediaHandler);
155
162 bool isAttached(const CallMediaHandlerPtr& mediaHandler);
163
164 // Components that a plugin can register through registerMediaHandler service.
165 // These objects can then be activated with toggleCallMediaHandler.
166 std::list<CallMediaHandlerPtr> callMediaHandlers_;
167
168 // When there is a SIPCall, AVSubjects are created there.
169 // Here we store their references in order to make them interact with MediaHandlers.
170 // For easy access they are mapped with the call they belong to.
171 std::map<std::string, std::list<std::pair<const StreamData, AVSubjectSPtr>>> callAVsubjects_;
172
173 // Component that stores MediaHandlers' status for each existing call.
174 // A map of callIds and MediaHandler-status pairs.
175 std::map<std::string, std::map<uintptr_t, bool>> mediaHandlerToggled_;
176};
177} // namespace jami
This class provides the interface between loaded MediaHandlers and call's audio/video streams.
void clearAVSubject(const std::string &callId)
Clears all stream subjects related to the callId.
std::vector< std::string > getCallMediaHandlerStatus(const std::string &callId)
Returns a list of active MediaHandlers for a given call.
void toggleCallMediaHandler(const std::string &mediaHandlerId, const std::string &callId, const bool toggle)
(De)Activates a given MediaHandler to a given call.
void clearCallHandlerMaps(const std::string &callId)
Removes call from mediaHandlerToggled_ mapping.
std::map< std::string, std::string > getCallMediaHandlerDetails(const std::string &mediaHandlerIdStr)
Returns details Map from MediaHandler implementation.
void createAVSubject(const StreamData &data, AVSubjectSPtr subject)
Stores a AV stream subject with StreamData properties.
NON_COPYABLE(CallServicesManager)
bool setPreference(const std::string &key, const std::string &value, const std::string &rootPath)
Sets a preference that may be changed while MediaHandler is active.
std::vector< std::string > getCallMediaHandlers()
List all MediaHandlers available.
This class manages plugin (un)loading.
std::unique_ptr< CallMediaHandler > CallMediaHandlerPtr
void emitSignal(Args... args)
Definition ring_signal.h:64
std::weak_ptr< Observable< AVFrame * > > AVSubjectSPtr
Simple macro to hide class' copy constructor and assignment operator.
Contains information about an AV subject.
Definition streamdata.h:29