Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
84ad5808
Commit
84ad5808
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
manager: conference cleanup
Change-Id: I6282eaeefc8f8e17278991ba8c0f64b30234adac
parent
eccacbc4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/manager.cpp
+47
-96
47 additions, 96 deletions
src/manager.cpp
src/manager.h
+3
-2
3 additions, 2 deletions
src/manager.h
with
50 additions
and
98 deletions
src/manager.cpp
+
47
−
96
View file @
84ad5808
...
@@ -517,8 +517,7 @@ Manager::ManagerPimpl::processRemainingParticipants(Conference &conf)
...
@@ -517,8 +517,7 @@ Manager::ManagerPimpl::processRemainingParticipants(Conference &conf)
}
else
if
(
n
==
1
)
{
}
else
if
(
n
==
1
)
{
// this call is the last participant, hence
// this call is the last participant, hence
// the conference is over
// the conference is over
ParticipantSet
::
iterator
p
=
participants
.
begin
();
auto
p
=
participants
.
begin
();
if
(
auto
call
=
base_
.
getCallFromCallID
(
*
p
))
{
if
(
auto
call
=
base_
.
getCallFromCallID
(
*
p
))
{
call
->
setConfId
(
""
);
call
->
setConfId
(
""
);
// if we are not listening to this conference
// if we are not listening to this conference
...
@@ -1032,27 +1031,16 @@ bool
...
@@ -1032,27 +1031,16 @@ bool
Manager
::
hangupConference
(
const
std
::
string
&
id
)
Manager
::
hangupConference
(
const
std
::
string
&
id
)
{
{
JAMI_DBG
(
"Hangup conference %s"
,
id
.
c_str
());
JAMI_DBG
(
"Hangup conference %s"
,
id
.
c_str
());
if
(
auto
conf
=
getConferenceFromID
(
id
))
{
ConferenceMap
::
iterator
iter_conf
=
pimpl_
->
conferenceMap_
.
find
(
id
);
if
(
iter_conf
!=
pimpl_
->
conferenceMap_
.
end
())
{
auto
conf
=
iter_conf
->
second
;
if
(
conf
)
{
ParticipantSet
participants
(
conf
->
getParticipantList
());
ParticipantSet
participants
(
conf
->
getParticipantList
());
for
(
const
auto
&
item
:
participants
)
for
(
const
auto
&
item
:
participants
)
hangupCall
(
item
);
hangupCall
(
item
);
}
else
{
JAMI_ERR
(
"No such conference %s"
,
id
.
c_str
());
return
false
;
}
}
pimpl_
->
unsetCurrentCall
();
pimpl_
->
unsetCurrentCall
();
return
true
;
return
true
;
}
}
JAMI_ERR
(
"No such conference %s"
,
id
.
c_str
());
return
false
;
}
//THREAD=Main
//THREAD=Main
bool
bool
...
@@ -1202,16 +1190,9 @@ Manager::refuseCall(const std::string& id)
...
@@ -1202,16 +1190,9 @@ Manager::refuseCall(const std::string& id)
void
void
Manager
::
removeConference
(
const
std
::
string
&
conference_id
)
Manager
::
removeConference
(
const
std
::
string
&
conference_id
)
{
{
JAMI_DBG
(
"Remove conference %s"
,
conference_id
.
c_str
());
JAMI_DBG
(
"Remove conference %s with %zu participants"
,
conference_id
.
c_str
(),
pimpl_
->
conferenceMap_
.
size
());
JAMI_DBG
(
"number of participants: %zu"
,
pimpl_
->
conferenceMap_
.
size
());
auto
iter
=
pimpl_
->
conferenceMap_
.
find
(
conference_id
);
ConferenceMap
::
iterator
iter
=
pimpl_
->
conferenceMap_
.
find
(
conference_id
);
if
(
iter
==
pimpl_
->
conferenceMap_
.
end
())
{
std
::
shared_ptr
<
Conference
>
conf
;
if
(
iter
!=
pimpl_
->
conferenceMap_
.
end
())
conf
=
iter
->
second
;
if
(
not
conf
)
{
JAMI_ERR
(
"Conference not found"
);
JAMI_ERR
(
"Conference not found"
);
return
;
return
;
}
}
...
@@ -1219,57 +1200,47 @@ Manager::removeConference(const std::string& conference_id)
...
@@ -1219,57 +1200,47 @@ Manager::removeConference(const std::string& conference_id)
emitSignal
<
DRing
::
CallSignal
::
ConferenceRemoved
>
(
conference_id
);
emitSignal
<
DRing
::
CallSignal
::
ConferenceRemoved
>
(
conference_id
);
// We now need to bind the audio to the remain participant
// We now need to bind the audio to the remain participant
// Unbind main participant audio from conference
// Unbind main participant audio from conference
getRingBufferPool
().
unBindAll
(
RingBufferPool
::
DEFAULT_ID
);
getRingBufferPool
().
unBindAll
(
RingBufferPool
::
DEFAULT_ID
);
ParticipantSet
participants
(
conf
->
getParticipantList
());
// bind main participant audio to remaining conference call
// bind main participant audio to remaining conference call
ParticipantSet
::
iterator
iter_p
=
p
articipant
s
.
begin
(
);
ParticipantSet
participants
(
iter
->
second
->
getP
articipant
List
()
);
auto
iter_p
=
participants
.
begin
();
if
(
iter_p
!=
participants
.
end
())
if
(
iter_p
!=
participants
.
end
())
getRingBufferPool
().
bindCallID
(
*
iter_p
,
RingBufferPool
::
DEFAULT_ID
);
getRingBufferPool
().
bindCallID
(
*
iter_p
,
RingBufferPool
::
DEFAULT_ID
);
// Then remove the conference from the conference map
// Then remove the conference from the conference map
if
(
pimpl_
->
conferenceMap_
.
erase
(
conference_id
))
pimpl_
->
conferenceMap_
.
erase
(
iter
);
JAMI_DBG
(
"Conference %s removed successfully"
,
conference_id
.
c_str
());
JAMI_DBG
(
"Conference %s removed successfully"
,
conference_id
.
c_str
());
else
JAMI_ERR
(
"Cannot remove conference: %s"
,
conference_id
.
c_str
());
}
}
std
::
shared_ptr
<
Conference
>
std
::
shared_ptr
<
Conference
>
Manager
::
getConferenceFromCallID
(
const
std
::
string
&
call_id
)
Manager
::
getConferenceFromCallID
(
const
std
::
string
&
call_id
)
const
{
{
auto
call
=
getCallFromCallID
(
call_id
)
;
if
(
auto
call
=
getCallFromCallID
(
call_id
)
)
if
(
!
call
)
return
getConferenceFromID
(
call
->
getConfId
());
return
nullptr
;
return
nullptr
;
}
ConferenceMap
::
const_iterator
iter
(
pimpl_
->
conferenceMap_
.
find
(
call
->
getConfId
()));
std
::
shared_ptr
<
Conference
>
Manager
::
getConferenceFromID
(
const
std
::
string
&
confID
)
const
if
(
iter
!=
pimpl_
->
conferenceMap_
.
end
())
{
return
iter
->
second
;
auto
iter
=
pimpl_
->
conferenceMap_
.
find
(
confID
);
else
return
iter
==
pimpl_
->
conferenceMap_
.
end
()
?
nullptr
:
iter
->
second
;
return
nullptr
;
}
}
bool
bool
Manager
::
holdConference
(
const
std
::
string
&
id
)
Manager
::
holdConference
(
const
std
::
string
&
id
)
{
{
ConferenceMap
::
iterator
iter_conf
=
pimpl_
->
conferenceMap_
.
find
(
id
);
auto
conf
=
getConferenceFromID
(
id
);
if
(
not
conf
)
if
(
iter_conf
==
pimpl_
->
conferenceMap_
.
end
())
return
false
;
return
false
;
auto
conf
=
iter_conf
->
second
;
bool
isRec
=
conf
->
getState
()
==
Conference
::
ACTIVE_ATTACHED_REC
or
bool
isRec
=
conf
->
getState
()
==
Conference
::
ACTIVE_ATTACHED_REC
or
conf
->
getState
()
==
Conference
::
ACTIVE_DETACHED_REC
or
conf
->
getState
()
==
Conference
::
ACTIVE_DETACHED_REC
or
conf
->
getState
()
==
Conference
::
HOLD_REC
;
conf
->
getState
()
==
Conference
::
HOLD_REC
;
ParticipantSet
participants
(
conf
->
getParticipantList
());
for
(
const
auto
&
item
:
conf
->
getParticipantList
())
{
for
(
const
auto
&
item
:
participants
)
{
pimpl_
->
switchCall
(
getCallFromCallID
(
item
));
pimpl_
->
switchCall
(
getCallFromCallID
(
item
));
onHoldCall
(
item
);
onHoldCall
(
item
);
}
}
...
@@ -1284,20 +1255,15 @@ Manager::holdConference(const std::string& id)
...
@@ -1284,20 +1255,15 @@ Manager::holdConference(const std::string& id)
bool
bool
Manager
::
unHoldConference
(
const
std
::
string
&
id
)
Manager
::
unHoldConference
(
const
std
::
string
&
id
)
{
{
ConferenceMap
::
iterator
iter_conf
=
pimpl_
->
conferenceMap_
.
find
(
id
);
auto
conf
=
getConferenceFromID
(
id
);
if
(
not
conf
)
if
(
iter_conf
==
pimpl_
->
conferenceMap_
.
end
()
or
iter_conf
->
second
==
0
)
return
false
;
return
false
;
auto
conf
=
iter_conf
->
second
;
bool
isRec
=
conf
->
getState
()
==
Conference
::
ACTIVE_ATTACHED_REC
or
bool
isRec
=
conf
->
getState
()
==
Conference
::
ACTIVE_ATTACHED_REC
or
conf
->
getState
()
==
Conference
::
ACTIVE_DETACHED_REC
or
conf
->
getState
()
==
Conference
::
ACTIVE_DETACHED_REC
or
conf
->
getState
()
==
Conference
::
HOLD_REC
;
conf
->
getState
()
==
Conference
::
HOLD_REC
;
ParticipantSet
participants
(
conf
->
getParticipantList
());
for
(
const
auto
&
item
:
conf
->
getParticipantList
())
{
for
(
const
auto
&
item
:
participants
)
{
if
(
auto
call
=
getCallFromCallID
(
item
))
{
if
(
auto
call
=
getCallFromCallID
(
item
))
{
// if one call is currently recording, the conference is in state recording
// if one call is currently recording, the conference is in state recording
isRec
|=
call
->
isRecording
();
isRec
|=
call
->
isRecording
();
...
@@ -1331,8 +1297,8 @@ bool
...
@@ -1331,8 +1297,8 @@ bool
Manager
::
addParticipant
(
const
std
::
string
&
callId
,
Manager
::
addParticipant
(
const
std
::
string
&
callId
,
const
std
::
string
&
conferenceId
)
const
std
::
string
&
conferenceId
)
{
{
auto
iter
=
pimpl_
->
conferenceMap_
.
find
(
conferenceId
);
auto
conf
=
getConferenceFromID
(
conferenceId
);
if
(
iter
==
pimpl_
->
conferenceMap_
.
end
()
or
iter
->
second
==
nullptr
)
{
if
(
not
conf
)
{
JAMI_ERR
(
"Conference id is not valid"
);
JAMI_ERR
(
"Conference id is not valid"
);
return
false
;
return
false
;
}
}
...
@@ -1354,7 +1320,7 @@ Manager::addParticipant(const std::string& callId,
...
@@ -1354,7 +1320,7 @@ Manager::addParticipant(const std::string& callId,
// store the current call id (it will change in offHoldCall or in answerCall)
// store the current call id (it will change in offHoldCall or in answerCall)
auto
current_call_id
=
getCurrentCallId
();
auto
current_call_id
=
getCurrentCallId
();
pimpl_
->
bindCallToConference
(
*
call
,
*
iter
->
se
con
d
);
pimpl_
->
bindCallToConference
(
*
call
,
*
con
f
);
// TODO: remove this ugly hack => There should be different calls when double clicking
// TODO: remove this ugly hack => There should be different calls when double clicking
// a conference to add main participant to it, or (in this case) adding a participant
// a conference to add main participant to it, or (in this case) adding a participant
...
@@ -1374,17 +1340,11 @@ Manager::addMainParticipant(const std::string& conference_id)
...
@@ -1374,17 +1340,11 @@ Manager::addMainParticipant(const std::string& conference_id)
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
pimpl_
->
audioLayerMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
pimpl_
->
audioLayerMutex_
);
auto
conf
=
getConferenceFromID
(
conference_id
);
ConferenceMap
::
const_iterator
iter
=
pimpl_
->
conferenceMap_
.
find
(
conference_id
);
if
(
not
conf
)
if
(
iter
==
pimpl_
->
conferenceMap_
.
end
()
or
iter
->
second
==
0
)
return
false
;
return
false
;
auto
conf
=
iter
->
second
;
for
(
const
auto
&
item_p
:
conf
->
getParticipantList
())
{
ParticipantSet
participants
(
conf
->
getParticipantList
());
for
(
const
auto
&
item_p
:
participants
)
{
getRingBufferPool
().
bindCallID
(
item_p
,
RingBufferPool
::
DEFAULT_ID
);
getRingBufferPool
().
bindCallID
(
item_p
,
RingBufferPool
::
DEFAULT_ID
);
// Reset ringbuffer's readpointers
// Reset ringbuffer's readpointers
getRingBufferPool
().
flush
(
item_p
);
getRingBufferPool
().
flush
(
item_p
);
...
@@ -1498,15 +1458,14 @@ Manager::detachLocalParticipant()
...
@@ -1498,15 +1458,14 @@ Manager::detachLocalParticipant()
return
false
;
return
false
;
}
}
auto
iter
=
pimpl_
->
conferenceMap_
.
find
(
current_call_id
);
auto
conf
=
getConferenceFromID
(
current_call_id
);
if
(
iter
==
pimpl_
->
conferenceMap_
.
end
()
or
iter
->
second
==
nullptr
)
{
if
(
not
conf
)
{
JAMI_ERR
(
"Conference is NULL"
);
JAMI_ERR
(
"Conference is NULL"
);
return
false
;
return
false
;
}
}
getRingBufferPool
().
unBindAll
(
RingBufferPool
::
DEFAULT_ID
);
getRingBufferPool
().
unBindAll
(
RingBufferPool
::
DEFAULT_ID
);
auto
conf
=
iter
->
second
;
switch
(
conf
->
getState
())
{
switch
(
conf
->
getState
())
{
case
Conference
::
ACTIVE_ATTACHED
:
case
Conference
::
ACTIVE_ATTACHED
:
conf
->
setState
(
Conference
::
ACTIVE_DETACHED
);
conf
->
setState
(
Conference
::
ACTIVE_DETACHED
);
...
@@ -1561,10 +1520,8 @@ Manager::removeParticipant(const std::string& call_id)
...
@@ -1561,10 +1520,8 @@ Manager::removeParticipant(const std::string& call_id)
return
;
return
;
}
}
ConferenceMap
::
const_iterator
iter
=
pimpl_
->
conferenceMap_
.
find
(
call
->
getConfId
());
auto
conf
=
getConferenceFromID
(
call
->
getConfId
());
if
(
not
conf
)
{
auto
conf
=
iter
->
second
;
if
(
iter
==
pimpl_
->
conferenceMap_
.
end
()
or
conf
==
0
)
{
JAMI_ERR
(
"No conference with id %s, cannot remove participant"
,
call
->
getConfId
().
c_str
());
JAMI_ERR
(
"No conference with id %s, cannot remove participant"
,
call
->
getConfId
().
c_str
());
return
;
return
;
}
}
...
@@ -1583,7 +1540,8 @@ bool
...
@@ -1583,7 +1540,8 @@ bool
Manager
::
joinConference
(
const
std
::
string
&
conf_id1
,
Manager
::
joinConference
(
const
std
::
string
&
conf_id1
,
const
std
::
string
&
conf_id2
)
const
std
::
string
&
conf_id2
)
{
{
if
(
pimpl_
->
conferenceMap_
.
find
(
conf_id1
)
==
pimpl_
->
conferenceMap_
.
end
())
{
auto
conf
=
getConferenceFromID
(
conf_id1
);
if
(
not
conf
)
{
JAMI_ERR
(
"Not a valid conference ID: %s"
,
conf_id1
.
c_str
());
JAMI_ERR
(
"Not a valid conference ID: %s"
,
conf_id1
.
c_str
());
return
false
;
return
false
;
}
}
...
@@ -1593,7 +1551,6 @@ Manager::joinConference(const std::string& conf_id1,
...
@@ -1593,7 +1551,6 @@ Manager::joinConference(const std::string& conf_id1,
return
false
;
return
false
;
}
}
auto
conf
=
pimpl_
->
conferenceMap_
.
find
(
conf_id1
)
->
second
;
ParticipantSet
participants
(
conf
->
getParticipantList
());
ParticipantSet
participants
(
conf
->
getParticipantList
());
// Detach and remove all participant from conf1 before add
// Detach and remove all participant from conf1 before add
...
@@ -1927,15 +1884,9 @@ Manager::sendCallTextMessage(const std::string& callID,
...
@@ -1927,15 +1884,9 @@ Manager::sendCallTextMessage(const std::string& callID,
const
std
::
string
&
from
,
const
std
::
string
&
from
,
bool
/*isMixed TODO: use it */
)
bool
/*isMixed TODO: use it */
)
{
{
if
(
isConference
(
callID
))
{
if
(
auto
conf
=
getConferenceFromID
(
callID
))
{
const
auto
&
it
=
pimpl_
->
conferenceMap_
.
find
(
callID
);
if
(
it
==
pimpl_
->
conferenceMap_
.
cend
()
or
not
it
->
second
)
{
JAMI_ERR
(
"no conference associated to ID %s"
,
callID
.
c_str
());
return
;
}
JAMI_DBG
(
"Is a conference, send instant message to everyone"
);
JAMI_DBG
(
"Is a conference, send instant message to everyone"
);
pimpl_
->
sendTextMessageToConference
(
*
it
->
se
con
d
,
messages
,
from
);
pimpl_
->
sendTextMessageToConference
(
*
con
f
,
messages
,
from
);
}
else
if
(
isConferenceParticipant
(
callID
))
{
}
else
if
(
isConferenceParticipant
(
callID
))
{
auto
conf
=
getConferenceFromCallID
(
callID
);
auto
conf
=
getConferenceFromCallID
(
callID
);
...
...
This diff is collapsed.
Click to expand it.
src/manager.h
+
3
−
2
View file @
84ad5808
...
@@ -226,8 +226,9 @@ class Manager {
...
@@ -226,8 +226,9 @@ class Manager {
* Return the conference id for which this call is attached
* Return the conference id for which this call is attached
* @ param the call id
* @ param the call id
*/
*/
std
::
shared_ptr
<
Conference
>
std
::
shared_ptr
<
Conference
>
getConferenceFromCallID
(
const
std
::
string
&
call_id
)
const
;
getConferenceFromCallID
(
const
std
::
string
&
call_id
);
std
::
shared_ptr
<
Conference
>
getConferenceFromID
(
const
std
::
string
&
confID
)
const
;
/**
/**
* Hold every participant to a conference
* Hold every participant to a conference
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment