mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 17:29:20 +00:00
add possibility to set/get subject in SDP
This commit is contained in:
parent
7bfd12788a
commit
9d5c1e7403
7 changed files with 114 additions and 14 deletions
|
|
@ -218,7 +218,8 @@ belle_sdp_session_description_t * media_description_to_sdp ( const SalMediaDescr
|
|||
|
||||
belle_sdp_session_description_set_origin ( session_desc,origin );
|
||||
|
||||
belle_sdp_session_description_set_session_name ( session_desc,belle_sdp_session_name_create ( "Talk" ) );
|
||||
belle_sdp_session_description_set_session_name ( session_desc,
|
||||
belle_sdp_session_name_create ( desc->name[0]!='\0' ? desc->name : "Talk" ) );
|
||||
|
||||
if ( (!sal_media_description_has_dir ( desc,SalStreamSendOnly ) && !sal_media_description_has_dir ( desc,SalStreamInactive ))
|
||||
|| desc->ice_ufrag[0] != '\0' ) {
|
||||
|
|
@ -251,21 +252,10 @@ belle_sdp_session_description_t * media_description_to_sdp ( const SalMediaDescr
|
|||
|
||||
|
||||
int sdp_to_media_description ( belle_sdp_session_description_t *session_desc, SalMediaDescription *desc ) {
|
||||
/*
|
||||
typedef struct SalMediaDescription{
|
||||
int refcount;
|
||||
char addr[64];
|
||||
char username[64];
|
||||
int nstreams;
|
||||
int bandwidth;
|
||||
unsigned int session_ver;
|
||||
unsigned int session_id;
|
||||
SalStreamDescription streams[SAL_MEDIA_DESCRIPTION_MAX_STREAMS];
|
||||
} SalMediaDescription;
|
||||
*/
|
||||
belle_sdp_connection_t* cnx;
|
||||
belle_sip_list_t* media_desc_it;
|
||||
belle_sdp_media_description_t* media_desc;
|
||||
belle_sdp_session_name_t *sname;
|
||||
const char *mtype,*proto;
|
||||
SalStreamDescription *stream;
|
||||
belle_sdp_media_t* media;
|
||||
|
|
@ -287,9 +277,14 @@ int sdp_to_media_description ( belle_sdp_session_description_t *session_desc, S
|
|||
if ( ( cnx=belle_sdp_session_description_get_connection ( session_desc ) ) && belle_sdp_connection_get_address ( cnx ) ) {
|
||||
strncpy ( desc->addr,belle_sdp_connection_get_address ( cnx ),sizeof ( desc->addr ) );
|
||||
}
|
||||
if ( (sname=belle_sdp_session_description_get_session_name(session_desc)) && belle_sdp_session_name_get_value(sname) ){
|
||||
strncpy(desc->name,belle_sdp_session_name_get_value(sname),sizeof(desc->name));
|
||||
}
|
||||
|
||||
if ( belle_sdp_session_description_get_bandwidth ( session_desc,"AS" ) >0 ) {
|
||||
desc->bandwidth=belle_sdp_session_description_get_bandwidth ( session_desc,"AS" );
|
||||
}
|
||||
|
||||
/*in some very rare case, session attribute may set stream dir*/
|
||||
if ( belle_sdp_session_description_get_attribute ( session_desc,"sendrecv" ) ) {
|
||||
stream_dir=SalStreamSendRecv;
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ void linphone_call_make_local_media_description(LinphoneCore *lc, LinphoneCall *
|
|||
SalMediaDescription *md=sal_media_description_new();
|
||||
LinphoneAddress *addr;
|
||||
char* local_ip=call->localip;
|
||||
const char *subject=linphone_call_params_get_session_name(&call->params);
|
||||
|
||||
linphone_core_adapt_to_network(lc,call->ping_time,&call->params);
|
||||
|
||||
|
|
@ -282,6 +283,7 @@ void linphone_call_make_local_media_description(LinphoneCore *lc, LinphoneCall *
|
|||
|
||||
strncpy(md->addr,local_ip,sizeof(md->addr));
|
||||
strncpy(md->username,linphone_address_get_username(addr),sizeof(md->username));
|
||||
strncpy(md->name,subject,sizeof(md->name));
|
||||
|
||||
if (call->params.down_bw)
|
||||
md->bandwidth=call->params.down_bw;
|
||||
|
|
@ -943,6 +945,7 @@ const LinphoneCallParams * linphone_call_get_remote_params(LinphoneCall *call){
|
|||
cp->low_bandwidth=TRUE;
|
||||
}
|
||||
}
|
||||
if (md->name[0]!='\0') linphone_call_params_set_session_name(cp,md->name);
|
||||
}
|
||||
cp->custom_headers=(SalCustomHeader*)sal_op_get_recv_custom_header(call->op);
|
||||
return cp;
|
||||
|
|
@ -1260,10 +1263,31 @@ const char *linphone_call_params_get_custom_header(const LinphoneCallParams *par
|
|||
return sal_custom_header_find(params->custom_headers,header_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subject of the media session (ie in SDP). Subject from the SIP message can be retrieved using linphone_call_params_get_custom_header().
|
||||
* @param cp the call parameters.
|
||||
**/
|
||||
const char *linphone_call_params_get_session_name(const LinphoneCallParams *cp){
|
||||
return cp->subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subject of the media session (ie in SDP). Subject from the SIP message can be set using linphone_call_params_set_custom_header().
|
||||
* @param cp the call parameters.
|
||||
**/
|
||||
void linphone_call_params_set_session_name(LinphoneCallParams *cp, const char *subject){
|
||||
if (cp->subject){
|
||||
ms_free(cp->subject);
|
||||
cp->subject=NULL;
|
||||
}
|
||||
if (subject) cp->subject=ms_strdup(subject);
|
||||
}
|
||||
|
||||
void _linphone_call_params_copy(LinphoneCallParams *ncp, const LinphoneCallParams *cp){
|
||||
if (ncp==cp) return;
|
||||
memcpy(ncp,cp,sizeof(LinphoneCallParams));
|
||||
if (cp->record_file) ncp->record_file=ms_strdup(cp->record_file);
|
||||
if (cp->subject) ncp->subject=ms_strdup(cp->subject);
|
||||
/*
|
||||
* The management of the custom headers is not optimal. We copy everything while ref counting would be more efficient.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -371,6 +371,8 @@ LINPHONE_PUBLIC bool_t linphone_call_params_low_bandwidth_enabled(const Linphone
|
|||
LINPHONE_PUBLIC void linphone_call_params_enable_low_bandwidth(LinphoneCallParams *cp, bool_t enabled);
|
||||
LINPHONE_PUBLIC void linphone_call_params_set_record_file(LinphoneCallParams *cp, const char *path);
|
||||
LINPHONE_PUBLIC const char *linphone_call_params_get_record_file(const LinphoneCallParams *cp);
|
||||
LINPHONE_PUBLIC const char *linphone_call_params_get_session_name(const LinphoneCallParams *cp);
|
||||
LINPHONE_PUBLIC void linphone_call_params_set_session_name(LinphoneCallParams *cp, const char *subject);
|
||||
|
||||
/**
|
||||
* Add a custom SIP header in the INVITE for a call.
|
||||
|
|
@ -2302,6 +2304,8 @@ LINPHONE_PUBLIC void linphone_core_set_provisioning_uri(LinphoneCore *lc, const
|
|||
**/
|
||||
LINPHONE_PUBLIC const char* linphone_core_get_provisioning_uri(const LinphoneCore *lc);
|
||||
|
||||
|
||||
LINPHONE_PUBLIC int linphone_core_migrate_to_multi_transport(LinphoneCore *lc);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1200,4 +1200,79 @@ void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun
|
|||
belle_sip_object_unref(s);
|
||||
}
|
||||
|
||||
static int get_unique_transport(LinphoneCore *lc, LinphoneTransportType *type, int *port){
|
||||
LCSipTransports tp;
|
||||
linphone_core_get_sip_transports(lc,&tp);
|
||||
if (tp.tcp_port==0 && tp.tls_port==0 && tp.udp_port!=0){
|
||||
*type=LinphoneTransportUdp;
|
||||
*port=tp.udp_port;
|
||||
return 0;
|
||||
}else if (tp.tcp_port==0 && tp.udp_port==0 && tp.tls_port!=0){
|
||||
*type=LinphoneTransportTls;
|
||||
*port=tp.tls_port;
|
||||
return 0;
|
||||
}else if (tp.tcp_port!=0 && tp.udp_port==0 && tp.tls_port==0){
|
||||
*type=LinphoneTransportTcp;
|
||||
*port=tp.tcp_port;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void linphone_core_migrate_proxy_config(LinphoneCore *lc, LinphoneTransportType type){
|
||||
const MSList *elem;
|
||||
for(elem=linphone_core_get_proxy_config_list(lc);elem!=NULL;elem=elem->next){
|
||||
LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
|
||||
const char *proxy=linphone_proxy_config_get_addr(cfg);
|
||||
const char *route=linphone_proxy_config_get_route(cfg);
|
||||
LinphoneAddress *proxy_addr=linphone_address_new(proxy);
|
||||
LinphoneAddress *route_addr=NULL;
|
||||
char *tmp;
|
||||
if (route) route_addr=linphone_address_new(route);
|
||||
if (proxy_addr){
|
||||
linphone_address_set_transport(proxy_addr,type);
|
||||
tmp=linphone_address_as_string(proxy_addr);
|
||||
linphone_proxy_config_set_server_addr(cfg,tmp);
|
||||
ms_free(tmp);
|
||||
linphone_address_destroy(proxy_addr);
|
||||
}
|
||||
if (route_addr){
|
||||
linphone_address_set_transport(route_addr,type);
|
||||
tmp=linphone_address_as_string(route_addr);
|
||||
linphone_proxy_config_set_route(cfg,tmp);
|
||||
ms_free(tmp);
|
||||
linphone_address_destroy(route_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate configuration so that all SIP transports are enabled.
|
||||
* Versions of linphone < 3.7 did not support using multiple SIP transport simultaneously.
|
||||
* This function helps application to migrate the configuration so that all transports are enabled.
|
||||
* Existing proxy configuration are added a transport parameter so that they continue using the unique transport that was set previously.
|
||||
* This function must be used just after creating the core, before any call to linphone_core_iterate()
|
||||
* @param lc the linphone core
|
||||
* @returns 1 if migration was done, 0 if not done because unnecessary or already done, -1 in case of error.
|
||||
* @ingroup initializing
|
||||
**/
|
||||
int linphone_core_migrate_to_multi_transport(LinphoneCore *lc){
|
||||
if (!lp_config_get_int(lc->config,"sip","multi_transport_migration_done",0)){
|
||||
LinphoneTransportType tpt;
|
||||
int port;
|
||||
if (get_unique_transport(lc,&tpt,&port)==0){
|
||||
LCSipTransports newtp={0};
|
||||
ms_message("Core is using a single SIP transport, migrating proxy config and enabling multi-transport.");
|
||||
linphone_core_migrate_proxy_config(lc,tpt);
|
||||
newtp.udp_port=port;
|
||||
newtp.tcp_port=port;
|
||||
newtp.tls_port=LC_SIP_TRANSPORT_RANDOM;
|
||||
linphone_core_set_sip_transports(lc,&newtp);
|
||||
}
|
||||
lp_config_set_int(lc->config,"sip","multi_transport_migration_done",1);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -91,11 +91,11 @@ struct _LinphoneCallParams{
|
|||
int down_ptime;
|
||||
int up_ptime;
|
||||
char *record_file;
|
||||
char *subject;
|
||||
SalCustomHeader *custom_headers;
|
||||
bool_t has_video;
|
||||
bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/
|
||||
bool_t in_conference; /*in conference mode */
|
||||
bool_t pad;
|
||||
bool_t low_bandwidth;
|
||||
LinphonePrivacyMask privacy;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ static void linphone_gtk_init_liblinphone(const char *config_file,
|
|||
vtable.configuring_status=linphone_gtk_configuring_status;
|
||||
|
||||
the_core=linphone_core_new(&vtable,config_file,factory_config_file,NULL);
|
||||
linphone_core_migrate_to_multi_transport(the_core);
|
||||
//lp_config_set_int(linphone_core_get_config(the_core), "sip", "store_auth_info", 0);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ typedef struct SalStreamDescription{
|
|||
|
||||
typedef struct SalMediaDescription{
|
||||
int refcount;
|
||||
char name[64];
|
||||
char addr[64];
|
||||
char username[64];
|
||||
int n_active_streams;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue