Ring Daemon 16.0.0
Loading...
Searching...
No Matches
conference_protocol.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 <string_view>
24#include <functional>
25#include <json/json.h>
26
27#include "logger.h"
28
29namespace jami {
30
36{
37public:
39
40 void onVersion(std::function<void(uint32_t)>&& cb) { version_ = std::move(cb); }
44 void onCheckAuthorization(std::function<bool(std::string_view)>&& cb)
45 {
46 checkAuthorization_ = std::move(cb);
47 }
48
49 void onHangupParticipant(std::function<void(const std::string&, const std::string&)>&& cb)
50 {
51 hangupParticipant_ = std::move(cb);
52 }
53 void onRaiseHand(std::function<void(const std::string&, bool)>&& cb)
54 {
55 raiseHand_ = std::move(cb);
56 }
57 void onSetActiveStream(std::function<void(const std::string&, bool)>&& cb)
58 {
59 setActiveStream_ = std::move(cb);
60 }
62 std::function<void(const std::string&, const std::string&, const std::string&, bool)>&& cb)
63 {
64 muteStreamAudio_ = std::move(cb);
65 }
67 std::function<void(const std::string&, const std::string&, const std::string&, bool)>&& cb)
68 {
69 muteStreamVideo_ = std::move(cb);
70 }
71 void onSetLayout(std::function<void(int)>&& cb) { setLayout_ = std::move(cb); }
72
73 // Version 0, deprecated
74 void onKickParticipant(std::function<void(const std::string&)>&& cb)
75 {
76 kickParticipant_ = std::move(cb);
77 }
78 void onSetActiveParticipant(std::function<void(const std::string&)>&& cb)
79 {
80 setActiveParticipant_ = std::move(cb);
81 }
82 void onMuteParticipant(std::function<void(const std::string&, bool)>&& cb)
83 {
84 muteParticipant_ = std::move(cb);
85 }
86 void onRaiseHandUri(std::function<void(const std::string&, bool)>&& cb)
87 {
88 raiseHandUri_ = std::move(cb);
89 }
90 void onVoiceActivity(std::function<void(const std::string&, bool)>&& cb)
91 {
92 voiceActivity_ = std::move(cb);
93 }
94
98 void initData(Json::Value&& d, std::string_view peerId)
99 {
100 data_ = std::move(d);
101 peerId_ = peerId;
102 }
103
107 void parse();
108
109private:
110 void parseV0();
111 void parseV1();
112
113 std::string_view peerId_;
114 Json::Value data_;
115
116 std::function<void(uint32_t)> version_;
117
118 std::function<bool(std::string_view)> checkAuthorization_;
119 std::function<void(const std::string&, const std::string&)> hangupParticipant_;
120 std::function<void(const std::string&, bool)> raiseHand_;
121 std::function<void(const std::string&, bool)> setActiveStream_;
122 std::function<void(const std::string&, const std::string&, const std::string&, bool)>
123 muteStreamAudio_;
124 std::function<void(const std::string&, const std::string&, const std::string&, bool)>
125 muteStreamVideo_;
126 std::function<void(int)> setLayout_;
127
128 std::function<void(const std::string&, bool)> raiseHandUri_;
129 std::function<void(const std::string&)> kickParticipant_;
130 std::function<void(const std::string&)> setActiveParticipant_;
131 std::function<void(const std::string&, bool)> muteParticipant_;
132 std::function<void(const std::string&, bool)> voiceActivity_;
133};
134
135} // namespace jami
Used to parse confOrder objects.
void onHangupParticipant(std::function< void(const std::string &, const std::string &)> &&cb)
void onMuteStreamAudio(std::function< void(const std::string &, const std::string &, const std::string &, bool)> &&cb)
void onKickParticipant(std::function< void(const std::string &)> &&cb)
void onRaiseHand(std::function< void(const std::string &, bool)> &&cb)
void onMuteStreamVideo(std::function< void(const std::string &, const std::string &, const std::string &, bool)> &&cb)
void initData(Json::Value &&d, std::string_view peerId)
Inject in the parser the data to parse.
void onMuteParticipant(std::function< void(const std::string &, bool)> &&cb)
void onSetActiveParticipant(std::function< void(const std::string &)> &&cb)
void onSetActiveStream(std::function< void(const std::string &, bool)> &&cb)
void onCheckAuthorization(std::function< bool(std::string_view)> &&cb)
Ask the caller to check if a peer is authorized (moderator of the conference)
void onSetLayout(std::function< void(int)> &&cb)
void onVersion(std::function< void(uint32_t)> &&cb)
void parse()
Parse the datas, this will call the methods injected if necessary.
void onVoiceActivity(std::function< void(const std::string &, bool)> &&cb)
void onRaiseHandUri(std::function< void(const std::string &, bool)> &&cb)
void emitSignal(Args... args)
Definition ring_signal.h:64