Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
d88e17cd
Commit
d88e17cd
authored
Jul 22, 2017
by
Wescoeur
Browse files
fix(Conference): better and cleaned code
parent
dd2de72f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
80 deletions
+76
-80
coreapi/Call.cc
coreapi/Call.cc
+12
-13
coreapi/CallLog.cc
coreapi/CallLog.cc
+6
-7
coreapi/Conference.cc
coreapi/Conference.cc
+56
-58
include/linphone/conference.h
include/linphone/conference.h
+2
-2
No files found.
coreapi/Call.cc
View file @
d88e17cd
...
...
@@ -1171,21 +1171,21 @@ void linphone_call_create_op_to(LinphoneCall *call, LinphoneAddress *to){
sal_op_set_user_pointer
(
call
->
op
,
call
);
if
(
call
->
params
->
referer
)
sal_call_set_referer
(
call
->
op
,
call
->
params
->
referer
->
op
);
linphone_configure_op
(
call
->
core
,
call
->
op
,
to
,
call
->
params
->
custom_headers
,
FALSE
);
linphone_configure_op
(
call
->
core
,
call
->
op
,
to
,
call
->
params
->
custom_headers
,
FALSE
);
if
(
call
->
params
->
privacy
!=
LinphonePrivacyDefault
)
sal_op_set_privacy
(
call
->
op
,(
SalPrivacyMask
)
call
->
params
->
privacy
);
/*else privacy might be set by proxy */
}
void
linphone_call_create_op
(
LinphoneCall
*
call
){
if
(
call
->
op
)
sal_op_release
(
call
->
op
);
call
->
op
=
sal_op_new
(
call
->
core
->
sal
);
sal_op_set_user_pointer
(
call
->
op
,
call
);
if
(
call
->
params
->
referer
)
sal_call_set_referer
(
call
->
op
,
call
->
params
->
referer
->
op
);
linphone_configure_op
(
call
->
core
,
call
->
op
,
call
->
log
->
to
,
call
->
params
->
custom_headers
,
FALSE
);
if
(
call
->
params
->
privacy
!=
LinphonePrivacyDefault
)
sal_op_set_privacy
(
call
->
op
,(
SalPrivacyMask
)
call
->
params
->
privacy
);
if
(
call
->
op
)
sal_op_release
(
call
->
op
);
call
->
op
=
sal_op_new
(
call
->
core
->
sal
);
sal_op_set_user_pointer
(
call
->
op
,
call
);
if
(
call
->
params
->
referer
)
sal_call_set_referer
(
call
->
op
,
call
->
params
->
referer
->
op
);
linphone_configure_op
(
call
->
core
,
call
->
op
,
call
->
log
->
to
,
call
->
params
->
custom_headers
,
FALSE
);
if
(
call
->
params
->
privacy
!=
LinphonePrivacyDefault
)
sal_op_set_privacy
(
call
->
op
,(
SalPrivacyMask
)
call
->
params
->
privacy
);
/*else privacy might be set by proxy */
}
...
...
@@ -1378,7 +1378,7 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr
call
->
referer
=
linphone_call_ref
(
params
->
referer
);
}
linphone_call_create_op_to
(
call
,
to
);
linphone_call_create_op_to
(
call
,
to
);
return
call
;
}
...
...
@@ -2184,7 +2184,7 @@ const LinphoneAddress * linphone_call_get_to_address(const LinphoneCall *call){
}
const
char
*
linphone_call_get_to_header
(
const
LinphoneCall
*
call
,
const
char
*
name
){
return
sal_custom_header_find
(
sal_op_get_recv_custom_header
(
call
->
op
),
name
);
return
sal_custom_header_find
(
sal_op_get_recv_custom_header
(
call
->
op
),
name
);
}
char
*
linphone_call_get_remote_address_as_string
(
const
LinphoneCall
*
call
){
...
...
@@ -5969,7 +5969,7 @@ end:
}
int
linphone_call_restart_invite
(
LinphoneCall
*
call
)
{
linphone_call_create_op
(
call
);
linphone_call_create_op
(
call
);
linphone_call_stop_media_streams
(
call
);
ms_media_stream_sessions_uninit
(
&
call
->
sessions
[
call
->
main_audio_stream_index
]);
ms_media_stream_sessions_uninit
(
&
call
->
sessions
[
call
->
main_video_stream_index
]);
...
...
@@ -6204,4 +6204,3 @@ void linphone_call_notify_info_message_received(LinphoneCall *call, const Linpho
void
linphone_call_notify_ack_processing
(
LinphoneCall
*
call
,
LinphoneHeaders
*
msg
,
bool_t
is_received
)
{
NOTIFY_IF_EXIST
(
ack_processing
,
call
,
msg
,
is_received
)
}
coreapi/CallLog.cc
View file @
d88e17cd
...
...
@@ -86,7 +86,7 @@ void call_logs_write_to_config_file(LinphoneCore *lc){
LpConfig
*
cfg
=
lc
->
config
;
if
(
linphone_core_get_global_state
(
lc
)
==
LinphoneGlobalStartup
)
return
;
if
(
lc
->
max_call_logs
==
LINPHONE_MAX_CALL_HISTORY_UNLIMITED
)
return
;
for
(
i
=
0
,
elem
=
lc
->
call_logs
;
elem
!=
NULL
;
elem
=
elem
->
next
,
++
i
){
...
...
@@ -310,9 +310,8 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *fr
set_call_log_date
(
cl
,
cl
->
start_date_time
);
cl
->
from
=
from
;
LinphoneAddress
*
to_tmp
=
linphone_address_clone
(
to
);
linphone_address_clean
(
to_tmp
);
cl
->
to
=
to_tmp
;
cl
->
to
=
linphone_address_clone
(
to
);
linphone_address_clean
(
cl
->
to
);
cl
->
status
=
LinphoneCallAborted
;
/*default status*/
cl
->
quality
=-
1
;
...
...
@@ -459,9 +458,9 @@ static int create_call_log(void *data, int argc, char **argv, char **colName) {
from
=
linphone_address_new
(
argv
[
1
]);
to
=
linphone_address_new
(
argv
[
2
]);
if
(
from
==
NULL
||
to
==
NULL
)
goto
error
;
dir
=
(
LinphoneCallDir
)
atoi
(
argv
[
3
]);
log
=
linphone_call_log_new
(
dir
,
from
,
to
);
...
...
@@ -485,7 +484,7 @@ static int create_call_log(void *data, int argc, char **argv, char **colName) {
clsres
->
result
=
bctbx_list_append
(
clsres
->
result
,
log
);
return
0
;
error:
if
(
from
){
linphone_address_unref
(
from
);
...
...
coreapi/Conference.cc
View file @
d88e17cd
...
...
@@ -30,6 +30,7 @@
#include <typeinfo>
#include <list>
#include <algorithm>
#include <string>
namespace
Linphone
{
...
...
@@ -41,7 +42,7 @@ inline std::list<_type> toStd(const bctbx_list_t *l){
}
return
ret
;
}
class
Conference
{
public:
class
Participant
{
...
...
@@ -50,33 +51,33 @@ public:
m_uri
=
linphone_address_clone
(
linphone_call_get_remote_address
(
call
));
m_call
=
call
;
}
~
Participant
()
{
linphone_address_unref
(
m_uri
);
if
(
m_call
)
m_call
->
conf_ref
=
NULL
;
}
const
LinphoneAddress
*
getUri
()
const
{
return
m_uri
;
}
LinphoneCall
*
getCall
()
const
{
return
m_call
;
}
private:
Participant
(
const
Participant
&
src
);
Participant
&
operator
=
(
const
Participant
&
src
);
private:
LinphoneAddress
*
m_uri
;
LinphoneCall
*
m_call
;
friend
class
RemoteConference
;
};
class
Params
{
public:
Params
(
const
LinphoneCore
*
core
=
NULL
)
{
...
...
@@ -97,63 +98,60 @@ public:
private:
bool
m_enableVideo
;
LinphoneConferenceStateChangedCb
m_stateChangedCb
;
void
*
m_userData
;
void
*
m_userData
;
friend
class
Conference
;
};
Conference
(
LinphoneCore
*
core
,
LinphoneConference
*
conf
,
const
Params
*
params
=
NULL
);
virtual
~
Conference
()
{
if
(
m_conferenceID
)
ms_free
(
m_conferenceID
);
}
virtual
~
Conference
()
{}
const
Params
&
getCurrentParams
()
const
{
return
m_currentParams
;}
virtual
int
inviteAddresses
(
const
std
::
list
<
const
LinphoneAddress
*>
&
addresses
,
const
LinphoneCallParams
*
params
)
=
0
;
virtual
int
addParticipant
(
LinphoneCall
*
call
)
=
0
;
virtual
int
removeParticipant
(
LinphoneCall
*
call
)
=
0
;
virtual
int
removeParticipant
(
const
LinphoneAddress
*
uri
)
=
0
;
virtual
int
terminate
()
=
0
;
virtual
int
enter
()
=
0
;
virtual
int
leave
()
=
0
;
virtual
bool
isIn
()
const
=
0
;
AudioStream
*
getAudioStream
()
const
{
return
m_localParticipantStream
;}
int
muteMicrophone
(
bool
val
);
bool
microphoneIsMuted
()
const
{
return
m_isMuted
;}
float
getInputVolume
()
const
;
virtual
int
getSize
()
const
{
return
(
int
)
m_participants
.
size
()
+
(
isIn
()
?
1
:
0
);}
const
std
::
list
<
Participant
*>
&
getParticipants
()
const
{
return
m_participants
;}
virtual
int
startRecording
(
const
char
*
path
)
=
0
;
virtual
int
stopRecording
()
=
0
;
virtual
void
onCallStreamStarting
(
LinphoneCall
*
call
,
bool
isPausedByRemote
)
{};
virtual
void
onCallStreamStopping
(
LinphoneCall
*
call
)
{};
virtual
void
onCallTerminating
(
LinphoneCall
*
call
)
{};
LinphoneConferenceState
getState
()
const
{
return
m_state
;}
LinphoneCore
*
getCore
()
const
{
return
m_core
;
}
static
const
char
*
stateToString
(
LinphoneConferenceState
state
);
void
setID
(
const
char
*
conferenceID
)
{
if
(
m_
conferenceID
)
ms_free
(
m_conferenceID
);
m_conferenceID
=
ms_strdup
(
conferenceID
);
}
const
char
*
getID
()
{
return
m_conferenceID
;
}
void
setID
(
const
char
*
conferenceID
)
{
m_conferenceID
=
conferenceID
;
}
const
char
*
getID
()
{
return
m_conferenceID
.
c_str
();
}
protected:
void
setState
(
LinphoneConferenceState
state
);
Participant
*
findParticipant
(
const
LinphoneCall
*
call
)
const
;
Participant
*
findParticipant
(
const
LinphoneAddress
*
uri
)
const
;
protected:
char
*
m_conferenceID
=
NULL
;
std
::
string
m_conferenceID
;
LinphoneCore
*
m_core
;
AudioStream
*
m_localParticipantStream
;
bool
m_isMuted
;
...
...
@@ -167,25 +165,25 @@ class LocalConference: public Conference {
public:
LocalConference
(
LinphoneCore
*
core
,
LinphoneConference
*
conf
,
const
Params
*
params
=
NULL
);
virtual
~
LocalConference
();
virtual
int
inviteAddresses
(
const
std
::
list
<
const
LinphoneAddress
*>
&
addresses
,
const
LinphoneCallParams
*
params
);
virtual
int
addParticipant
(
LinphoneCall
*
call
);
virtual
int
removeParticipant
(
LinphoneCall
*
call
);
virtual
int
removeParticipant
(
const
LinphoneAddress
*
uri
);
virtual
int
terminate
();
virtual
int
enter
();
virtual
int
leave
();
virtual
bool
isIn
()
const
{
return
m_localParticipantStream
!=
NULL
;}
virtual
int
getSize
()
const
;
virtual
int
startRecording
(
const
char
*
path
);
virtual
int
stopRecording
();
virtual
void
onCallStreamStarting
(
LinphoneCall
*
call
,
bool
isPausedByRemote
);
virtual
void
onCallStreamStopping
(
LinphoneCall
*
call
);
virtual
void
onCallTerminating
(
LinphoneCall
*
call
);
private:
void
addLocalEndpoint
();
int
remoteParticipantsCount
();
...
...
@@ -205,17 +203,17 @@ class RemoteConference: public Conference {
public:
RemoteConference
(
LinphoneCore
*
core
,
LinphoneConference
*
conf
,
const
Params
*
params
=
NULL
);
virtual
~
RemoteConference
();
virtual
int
inviteAddresses
(
const
std
::
list
<
const
LinphoneAddress
*>
&
addresses
,
const
LinphoneCallParams
*
params
);
virtual
int
addParticipant
(
LinphoneCall
*
call
);
virtual
int
removeParticipant
(
LinphoneCall
*
call
)
{
return
-
1
;}
virtual
int
removeParticipant
(
const
LinphoneAddress
*
uri
);
virtual
int
terminate
();
virtual
int
enter
();
virtual
int
leave
();
virtual
bool
isIn
()
const
;
virtual
int
startRecording
(
const
char
*
path
)
{
return
0
;}
virtual
int
stopRecording
()
{
return
0
;}
...
...
@@ -223,14 +221,14 @@ private:
bool
focusIsReady
()
const
;
bool
transferToFocus
(
LinphoneCall
*
call
);
void
reset
();
void
onFocusCallSateChanged
(
LinphoneCallState
state
);
void
onPendingCallStateChanged
(
LinphoneCall
*
call
,
LinphoneCallState
state
);
void
onTransferingCallStateChanged
(
LinphoneCall
*
transfered
,
LinphoneCallState
newCallState
);
static
void
callStateChangedCb
(
LinphoneCore
*
lc
,
LinphoneCall
*
call
,
LinphoneCallState
cstate
,
const
char
*
message
);
static
void
transferStateChanged
(
LinphoneCore
*
lc
,
LinphoneCall
*
transfered
,
LinphoneCallState
new_call_state
);
const
char
*
m_focusAddr
;
char
*
m_focusContact
;
LinphoneCall
*
m_focusCall
;
...
...
@@ -408,7 +406,7 @@ void LocalConference::addLocalEndpoint() {
}
int
LocalConference
::
inviteAddresses
(
const
std
::
list
<
const
LinphoneAddress
*>
&
addresses
,
const
LinphoneCallParams
*
params
){
for
(
std
::
list
<
const
LinphoneAddress
*>::
const_iterator
it
=
addresses
.
begin
();
it
!=
addresses
.
end
();
++
it
){
const
LinphoneAddress
*
addr
=
*
it
;
LinphoneCall
*
call
=
linphone_core_get_call_by_remote_address2
(
m_core
,
addr
);
...
...
@@ -572,10 +570,10 @@ int LocalConference::terminate() {
linphone_call_terminate
(
call
);
}
}
Conference
::
terminate
();
m_terminating
=
FALSE
;
return
0
;
}
...
...
@@ -705,7 +703,7 @@ int RemoteConference::inviteAddresses(const std::list<const LinphoneAddress *> &
int
RemoteConference
::
addParticipant
(
LinphoneCall
*
call
)
{
LinphoneAddress
*
addr
;
LinphoneCallParams
*
params
;
switch
(
m_state
)
{
case
LinphoneConferenceStopped
:
case
LinphoneConferenceStartingFailed
:
...
...
@@ -734,7 +732,7 @@ int RemoteConference::addParticipant(LinphoneCall *call) {
m_pendingCalls
.
push_back
(
call
);
}
return
0
;
case
LinphoneConferenceRunning
:
Conference
::
addParticipant
(
call
);
transferToFocus
(
call
);
...
...
@@ -750,7 +748,7 @@ int RemoteConference::removeParticipant(const LinphoneAddress *uri) {
char
*
refer_to
;
LinphoneAddress
*
refer_to_addr
;
int
res
;
switch
(
m_state
)
{
case
LinphoneConferenceRunning
:
if
(
findParticipant
(
uri
)
==
NULL
)
{
...
...
@@ -759,14 +757,14 @@ int RemoteConference::removeParticipant(const LinphoneAddress *uri) {
ms_free
(
tmp
);
return
-
1
;
}
refer_to_addr
=
linphone_address_clone
(
uri
);
linphone_address_set_method_param
(
refer_to_addr
,
"BYE"
);
refer_to
=
linphone_address_as_string
(
refer_to_addr
);
linphone_address_unref
(
refer_to_addr
);
res
=
sal_call_refer
(
m_focusCall
->
op
,
refer_to
);
ms_free
(
refer_to
);
if
(
res
==
0
)
{
return
Conference
::
removeParticipant
(
uri
);
}
else
{
...
...
@@ -775,7 +773,7 @@ int RemoteConference::removeParticipant(const LinphoneAddress *uri) {
ms_free
(
tmp
);
return
-
1
;
}
default:
ms_error
(
"Cannot remove %s from conference: Bad conference state (%s)"
,
linphone_address_as_string
(
uri
),
stateToString
(
m_state
));
return
-
1
;
...
...
@@ -788,7 +786,7 @@ int RemoteConference::terminate() {
case
LinphoneConferenceStarting
:
linphone_call_terminate
(
m_focusCall
);
break
;
default:
break
;
}
return
0
;
...
...
@@ -867,7 +865,7 @@ void RemoteConference::reset() {
void
RemoteConference
::
onFocusCallSateChanged
(
LinphoneCallState
state
)
{
list
<
LinphoneCall
*>::
iterator
it
;
switch
(
state
)
{
case
LinphoneCallConnected
:
m_focusContact
=
ms_strdup
(
linphone_call_get_remote_contact
(
m_focusCall
));
...
...
@@ -890,7 +888,7 @@ void RemoteConference::onFocusCallSateChanged(LinphoneCallState state) {
Conference
::
terminate
();
setState
(
LinphoneConferenceStartingFailed
);
break
;
case
LinphoneCallEnd
:
reset
();
Conference
::
terminate
();
...
...
@@ -911,7 +909,7 @@ void RemoteConference::onPendingCallStateChanged(LinphoneCall *call, LinphoneCal
linphone_call_transfer
(
call
,
m_focusContact
);
}
break
;
case
LinphoneCallError
:
case
LinphoneCallEnd
:
m_pendingCalls
.
remove
(
call
);
...
...
@@ -920,7 +918,7 @@ void RemoteConference::onPendingCallStateChanged(LinphoneCall *call, LinphoneCal
terminate
();
}
break
;
default:
break
;
}
}
...
...
@@ -931,7 +929,7 @@ void RemoteConference::onTransferingCallStateChanged(LinphoneCall* transfered, L
m_transferingCalls
.
push_back
(
transfered
);
findParticipant
(
transfered
)
->
m_call
=
NULL
;
break
;
case
LinphoneCallError
:
m_transferingCalls
.
remove
(
transfered
);
Conference
::
removeParticipant
(
transfered
);
...
...
include/linphone/conference.h
View file @
d88e17cd
...
...
@@ -126,12 +126,12 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_conference_get_participants(const Linphon
LINPHONE_PUBLIC
LinphoneStatus
linphone_conference_invite_participants
(
LinphoneConference
*
conf
,
const
bctbx_list_t
*
addresses
,
const
LinphoneCallParams
*
params
);
/**
*Get the conference id as string
*
Get the conference id as string
*/
LINPHONE_PUBLIC
const
char
*
linphone_conference_get_ID
(
const
LinphoneConference
*
obj
);
/**
*
s
et the conference id as string
*
S
et the conference id as string
*/
LINPHONE_PUBLIC
void
linphone_conference_set_ID
(
const
LinphoneConference
*
obj
,
const
char
*
conferenceID
);
...
...
Write
Preview
Markdown
is supported
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