From f2c5aab9eebe6eea17116e55943d34913d5ccb92 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 8 Sep 2010 15:46:52 +0200 Subject: [PATCH] remove unused files --- coreapi/exevents.h | 40 --- coreapi/general_state.c | 118 ------- coreapi/sdphandler.c | 694 ---------------------------------------- coreapi/sdphandler.h | 101 ------ 4 files changed, 953 deletions(-) delete mode 100644 coreapi/exevents.h delete mode 100644 coreapi/general_state.c delete mode 100644 coreapi/sdphandler.c delete mode 100644 coreapi/sdphandler.h diff --git a/coreapi/exevents.h b/coreapi/exevents.h deleted file mode 100644 index c7e7baa9b..000000000 --- a/coreapi/exevents.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -linphone -Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr) - -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. -*/ - -#ifndef EXEVENTS_H -#define EXEVENTS_H -#include -#include "sdphandler.h" - - -void linphone_core_process_event(LinphoneCore *lc, eXosip_event_t *ev); - -/* these are the SdpHandler callbacks: we are called in to be aware of the content -of the SDP messages exchanged */ - -int linphone_set_audio_offer(sdp_context_t *ctx); -int linphone_set_video_offer(sdp_context_t *ctx); -int linphone_accept_audio_offer(sdp_context_t *ctx,sdp_payload_t *payload); -int linphone_accept_video_offer(sdp_context_t *ctx,sdp_payload_t *payload); -int linphone_read_audio_answer(sdp_context_t *ctx,sdp_payload_t *payload); -int linphone_read_video_answer(sdp_context_t *ctx,sdp_payload_t *payload); - -void linphone_core_text_received(LinphoneCore *lc, eXosip_event_t *ev); - -#endif diff --git a/coreapi/general_state.c b/coreapi/general_state.c deleted file mode 100644 index dc9e3e642..000000000 --- a/coreapi/general_state.c +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * - * File: general_state.c - * - * Copyright (C) 2006, 2007 Thomas Reitmayr - * - **************************************************************************** - * - * 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 Library 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 "linphonecore.h" -#include "private.h" -#if 0 -static const char *_gstates_text[] = { - "GSTATE_POWER_OFF", /* 0 */ - "GSTATE_POWER_STARTUP", /* 1 */ - "GSTATE_POWER_ON", /* 2 */ - "GSTATE_POWER_SHUTDOWN", /* 3 */ - NULL, NULL, NULL, NULL, NULL, NULL, - - "GSTATE_REG_NONE", /* 10 */ - "GSTATE_REG_OK", /* 11 */ - "GSTATE_REG_FAILED", /* 12 */ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, - - "GSTATE_CALL_IDLE", /* 20 */ - "GSTATE_CALL_OUT_INVITE", /* 21 */ - "GSTATE_CALL_OUT_CONNECTED", /* 22 */ - "GSTATE_CALL_IN_INVITE", /* 23 */ - "GSTATE_CALL_IN_CONNECTED", /* 24 */ - "GSTATE_CALL_END", /* 25 */ - "GSTATE_CALL_ERROR" /* 26 */ -}; -#endif - -/* set the initial states */ -void gstate_initialize(LinphoneCore *lc) { - lc->gstate_power = GSTATE_POWER_OFF; - lc->gstate_reg = GSTATE_REG_NONE; - lc->gstate_call = GSTATE_CALL_IDLE; -} - -gstate_t linphone_core_get_state(const LinphoneCore *lc, gstate_group_t group){ - switch(group){ - case GSTATE_GROUP_POWER: - return lc->gstate_power; - case GSTATE_GROUP_REG: - return lc->gstate_reg; - case GSTATE_GROUP_CALL: - return lc->gstate_call; - } - return GSTATE_INVALID; -} - -static void linphone_core_set_state(LinphoneCore *lc, gstate_group_t group, gstate_t new_state){ - switch(group){ - case GSTATE_GROUP_POWER: - lc->gstate_power=new_state; - break; - case GSTATE_GROUP_REG: - lc->gstate_reg=new_state; - break; - case GSTATE_GROUP_CALL: - lc->gstate_call=new_state; - break; - } -} - -void gstate_new_state(struct _LinphoneCore *lc, - gstate_t new_state, - LinphoneGeneralStateContext gctx, - const char *message) { - LinphoneGeneralState states_arg; - - /* determine the affected group */ - if (new_state < GSTATE_REG_NONE) - states_arg.group = GSTATE_GROUP_POWER; - else if (new_state < GSTATE_CALL_IDLE) - states_arg.group = GSTATE_GROUP_REG; - else - states_arg.group = GSTATE_GROUP_CALL; - - /* store the new state while remembering the old one */ - states_arg.new_state = new_state; - states_arg.old_state = linphone_core_get_state(lc,states_arg.group); - linphone_core_set_state(lc, states_arg.group,new_state); - states_arg.message = message; - - /*printf("gstate_new_state: %s\t-> %s\t(%s)\n", - _gstates_text[states_arg.old_state], - _gstates_text[states_arg.new_state], - message);*/ - - /* call the virtual method */ - if (lc->vtable.general_state) - lc->vtable.general_state(lc, &states_arg, gctx); - - /* immediately proceed to idle state */ - if (new_state == GSTATE_CALL_END || - new_state == GSTATE_CALL_ERROR) - gstate_new_state(lc, GSTATE_CALL_IDLE, gctx, NULL); -} - diff --git a/coreapi/sdphandler.c b/coreapi/sdphandler.c deleted file mode 100644 index bf622a92e..000000000 --- a/coreapi/sdphandler.c +++ /dev/null @@ -1,694 +0,0 @@ -/* - * Linphone is sip (RFC3261) compatible internet phone. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "sdphandler.h" -#include -#include -#include -#include "linphonecore.h" -#include "ortp/b64.h" - -#define keywordcmp(key,str) strncmp(key,str,strlen(key)) - - -#define sstrdup_sprintf ms_strdup_printf - -#define eXosip_trace(loglevel,args) do \ -{ \ - char *__strmsg; \ - __strmsg=ms_strdup_printf args ; \ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,(loglevel),NULL,"%s\n",__strmsg)); \ - osip_free (__strmsg); \ -}while (0); - - -static char *make_relay_session_id(const char *username, const char *relay){ - /*ideally this should be a hash of the parameters with a random part*/ - char tmp[128]; - int s1=(int)random(); - int s2=(int)random(); - long long int res=((long long int)s1)<<32 | (long long int) s2; - void *src=&res; - b64_encode(src, sizeof(long long int), tmp, sizeof(tmp)); - return osip_strdup(tmp); -} - -char * int_2char(int a){ - char *p=osip_malloc(16); - snprintf(p,16,"%i",a); - return p; -} - -/* return the value of attr "field" for payload pt at line pos (field=rtpmap,fmtp...)*/ -char *sdp_message_a_attr_value_get_with_pt(sdp_message_t *sdp,int pos,int pt,const char *field) -{ - int i,tmppt=0,scanned=0; - char *tmp; - sdp_attribute_t *attr; - for (i=0;(attr=sdp_message_attribute_get(sdp,pos,i))!=NULL;i++){ - if (keywordcmp(field,attr->a_att_field)==0 && attr->a_att_value!=NULL){ - int nb = sscanf(attr->a_att_value,"%i %n",&tmppt,&scanned); - /* the return value may depend on how %n is interpreted by the libc: see manpage*/ - if (nb == 1 || nb==2 ){ - if (pt==tmppt){ - tmp=attr->a_att_value+scanned; - if (strlen(tmp)>0) - return tmp; - } - }else eXosip_trace(OSIP_WARNING,("sdp has a strange a= line (%s) nb=%i",attr->a_att_value,nb)); - } - } - return NULL; -} - -/* return the value of attr "field" */ -char *sdp_message_a_attr_value_get(sdp_message_t *sdp,int pos,const char *field) -{ - int i; - sdp_attribute_t *attr; - for (i=0;(attr=sdp_message_attribute_get(sdp,pos,i))!=NULL;i++){ - if (keywordcmp(field,attr->a_att_field)==0 && attr->a_att_value!=NULL){ - return attr->a_att_value; - } - } - return NULL; -} - -static int _sdp_message_get_a_ptime(sdp_message_t *sdp, int mline){ - int i,ret; - sdp_attribute_t *attr; - for (i=0;(attr=sdp_message_attribute_get(sdp,mline,i))!=NULL;i++){ - if (keywordcmp("ptime",attr->a_att_field)==0){ - int nb = sscanf(attr->a_att_value,"%i",&ret); - /* the return value may depend on how %n is interpreted by the libc: see manpage*/ - if (nb == 1){ - return ret; - }else eXosip_trace(OSIP_WARNING,("sdp has a strange a=ptime line (%s) ",attr->a_att_value)); - } - } - return 0; -} - -int -sdp_payload_init (sdp_payload_t * payload) -{ - memset (payload, 0, sizeof (sdp_payload_t)); - return 0; -} - -sdp_context_t *sdp_handler_create_context(sdp_handler_t *handler, const char *localip, const char *username, const char *relay){ - sdp_context_t *ctx=osip_malloc(sizeof(sdp_context_t)); - memset(ctx,0,sizeof(sdp_context_t)); - if (localip!=NULL) ctx->localip=osip_strdup(localip); - ctx->username=osip_strdup(username); - ctx->handler=handler; - if (relay){ - ctx->relay=osip_strdup(relay); - ctx->relay_session_id=make_relay_session_id(username,relay); - } - return ctx; -} - -void sdp_context_set_user_pointer(sdp_context_t * ctx, void* up){ - ctx->reference=up; -} - -void *sdp_context_get_user_pointer(sdp_context_t * ctx){ - return ctx->reference; -} - -int sdp_context_get_status(sdp_context_t* ctx){ - return ctx->negoc_status; -} - -/* generate a template sdp */ -sdp_message_t * -sdp_context_generate_template (sdp_context_t * ctx) -{ - sdp_message_t *local; - int inet6; - - sdp_message_init (&local); - if (strchr(ctx->localip,':')!=NULL){ - inet6=1; - }else inet6=0; - if (!inet6){ - sdp_message_v_version_set (local, osip_strdup ("0")); - sdp_message_o_origin_set (local, osip_strdup (ctx->username), - osip_strdup ("123456"), osip_strdup ("654321"), - osip_strdup ("IN"), osip_strdup ("IP4"), - osip_strdup (ctx->localip)); - sdp_message_s_name_set (local, osip_strdup ("A conversation")); - sdp_message_c_connection_add (local, -1, - osip_strdup ("IN"), osip_strdup ("IP4"), - osip_strdup (ctx->localip), NULL, NULL); - sdp_message_t_time_descr_add (local, osip_strdup ("0"), osip_strdup ("0")); - }else{ - sdp_message_v_version_set (local, osip_strdup ("0")); - sdp_message_o_origin_set (local, osip_strdup (ctx->username), - osip_strdup ("123456"), osip_strdup ("654321"), - osip_strdup ("IN"), osip_strdup ("IP6"), - osip_strdup (ctx->localip)); - sdp_message_s_name_set (local, osip_strdup ("A conversation")); - sdp_message_c_connection_add (local, -1, - osip_strdup ("IN"), osip_strdup ("IP6"), - osip_strdup (ctx->localip), NULL, NULL); - sdp_message_t_time_descr_add (local, osip_strdup ("0"), osip_strdup ("0")); - } - return local; -} - -static void add_relay_info(sdp_message_t *sdp, int mline, const char *relay, const char *relay_session_id){ - - if (relay) sdp_message_a_attribute_add(sdp, mline, - osip_strdup ("relay-addr"),osip_strdup(relay)); - if (relay_session_id) sdp_message_a_attribute_add(sdp, mline, - osip_strdup ("relay-session-id"), osip_strdup(relay_session_id)); -} - -/* to add payloads to the offer, must be called inside the write_offer callback */ -void -sdp_context_add_payload (sdp_context_t * ctx, sdp_payload_t * payload, char *media) -{ - sdp_message_t *offer = ctx->offer; - char *attr_field; - if (!ctx->incb) - { - eXosip_trace (OSIP_ERROR, - ("You must not call sdp_context_add_*_payload outside the write_offer callback\n")); -#if !defined(_WIN32_WCE) - abort(); -#else - exit(-1); -#endif /*_WIN32_WCE*/ - - } - if (payload->proto == NULL) - payload->proto = "RTP/AVP"; - /*printf("payload->line=%i payload->pt=%i\n",payload->line, payload->pt);*/ - if (sdp_message_m_media_get (offer, payload->line) == NULL) - { - /*printf("Adding new mline %s \n",media);*/ - /* need a new line */ - sdp_message_m_media_add (offer, osip_strdup (media), - int_2char (payload->localport), NULL, - osip_strdup (payload->proto)); - if (ctx->relay){ - add_relay_info(offer,payload->line,ctx->relay,ctx->relay_session_id); - } - } - sdp_message_m_payload_add (offer, payload->line, int_2char (payload->pt)); - if (payload->a_rtpmap != NULL) - { - attr_field = - sstrdup_sprintf ("%i %s", payload->pt, - payload->a_rtpmap); - sdp_message_a_attribute_add (offer, payload->line, - osip_strdup ("rtpmap"), attr_field); - } - if (payload->a_fmtp != NULL) - { - attr_field = - sstrdup_sprintf ("%i %s", payload->pt, - payload->a_fmtp); - sdp_message_a_attribute_add (offer, payload->line, osip_strdup ("fmtp"), - attr_field); - } - if (payload->b_as_bandwidth != 0) - { - if (sdp_message_bandwidth_get(offer,payload->line,0)==NULL){ - attr_field = - sstrdup_sprintf ("%i", payload->b_as_bandwidth); - sdp_message_b_bandwidth_add (offer, payload->line, osip_strdup ("AS"), - attr_field); - } - } - if (payload->a_ptime !=0) { - attr_field = sstrdup_sprintf ("%i", payload->a_ptime); - sdp_message_a_attribute_add(offer, payload->line,osip_strdup ("ptime"),attr_field); - ms_message("adding ptime [%s]",attr_field); - } -} - -void -sdp_context_add_audio_payload (sdp_context_t * ctx, sdp_payload_t * payload) -{ - sdp_context_add_payload (ctx, payload, "audio"); -} - -void -sdp_context_add_video_payload (sdp_context_t * ctx, sdp_payload_t * payload) -{ - sdp_context_add_payload (ctx, payload, "video"); -} - -char * -sdp_context_get_offer ( sdp_context_t * ctx) -{ - sdp_message_t *offer; - sdp_handler_t *sdph=ctx->handler; - char *tmp; - - offer = sdp_context_generate_template (ctx); - /* add audio codecs */ - ctx->offer = offer; - ctx->incb = 1; - if (sdph->set_audio_codecs != NULL) - sdph->set_audio_codecs (ctx); - if (sdph->set_video_codecs != NULL) - sdph->set_video_codecs (ctx); - ctx->incb = 0; - sdp_message_to_str(offer,&tmp); - ctx->offerstr=tmp; - return tmp; -} - - -/* refuse the line */ -static void refuse_mline(sdp_message_t *answer,char *mtype,char *proto, int mline) -{ - sdp_message_m_media_add (answer, - osip_strdup (mtype), - int_2char (0), NULL, - osip_strdup (proto)); - /* add a payload just to comply with sdp RFC.*/ - sdp_message_m_payload_add(answer,mline,int_2char(0)); -} - -static char * parse_relay_addr(char *addr, int *port) -{ - char *semicolon=NULL; - char *p; - - *port=56789; - semicolon=strchr(addr,':'); - for (p=addr+strlen(addr)-1;p>addr;p--){ - if (*p==':') { - semicolon=p; - break; - } - } - if (semicolon){ - *port=atoi(semicolon+1); - *semicolon='\0'; - } - return addr; -} - - -char * -sdp_context_get_answer ( sdp_context_t *ctx,sdp_message_t *remote) -{ - sdp_message_t *answer=NULL; - char *mtype=NULL, *tmp=NULL; - char *proto=NULL, *port=NULL, *pt=NULL; - int i, j, ncodec, m_lines_accepted = 0; - int err; - sdp_payload_t payload; - sdp_payload_t init_payload; - sdp_handler_t *sdph=ctx->handler; - sdp_bandwidth_t *sbw=NULL; - char *relay; - - tmp = sdp_message_c_addr_get (remote, 0, 0); - if (tmp == NULL) - tmp = sdp_message_c_addr_get (remote, -1, 0); - if (ctx->localip==NULL) { - /* NULL means guess, otherwise we use the address given as localip */ - ctx->localip=osip_malloc(128); - eXosip_guess_localip(strchr(tmp,':') ? AF_INET6 : AF_INET,ctx->localip,128); - } - else eXosip_trace(OSIP_INFO1,("Using firewall address in sdp.")); - - answer = sdp_context_generate_template (ctx); - - /* for each m= line */ - for (i = 0; !sdp_message_endof_media (remote, i); i++){ - sdp_payload_init(&init_payload); - mtype = sdp_message_m_media_get (remote, i); - proto = sdp_message_m_proto_get (remote, i); - port = sdp_message_m_port_get (remote, i); - init_payload.remoteport = osip_atoi (port); - init_payload.proto = proto; - init_payload.line = i; - init_payload.c_addr = sdp_message_c_addr_get (remote, i, 0); - if (init_payload.c_addr == NULL) - init_payload.c_addr = sdp_message_c_addr_get (remote, -1, 0); - /*parse relay address if given*/ - relay=sdp_message_a_attr_value_get(remote,i,"relay-addr"); - if (relay){ - init_payload.relay_host=parse_relay_addr(relay,&init_payload.relay_port); - } - init_payload.relay_session_id=sdp_message_a_attr_value_get(remote,i,"relay-session-id"); - /* get application specific bandwidth, if any */ - for(j=0;(sbw=sdp_message_bandwidth_get(remote,i,j))!=NULL;j++){ - if (strcasecmp(sbw->b_bwtype,"AS")==0) init_payload.b_as_bandwidth=atoi(sbw->b_bandwidth); - } - init_payload.a_ptime=_sdp_message_get_a_ptime(remote,i); - if (keywordcmp ("audio", mtype) == 0) - { - if (sdph->accept_audio_codecs != NULL) - { - ncodec = 0; - /* for each payload type */ - for (j = 0; - ((pt = - sdp_message_m_payload_get (remote, i, - j)) != NULL); j++) - { - memcpy(&payload,&init_payload,sizeof(payload)); - payload.pt = osip_atoi (pt); - /* get the rtpmap associated to this codec, if any */ - payload.a_rtpmap = - sdp_message_a_attr_value_get_with_pt - (remote, i, payload.pt, - "rtpmap"); - /* get the fmtp, if any */ - payload.a_fmtp = - sdp_message_a_attr_value_get_with_pt - (remote, i, payload.pt, - "fmtp"); - - /* ask the application if this codec is supported */ - err = sdph->accept_audio_codecs (ctx, - &payload); - if (err == 0) - { - ncodec++; - /* codec accepted */ - if (ncodec == 1) - { - /* first codec accepted, setup the line */ - sdp_message_m_media_add - (answer, - osip_strdup - (mtype), - int_2char - (payload. - localport), - NULL, - osip_strdup - (proto)); - /* and accept the remote relay addr if we planned to use our own */ - if (ctx->relay!=NULL && relay){ - add_relay_info(answer,i,relay,payload.relay_session_id); - } - } - /* add the payload, rtpmap, fmtp */ - sdp_message_m_payload_add (answer, i, - int_2char - (payload. - pt)); - if (payload.a_rtpmap != NULL) - { - sdp_message_a_attribute_add - (answer, i, - osip_strdup - ("rtpmap"), - sstrdup_sprintf - ("%i %s", - payload.pt, - payload. - a_rtpmap)); - } - if (payload.a_fmtp != NULL) - { - sdp_message_a_attribute_add - (answer, i, - osip_strdup - ("fmtp"), - sstrdup_sprintf - ("%i %s", - payload.pt, - payload. - a_fmtp)); - } - if (payload.b_as_bandwidth != - 0) - { - if (sdp_message_bandwidth_get(answer,i,0)==NULL) - sdp_message_b_bandwidth_add - (answer, i, - osip_strdup - ("AS"), - sstrdup_sprintf - ("%i", - payload. - b_as_bandwidth)); - } - } - } - if (ncodec == 0) - { - /* refuse the line */ - refuse_mline(answer,mtype,proto,i); - - } - else - m_lines_accepted++; - } - else - { - /* refuse this line (leave port to 0) */ - refuse_mline(answer,mtype,proto,i); - } - - } - else if (keywordcmp ("video", mtype) == 0) - { - if (sdph->accept_video_codecs != NULL) - { - ncodec = 0; - /* for each payload type */ - for (j = 0; - ((pt = - sdp_message_m_payload_get (remote, i, - j)) != NULL); j++) - { - memcpy(&payload,&init_payload,sizeof(payload)); - payload.pt = osip_atoi (pt); - /* get the rtpmap associated to this codec, if any */ - payload.a_rtpmap = - sdp_message_a_attr_value_get_with_pt - (remote, i, payload.pt, - "rtpmap"); - /* get the fmtp, if any */ - payload.a_fmtp = - sdp_message_a_attr_value_get_with_pt - (remote, i, payload.pt, - "fmtp"); - /* ask the application if this codec is supported */ - err = sdph->accept_video_codecs (ctx, - &payload); - if (err == 0 ) - { - ncodec++; - /* codec accepted */ - if (ncodec == 1) - { - /* first codec accepted, setup the line */ - sdp_message_m_media_add - (answer, - osip_strdup - (mtype), - int_2char - (payload.localport), NULL, - osip_strdup - (proto)); - /* and accept the remote relay addr if we planned to use our own */ - if (ctx->relay!=NULL && relay){ - add_relay_info(answer,i,relay,payload.relay_session_id); - } - } - /* add the payload, rtpmap, fmtp */ - sdp_message_m_payload_add (answer, i, - int_2char - (payload. - pt)); - if (payload.a_rtpmap != NULL) - { - sdp_message_a_attribute_add - (answer, i, - osip_strdup - ("rtpmap"), - sstrdup_sprintf - ("%i %s", - payload.pt, - payload. - a_rtpmap)); - } - if (payload.a_fmtp != NULL) - { - sdp_message_a_attribute_add - (answer, i, - osip_strdup - ("fmtp"), - sstrdup_sprintf - ("%i %s", - payload.pt, - payload. - a_fmtp)); - } - if (payload.b_as_bandwidth !=0) - { - if (sdp_message_bandwidth_get(answer,i,0)==NULL) - sdp_message_b_bandwidth_add - (answer, i, - osip_strdup - ("AS"), - sstrdup_sprintf - ("%i", - payload. - b_as_bandwidth)); - } - } - } - if (ncodec == 0) - { - /* refuse the line */ - refuse_mline(answer,mtype,proto,i); - } - else - m_lines_accepted++; - } - else - { - /* refuse the line */ - refuse_mline(answer,mtype,proto,i); - } - } - } - if (ctx->answer!=NULL) - sdp_message_free(ctx->answer); - ctx->answer = answer; - if (m_lines_accepted > 0){ - ctx->negoc_status = 200; - sdp_message_to_str(answer,&tmp); - if (ctx->answerstr!=NULL) - osip_free(ctx->answerstr); - ctx->answerstr=tmp; - return tmp; - }else{ - ctx->negoc_status = 415; - return NULL; - } -} - -void -sdp_context_read_answer (sdp_context_t *ctx, sdp_message_t *remote) -{ - char *mtype; - char *proto, *port, *pt; - int i, j,err; - char *relay; - sdp_payload_t payload,arg_payload; - sdp_handler_t *sdph=ctx->handler; - sdp_bandwidth_t *sbw=NULL; - /* for each m= line */ - for (i = 0; !sdp_message_endof_media (remote, i); i++) - { - sdp_payload_init(&payload); - mtype = sdp_message_m_media_get (remote, i); - proto = sdp_message_m_proto_get (remote, i); - port = sdp_message_m_port_get (remote, i); - payload.remoteport = osip_atoi (port); - payload.localport = osip_atoi (sdp_message_m_port_get (ctx->offer, i)); - payload.proto = proto; - payload.line = i; - payload.c_addr = sdp_message_c_addr_get (remote, i, 0); - if (payload.c_addr == NULL) - payload.c_addr = sdp_message_c_addr_get (remote, -1, 0); - /*parse relay address if given*/ - relay=sdp_message_a_attr_value_get(remote,i,"relay-addr"); - if (relay){ - payload.relay_host=parse_relay_addr(relay,&payload.relay_port); - } - payload.relay_session_id=sdp_message_a_attr_value_get(remote,i,"relay-session-id"); - for(j=0;(sbw=sdp_message_bandwidth_get(remote,i,j))!=NULL;++j){ - if (strcasecmp(sbw->b_bwtype,"AS")==0) payload.b_as_bandwidth=atoi(sbw->b_bandwidth); - } - payload.a_ptime=_sdp_message_get_a_ptime(remote,i); - if (keywordcmp ("audio", mtype) == 0) - { - if (sdph->get_audio_codecs != NULL) - { - /* for each payload type */ - for (j = 0; - ((pt = - sdp_message_m_payload_get (remote, i, - j)) != NULL); j++) - { - payload.pt = osip_atoi (pt); - /* get the rtpmap associated to this codec, if any */ - payload.a_rtpmap = - sdp_message_a_attr_value_get_with_pt - (remote, i, payload.pt, - "rtpmap"); - /* get the fmtp, if any */ - payload.a_fmtp = - sdp_message_a_attr_value_get_with_pt - (remote, i, payload.pt, - "fmtp"); - /* ask the application if this codec is supported */ - memcpy(&arg_payload,&payload,sizeof(payload)); - err = sdph->get_audio_codecs (ctx, - &arg_payload); - } - } - } - else if (keywordcmp ("video", mtype) == 0) - { - if (sdph->get_video_codecs != NULL) - { - /* for each payload type */ - for (j = 0; - ((pt = - sdp_message_m_payload_get (remote, i, - j)) != NULL); j++) - { - payload.pt = osip_atoi (pt); - /* get the rtpmap associated to this codec, if any */ - payload.a_rtpmap = - sdp_message_a_attr_value_get_with_pt - (remote, i, payload.pt, - "rtpmap"); - /* get the fmtp, if any */ - payload.a_fmtp = - sdp_message_a_attr_value_get_with_pt - (remote, i, payload.pt, - "fmtp"); - /* ask the application if this codec is supported */ - memcpy(&arg_payload,&payload,sizeof(payload)); - err = sdph->get_video_codecs (ctx, - &arg_payload); - } - } - } - } -} -void sdp_context_free(sdp_context_t *ctx){ - osip_free(ctx->localip); - osip_free(ctx->username); - if (ctx->offer!=NULL) sdp_message_free(ctx->offer); - if (ctx->answer!=NULL) sdp_message_free(ctx->answer); - if (ctx->offerstr!=NULL) osip_free(ctx->offerstr); - if (ctx->answerstr!=NULL) osip_free(ctx->answerstr); - if (ctx->relay!=NULL) osip_free(ctx->relay); - if (ctx->relay_session_id!=NULL) osip_free(ctx->relay_session_id); - osip_free(ctx); -} diff --git a/coreapi/sdphandler.h b/coreapi/sdphandler.h deleted file mode 100644 index b3e811b70..000000000 --- a/coreapi/sdphandler.h +++ /dev/null @@ -1,101 +0,0 @@ - /* - * Linphone is sip (RFC3261) compatible internet phone. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef SDP_HANDLER_H -#define SDP_HANDLER_H - -#include -#include "linphonecore.h" - -typedef struct _sdp_payload -{ - int line; /* the index of the m= line */ - int pt; /*payload type */ - int localport; - int remoteport; - int b_as_bandwidth; /* application specific bandwidth */ - char *proto; - char *c_nettype; - char *c_addrtype; - char *c_addr; - char *c_addr_multicast_ttl; - char *c_addr_multicast_int; - char *a_rtpmap; - char *a_fmtp; - char *relay_host; - int relay_port; - char *relay_session_id; - int a_ptime; -} sdp_payload_t; - -typedef struct _sdp_context sdp_context_t; - -typedef int (*sdp_handler_read_codec_func_t) (struct _sdp_context *, - sdp_payload_t *); -typedef int (*sdp_handler_write_codec_func_t) (struct _sdp_context *); - -typedef struct _sdp_handler -{ - sdp_handler_read_codec_func_t accept_audio_codecs; /*from remote sdp */ - sdp_handler_read_codec_func_t accept_video_codecs; /*from remote sdp */ - sdp_handler_write_codec_func_t set_audio_codecs; /*to local sdp */ - sdp_handler_write_codec_func_t set_video_codecs; /*to local sdp */ - sdp_handler_read_codec_func_t get_audio_codecs; /*from incoming answer */ - sdp_handler_read_codec_func_t get_video_codecs; /*from incoming answer */ -} sdp_handler_t; - - -typedef enum _sdp_context_state -{ - SDP_CONTEXT_STATE_INIT, - SDP_CONTEXT_STATE_NEGOCIATION_OPENED, - SDP_CONTEXT_STATE_NEGOCIATION_CLOSED -} sdp_context_state_t; - -struct _sdp_context -{ - sdp_handler_t *handler; - char *localip; - char *username; - void *reference; - sdp_message_t *offer; /* the local sdp to be used for outgoing request */ - char *offerstr; - sdp_message_t *answer; /* the local sdp generated from an inc request */ - char *answerstr; - char *relay; - char *relay_session_id; - int negoc_status; /* in sip code */ - int incb; - sdp_context_state_t state; -}; - -/* create a context for a sdp negociation: localip is the ip address to be used in the sdp message, can -be a firewall address. -It can be null when negociating for an incoming offer; In that case it will be guessed. */ -sdp_context_t *sdp_handler_create_context(sdp_handler_t *handler, const char *localip, const char *username, const char *relay); -void sdp_context_set_user_pointer(sdp_context_t * ctx, void* up); -void *sdp_context_get_user_pointer(sdp_context_t * ctx); -void sdp_context_add_audio_payload( sdp_context_t * ctx, sdp_payload_t * payload); -void sdp_context_add_video_payload( sdp_context_t * ctx, sdp_payload_t * payload); -char * sdp_context_get_offer(sdp_context_t *ctx); -char * sdp_context_get_answer(sdp_context_t* ctx, sdp_message_t *remote_offer); -int sdp_context_get_status(sdp_context_t* ctx); -void sdp_context_read_answer(sdp_context_t *ctx, sdp_message_t *remote_answer); -void sdp_context_free(sdp_context_t *ctx); - -int sdp_payload_init (sdp_payload_t * payload); -#endif