Liblinphone  3.12.0
Basic call

This program is a very simple usage example of liblinphone. It just takes a sip-uri as first argument and attempts to call it

/*
linphone
Copyright (C) 2010 Belledonne Communications SARL
(simon.morlat@linphone.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "linphone/core.h"
#include <signal.h>
static bool_t running=TRUE;
static void stop(int signum){
running=FALSE;
}
/*
* Call state notification callback
*/
static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){
switch(cstate){
printf("It is now ringing remotely !\n");
break;
printf("Receiving some early media\n");
break;
printf("We are connected !\n");
break;
printf("Media streams established !\n");
break;
printf("Call is terminated.\n");
break;
printf("Call failure !");
break;
default:
printf("Unhandled notification %i\n",cstate);
}
}
int main(int argc, char *argv[]){
LinphoneCoreVTable vtable={0};
LinphoneCall *call=NULL;
const char *dest=NULL;
/* take the destination sip uri from the command line arguments */
if (argc>1){
dest=argv[1];
}
signal(SIGINT,stop);
#ifdef DEBUG
linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/
#endif
/*
Fill the LinphoneCoreVTable with application callbacks.
All are optional. Here we only use the call_state_changed callbacks
in order to get notifications about the progress of the call.
*/
vtable.call_state_changed=call_state_changed;
/*
Instanciate a LinphoneCore object given the LinphoneCoreVTable
*/
lc=linphone_core_new(&vtable,NULL,NULL,NULL);
if (dest){
/*
Place an outgoing call
*/
call=linphone_core_invite(lc,dest);
if (call==NULL){
printf("Could not place call to %s\n",dest);
goto end;
}else printf("Call to %s is in progress...",dest);
}
/* main loop for receiving notifications and doing background linphonecore work: */
while(running){
ms_usleep(50000);
}
/* terminate the call */
printf("Terminating the call...\n");
/*at this stage we don't need the call object */
}
end:
printf("Shutting down...\n");
printf("Exited\n");
return 0;
}
LinphoneCallOutgoingEarlyMedia
An outgoing call is proposed early media.
Definition: types.h:308
LinphoneCallError
The call encountered an error.
Definition: types.h:315
LinphoneCore
struct _LinphoneCore LinphoneCore
Linphone core main object created by function linphone_core_new() .
Definition: types.h:472
linphone_call_ref
LinphoneCall * linphone_call_ref(LinphoneCall *call)
Acquire a reference to the call.
linphone_core_enable_logs
LINPHONE_DEPRECATED void linphone_core_enable_logs(FILE *file)
Enable logs in supplied FILE*.
LinphoneCallEnd
The call ended normally.
Definition: types.h:316
LinphoneCallState
enum _LinphoneCallState LinphoneCallState
LinphoneCallState enum represents the different state a call can reach into.
linphone_core_iterate
void linphone_core_iterate(LinphoneCore *lc)
Main loop function.
_LinphoneCoreVTable::call_state_changed
LinphoneCoreCallStateChangedCb call_state_changed
Notifies call state changes.
Definition: core.h:183
LinphoneCallOutgoingRinging
An outgoing call is ringing at remote end.
Definition: types.h:307
linphone_core_new
LINPHONE_DEPRECATED LinphoneCore * linphone_core_new(const LinphoneCoreVTable *vtable, const char *config_path, const char *factory_config_path, void *userdata)
Instanciates a LinphoneCore object.
LinphoneCall
struct _LinphoneCall LinphoneCall
The LinphoneCall object represents a call issued or received by the LinphoneCore.
Definition: types.h:262
linphone_core_invite
LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url)
Initiates an outgoing call The application doesn't own a reference to the returned LinphoneCall objec...
LinphoneCallStreamsRunning
The media streams are established and running.
Definition: types.h:310
linphone_call_get_state
LinphoneCallState linphone_call_get_state(const LinphoneCall *call)
Retrieves the call's current state.
linphone_call_unref
void linphone_call_unref(LinphoneCall *call)
Release reference to the call.
linphone_core_terminate_call
LINPHONE_DEPRECATED LinphoneStatus linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call)
Terminates a call.
_LinphoneCoreVTable
This structure holds all callbacks that the application should implement.
Definition: core.h:180
LinphoneCallConnected
Connected, the call is answered.
Definition: types.h:309
linphone_core_destroy
LINPHONE_DEPRECATED void linphone_core_destroy(LinphoneCore *lc)
Destroys a LinphoneCore.