Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
da914587
Commit
da914587
authored
Jul 07, 2020
by
Adrien Béraud
Browse files
conference: allow to attach/detach local participant
Change-Id: I610f85d22ff06e715af2a8866dd4f135e0a98afe
parent
55d05ad0
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/conference.cpp
View file @
da914587
...
...
@@ -89,6 +89,45 @@ void Conference::remove(const std::string &participant_id)
}
}
void
Conference
::
attach
()
{
if
(
getState
()
==
State
::
ACTIVE_DETACHED
)
{
auto
&
rbPool
=
Manager
::
instance
().
getRingBufferPool
();
for
(
const
auto
&
participant
:
getParticipantList
())
{
rbPool
.
bindCallID
(
participant
,
RingBufferPool
::
DEFAULT_ID
);
// Reset ringbuffer's readpointers
rbPool
.
flush
(
participant
);
}
rbPool
.
flush
(
RingBufferPool
::
DEFAULT_ID
);
#ifdef ENABLE_VIDEO
if
(
auto
mixer
=
getVideoMixer
())
{
mixer
->
switchInput
(
mediaInput_
);
}
#endif
setState
(
State
::
ACTIVE_ATTACHED
);
}
else
{
JAMI_WARN
(
"Invalid conference state in attach participant"
);
}
}
void
Conference
::
detach
()
{
if
(
getState
()
==
State
::
ACTIVE_ATTACHED
)
{
Manager
::
instance
().
getRingBufferPool
().
unBindAll
(
RingBufferPool
::
DEFAULT_ID
);
#ifdef ENABLE_VIDEO
if
(
auto
mixer
=
getVideoMixer
())
{
mixer
->
stopInput
();
}
#endif
setState
(
State
::
ACTIVE_DETACHED
);
}
else
{
JAMI_WARN
(
"Invalid conference state in detach participant"
);
}
}
void
Conference
::
bindParticipant
(
const
std
::
string
&
participant_id
)
{
auto
&
rbPool
=
Manager
::
instance
().
getRingBufferPool
();
...
...
@@ -113,11 +152,12 @@ std::vector<std::string>
Conference
::
getDisplayNames
()
const
{
std
::
vector
<
std
::
string
>
result
;
result
.
reserve
(
participants_
.
size
());
for
(
const
auto
&
p
:
participants_
)
{
auto
details
=
Manager
::
instance
().
getCallDetails
(
p
);
const
auto
tmp
=
details
[
"DISPLAY_NAME"
];
result
.
push
_back
(
tmp
.
empty
()
?
details
[
"PEER_NUMBER"
]
:
tmp
);
result
.
emplace
_back
(
tmp
.
empty
()
?
details
[
"PEER_NUMBER"
]
:
tmp
);
}
return
result
;
}
...
...
src/conference.h
View file @
da914587
...
...
@@ -102,6 +102,16 @@ public:
*/
void
remove
(
const
std
::
string
&
participant_id
);
/**
* Attach local audio/video to the conference
*/
void
attach
();
/**
* Detach local audio/video from the conference
*/
void
detach
();
/**
* Bind a participant to the conference
*/
...
...
src/manager.cpp
View file @
da914587
...
...
@@ -1356,19 +1356,8 @@ Manager::ManagerPimpl::addMainParticipant(Conference& conf)
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
audioLayerMutex_
);
for
(
const
auto
&
item_p
:
conf
.
getParticipantList
())
{
ringbufferpool_
->
bindCallID
(
item_p
,
RingBufferPool
::
DEFAULT_ID
);
// Reset ringbuffer's readpointers
ringbufferpool_
->
flush
(
item_p
);
}
ringbufferpool_
->
flush
(
RingBufferPool
::
DEFAULT_ID
);
conf
.
attach
();
}
if
(
conf
.
getState
()
==
Conference
::
State
::
ACTIVE_DETACHED
)
conf
.
setState
(
Conference
::
State
::
ACTIVE_ATTACHED
);
else
JAMI_WARN
(
"Invalid conference state %d while adding main participant"
,
(
int
)
conf
.
getState
());
emitSignal
<
DRing
::
CallSignal
::
ConferenceChanged
>
(
conf
.
getConfID
(),
conf
.
getStateStr
());
switchCall
(
conf
.
getConfID
());
}
...
...
@@ -1463,29 +1452,17 @@ Manager::createConfFromParticipantList(const std::vector< std::string > &partici
}
bool
Manager
::
detachLocalParticipant
()
Manager
::
detachLocalParticipant
(
const
std
::
string
&
conf_id
)
{
JAMI_DBG
(
"Unbind local participant from conference"
);
auto
conf
=
getConferenceFromID
(
getCurrentCallId
());
if
(
not
conf
)
{
JAMI_ERR
(
"Current call id (%s) is not a conference"
,
getCurrentCallId
().
c_str
());
return
false
;
}
getRingBufferPool
().
unBindAll
(
RingBufferPool
::
DEFAULT_ID
);
switch
(
conf
->
getState
())
{
case
Conference
::
State
::
ACTIVE_ATTACHED
:
conf
->
setState
(
Conference
::
State
::
ACTIVE_DETACHED
);
break
;
default:
JAMI_WARN
(
"Undefined behavior, invalid conference state in detach participant"
);
if
(
auto
conf
=
getConferenceFromID
(
conf_id
.
empty
()
?
getCurrentCallId
()
:
conf_id
))
{
conf
->
detach
();
emitSignal
<
DRing
::
CallSignal
::
ConferenceChanged
>
(
conf
->
getConfID
(),
conf
->
getStateStr
());
pimpl_
->
unsetCurrentCall
();
return
true
;
}
emitSignal
<
DRing
::
CallSignal
::
ConferenceChanged
>
(
conf
->
getConfID
(),
conf
->
getStateStr
());
pimpl_
->
unsetCurrentCall
();
return
true
;
JAMI_ERR
(
"Current call id (%s) is not a conference"
,
getCurrentCallId
().
c_str
());
return
false
;
}
bool
...
...
src/manager.h
View file @
da914587
...
...
@@ -304,7 +304,7 @@ class DRING_TESTABLE Manager {
* Detach the local participant from curent conference.
* Remote participants are placed in hold.
*/
bool
detachLocalParticipant
();
bool
detachLocalParticipant
(
const
std
::
string
&
conf_id
=
{}
);
/**
* Remove the conference participant from a conference
...
...
src/media/video/video_mixer.cpp
View file @
da914587
...
...
@@ -91,20 +91,34 @@ VideoMixer::~VideoMixer()
void
VideoMixer
::
switchInput
(
const
std
::
string
&
input
)
{
// Detach videoInput from mixer
videoLocal_
->
detach
(
this
);
if
(
auto
local
=
videoLocal_
)
{
if
(
auto
localInput
=
std
::
dynamic_pointer_cast
<
VideoInput
>
(
local
))
{
// Detach videoInput from mixer
local
->
detach
(
this
);
#if !VIDEO_CLIENT_INPUT
if
(
auto
localInput
=
std
::
dynamic_pointer_cast
<
VideoInput
>
(
local
))
{
// Stop old VideoInput
localInput
->
stopInput
();
}
#endif
// Start new VideoInput
}
else
{
videoLocal_
=
getVideoCamera
();
}
// Re-attach videoInput to mixer
if
(
videoLocal_
)
{
if
(
auto
localInput
=
std
::
dynamic_pointer_cast
<
VideoInput
>
(
videoLocal_
))
{
localInput
->
switchInput
(
input
);
}
videoLocal_
->
attach
(
this
);
}
}
void
VideoMixer
::
stopInput
()
{
if
(
auto
local
=
std
::
move
(
videoLocal_
))
{
local
->
detach
(
this
);
}
// Re-attach videoInput to mixer
videoLocal_
->
attach
(
this
);
}
void
...
...
src/media/video/video_mixer.h
View file @
da914587
...
...
@@ -55,6 +55,7 @@ public:
void
detached
(
Observable
<
std
::
shared_ptr
<
MediaFrame
>>*
ob
)
override
;
void
switchInput
(
const
std
::
string
&
input
);
void
stopInput
();
private:
NON_COPYABLE
(
VideoMixer
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment