79 uri = v[
"uri"].asString();
80 device = v[
"device"].asString();
81 sinkId = v[
"sinkId"].asString();
82 active = v[
"active"].asBool();
117 std::map<std::string, std::string>
toMap()
const
119 return {{
"uri",
uri},
122 {
"active",
active ?
"true" :
"false"},
123 {
"x", std::to_string(
x)},
124 {
"y", std::to_string(
y)},
125 {
"w", std::to_string(
w)},
126 {
"h", std::to_string(
h)},
127 {
"videoMuted",
videoMuted ?
"true" :
"false"},
131 {
"handRaised",
handRaised ?
"true" :
"false"},
133 {
"recording",
recording ?
"true" :
"false"}};
141 and p1.audioLocalMuted ==
p2.audioLocalMuted
142 and p1.audioModeratorMuted ==
p2.audioModeratorMuted
143 and p1.isModerator ==
p2.isModerator
and p1.handRaised ==
p2.handRaised
144 and p1.voiceActivity ==
p2.voiceActivity
and p1.recording ==
p2.recording;
153struct ConfInfo :
public std::vector<ParticipantInfo>
164 if (
c1.size() !=
c2.size())
167 for (
auto&
p1 :
c1) {
186using clock = std::chrono::steady_clock;
196 explicit Conference(
const std::shared_ptr<Account>&,
197 const std::string&
confId =
"");
209 std::shared_ptr<Account>
getAccount()
const {
return account_.lock(); }
235 return "ACTIVE_ATTACHED";
237 return "ACTIVE_DETACHED";
310 void onConfOrder(
const std::string& callId,
const std::string& order);
316 std::shared_ptr<video::VideoMixer> getVideoMixer();
322 std::lock_guard
lk(confInfoMutex_);
327 void setModerator(
const std::string& uri,
const bool& state);
329 void setHandRaised(
const std::string& uri,
const bool& state);
347 const std::string& deviceId,
348 const std::string& streamId,
377 return duration_start_ == clock::time_point::min()
378 ? std::chrono::milliseconds::zero()
379 : std::chrono::duration_cast<std::chrono::milliseconds>(clock::now()
384 std::weak_ptr<Conference> weak()
389 static std::shared_ptr<Call> getCall(
const std::string& callId);
390 bool isModerator(std::string_view uri)
const;
391 bool isHandRaised(std::string_view uri)
const;
392 bool isVoiceActive(std::string_view uri)
const;
393 void updateModerators();
394 void updateHandsRaised();
395 void muteHost(
bool state);
396 void muteCall(
const std::string& callId,
bool state);
398 void foreachCall(
const std::function<
void(
const std::shared_ptr<Call>& call)>&
cb);
401 std::weak_ptr<Account> account_;
403 mutable std::mutex subcallsMtx_ {};
405 std::string mediaPlayerId_ {};
407 mutable std::mutex confInfoMutex_ {};
408 ConfInfo confInfo_ {};
410 void sendConferenceInfos();
411 std::shared_ptr<RingBuffer> ghostRingBuffer_;
415 std::shared_ptr<video::VideoMixer> videoMixer_;
416 std::map<std::string, std::shared_ptr<video::SinkClient>>
confSinksMap_ {};
419 std::shared_ptr<jami::AudioInput> audioMixer_;
420 std::set<std::string, std::less<>> moderators_ {};
421 std::set<std::string, std::less<>> participantsMuted_ {};
422 std::set<std::string, std::less<>> handsRaised_;
425 std::set<std::string, std::less<>> streamsVoiceActive {};
427 void initRecorder(std::shared_ptr<MediaRecorder>&
rec);
428 void deinitRecorder(std::shared_ptr<MediaRecorder>&
rec);
430 bool isMuted(std::string_view uri)
const;
433 bool isHost(std::string_view uri)
const;
434 bool isHostDevice(std::string_view deviceId)
const;
441 std::vector<MediaAttribute> hostSources_;
443 std::map<std::string, std::shared_ptr<jami::AudioInput>> hostAudioInputs_;
445 bool localModAdded_ {
false};
447 std::map<std::string, ConfInfo> remoteHosts_;
451 std::string_view findHostforRemoteParticipant(std::string_view uri,
452 std::string_view deviceId =
"");
454 std::shared_ptr<Call> getCallWith(
const std::string&
accountUri,
const std::string& deviceId);
456 std::mutex sinksMtx_ {};
470 [](
const std::shared_ptr<jami::MediaFrame>&
m) ->
AVFrame* {
471 return std::static_pointer_cast<VideoFrame>(
m)->pointer();
493 std::map<std::string, std::shared_ptr<MediaStreamSubject>>
confAVStreams;
496 ConfProtocolParser parser_;
497 std::string getRemoteId(
const std::shared_ptr<jami::Call>& call)
const;
499 std::function<
void(
int)> shutdownCb_;
500 clock::time_point duration_start_;
505 void initSourcesForHost();
513 void takeOverMediaSourceControl(
const std::string& callId);
518 void bindHostAudio();
523 void unbindHostAudio();
528 void bindSubCallAudio(
const std::string& callId);
533 void unbindSubCallAudio(
const std::string& callId);
const char * getStateStr() const
void attachHost(const std::vector< libjami::MediaMap > &mediaList={})
Attach host.
void setVoiceActivity(const std::string &streamId, const bool &newState)
std::string getAccountId() const
bool isVideoEnabled() const
void hangupParticipant(const std::string &accountUri, const std::string &deviceId="")
void muteLocalHost(bool is_muted, const std::string &mediaType)
std::chrono::milliseconds getDuration() const
bool startRecording(const std::string &path) override
Start recording.
const std::string & getConfId() const
Return the conference id.
void removeSubCall(const std::string &callId)
Remove a subcall from the conference.
void updateVoiceActivity()
std::vector< libjami::MediaMap > currentMediaList() const
Retrieve current medias list.
std::vector< std::map< std::string, std::string > > getConferenceInfos() const
void detachHost()
Detach local audio/video from the conference.
~Conference()
Destructor for this class, decrement static counter.
void mergeConfInfo(ConfInfo &newInfo, const std::string &peerURI)
void setActiveParticipant(const std::string &participant_id)
void handleMediaChangeRequest(const std::shared_ptr< Call > &call, const std::vector< libjami::MediaMap > &remoteMediaList)
Process incoming media change request.
void setLocalHostMuteState(MediaType type, bool muted)
Set the mute state of the local host.
void setState(State state)
Set conference state.
bool requestMediaChange(const std::vector< libjami::MediaMap > &mediaList)
Process a media change request.
void onConfOrder(const std::string &callId, const std::string &order)
void addSubCall(const std::string &callId)
Add a new subcall to the conference.
std::shared_ptr< Account > getAccount() const
void onShutdown(std::function< void(int)> cb)
Set a callback that will be called when the conference will be destroyed.
std::shared_ptr< Call > getCallFromPeerID(std::string_view peerId)
void setActiveStream(const std::string &streamId, bool state)
void setModerator(const std::string &uri, const bool &state)
static constexpr const char * getStateStr(State state)
Return a string description of the conference state.
void stopRecording() override
Stop recording.
bool toggleRecording() override
Start/stop recording toggle.
CallIdSet getSubCalls() const
Get the participant list for this conference.
void setHandRaised(const std::string &uri, const bool &state)
void muteParticipant(const std::string &uri, const bool &state)
State getState() const
Return the current conference state.
void muteStream(const std::string &accountUri, const std::string &deviceId, const std::string &streamId, const bool &state)
The client shows one tile per stream (video/audio related to a media)
void updateConferenceInfo(ConfInfo confInfo)
void switchInput(const std::string &input)
bool isRemoteParticipant(const std::string &uri)
void setLayout(int layout)
void reportMediaNegotiationStatus()
Announce to the client that medias are successfully negotiated.
bool isMediaSourceMuted(MediaType type) const
Get the mute state of the local host.
std::set< std::string > CallIdSet
void emitSignal(Args... args)
std::chrono::steady_clock clock
Contains information about an AV subject.
std::string toString() const
std::vector< std::map< std::string, std::string > > toVectorMapStringString() const
friend bool operator!=(const ConfInfo &c1, const ConfInfo &c2)
friend bool operator==(const ConfInfo &c1, const ConfInfo &c2)
Json::Value toJson() const
friend bool operator==(const ParticipantInfo &p1, const ParticipantInfo &p2)
std::map< std::string, std::string > toMap() const
friend bool operator!=(const ParticipantInfo &p1, const ParticipantInfo &p2)
void fromJson(const Json::Value &v)