belle_sdp_session_description_t * media_description_to_sdp ( const SalMediaDescription *desc ) { belle_sdp_session_description_t* session_desc=belle_sdp_session_description_new(); bool_t inet6; belle_sdp_origin_t* origin; int i; if ( strchr ( desc->addr,':' ) !=NULL ) { inet6=1; } else inet6=0; belle_sdp_session_description_set_version ( session_desc,belle_sdp_version_create ( 0 ) ); origin = belle_sdp_origin_create ( desc->username ,desc->session_id ,desc->session_ver ,"IN" , inet6 ? "IP6" :"IP4" ,desc->addr ); belle_sdp_session_description_set_origin ( session_desc,origin ); 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' ) { belle_sdp_session_description_set_connection ( session_desc ,belle_sdp_connection_create ( "IN",inet6 ? "IP6" :"IP4",desc->addr ) ); } else { belle_sdp_session_description_set_connection ( session_desc ,belle_sdp_connection_create ( "IN" ,inet6 ? "IP6" :"IP4" ,inet6 ? "::0" :"0.0.0.0" ) ); } belle_sdp_session_description_set_time_description ( session_desc,belle_sdp_time_description_create ( 0,0 ) ); if ( desc->bandwidth>0 ) { belle_sdp_session_description_set_bandwidth ( session_desc,"AS",desc->bandwidth ); } if (desc->ice_completed == TRUE) belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("nortpproxy","yes")); if (desc->ice_pwd[0] != '\0') belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("ice-pwd",desc->ice_pwd)); if (desc->ice_ufrag[0] != '\0') belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("ice-ufrag",desc->ice_ufrag)); if (desc->rtcp_xr.enabled == TRUE) { belle_sdp_session_description_add_attribute(session_desc, create_rtcp_xr_attribute(&desc->rtcp_xr)); } for ( i=0; i<desc->n_total_streams; i++ ) { stream_description_to_sdp(session_desc, desc, &desc->streams[i]); } return session_desc; }
SalCustomSdpAttribute * sal_custom_sdp_attribute_append(SalCustomSdpAttribute *csa, const char *name, const char *value) { belle_sdp_session_description_t *desc = (belle_sdp_session_description_t *)csa; belle_sdp_attribute_t *attr; if (desc == NULL) { desc = (belle_sdp_session_description_t *)belle_sdp_session_description_new(); belle_sip_object_ref(desc); } attr = BELLE_SDP_ATTRIBUTE(belle_sdp_raw_attribute_create(name, value)); if (attr == NULL) { belle_sip_error("Fail to create custom SDP attribute."); return (SalCustomSdpAttribute*)desc; } belle_sdp_session_description_add_attribute(desc, attr); return (SalCustomSdpAttribute *)desc; }
belle_sdp_session_description_t * media_description_to_sdp ( const SalMediaDescription *desc ) { belle_sdp_session_description_t* session_desc=belle_sdp_session_description_new(); bool_t inet6; belle_sdp_origin_t* origin; int i; if ( strchr ( desc->addr,':' ) !=NULL ) { inet6=1; } else inet6=0; belle_sdp_session_description_set_version ( session_desc,belle_sdp_version_create ( 0 ) ); origin = belle_sdp_origin_create ( desc->username ,desc->session_id ,desc->session_ver ,"IN" , inet6 ? "IP6" :"IP4" ,desc->addr ); belle_sdp_session_description_set_origin ( session_desc,origin ); 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,SalStreamInactive ) || desc->ice_ufrag[0] != '\0' ) { /*in case of sendonly, setting of the IP on cnx we give a chance to receive stun packets*/ belle_sdp_session_description_set_connection ( session_desc ,belle_sdp_connection_create ( "IN",inet6 ? "IP6" :"IP4",desc->addr ) ); } else { belle_sdp_session_description_set_connection ( session_desc ,belle_sdp_connection_create ( "IN" ,inet6 ? "IP6" :"IP4" ,inet6 ? "::0" :"0.0.0.0" ) ); } belle_sdp_session_description_set_time_description ( session_desc,belle_sdp_time_description_create ( 0,0 ) ); if ( desc->bandwidth>0 ) { belle_sdp_session_description_set_bandwidth ( session_desc,"AS",desc->bandwidth ); } if (desc->set_nortpproxy == TRUE) belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("nortpproxy","yes")); if (desc->ice_pwd[0] != '\0') belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("ice-pwd",desc->ice_pwd)); if (desc->ice_ufrag[0] != '\0') belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("ice-ufrag",desc->ice_ufrag)); if (desc->rtcp_xr.enabled == TRUE) { belle_sdp_session_description_add_attribute(session_desc, create_rtcp_xr_attribute(&desc->rtcp_xr)); } if (desc->custom_sdp_attributes) { belle_sdp_session_description_t *custom_desc = (belle_sdp_session_description_t *)desc->custom_sdp_attributes; belle_sip_list_t *l = belle_sdp_session_description_get_attributes(custom_desc); belle_sip_list_t *elem; for (elem = l; elem != NULL; elem = elem->next) { belle_sdp_session_description_add_attribute(session_desc, (belle_sdp_attribute_t *)elem->data); } } for ( i=0; i<desc->nb_streams; i++ ) { stream_description_to_sdp(session_desc, desc, &desc->streams[i]); } return session_desc; }