Ring Daemon
Loading...
Searching...
No Matches
callservicesmanager.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#include "mediahandler.h"
20#include "streamdata.h"
21
22#include "noncopyable.h"
23
24#include <list>
25#include <map>
26
27namespace jami {
28
29class PluginManager;
30
31using CallMediaHandlerPtr = std::unique_ptr<CallMediaHandler>;
32using AVSubjectSPtr = std::weak_ptr<Observable<AVFrame*>>;
33
43{
44public:
52
54
56
65
70 void clearAVSubject(const std::string& callId);
71
76 std::vector<std::string> getCallMediaHandlers();
77
89 void toggleCallMediaHandler(const std::string& mediaHandlerId, const std::string& callId, const bool toggle);
90
96 std::map<std::string, std::string> getCallMediaHandlerDetails(const std::string& mediaHandlerIdStr);
97
103 std::vector<std::string> getCallMediaHandlerStatus(const std::string& callId);
104
112 bool setPreference(const std::string& key, const std::string& value, const std::string& rootPath);
113
118 void clearCallHandlerMaps(const std::string& callId);
119
120private:
125 void registerComponentsLifeCycleManagers(PluginManager& pluginManager);
126
134 void notifyAVSubject(CallMediaHandlerPtr& callMediaHandlerPtr, const StreamData& data, AVSubjectSPtr& subject);
135
136 void toggleCallMediaHandler(const uintptr_t mediaHandlerId, const std::string& callId, const bool toggle);
137
144 bool isVideoType(const CallMediaHandlerPtr& mediaHandler);
145
152 bool isAttached(const CallMediaHandlerPtr& mediaHandler);
153
154 // Components that a plugin can register through registerMediaHandler service.
155 // These objects can then be activated with toggleCallMediaHandler.
156 std::list<CallMediaHandlerPtr> callMediaHandlers_;
157
158 // When there is a SIPCall, AVSubjects are created there.
159 // Here we store their references in order to make them interact with MediaHandlers.
160 // For easy access they are mapped with the call they belong to.
161 std::map<std::string, std::list<std::pair<const StreamData, AVSubjectSPtr>>> callAVsubjects_;
162
163 // Component that stores MediaHandlers' status for each existing call.
164 // A map of callIds and MediaHandler-status pairs.
165 std::map<std::string, std::map<uintptr_t, bool>> mediaHandlerToggled_;
166};
167} // 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 jami_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:30