Merge branch 'dev_conference'

Conflicts:
	coreapi/linphonecall.c
	coreapi/linphonecore.c
	java/common/org/linphone/core/LinphoneCall.java
	mediastreamer2
This commit is contained in:
Simon Morlat 2011-09-16 21:51:26 +02:00
commit 6d0b58eb71
16 changed files with 829 additions and 321 deletions

View file

@ -47,6 +47,7 @@ LOCAL_SRC_FILES := \
offeranswer.c \
callbacks.c \
linphonecall.c \
conference.c \
ec-calibrator.c
ifndef MY_LOG_DOMAIN

View file

@ -145,6 +145,28 @@ else
echo "GTK interface compilation is disabled."
fi
AC_ARG_ENABLE(notify,
[ --enable-notify=[yes/no] Enable libnotify support [default=yes]],
[case "${enableval}" in
yes) notify=true ;;
no) notify=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-notify) ;;
esac],[notify=true])
dnl conditionnal build of the notify library
if test "$gtk_ui" = "true" ; then
if test "$notify" = "true"; then
PKG_CHECK_MODULES([NOTIFY], [libnotify >= 0.7.0 ], [found_notify=yes], foo=bar)
case "$found_notify" in
yes)
AC_SUBST(NOTIFY_CFLAGS)
AC_SUBST(NOTIFY_LIBS)
AC_DEFINE([HAVE_NOTIFY],[1],[NOTIFY support])
esac
else
echo "Libnotify support is disabled."
fi
fi
dnl os-specific problems not handled by existing macros.
case "$host_os" in

View file

@ -102,6 +102,7 @@ static int lpc_cmd_vfureq(LinphoneCore *lc, char *arg);
static int lpc_cmd_states(LinphoneCore *lc, char *args);
static int lpc_cmd_identify(LinphoneCore *lc, char *args);
static int lpc_cmd_ringback(LinphoneCore *lc, char *args);
static int lpc_cmd_conference(LinphoneCore *lc, char *args);
/* Command handler helpers */
static void linphonec_proxy_add(LinphoneCore *lc);
@ -122,8 +123,7 @@ static int linphonec_friend_delete(LinphoneCore *lc, int num);
static void linphonec_codec_list(int type, LinphoneCore *lc);
static void linphonec_codec_enable(int type, LinphoneCore *lc, int index);
static void linphonec_codec_disable(int type, LinphoneCore *lc, int index);
static void lpc_display_call_states(LinphoneCore *lc);
/* Command table management */
static LPC_COMMAND *lpc_find_command(const char *name);
@ -184,6 +184,10 @@ static LPC_COMMAND commands[] = {
"'transfer <call id> <sip-uri>': transfers the call with 'id' to the destination sip-uri\n"
"'transfer <call id1> --to-call <call id2>': transfers the call with 'id1' to the destination of call 'id2' (attended transfer)\n"
},
{ "conference", lpc_cmd_conference, "Create and manage an audio conference.",
"'conference add <call id> : join the call with id 'call id' into the audio conference."
"'conference rm <call id> : remove the call with id 'call id' from the audio conference."
},
{ "mute", lpc_cmd_mute_mic,
"Mute microphone and suspend voice transmission."},
#ifdef VIDEO_ENABLED
@ -523,37 +527,6 @@ lpc_cmd_help(LinphoneCore *lc, char *arg)
static char callee_name[256]={0};
static char caller_name[256]={0};
static const char *get_call_status(LinphoneCall *call){
switch(linphone_call_get_state(call)){
case LinphoneCallPaused:
if (linphone_call_get_refer_to (call)!=NULL){
return "Paused (transfered)";
}else{
return "Paused";
}
break;
case LinphoneCallPausedByRemote:
return "Paused by remote";
break;
case LinphoneCallIncomingReceived:
return "Pending";
break;
case LinphoneCallOutgoingInit:
case LinphoneCallOutgoingProgress:
return "Dialing out";
break;
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallOutgoingRinging:
return "Remote ringing";
break;
default:
if (linphone_call_has_transfer_pending(call)){
return "Running (transfer pending)";
}else
return "Running";
}
return "";
}
static int
lpc_cmd_call(LinphoneCore *lc, char *args)
@ -599,19 +572,7 @@ lpc_cmd_calls(LinphoneCore *lc, char *args){
const MSList *calls = linphone_core_get_calls(lc);
if(calls)
{
const MSList *p_calls = calls;
linphonec_out("ID\t\tDestination\t\t\t\tStatus\n---------------------------------------------------------------------\n");
while(p_calls != NULL)
{
LinphoneCall *call=(LinphoneCall*)p_calls->data;
char *tmp=linphone_call_get_remote_address_as_string(call);
linphonec_out("%li\t%s\t\t\t%s\r\n",
(long)linphone_call_get_user_pointer (call),
tmp,
get_call_status(call));
p_calls = p_calls->next;
ms_free(tmp);
}
lpc_display_call_states(lc);
}else
{
linphonec_out("No active call.\n");
@ -1461,6 +1422,32 @@ static int lpc_cmd_resume(LinphoneCore *lc, char *args){
}
static int lpc_cmd_conference(LinphoneCore *lc, char *args){
long id;
char subcommand[32]={0};
int n;
if (args==NULL) return 0;
n=sscanf(args, "%31s %li", subcommand,&id);
if (n == 2){
LinphoneCall *call=linphonec_get_call(id);
if (call==NULL) return 1;
if (strcmp(subcommand,"add")==0){
linphone_core_add_to_conference(lc,call);
return 1;
}else if (strcmp(subcommand,"rm")==0){
linphone_core_remove_from_conference(lc,call);
return 1;
}else if (strcmp(subcommand,"enter")==0){
linphone_core_enter_conference(lc);
return 1;
}else if (strcmp(subcommand,"leave")==0){
linphone_core_leave_conference(lc);
return 1;
}
}
return 0;
}
/***************************************************************************
*
* Commands helper functions
@ -2403,17 +2390,21 @@ static void lpc_display_call_states(LinphoneCore *lc){
const MSList *elem;
char *tmp;
linphonec_out("Call states\n"
"Id | Destination | State\n"
"---------------------------------------------------------------\n");
"Id | Destination | State | Flags |\n"
"------------------------------------------------------------------------\n");
elem=linphone_core_get_calls(lc);
if (elem==NULL){
linphonec_out("(empty)\n");
}else{
for(;elem!=NULL;elem=elem->next){
const char *flag;
call=(LinphoneCall*)elem->data;
bool_t in_conference=linphone_call_params_local_conference_mode(linphone_call_get_current_params(call));
tmp=linphone_call_get_remote_address_as_string (call);
linphonec_out("%-2i | %-35s | %s\n",(int)(long)linphone_call_get_user_pointer(call),
tmp,linphone_call_state_to_string(linphone_call_get_state(call)));
flag=in_conference ? "conferencing" : "";
flag=linphone_call_has_transfer_pending(call) ? "transfer pending" : flag;
linphonec_out("%-2i | %-35s | %-15s | %s\n",(int)(long)linphone_call_get_user_pointer(call),
tmp,linphone_call_state_to_string(linphone_call_get_state(call))+strlen("LinphoneCall"),flag);
ms_free(tmp);
}
}

View file

@ -36,7 +36,8 @@ liblinphone_la_SOURCES=\
sipsetup.c sipsetup.h \
siplogin.c \
lsd.c linphonecore_utils.h \
ec-calibrator.c
ec-calibrator.c \
conference.c
liblinphone_la_LDFLAGS= -version-info $(LIBLINPHONE_SO_VERSION) -no-undefined

View file

@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details);
static bool_t media_parameters_changed(LinphoneCall *call, SalMediaDescription *oldmd, SalMediaDescription *newmd){
if (call->params.in_conference!=call->current_params.in_conference) return TRUE;
return !sal_media_description_equals(oldmd,newmd) || call->up_bw!=linphone_core_get_upload_bandwidth(call->core);
}
@ -194,7 +195,8 @@ static void call_received(SalOp *h){
ms_message("the local ring is already started");
}
}else{
/*TODO : play a tone within the context of the current call */
/* play a tone within the context of the current call */
linphone_core_play_tone(lc);
}

162
coreapi/conference.c Normal file
View file

@ -0,0 +1,162 @@
/***************************************************************************
* conference.c
*
* Mon Sep 12, 2011
* Copyright 2011 Belledonne Communications
* Author: Simon Morlat
* Email simon dot morlat at linphone dot org
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "private.h"
static void conference_check_init(LinphoneConference *ctx){
if (ctx->conf==NULL){
ctx->conf=ms_audio_conference_new();
}
}
static void remove_local_endpoint(LinphoneConference *ctx){
if (ctx->local_endpoint){
ms_audio_conference_remove_member(ctx->conf,ctx->local_endpoint);
ms_audio_endpoint_release_from_stream(ctx->local_endpoint);
ctx->local_endpoint=NULL;
audio_stream_stop(ctx->local_participant);
ctx->local_participant=NULL;
}
}
static void conference_check_uninit(LinphoneConference *ctx){
if (ctx->conf){
if (ctx->conf->nmembers==0){
remove_local_endpoint(ctx);
ms_audio_conference_destroy(ctx->conf);
ctx->conf=NULL;
}
}
}
void linphone_call_add_to_conf(LinphoneCall *call){
LinphoneCore *lc=call->core;
LinphoneConference *conf=&lc->conf_ctx;
MSAudioEndpoint *ep;
ep=ms_audio_endpoint_get_from_stream(call->audiostream,TRUE);
ms_audio_conference_add_member(conf->conf,ep);
call->endpoint=ep;
}
void linphone_call_remove_from_conf(LinphoneCall *call){
LinphoneCore *lc=call->core;
LinphoneConference *conf=&lc->conf_ctx;
ms_audio_conference_remove_member(conf->conf,call->endpoint);
ms_audio_endpoint_release_from_stream(call->endpoint);
call->endpoint=NULL;
conference_check_uninit(conf);
}
static void add_local_endpoint(LinphoneConference *conf,LinphoneCore *lc){
/*create a dummy audiostream in order to extract the local part of it */
/* network address and ports have no meaning and are not used here. */
AudioStream *st=audio_stream_new(65000,FALSE);
MSSndCard *playcard=lc->sound_conf.lsd_card ?
lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
audio_stream_start_full(st, &av_profile,
"127.0.0.1",
65000,
65001,
0,
40,
NULL,
NULL,
playcard,
captcard,
linphone_core_echo_cancellation_enabled(lc)
);
_post_configure_audio_stream(st,lc,FALSE);
conf->local_participant=st;
conf->local_endpoint=ms_audio_endpoint_get_from_stream(st,FALSE);
ms_audio_conference_add_member(conf->conf,conf->local_endpoint);
}
int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call){
LinphoneCallParams params;
LinphoneConference *conf=&lc->conf_ctx;
if (call->current_params.in_conference){
ms_error("Already in conference");
return -1;
}
conference_check_init(&lc->conf_ctx);
call->params.in_conference=TRUE;
call->params.has_video=FALSE;
params=call->params;
if (call->state==LinphoneCallPaused)
linphone_core_resume_call(lc,call);
else if (call->state==LinphoneCallStreamsRunning){
/*this will trigger a reINVITE that will later redraw the streams */
if (call->audiostream || call->videostream)
linphone_call_stop_media_streams (call); /*free the audio & video local resources*/
linphone_core_update_call(lc,call,&params);
add_local_endpoint(conf,lc);
}else{
ms_error("Call is in state %s, it cannot be added to the conference.",linphone_call_state_to_string(call->state));
return -1;
}
return 0;
}
int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){
if (!call->current_params.in_conference){
if (call->params.in_conference){
ms_warning("Not (yet) in conference, be patient");
return -1;
}else{
ms_error("Not in a conference.");
return -1;
}
}
call->params.in_conference=FALSE;
return linphone_core_pause_call(lc,call);
}
bool_t linphone_core_is_in_conference(const LinphoneCore *lc){
return lc->conf_ctx.local_participant!=NULL;
}
int linphone_core_leave_conference(LinphoneCore *lc){
LinphoneConference *conf=&lc->conf_ctx;
if (linphone_core_is_in_conference(lc))
remove_local_endpoint(conf);
return 0;
}
int linphone_core_enter_conference(LinphoneCore *lc){
LinphoneConference *conf=&lc->conf_ctx;
if (conf->local_participant==NULL) add_local_endpoint(conf,lc);
return 0;
}
int linphone_core_add_all_to_conference(LinphoneCore *lc) {return 0;}
int linphone_core_terminate_conference(LinphoneCore *lc) {return 0;}
int linphone_core_get_conference_size(LinphoneCore *lc) {return 0;}

