mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
work in progress, new layout
This commit is contained in:
parent
a371ab7df3
commit
df89bafa70
6 changed files with 101 additions and 47 deletions
|
|
@ -17,7 +17,8 @@ liblinphone_la_SOURCES=\
|
|||
linphonecore.c linphonecore.h private.h\
|
||||
exevents.c exevents.h \
|
||||
offeranswer.c offeranswer.h\
|
||||
sal_eXosip2.c sal.h \
|
||||
sal.c sal.h \
|
||||
sal_eXosip2.c \
|
||||
sal_eXosip2_sdp.c \
|
||||
misc.c \
|
||||
address.c \
|
||||
|
|
@ -29,7 +30,7 @@ liblinphone_la_SOURCES=\
|
|||
authentication.c \
|
||||
lpconfig.c lpconfig.h \
|
||||
chat.c \
|
||||
general_state.c \
|
||||
general_state.c \
|
||||
sipsetup.c sipsetup.h \
|
||||
siplogin.c
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ struct SalOp;
|
|||
|
||||
typedef struct SalOp SalOp;
|
||||
|
||||
|
||||
Sal * sal_init();
|
||||
void sal_uninit(Sal* sal);
|
||||
|
||||
|
|
@ -75,7 +76,20 @@ typedef struct SalMediaDescription{
|
|||
SalStreamDescription streams[SAL_MEDIA_DESCRIPTION_MAX_STREAMS];
|
||||
} SalMediaDescription;
|
||||
|
||||
void sal_media_description_free(SalMediaDescription *md);
|
||||
SalMediaDescription *sal_media_description_new();
|
||||
void sal_media_description_destroy(SalMediaDescription *md);
|
||||
|
||||
/*this structure must be at the first byte of the SalOp structure defined by implementors*/
|
||||
typedef struct SalOpBase{
|
||||
Sal *root;
|
||||
char *route;
|
||||
char *contact;
|
||||
char *from;
|
||||
char *to;
|
||||
SalMediaDescription *local_media;
|
||||
SalMediaDescription *remote_media;
|
||||
} SalOpBase;
|
||||
|
||||
|
||||
typedef enum SalError{
|
||||
SalErrorNetwork,
|
||||
|
|
@ -90,25 +104,47 @@ typedef void (*SalOnCallAccepted)(SalOp *op);
|
|||
typedef void (*SalOnCallTerminated)(SalOp *op);
|
||||
typedef void (*SalOnCallFailure)(SalOp *op, SalError error, const char *details);
|
||||
|
||||
typedef struct SalCallbacks{
|
||||
SalOnCallReceived call_received;
|
||||
SalOnCallRinging call_ringing;
|
||||
SalOnCallAccepted call_accepted;
|
||||
SalOnCallTerminated call_terminated;
|
||||
SalOnCallFailure call_failure;
|
||||
}SalCallbacks;
|
||||
|
||||
void sal_set_callbacks(Sal *ctx, const SalCallbacks *cbs);
|
||||
int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int is_secure);
|
||||
void sal_set_user_agent(Sal *ctx, const char *user_agent);
|
||||
void sal_use_session_timers(Sal *ctx, int expires);
|
||||
|
||||
SalOp * sal_call_create(Sal *sal, const char *from, const char *to, const char *route, const char *contact);
|
||||
int sal_call_set_local_media_description(SalOp *h, const SalMediaDescription *desc);
|
||||
int sal_call(SalOp *h);
|
||||
int sal_call_accept(SalOp*h);
|
||||
int sal_call_get_final_media_description(SalOp *h, SalMediaDescription *result);
|
||||
int sal_call_terminate(SalOp *h);
|
||||
|
||||
int sal_iterate(Sal *sal);
|
||||
|
||||
SalOp *sal_register_create(Sal *ctx, const char *from, const char *contact, int expires);
|
||||
int sal_register(SalOp *h);
|
||||
/*create an operation */
|
||||
SalOp * sal_op_new(Sal *sal);
|
||||
|
||||
/*generic SalOp API, working for all operations */
|
||||
void sal_op_set_contact(SalOp *op, const char *contact);
|
||||
void sal_op_set_route(SalOp *op, const char *route);
|
||||
void sal_op_set_from(SalOp *op, const char *from);
|
||||
void sal_op_set_to(SalOp *op, const char *to);
|
||||
void sal_op_release(SalOp *h);
|
||||
|
||||
/*Call API*/
|
||||
int sal_call_set_local_media_description(SalOp *h, SalMediaDescription *desc);
|
||||
int sal_call(SalOp *h, const char *from, const char *to);
|
||||
int sal_call_accept(SalOp*h);
|
||||
const SalMediaDescription * sal_call_get_final_media_description(SalOp *h);
|
||||
int sal_call_terminate(SalOp *h);
|
||||
|
||||
int sal_register(SalOp *op, const char *from, const char *contact, int expires);
|
||||
|
||||
|
||||
#define payload_type_set_number(pt,n) (pt)->user_data=(void*)((long)n);
|
||||
#define payload_type_get_number(pt) ((int)(long)(pt)->user_data)
|
||||
|
||||
|
||||
/*internal API */
|
||||
void __sal_op_init(SalOp *b, Sal *sal);
|
||||
void __sal_op_free(SalOp *b);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -23,26 +23,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
extern char *media_description_to_sdp(const SalMediaDescription *sal);
|
||||
|
||||
struct Sal{
|
||||
SalCallbacks callbacks;
|
||||
int running;
|
||||
int session_expires;
|
||||
};
|
||||
|
||||
struct SalOp{
|
||||
SalOpBase base;
|
||||
int cid;
|
||||
int did;
|
||||
int tid;
|
||||
osip_message_t *request;
|
||||
bool_t supports_session_timers;
|
||||
};
|
||||
|
||||
static SalOp * sal_op_new(){
|
||||
SalOp * sal_op_new(Sal *sal){
|
||||
SalOp *op=ms_new(SalOp,1);
|
||||
__sal_op_init(op,sal);
|
||||
op->cid=op->did=op->tid=-1;
|
||||
op->request=NULL;
|
||||
op->supports_session_timers=FALSE;
|
||||
return op;
|
||||
}
|
||||
|
||||
void sal_op_release(SalOp *op){
|
||||
ms_free(op);
|
||||
__sal_op_free(op);
|
||||
}
|
||||
|
||||
Sal * sal_init(){
|
||||
|
|
@ -87,27 +90,6 @@ void sal_use_session_timers(Sal *ctx, int expires){
|
|||
ctx->session_expires=expires;
|
||||
}
|
||||
|
||||
SalOp * sal_call_create(Sal *sal, const char *from, const char *to, const char *route, const char *contact){
|
||||
int err;
|
||||
SalOp *op;
|
||||
osip_message_t *invite=NULL;
|
||||
err=eXosip_call_build_initial_invite(&invite,to,from,
|
||||
route,"Phone call");
|
||||
if (err!=0){
|
||||
ms_error("Could not create call.");
|
||||
return NULL;
|
||||
}
|
||||
if (contact)
|
||||
osip_message_set_contact(invite,contact);
|
||||
if (sal->session_expires!=0){
|
||||
osip_message_set_header(invite, "Session-expires", "200");
|
||||
osip_message_set_supported(invite, "timer");
|
||||
}
|
||||
op=sal_op_new();
|
||||
op->request=invite;
|
||||
return op;
|
||||
}
|
||||
|
||||
static void set_sdp(osip_message_t *sip, const SalMediaDescription *desc){
|
||||
int sdplen;
|
||||
char clen[10];
|
||||
|
|
@ -125,15 +107,30 @@ static void set_sdp(osip_message_t *sip, const SalMediaDescription *desc){
|
|||
osip_free(sdp);
|
||||
}
|
||||
|
||||
int sal_call_set_local_media_description(SalOp *h, const SalMediaDescription *desc){
|
||||
set_sdp(h->request,desc);
|
||||
int sal_call_set_local_media_description(SalOp *h, SalMediaDescription *desc){
|
||||
h->base.local_media=desc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sal_call(SalOp *h){
|
||||
int sal_call(SalOp *h, const char *from, const char *to){
|
||||
int err;
|
||||
osip_message_t *invite=NULL;
|
||||
sal_op_set_from(h,from);
|
||||
sal_op_set_to(h,to);
|
||||
err=eXosip_call_build_initial_invite(&invite,to,from,h->base.route,"Phone call");
|
||||
if (err!=0){
|
||||
ms_error("Could not create call.");
|
||||
return -1;
|
||||
}
|
||||
if (h->base.contact)
|
||||
osip_message_set_contact(invite,h->base.contact);
|
||||
if (h->base.root->session_expires!=0){
|
||||
osip_message_set_header(invite, "Session-expires", "200");
|
||||
osip_message_set_supported(invite, "timer");
|
||||
}
|
||||
if (h->base.local_media) set_sdp(invite,h->base.local_media);
|
||||
eXosip_lock();
|
||||
err=eXosip_call_send_initial_invite(h->request);
|
||||
err=eXosip_call_send_initial_invite(invite);
|
||||
eXosip_unlock();
|
||||
h->cid=err;
|
||||
if (err<0){
|
||||
|
|
@ -143,11 +140,31 @@ int sal_call(SalOp *h){
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sal_call_accept(SalOp*h);
|
||||
int sal_call_get_final_media_description(SalOp *h, SalMediaDescription *result);
|
||||
int sal_call_terminate(SalOp *h);
|
||||
int sal_call_accept(SalOp * h){
|
||||
osip_message_t *msg;
|
||||
/* sends a 200 OK */
|
||||
int err=eXosip_call_build_answer(h->tid,200,&msg);
|
||||
if (err<0 || msg==NULL){
|
||||
ms_error("Fail to build answer for call: err=%i",err);
|
||||
return -1;
|
||||
}
|
||||
if (h->base.root->session_expires!=0){
|
||||
if (h->supports_session_timers) osip_message_set_supported(msg, "timer");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const SalMediaDescription * sal_call_get_final_media_description(SalOp *h){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int sal_call_terminate(SalOp *h){
|
||||
eXosip_lock();
|
||||
eXosip_call_terminate(h->cid,h->did);
|
||||
eXosip_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sal_iterate(Sal *sal);
|
||||
|
||||
SalOp *sal_register_create(Sal *ctx, const char *from, const char *contact, int expires);
|
||||
int sal_register(SalOp *h);
|
||||
int sal_register(SalOp *h, const char *from, const char *contact, int expires);
|
||||
Loading…
Add table
Reference in a new issue