View file

@ -1,7 +1,7 @@
/*
linphone
Copyright (C) 2010 Belledonne Communications SARL
Copyright (C) 2010 Belledonne Communications SARL
(simon.morlat@linphone.org)
This program is free software; you can redistribute it and/or
@ -165,14 +165,14 @@ static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, Li
LinphoneAddress *addr=linphone_address_new(me);
const char *username=linphone_address_get_username (addr);
SalMediaDescription *md=sal_media_description_new();
md->session_id=session_id;
md->session_ver=session_ver;
md->nstreams=1;
strncpy(md->addr,call->localip,sizeof(md->addr));
strncpy(md->username,username,sizeof(md->username));
md->bandwidth=linphone_core_get_download_bandwidth(lc);
/*set audio capabilities */
strncpy(md->streams[0].addr,call->localip,sizeof(md->streams[0].addr));
md->streams[0].port=call->audio_port;
@ -183,7 +183,7 @@ static SalMediaDescription *_create_local_media_description(LinphoneCore *lc, Li
pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event"));
l=ms_list_append(l,pt);
md->streams[0].payloads=l;
if (call->params.has_video){
md->nstreams++;
@ -250,7 +250,7 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from,
if (port_offset==-1) return;
call->audio_port=linphone_core_get_audio_port(call->core)+port_offset;
call->video_port=linphone_core_get_video_port(call->core)+port_offset;
}
static void discover_mtu(LinphoneCore *lc, const char *remote){
@ -306,7 +306,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
sal_ping(call->ping_op,linphone_core_find_best_identity(lc,from,NULL),from_str);
ms_free(from_str);
}
linphone_address_clean(from);
linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip);
linphone_call_init_common(call, from, to);
@ -327,13 +327,13 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
static void linphone_call_set_terminated(LinphoneCall *call){
LinphoneCore *lc=call->core;
linphone_core_update_allocated_audio_bandwidth(lc);
call->owns_call_log=FALSE;
linphone_call_log_completed(call);
if (call == lc->current_call){
ms_message("Resetting the current call");
lc->current_call=NULL;
@ -342,10 +342,10 @@ static void linphone_call_set_terminated(LinphoneCall *call){
if (linphone_core_del_call(lc,call) != 0){
ms_error("Could not remove the call from the list !!!");
}
if (ms_list_size(lc->calls)==0)
linphone_core_notify_all_friends(lc,lc->presence_mode);
}
const char *linphone_call_state_to_string(LinphoneCallState cs){
@ -419,7 +419,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
if (cstate == LinphoneCallConnected) {
call->log->status=LinphoneCallSuccess;
}
if (lc->vtable.call_state_changed)
lc->vtable.call_state_changed(lc,call,cstate,message);
if (cstate==LinphoneCallReleased){
@ -588,7 +588,7 @@ const char *linphone_call_get_remote_user_agent(LinphoneCall *call){
* executed yet.
* Pending transfers are executed when this call is being paused or closed,
* locally or by remote endpoint.
* If the call is already paused while receiving the transfer request, the
* If the call is already paused while receiving the transfer request, the
* transfer immediately occurs.
**/
bool_t linphone_call_has_transfer_pending(const LinphoneCall *call){
@ -680,6 +680,13 @@ bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams
return cp->real_early_media;
}
/**
* Returns true if the call is part of the locally managed conference.
**/
bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp){
return cp->in_conference;
}
/**
* Refine bandwidth settings for this call by setting a bandwidth limit for audio streams.
* As a consequence, codecs whose bitrates are not compatible with this limit won't be used.
@ -746,7 +753,7 @@ void linphone_call_init_media_streams(LinphoneCall *call){
LinphoneCore *lc=call->core;
SalMediaDescription *md=call->localdesc;
AudioStream *audiostream;
call->audiostream=audiostream=audio_stream_new(md->streams[0].port,linphone_core_ipv6_enabled(lc));
if (linphone_core_echo_limiter_enabled(lc)){
const char *type=lp_config_get_string(lc->config,"sound","el_type","mic");
@ -772,7 +779,7 @@ void linphone_call_init_media_streams(LinphoneCall *call){
int enabled=lp_config_get_int(lc->config,"sound","noisegate",0);
audio_stream_enable_noise_gate(audiostream,enabled);
}
if (lc->a_rtp)
rtp_session_set_transports(audiostream->session,lc->a_rtp,lc->a_rtcp);
@ -834,20 +841,17 @@ static void parametrize_equalizer(LinphoneCore *lc, AudioStream *st){
}
}
static void post_configure_audio_streams(LinphoneCall*call){
AudioStream *st=call->audiostream;
LinphoneCore *lc=call->core;
void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t muted){
float mic_gain=lp_config_get_float(lc->config,"sound","mic_gain",1);
float thres = 0;
float recv_gain;
float ng_thres=lp_config_get_float(lc->config,"sound","ng_thres",0.05);
float ng_floorgain=lp_config_get_float(lc->config,"sound","ng_floorgain",0);
int dc_removal=lp_config_get_int(lc->config,"sound","dc_removal",0);
if (!call->audio_muted)
if (!muted)
audio_stream_set_mic_gain(st,mic_gain);
else
else
audio_stream_set_mic_gain(st,0);
recv_gain = lc->sound_conf.soft_play_lev;
@ -884,6 +888,12 @@ static void post_configure_audio_streams(LinphoneCall*call){
ms_filter_call_method(st->volrecv,MS_VOLUME_SET_NOISE_GATE_FLOORGAIN,&floorgain);
}
parametrize_equalizer(lc,st);
}
static void post_configure_audio_streams(LinphoneCall*call){
AudioStream *st=call->audiostream;
LinphoneCore *lc=call->core;
_post_configure_audio_stream(st,lc,call->audio_muted);
if (lc->vtable.dtmf_received!=NULL){
/* replace by our default action*/
audio_stream_play_received_dtmfs(call->audiostream,FALSE);
@ -900,11 +910,11 @@ static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *m
LinphoneCore *lc=call->core;
int up_ptime=0;
*used_pt=-1;
for(elem=desc->payloads;elem!=NULL;elem=elem->next){
PayloadType *pt=(PayloadType*)elem->data;
int number;
if ((pt->flags & PAYLOAD_TYPE_FLAG_CAN_SEND) && first) {
if (desc->type==SalAudio){
linphone_core_update_allocated_audio_bandwidth_in_call(call,pt);
@ -921,8 +931,8 @@ static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *m
remote_bw=get_video_bandwidth(remote_bw,call->audio_bw);
}
}
if (desc->type==SalAudio){
if (desc->type==SalAudio){
bw=get_min_bandwidth(call->audio_bw,remote_bw);
}else bw=get_min_bandwidth(get_video_bandwidth(linphone_core_get_upload_bandwidth (lc),call->audio_bw),remote_bw);
if (bw>0) pt->normal_bitrate=bw*1000;
@ -953,180 +963,192 @@ static void setup_ring_player(LinphoneCore *lc, LinphoneCall *call){
ms_filter_call_method(call->audiostream->soundread,MS_FILE_PLAYER_LOOP,&pause_time);
}
#define LINPHONE_RTCP_SDES_TOOL "Linphone-" LINPHONE_VERSION
static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cname, bool_t muted, bool_t send_ringbacktone, bool_t use_arc){
LinphoneCore *lc=call->core;
int jitt_comp=lc->rtp_conf.audio_jitt_comp;
int used_pt=-1;
const SalStreamDescription *stream=sal_media_description_find_stream(call->resultdesc,
SalProtoRtpAvp,SalAudio);
if (stream && stream->dir!=SalStreamInactive && stream->port!=0){
MSSndCard *playcard=lc->sound_conf.lsd_card ?
lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
const char *playfile=lc->play_file;
const char *recfile=lc->rec_file;
call->audio_profile=make_profile(call,call->resultdesc,stream,&used_pt);
bool_t use_ec;
if (used_pt!=-1){
if (playcard==NULL) {
ms_warning("No card defined for playback !");
}
if (captcard==NULL) {
ms_warning("No card defined for capture !");
}
/*Replace soundcard filters by inactive file players or recorders
when placed in recvonly or sendonly mode*/
if (stream->port==0 || stream->dir==SalStreamRecvOnly){
captcard=NULL;
playfile=NULL;
}else if (stream->dir==SalStreamSendOnly){
playcard=NULL;
captcard=NULL;
recfile=NULL;
/*And we will eventually play "playfile" if set by the user*/
/*playfile=NULL;*/
}
if (send_ringbacktone){
captcard=NULL;
playfile=NULL;/* it is setup later*/
}
/*if playfile are supplied don't use soundcards*/
if (lc->use_files) {
captcard=NULL;
playcard=NULL;
}
if (call->params.in_conference){
/* first create the graph without soundcard resources*/
captcard=playcard=NULL;
}
use_ec=captcard==NULL ? FALSE : linphone_core_echo_cancellation_enabled(lc);
audio_stream_enable_adaptive_bitrate_control(call->audiostream,use_arc);
audio_stream_start_full(
call->audiostream,
call->audio_profile,
stream->addr[0]!='\0' ? stream->addr : call->resultdesc->addr,
stream->port,
stream->port+1,
used_pt,
jitt_comp,
playfile,
recfile,
playcard,
captcard,
use_ec
);
post_configure_audio_streams(call);
if (muted && !send_ringbacktone){
audio_stream_set_mic_gain(call->audiostream,0);
}
if (stream->dir==SalStreamSendOnly && playfile!=NULL){
int pause_time=500;
ms_filter_call_method(call->audiostream->soundread,MS_FILE_PLAYER_LOOP,&pause_time);
}
if (send_ringbacktone){
setup_ring_player(lc,call);
}
audio_stream_set_rtcp_information(call->audiostream, cname, LINPHONE_RTCP_SDES_TOOL);
if (call->params.in_conference){
/*transform the graph to connect it to the conference filter */
linphone_call_add_to_conf(call);
}
}else ms_warning("No audio stream accepted ?");
}
}
static void linphone_call_start_video_stream(LinphoneCall *call, const char *cname,bool_t all_inputs_muted){
#ifdef VIDEO_ENABLED
LinphoneCore *lc=call->core;
int used_pt=-1;
const SalStreamDescription *vstream=sal_media_description_find_stream(call->resultdesc,
SalProtoRtpAvp,SalVideo);
/* shutdown preview */
if (lc->previewstream!=NULL) {
video_preview_stop(lc->previewstream);
lc->previewstream=NULL;
}
call->current_params.has_video=FALSE;
if (vstream && vstream->dir!=SalStreamInactive && vstream->port!=0) {
const char *addr=vstream->addr[0]!='\0' ? vstream->addr : call->resultdesc->addr;
call->video_profile=make_profile(call,call->resultdesc,vstream,&used_pt);
if (used_pt!=-1){
VideoStreamDir dir=VideoStreamSendRecv;
MSWebCam *cam=lc->video_conf.device;
bool_t is_inactive=FALSE;
call->current_params.has_video=TRUE;
video_stream_set_sent_video_size(call->videostream,linphone_core_get_preferred_video_size(lc));
video_stream_enable_self_view(call->videostream,lc->video_conf.selfview);
if (lc->video_window_id!=0)
video_stream_set_native_window_id(call->videostream,lc->video_window_id);
if (lc->preview_window_id!=0)
video_stream_set_native_preview_window_id (call->videostream,lc->preview_window_id);
video_stream_use_preview_video_window (call->videostream,lc->use_preview_window);
if (vstream->dir==SalStreamSendOnly && lc->video_conf.capture ){
cam=get_nowebcam_device();
dir=VideoStreamSendOnly;
}else if (vstream->dir==SalStreamRecvOnly && lc->video_conf.display ){
dir=VideoStreamRecvOnly;
}else if (vstream->dir==SalStreamSendRecv){
if (lc->video_conf.display && lc->video_conf.capture)
dir=VideoStreamSendRecv;
else if (lc->video_conf.display)
dir=VideoStreamRecvOnly;
else
dir=VideoStreamSendOnly;
}else{
ms_warning("video stream is inactive.");
/*either inactive or incompatible with local capabilities*/
is_inactive=TRUE;
}
if (call->camera_active==FALSE || all_inputs_muted){
cam=get_nowebcam_device();
}
if (!is_inactive){
video_stream_set_direction (call->videostream, dir);
ms_message("%s lc rotation:%d\n", __FUNCTION__, lc->device_rotation);
video_stream_set_device_rotation(call->videostream, lc->device_rotation);
video_stream_start(call->videostream,
call->video_profile, addr, vstream->port,
vstream->port+1,
used_pt, lc->rtp_conf.audio_jitt_comp, cam);
video_stream_set_rtcp_information(call->videostream, cname,LINPHONE_RTCP_SDES_TOOL);
}
}else ms_warning("No video stream accepted.");
}else{
ms_warning("No valid video stream defined.");
}
#endif
}
void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_muted, bool_t send_ringbacktone){
LinphoneCore *lc=call->core;
LinphoneAddress *me=linphone_core_get_primary_contact_parsed(lc);
const char *tool="linphone-" LINPHONE_VERSION;
char *cname;
int used_pt=-1;
bool_t use_arc;
#ifdef VIDEO_ENABLED
const SalStreamDescription *vstream=sal_media_description_find_stream(call->resultdesc,
SalProtoRtpAvp,SalVideo);
#endif
bool_t use_arc=linphone_core_adaptive_rate_control_enabled(lc);
if(call->audiostream == NULL)
{
ms_fatal("start_media_stream() called without prior init !");
return;
}
call->current_params = call->params;
/* adjust rtp jitter compensation. It must be at least the latency of the sound card */
int jitt_comp=MAX(lc->sound_conf.latency,lc->rtp_conf.audio_jitt_comp);
if (call->media_start_time==0) call->media_start_time=time(NULL);
cname=linphone_address_as_string_uri_only(me);
{
const SalStreamDescription *stream=sal_media_description_find_stream(call->resultdesc,
SalProtoRtpAvp,SalAudio);
if (stream && stream->dir!=SalStreamInactive && stream->port!=0){
MSSndCard *playcard=lc->sound_conf.lsd_card ?
lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
const char *playfile=lc->play_file;
const char *recfile=lc->rec_file;
call->audio_profile=make_profile(call,call->resultdesc,stream,&used_pt);
bool_t use_ec,use_arc_audio=use_arc;
if (used_pt!=-1){
if (playcard==NULL) {
ms_warning("No card defined for playback !");
}
if (captcard==NULL) {
ms_warning("No card defined for capture !");
}
/*Replace soundcard filters by inactive file players or recorders
when placed in recvonly or sendonly mode*/
if (stream->port==0 || stream->dir==SalStreamRecvOnly){
captcard=NULL;
playfile=NULL;
}else if (stream->dir==SalStreamSendOnly){
playcard=NULL;
captcard=NULL;
recfile=NULL;
/*And we will eventually play "playfile" if set by the user*/
/*playfile=NULL;*/
}
if (send_ringbacktone){
captcard=NULL;
playfile=NULL;/* it is setup later*/
}
/*if playfile are supplied don't use soundcards*/
if (lc->use_files) {
captcard=NULL;
playcard=NULL;
}
use_ec=captcard==NULL ? FALSE : linphone_core_echo_cancellation_enabled(lc);
#if defined(VIDEO_ENABLED)
if (vstream && vstream->dir!=SalStreamInactive && vstream->payloads!=NULL){
/*when video is used, do not make adaptive rate control on audio, it is stupid.*/
use_arc_audio=FALSE;
#if defined(ANDROID)
/*On android we have to disable the echo canceller to preserve CPU for video codecs */
use_ec=FALSE;
#endif
}
#endif
audio_stream_enable_adaptive_bitrate_control(call->audiostream,use_arc_audio);
audio_stream_start_full(
call->audiostream,
call->audio_profile,
stream->addr[0]!='\0' ? stream->addr : call->resultdesc->addr,
stream->port,
stream->port+1,
used_pt,
jitt_comp,
playfile,
recfile,
playcard,
captcard,
use_ec
);
post_configure_audio_streams(call);
if (all_inputs_muted && !send_ringbacktone){
audio_stream_set_mic_gain(call->audiostream,0);
}
if (stream->dir==SalStreamSendOnly && playfile!=NULL){
int pause_time=500;
ms_filter_call_method(call->audiostream->soundread,MS_FILE_PLAYER_LOOP,&pause_time);
}
if (send_ringbacktone){
setup_ring_player(lc,call);
}
audio_stream_set_rtcp_information(call->audiostream, cname, tool);
}else ms_warning("No audio stream accepted ?");
}
}
#ifdef VIDEO_ENABLED
{
used_pt=-1;
/* shutdown preview */
if (lc->previewstream!=NULL) {
video_preview_stop(lc->previewstream);
lc->previewstream=NULL;
}
call->current_params.has_video=FALSE;
if (vstream && vstream->dir!=SalStreamInactive && vstream->port!=0) {
const char *addr=vstream->addr[0]!='\0' ? vstream->addr : call->resultdesc->addr;
call->video_profile=make_profile(call,call->resultdesc,vstream,&used_pt);
if (used_pt!=-1){
VideoStreamDir dir=VideoStreamSendRecv;
MSWebCam *cam=lc->video_conf.device;
bool_t is_inactive=FALSE;
call->current_params.has_video=TRUE;
video_stream_set_sent_video_size(call->videostream,linphone_core_get_preferred_video_size(lc));
video_stream_enable_self_view(call->videostream,lc->video_conf.selfview);
if (lc->video_window_id!=0)
video_stream_set_native_window_id(call->videostream,lc->video_window_id);
if (lc->preview_window_id!=0)
video_stream_set_native_preview_window_id (call->videostream,lc->preview_window_id);
video_stream_use_preview_video_window (call->videostream,lc->use_preview_window);
if (vstream->dir==SalStreamSendOnly && lc->video_conf.capture ){
cam=get_nowebcam_device();
dir=VideoStreamSendOnly;
}else if (vstream->dir==SalStreamRecvOnly && lc->video_conf.display ){
dir=VideoStreamRecvOnly;
}else if (vstream->dir==SalStreamSendRecv){
if (lc->video_conf.display && lc->video_conf.capture)
dir=VideoStreamSendRecv;
else if (lc->video_conf.display)
dir=VideoStreamRecvOnly;
else
dir=VideoStreamSendOnly;
}else{
ms_warning("video stream is inactive.");
/*either inactive or incompatible with local capabilities*/
is_inactive=TRUE;
}
if (call->camera_active==FALSE || all_inputs_muted){
cam=get_nowebcam_device();
}
if (!is_inactive){
video_stream_set_direction (call->videostream, dir);
ms_message("%s lc rotation:%d\n", __FUNCTION__, lc->device_rotation);
video_stream_set_device_rotation(call->videostream, lc->device_rotation);
video_stream_start(call->videostream,
call->video_profile, addr, vstream->port,
vstream->port+1,
used_pt, jitt_comp, cam);
video_stream_set_rtcp_information(call->videostream, cname,tool);
}
}else ms_warning("No video stream accepted.");
}else{
ms_warning("No valid video stream defined.");
}
if (vstream && vstream->dir!=SalStreamInactive && vstream->payloads!=NULL){
/*when video is used, do not make adaptive rate control on audio, it is stupid.*/
use_arc=FALSE;
}
#endif
linphone_call_start_audio_stream(call,cname,all_inputs_muted,send_ringbacktone,use_arc);
linphone_call_start_video_stream(call,cname,all_inputs_muted);
call->all_muted=all_inputs_muted;
call->playing_ringbacktone=send_ringbacktone;
call->up_bw=linphone_core_get_upload_bandwidth(lc);
if (ortp_zrtp_available()) {
OrtpZrtpParams params;
params.zid=get_hexa_zrtp_identifier(lc);
@ -1160,6 +1182,9 @@ void linphone_call_stop_media_streams(LinphoneCall *call){
}
}
linphone_call_log_fill_stats (call->log,call->audiostream);
if (call->endpoint){
linphone_call_remove_from_conf(call);
}
audio_stream_stop(call->audiostream);
call->audiostream=NULL;
}
@ -1174,7 +1199,7 @@ void linphone_call_stop_media_streams(LinphoneCall *call){
call->videostream=NULL;
}
ms_event_queue_skip(call->core->msevq);
#endif
if (call->audio_profile){
rtp_profile_clear_all(call->audio_profile);
@ -1231,11 +1256,11 @@ bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call){
/**
* @addtogroup call_misc
* @{
**/
**/
/**
* Returns the measured sound volume played locally (received from remote)
* It is expressed in dbm0.
* It is expressed in dbm0.
**/
float linphone_call_get_play_volume(LinphoneCall *call){
AudioStream *st=call->audiostream;
@ -1243,14 +1268,14 @@ float linphone_call_get_play_volume(LinphoneCall *call){
float vol=0;
ms_filter_call_method(st->volsend,MS_VOLUME_GET,&vol);
return vol;
}
return LINPHONE_VOLUME_DB_LOWEST;
}
/**
* Returns the measured sound volume recorded locally (sent to remote)
* It is expressed in dbm0.
* It is expressed in dbm0.
**/
float linphone_call_get_record_volume(LinphoneCall *call){
AudioStream *st=call->audiostream;
@ -1258,7 +1283,7 @@ float linphone_call_get_record_volume(LinphoneCall *call){
float vol=0;
ms_filter_call_method(st->volrecv,MS_VOLUME_GET,&vol);
return vol;
}
return LINPHONE_VOLUME_DB_LOWEST;
}
@ -1277,7 +1302,7 @@ float linphone_call_get_record_volume(LinphoneCall *call){
* 1-2 = very poor quality <br>
* 0-1 = can't be worse, mostly unusable <br>
*
* @returns The function returns -1 if no quality measurement is available, for example if no
* @returns The function returns -1 if no quality measurement is available, for example if no
* active audio stream exist. Otherwise it returns the quality rating.
**/
float linphone_call_get_current_quality(LinphoneCall *call){
@ -1320,7 +1345,7 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
{
snprintf(temp,sizeof(temp),"Remote end %s seems to have disconnected, the call is going to be closed.",from);
free(from);
}
}
else
{
snprintf(temp,sizeof(temp),"Remote end seems to have disconnected, the call is going to be closed.");
@ -1333,7 +1358,7 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapsed){
int disconnect_timeout = linphone_core_get_nortp_timeout(call->core);
bool_t disconnected=FALSE;
if (call->state==LinphoneCallStreamsRunning && one_second_elapsed){
RtpSession *as=NULL,*vs=NULL;
float audio_load=0, video_load=0;
@ -1389,7 +1414,7 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
}
}
}
if (one_second_elapsed && call->audiostream!=NULL && disconnect_timeout>0 )
if (call->state==LinphoneCallStreamsRunning && one_second_elapsed && call->audiostream!=NULL && disconnect_timeout>0 )
disconnected=!audio_stream_alive(call->audiostream,disconnect_timeout);
if (disconnected)
linphone_core_disconnected(call->core,call);
@ -1397,9 +1422,9 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
void linphone_call_log_completed(LinphoneCall *call){
LinphoneCore *lc=call->core;
call->log->duration=time(NULL)-call->start_time;
if (call->log->status==LinphoneCallMissed){
char *info;
lc->missed_calls++;
@ -1426,3 +1451,5 @@ void linphone_call_log_completed(LinphoneCall *call){
}
call_logs_write_to_config_file(lc);
}

View file

@ -1725,6 +1725,7 @@ void linphone_core_iterate(LinphoneCore *lc){
we are going to examine is destroy and removed during
linphone_core_start_invite() */
calls=calls->next;
linphone_call_background_tasks(call,one_second_elapsed);
if (call->state==LinphoneCallOutgoingInit && (curtime-call->start_time>=2)){
/*start the call even if the OPTIONS reply did not arrive*/
linphone_core_start_invite(lc,call,NULL);
@ -1738,9 +1739,7 @@ void linphone_core_iterate(LinphoneCore *lc){
}
}
}
call = linphone_core_get_current_call(lc);
if(call)
linphone_call_background_tasks(call,one_second_elapsed);
if (linphone_core_video_preview_enabled(lc)){
if (lc->previewstream==NULL && lc->calls==NULL)
toggle_video_preview(lc,TRUE);
@ -2096,7 +2095,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
if (linphone_core_in_call(lc)){
if (lc->vtable.display_warning)
lc->vtable.display_warning(lc,_("Sorry, you have to pause or stop the current call first !"));
lc->vtable.display_warning(lc,_("Sorry, you have to pause or stop the current call or conference first !"));
return NULL;
}
if(!linphone_core_can_we_add_call(lc)){
@ -2219,13 +2218,20 @@ bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){
int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){
int err=0;
if (params!=NULL){
const char *subject;
call->params=*params;
update_local_media_description(lc,call,&call->localdesc);
call->camera_active=params->has_video;
if (params->in_conference){
subject="Conference";
}else{
subject="Media change";
}
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Modifying call parameters..."));
sal_call_set_local_media_description (call->op,call->localdesc);
err=sal_call_update(call->op,"Media parameters update");
err=sal_call_update(call->op,subject);
}else{
#ifdef VIDEO_ENABLED
if (call->videostream!=NULL){
@ -2365,6 +2371,11 @@ static void terminate_call(LinphoneCore *lc, LinphoneCall *call){
ring_stop(lc->ringstream);
lc->ringstream=NULL;
}
/*stop any dtmf tone still playing */
ms_message("test");
linphone_core_stop_dtmf(lc);
linphone_call_stop_media_streams(call);
if (lc->vtable.display_status!=NULL)
lc->vtable.display_status(lc,_("Call ended") );
@ -2450,7 +2461,7 @@ const MSList *linphone_core_get_calls(LinphoneCore *lc)
* @ingroup call_control
**/
bool_t linphone_core_in_call(const LinphoneCore *lc){
return linphone_core_get_current_call((LinphoneCore *)lc)!=NULL;
return linphone_core_get_current_call((LinphoneCore *)lc)!=NULL || linphone_core_is_in_conference(lc);
}
/**
@ -2488,8 +2499,7 @@ int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *the_call)
ms_error("No reason to pause this call, it is already paused or inactive.");
return -1;
}
if (sal_call_update(call->op,subject) != 0)
{
if (sal_call_update(call->op,subject) != 0){
if (lc->vtable.display_warning)
lc->vtable.display_warning(lc,_("Could not pause the call"));
}
@ -2526,20 +2536,24 @@ int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *the_call)
{
char temp[255]={0};
LinphoneCall *call = the_call;
const char *subject="Call resuming";
if(call->state!=LinphoneCallPaused ){
ms_warning("we cannot resume a call that has not been established and paused before");
return -1;
}
if(linphone_core_get_current_call(lc) != NULL){
ms_warning("There is already a call in process, pause or stop it first.");
if (lc->vtable.display_warning)
lc->vtable.display_warning(lc,_("There is already a call in process, pause or stop it first."));
return -1;
if (call->params.in_conference==FALSE){
if(linphone_core_get_current_call(lc) != NULL){
ms_warning("There is already a call in process, pause or stop it first.");
if (lc->vtable.display_warning)
lc->vtable.display_warning(lc,_("There is already a call in process, pause or stop it first."));
return -1;
}
ms_message("Resuming call %p",call);
}
ms_message("Resuming call %p",call);
sal_media_description_set_dir(call->localdesc,SalStreamSendRecv);
if(sal_call_update(call->op,"Call resuming") != 0){
if (call->params.in_conference) subject="Resuming conference";
if(sal_call_update(call->op,subject) != 0){
return -1;
}
linphone_call_set_state (call,LinphoneCallResuming,"Resuming");
@ -3701,6 +3715,25 @@ void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms){
else ms_filter_call_method(f, MS_DTMF_GEN_START, &dtmf);
}
/**
* @ingroup media_parameters
* Plays a repeated tone to the local user until next further call to #linphone_core_stop_dtmf()
* @param lc #LinphoneCore
**/
void linphone_core_play_tone(LinphoneCore *lc){
MSFilter *f=get_dtmf_gen(lc);
MSDtmfGenCustomTone def;
if (f==NULL){
ms_error("No dtmf generator at this time !");
return;
}
def.duration=300;
def.frequency=500;
def.amplitude=1;
def.interval=800;
ms_filter_call_method(f, MS_DTMF_GEN_PLAY_CUSTOM,&def);
}
/**
* @ingroup media_parameters
*

View file

@ -181,6 +181,7 @@ void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled);
bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp);
void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled);
bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp);
bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp);
void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bw);
void linphone_call_params_destroy(LinphoneCallParams *cp);
@ -1024,8 +1025,15 @@ bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call);
const char* linphone_call_get_authentication_token(LinphoneCall *call);
bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call);
int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call);
int linphone_core_add_all_to_conference(LinphoneCore *lc);
int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call);
bool_t linphone_core_is_in_conference(const LinphoneCore *lc);
int linphone_core_enter_conference(LinphoneCore *lc);
int linphone_core_leave_conference(LinphoneCore *lc);
int linphone_core_terminate_conference(LinphoneCore *lc);
int linphone_core_get_conference_size(LinphoneCore *lc);
#ifdef __cplusplus
}

View file

@ -1215,6 +1215,11 @@ extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv
extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
}
extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
}
extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
return linphone_call_params_destroy((LinphoneCallParams*)lc);
}
@ -1344,6 +1349,41 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *en
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
}
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
return linphone_core_is_in_conference((LinphoneCore *) pCore);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
linphone_core_enter_conference((LinphoneCore *) pCore);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
linphone_core_leave_conference((LinphoneCore *) pCore);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
linphone_core_add_all_to_conference((LinphoneCore *) pCore);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
linphone_core_terminate_conference((LinphoneCore *) pCore);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
return linphone_core_get_conference_size((LinphoneCore *) pCore);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
linphone_core_terminate_all_calls((LinphoneCore *) pCore);
}
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
return (jlong)ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
if (jFile) {

View file

@ -33,6 +33,7 @@
#include "config.h"
#endif
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/msconference.h"
#ifndef LIBLINPHONE_VERSION
#define LIBLINPHONE_VERSION LINPHONE_VERSION
@ -62,7 +63,8 @@ struct _LinphoneCallParams{
int audio_bw; /* bandwidth limit for audio stream */
bool_t has_video;
bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/
bool_t pad[2];
bool_t in_conference; /*in conference mode */
bool_t pad;
};
struct _LinphoneCall
@ -87,6 +89,7 @@ struct _LinphoneCall
int video_port;
struct _AudioStream *audiostream; /**/
struct _VideoStream *videostream;
MSAudioEndpoint *endpoint; /*used for conferencing*/
char *refer_to;
LinphoneCallParams params;
LinphoneCallParams current_params;
@ -99,12 +102,13 @@ struct _LinphoneCall
bool_t all_muted; /*this flag is set during early medias*/
bool_t playing_ringbacktone;
bool_t owns_call_log;
bool_t pad;
OrtpEvQueue *audiostream_app_evq;
bool_t audiostream_encrypted;
char *auth_token;
bool_t auth_token_verified;
OrtpEvQueue *videostream_app_evq;
bool_t videostream_encrypted;
bool_t audiostream_encrypted;
bool_t auth_token_verified;
};
@ -206,6 +210,8 @@ int linphone_proxy_config_normalize_number(LinphoneProxyConfig *cfg, const char
void linphone_core_text_received(LinphoneCore *lc, const char *from, const char *msg);
void linphone_core_play_tone(LinphoneCore *lc);
void linphone_call_init_media_streams(LinphoneCall *call);
void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_muted, bool_t send_ringbacktone);
void linphone_call_stop_media_streams(LinphoneCall *call);
@ -388,6 +394,13 @@ typedef struct autoreplier_config
const char *message; /* the path of the file to be played */
}autoreplier_config_t;
struct _LinphoneConference{
MSAudioConference *conf;
AudioStream *local_participant;
MSAudioEndpoint *local_endpoint;
};
typedef struct _LinphoneConference LinphoneConference;
struct _LinphoneCore
{
@ -439,6 +452,8 @@ struct _LinphoneCore
time_t netup_time; /*time when network went reachable */
struct _EcCalibrator *ecc;
MSList *hooks;
LinphoneConference conf_ctx;
char* zrtp_secrets_cache;
bool_t use_files;
bool_t apply_nat_settings;
bool_t initial_subscribes_sent;
@ -449,7 +464,6 @@ struct _LinphoneCore
bool_t use_preview_window;
int device_rotation;
bool_t ringstream_autorelease;
char* zrtp_secrets_cache;
};
bool_t linphone_core_can_we_add_call(LinphoneCore *lc);
@ -494,6 +508,11 @@ void ec_calibrator_destroy(EcCalibrator *ecc);
void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapsed);
/*conferencing subsystem*/
void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t muted);
void linphone_call_add_to_conf(LinphoneCall *call);
void linphone_call_remove_from_conf(LinphoneCall *call);
#define HOLD_OFF (0)
#define HOLD_ON (1)

View file

@ -49,7 +49,7 @@ linphone_SOURCES= \
linphone_LDADD=$(ORTP_LIBS) \
$(MEDIASTREAMER_LIBS) \
$(top_builddir)/coreapi/liblinphone.la \
$(LIBGTK_LIBS) $(LIBGTKMAC_LIBS) $(INTLLIBS)
$(LIBGTK_LIBS) $(NOTIFY_LIBS) $(LIBGTKMAC_LIBS) $(INTLLIBS)
if BUILD_WIN32

View file

@ -36,6 +36,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define chdir _chdir
#endif
#ifdef HAVE_NOTIFY
#include <libnotify/notify.h>
#endif
#define LINPHONE_ICON "linphone.png"
const char *this_program_ident_string="linphone_ident_string=" LINPHONE_VERSION;
@ -56,6 +60,7 @@ static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl)
static void linphone_gtk_refer_received(LinphoneCore *lc, const char *refer_to);
static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cs, const char *msg);
static gboolean linphone_gtk_auto_answer(LinphoneCall *call);
static void linphone_gtk_status_icon_set_blinking(gboolean val);
static gboolean verbose=0;
@ -622,6 +627,24 @@ static void completion_add_text(GtkEntry *entry, const char *text){
save_uri_history();
}
static void linphone_gtk_show_main_window(){
GtkWidget *w=linphone_gtk_get_main_window();
LinphoneCore *lc=linphone_gtk_get_core();
if (linphone_core_video_enabled(lc)){
linphone_core_enable_video_preview(lc,linphone_gtk_get_ui_config_int("videoselfview",
VIDEOSELFVIEW_DEFAULT));
}
gtk_widget_show(w);
gtk_window_present(GTK_WINDOW(w));
}
static void linphone_gtk_show(LinphoneCore *lc){
#ifndef HAVE_NOTIFY
linphone_gtk_show_main_window();
#endif
}
void linphone_gtk_call_terminated(LinphoneCall *call, const char *error){
GtkWidget *mw=linphone_gtk_get_main_window();
if (linphone_core_get_calls(linphone_gtk_get_core())==NULL){
@ -749,6 +772,7 @@ void linphone_gtk_answer_clicked(GtkWidget *button){
if (call){
linphone_core_pause_all_calls(linphone_gtk_get_core());
linphone_core_accept_call(linphone_gtk_get_core(),call);
linphone_gtk_show_main_window(); /* useful when the button is clicked on a notification */
}
}
@ -759,7 +783,7 @@ void linphone_gtk_enable_video(GtkWidget *w){
gtk_widget_set_sensitive(selfview_item,val);
if (val){
linphone_core_enable_video_preview(linphone_gtk_get_core(),
linphone_gtk_get_ui_config_int("videoselfview",VIDEOSELFVIEW_DEFAULT));
linphone_gtk_get_ui_config_int("videoselfview",VIDEOSELFVIEW_DEFAULT));
}else{
linphone_core_enable_video_preview(linphone_gtk_get_core(),FALSE);
}
@ -783,21 +807,6 @@ void linphone_gtk_used_identity_changed(GtkWidget *w){
if (sel) g_free(sel);
}
static void linphone_gtk_show_main_window(){
GtkWidget *w=linphone_gtk_get_main_window();
LinphoneCore *lc=linphone_gtk_get_core();
if (linphone_core_video_enabled(lc)){
linphone_core_enable_video_preview(lc,linphone_gtk_get_ui_config_int("videoselfview",
VIDEOSELFVIEW_DEFAULT));
}
gtk_widget_show(w);
gtk_window_present(GTK_WINDOW(w));
}
static void linphone_gtk_show(LinphoneCore *lc){
linphone_gtk_show_main_window();
}
static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid){
linphone_gtk_show_friends();
}
@ -938,6 +947,54 @@ static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl)
if (w) linphone_gtk_call_log_update(w);
}
#ifdef HAVE_NOTIFY
static void make_notification(const char *title, const char *body){
NotifyNotification *n;
n = notify_notification_new(title,body,linphone_gtk_get_ui_config("icon",LINPHONE_ICON));
if (n && !notify_notification_show(n,NULL))
ms_error("Failed to send notification.");
}
#endif
static void linphone_gtk_notify(LinphoneCall *call, const char *msg){
#ifdef HAVE_NOTIFY
if (!notify_is_initted())
if (!notify_init ("Linphone")) ms_error("Libnotify failed to init.");
#endif
if (!call) {
#ifdef HAVE_NOTIFY
if (!notify_notification_show(notify_notification_new("Linphone",msg,NULL),NULL))
ms_error("Failed to send notification.");
#else
linphone_gtk_show_main_window();
#endif
} else if (!gtk_window_is_active((GtkWindow*)linphone_gtk_get_main_window())) {
#ifdef HAVE_NOTIFY
char *body=NULL;
char *remote=call!=NULL ? linphone_call_get_remote_address_as_string(call) : NULL;
switch(linphone_call_get_state(call)){
case LinphoneCallError:
make_notification(_("Call error"),body=g_markup_printf_escaped("<span size=\"large\">%s</span>\n%s",msg,remote));
break;
case LinphoneCallEnd:
make_notification(_("Call ended"),body=g_markup_printf_escaped("<span size=\"large\">%s</span>",remote));
break;
case LinphoneCallIncomingReceived:
make_notification(_("Incoming call"),body=g_markup_printf_escaped("<span size=\"large\">%s</span>",remote));
break;
case LinphoneCallPausedByRemote:
make_notification(_("Call paused"),body=g_markup_printf_escaped("<span size=\"large\">by %s</span>",remote));
break;
default:
break;
}
if (body) g_free(body);
if (remote) g_free(remote);
#endif
}
}
static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cs, const char *msg){
switch(cs){
case LinphoneCallOutgoingInit:
@ -954,10 +1011,12 @@ static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call
break;
case LinphoneCallEnd:
linphone_gtk_in_call_view_terminate(call,NULL);
linphone_gtk_status_icon_set_blinking(FALSE);
break;
case LinphoneCallIncomingReceived:
linphone_gtk_create_in_call_view (call);
linphone_gtk_in_call_view_set_incoming(call,!all_other_calls_paused (call,linphone_core_get_calls(lc)));
linphone_gtk_status_icon_set_blinking(TRUE);
if (auto_answer) {
linphone_call_ref(call);
g_timeout_add(2000,(GSourceFunc)linphone_gtk_auto_answer ,call);
@ -974,10 +1033,12 @@ static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call
break;
case LinphoneCallConnected:
linphone_gtk_enable_hold_button (call,TRUE,TRUE);
linphone_gtk_status_icon_set_blinking(FALSE);
break;
default:
break;
}
linphone_gtk_notify(call, msg);
linphone_gtk_update_call_buttons (call);
}
@ -1101,18 +1162,49 @@ static GtkStatusIcon *icon=NULL;
static void linphone_gtk_init_status_icon(){
const char *icon_path=linphone_gtk_get_ui_config("icon",LINPHONE_ICON);
const char *call_icon_path=linphone_gtk_get_ui_config("start_call_icon","startcall-green.png");
GdkPixbuf *pbuf=create_pixbuf(icon_path);
GtkWidget *menu=create_icon_menu();
const char *title;
title=linphone_gtk_get_ui_config("title",_("Linphone - a video internet phone"));
icon=gtk_status_icon_new_from_pixbuf(pbuf);
g_object_unref(G_OBJECT(pbuf));
gtk_status_icon_set_name(icon,title);
g_signal_connect_swapped(G_OBJECT(icon),"activate",(GCallback)linphone_gtk_show_main_window,linphone_gtk_get_main_window());
g_signal_connect(G_OBJECT(icon),"popup-menu",(GCallback)icon_popup_menu,NULL);
title=linphone_gtk_get_ui_config("title",_("Linphone - a video internet phone"));
gtk_status_icon_set_tooltip(icon,title);
gtk_status_icon_set_visible(icon,TRUE);
g_object_set_data(G_OBJECT(icon),"menu",menu);
g_object_weak_ref(G_OBJECT(icon),(GWeakNotify)gtk_widget_destroy,menu);
g_object_set_data(G_OBJECT(icon),"icon",pbuf);
g_object_weak_ref(G_OBJECT(icon),(GWeakNotify)g_object_unref,pbuf);
pbuf=create_pixbuf(call_icon_path);
g_object_set_data(G_OBJECT(icon),"call_icon",pbuf);
}
static gboolean do_icon_blink(GtkStatusIcon *gi){
GdkPixbuf *call_icon=g_object_get_data(G_OBJECT(gi),"call_icon");
GdkPixbuf *normal_icon=g_object_get_data(G_OBJECT(gi),"icon");
GdkPixbuf *cur_icon=gtk_status_icon_get_pixbuf(gi);
if (cur_icon==call_icon){
gtk_status_icon_set_from_pixbuf(gi,normal_icon);
}else{
gtk_status_icon_set_from_pixbuf(gi,call_icon);
}
return TRUE;
}
static void linphone_gtk_status_icon_set_blinking(gboolean val){
guint tout;
tout=(unsigned)GPOINTER_TO_INT(g_object_get_data(G_OBJECT(icon),"timeout"));
if (val && tout==0){
tout=g_timeout_add(500,(GSourceFunc)do_icon_blink,icon);
g_object_set_data(G_OBJECT(icon),"timeout",GINT_TO_POINTER(tout));
}else if (!val && tout!=0){
GdkPixbuf *normal_icon=g_object_get_data(G_OBJECT(icon),"icon");
g_source_remove(tout);
g_object_set_data(G_OBJECT(icon),"timeout",NULL);
gtk_status_icon_set_from_pixbuf(icon,normal_icon);
}
}
static void init_identity_combo(GtkComboBox *box){
@ -1411,9 +1503,11 @@ void linphone_gtk_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
static void linphone_gtk_refer_received(LinphoneCore *lc, const char *refer_to){
GtkEntry * uri_bar =GTK_ENTRY(linphone_gtk_get_widget(
GtkEntry * uri_bar =GTK_ENTRY(linphone_gtk_get_widget(
linphone_gtk_get_main_window(), "uribar"));
linphone_gtk_show_main_window();
char *text;
linphone_gtk_notify(NULL,(text=ms_strdup_printf(_("We are transferred to %s"),refer_to)));
g_free(text);
gtk_entry_set_text(uri_bar, refer_to);
linphone_gtk_start_call(linphone_gtk_get_main_window());
}
@ -1422,16 +1516,19 @@ static void linphone_gtk_check_soundcards(){
const char **devices=linphone_core_get_sound_devices(linphone_gtk_get_core());
if (devices==NULL || devices[0]==NULL){
linphone_gtk_display_something(GTK_MESSAGE_WARNING,
_("No sound cards have been detected on this computer.\n"
"You won't be able to send or receive audio calls."));
_("No sound cards have been detected on this computer.\n"
"You won't be able to send or receive audio calls."));
}
}
static void linphone_gtk_quit(void){
gdk_threads_leave();
linphone_gtk_destroy_log_window();
linphone_core_destroy(the_core);
linphone_gtk_log_uninit();
linphone_gtk_destroy_log_window();
linphone_core_destroy(the_core);
linphone_gtk_log_uninit();
#ifdef HAVE_NOTIFY
notify_uninit();
#endif
}
#ifdef HAVE_GTK_OSX

View file

@ -2,6 +2,66 @@
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="dummy_conf_window">
<property name="can_focus">False</property>
<child>
<object class="GtkFrame" id="callee_frame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="conf_alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkHBox" id="conf_hbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkProgressBar" id="sound_indicator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="hangup_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="linphone_gtk_conf_hangup_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="callee_name_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Callee name&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="dummy_in_call_window">
<property name="can_focus">False</property>
<child>
@ -90,7 +150,6 @@
<object class="GtkHButtonBox" id="mute_pause_buttons">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">spread</property>
<child>
<object class="GtkButton" id="incall_mute">
<property name="label" translatable="yes">Mute</property>
@ -106,6 +165,20 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="incall_merge">
<property name="label" translatable="yes">Merge to conference</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="linphone_gtk_merge_to_conference" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="hold_call">
<property name="label" translatable="yes">Pause</property>
@ -118,7 +191,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>

View file

@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
import java.util.Vector;
/**
* Object representing a Call. calls are created using {@link LinphoneCore#invite(LinphoneAddress)} or passed to the application by listener {@link LinphoneCoreListener#callState(LinphoneCore, LinphoneCall, State, String)}
@ -29,97 +30,113 @@ public interface LinphoneCall {
* Linphone call states
*
*/
enum State {
static class State {
@SuppressWarnings("unchecked")
static private Vector values = new Vector();
private final int mValue;
public final int value() {return mValue;}
public static final int ID_INCOMING_RECEIVED=1;
public static final int ID_OUTGOING_RINGING=4;
public static final int ID_STREAMS_RUNNING=7;
public static final int ID_PAUSED=9;
public static final int ID_CALL_END=13;
public static final int ID_PAUSED_BY_REMOTE=14;
private final String mStringValue;
/**
* Idle
*/
Idle(0, "Idle"),
public final static State Idle = new State(0,"Idle");
/**
* Incoming call received.
*/
IncomingReceived(1, "IncomingReceived"),
public final static State IncomingReceived = new State(ID_INCOMING_RECEIVED,"IncomingReceived");
/**
* Outgoing call initialized.
* Outgoing call initialiazed.
*/
OutgoingInit(2, "OutgoingInit"),
public final static State OutgoingInit = new State(2,"OutgoingInit");
/**
* Outgoing call in progress.
*/
OutgoingProgress(3, "OutgoingProgress"),
public final static State OutgoingProgress = new State(3,"OutgoingProgress");
/**
* Outgoing call ringing.
*/
OutgoingRinging(4, "OutgoingRinging"),
public final static State OutgoingRinging = new State(ID_OUTGOING_RINGING,"OutgoingRinging");
/**
* Outgoing call early media
*/
OutgoingEarlyMedia(5, "OutgoingEarlyMedia"),
public final static State OutgoingEarlyMedia = new State(5,"OutgoingEarlyMedia");
/**
* Connected
*/
Connected(6, "Connected"),
public final static State Connected = new State(6,"Connected");
/**
* Streams running
*/
StreamsRunning(7, "StreamsRunning"),
public final static State StreamsRunning = new State(ID_STREAMS_RUNNING,"StreamsRunning");
/**
* Pausing
*/
Pausing(8, "Pausing"),
public final static State Pausing = new State(8,"Pausing");
/**
* Paused
*/
Paused(9, "Paused"),
public final static State Paused = new State(ID_PAUSED,"Paused");
/**
* Resuming
*/
Resuming(10, "Resuming"),
public final static State Resuming = new State(10,"Resuming");
/**
* Refered
*/
Refered(11,"Refered"),
public final static State Refered = new State(11,"Refered");
/**
* Error
*/
Error(12,"Error"),
public final static State Error = new State(12,"Error");
/**
* Call end
*/
CallEnd(13,"CallEnd"),
public final static State CallEnd = new State(ID_CALL_END,"CallEnd");
/**
* Paused by remote
*/
PausedByRemote(14,"PausedByRemote"),
public final static State PausedByRemote = new State(ID_PAUSED_BY_REMOTE,"PausedByRemote");
/**
* The call's parameters are updated, used for example when video is asked by remote
*/
CallUpdatedByRemote(15, "CallUpdatedByRemote"),
public static final State CallUpdatedByRemote = new State(15, "CallUpdatedByRemote");
/**
* We are proposing early media to an incoming call
*/
CallIncomingEarlyMedia(16,"CallIncomingEarlyMedia"),
public static final State CallIncomingEarlyMedia = new State(16,"CallIncomingEarlyMedia");
/**
* The remote accepted the call update initiated by us
*/
CallUpdated(17, "CallUpdated"),
public static final State CallUpdated = new State(17, "CallUpdated");
/**
* The call object is now released.
*/
CallReleased(18,"CallReleased");
public static final State CallReleased = new State(18,"CallReleased");
private final int mValue;
private final String mStringValue;
private State(int v, String desc) {
this.mValue = v;
this.mStringValue = desc;
@SuppressWarnings("unchecked")
private State(int value,String stringValue) {
mValue = value;
values.addElement(this);
mStringValue=stringValue;
}
public static State fromInt(int value) {
State[] allStates = State.values();
for (int i=0; i<allStates.length;i++) {
if (allStates[i].mValue == value)
return allStates[i];
for (int i=0; i<values.size();i++) {
State state = (State) values.elementAt(i);
if (state.mValue == value) return state;
}
throw new RuntimeException("state not found ["+value+"]");
}
@ -213,4 +230,5 @@ public interface LinphoneCall {
String getAuthenticationToken();
boolean isAuthenticationTokenVerified();
boolean areStreamsEncrypted();
boolean isInConference();
}

View file

@ -599,6 +599,20 @@ public interface LinphoneCore {
boolean pauseAllCalls();
void setZrtpSecretsCache(String file);
public void enableEchoLimiter(boolean val);
void enableEchoLimiter(boolean val);
boolean isInConference();
void enterConference();
void leaveConference();
void addToConference(LinphoneCall call);
void addAllToConference();
void removeFromConference(LinphoneCall call);
void terminateConference();
int getConferenceSize();
void terminateAllCalls();
@SuppressWarnings("unchecked") List getCalls();
int getCallsNb();
}