📄 osip_negotiation.c
字号:
/* The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-) Copyright (C) 2001,2002,2003 Aymeric MOIZARD jack@atosc.org 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 <osip2/osip_negotiation.h>#include <osip2/internal.h>static int sdp_partial_clone (osip_negotiation_t * config, osip_negotiation_ctx_t * con, sdp_message_t * remote, sdp_message_t ** dest);static int sdp_confirm_media (osip_negotiation_t * config, osip_negotiation_ctx_t * context, sdp_message_t * remote, sdp_message_t ** dest);static __payload_t *osip_negotiation_find_audio_payload (osip_negotiation_t * cfg, char *payload);static __payload_t *osip_negotiation_find_video_payload (osip_negotiation_t * cfg, char *payload);static __payload_t *osip_negotiation_find_other_payload (osip_negotiation_t * cfg, char *payload);intosip_negotiation_ctx_init (osip_negotiation_ctx_t ** con){ (*con) = (osip_negotiation_ctx_t *) osip_malloc (sizeof (osip_negotiation_ctx_t)); if (*con == NULL) return -1; (*con)->mycontext = NULL; /* fixed Sep 24 2003 */ (*con)->remote = NULL; (*con)->local = NULL; return 0;}voidosip_negotiation_ctx_free (osip_negotiation_ctx_t * con){ if (con == NULL) return; sdp_message_free (con->remote); sdp_message_free (con->local); osip_free (con);}/* this method is used by end-user application so any pointer can be associated with this context (usefull to link with your own context */intosip_negotiation_ctx_set_mycontext (osip_negotiation_ctx_t * con, void *my_instance){ if (con == NULL) return -1; con->mycontext = my_instance; return 0;}void *osip_negotiation_ctx_get_mycontext (osip_negotiation_ctx_t * con){ if (con == NULL) return NULL; return con->mycontext;}sdp_message_t *osip_negotiation_ctx_get_local_sdp (osip_negotiation_ctx_t * con){ if (con == NULL) return NULL; return con->local;}intosip_negotiation_ctx_set_local_sdp (osip_negotiation_ctx_t * con, sdp_message_t * sdp){ if (con == NULL) return -1; con->local = sdp; return 0;}sdp_message_t *osip_negotiation_ctx_get_remote_sdp (osip_negotiation_ctx_t * con){ if (con == NULL) return NULL; return con->remote;}intosip_negotiation_ctx_set_remote_sdp (osip_negotiation_ctx_t * con, sdp_message_t * sdp){ if (con == NULL) return -1; con->remote = sdp; return 0;}int__payload_init (__payload_t ** payload){ *payload = (__payload_t *) osip_malloc (sizeof (__payload_t)); if (*payload == NULL) return -1; (*payload)->payload = NULL; (*payload)->number_of_port = NULL; (*payload)->proto = NULL; (*payload)->c_nettype = NULL; (*payload)->c_addrtype = NULL; (*payload)->c_addr = NULL; (*payload)->c_addr_multicast_ttl = NULL; (*payload)->c_addr_multicast_int = NULL; (*payload)->a_rtpmap = NULL; return 0;}void__payload_free (__payload_t * payload){ if (payload == NULL) return; osip_free (payload->payload); osip_free (payload->number_of_port); osip_free (payload->proto); osip_free (payload->c_nettype); osip_free (payload->c_addrtype); osip_free (payload->c_addr); osip_free (payload->c_addr_multicast_ttl); osip_free (payload->c_addr_multicast_int); osip_free (payload->a_rtpmap); osip_free (payload);}intosip_negotiation_init (osip_negotiation_t ** config_out){ osip_negotiation_t *config; config = (osip_negotiation_t *) osip_malloc (sizeof (osip_negotiation_t)); if (config == NULL) return -1; config->o_username = NULL; config->o_session_id = NULL; config->o_session_version = NULL; config->o_nettype = NULL; config->o_addrtype = NULL; config->o_addr = NULL; config->c_nettype = NULL; config->c_addrtype = NULL; config->c_addr = NULL; config->c_addr_multicast_ttl = NULL; config->c_addr_multicast_int = NULL; /* supported codec for the SIP User Agent */ config->audio_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->audio_codec); config->video_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->video_codec); config->other_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->other_codec); config->fcn_set_info = NULL; config->fcn_set_uri = NULL; config->fcn_set_emails = NULL; config->fcn_set_phones = NULL; config->fcn_set_attributes = NULL; config->fcn_accept_audio_codec = NULL; config->fcn_accept_video_codec = NULL; config->fcn_accept_other_codec = NULL; *config_out = config; return 0;}voidosip_negotiation_free (osip_negotiation_t * config){ if (config == NULL) return; osip_free (config->o_username); osip_free (config->o_session_id); osip_free (config->o_session_version); osip_free (config->o_nettype); osip_free (config->o_addrtype); osip_free (config->o_addr); osip_free (config->c_nettype); osip_free (config->c_addrtype); osip_free (config->c_addr); osip_free (config->c_addr_multicast_ttl); osip_free (config->c_addr_multicast_int); osip_list_special_free (config->audio_codec, (void *(*)(void *)) &__payload_free); osip_list_special_free (config->video_codec, (void *(*)(void *)) &__payload_free); osip_list_special_free (config->other_codec, (void *(*)(void *)) &__payload_free); /* other are pointer to func, they don't need free() calls */ /* yes, this is done here... :) */ osip_free (config);}intosip_negotiation_set_o_username (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->o_username = tmp; return 0;}intosip_negotiation_set_o_session_id (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->o_session_id = tmp; return 0;}intosip_negotiation_set_o_session_version (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->o_session_version = tmp; return 0;}intosip_negotiation_set_o_nettype (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->o_nettype = tmp; return 0;}intosip_negotiation_set_o_addrtype (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->o_addrtype = tmp; return 0;}intosip_negotiation_set_o_addr (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->o_addr = tmp; return 0;}intosip_negotiation_set_c_nettype (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->c_nettype = tmp; return 0;}intosip_negotiation_set_c_addrtype (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->c_addrtype = tmp; return 0;}intosip_negotiation_set_c_addr (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->c_addr = tmp; return 0;}intosip_negotiation_set_c_addr_multicast_ttl (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->c_addr_multicast_ttl = tmp; return 0;}intosip_negotiation_set_c_addr_multicast_int (osip_negotiation_t * config, char *tmp){ if (config == NULL) return -1; config->c_addr_multicast_int = tmp; return 0;}intosip_negotiation_add_support_for_audio_codec (osip_negotiation_t * config, char *payload, char *number_of_port, char *proto, char *c_nettype, char *c_addrtype, char *c_addr, char *c_addr_multicast_ttl, char *c_addr_multicast_int, char *a_rtpmap){ int i; __payload_t *my_payload; i = __payload_init (&my_payload); if (i != 0) return -1; my_payload->payload = payload; my_payload->number_of_port = number_of_port; my_payload->proto = proto; my_payload->c_nettype = c_nettype; my_payload->c_addrtype = c_addrtype; my_payload->c_addr = c_addr; my_payload->c_addr_multicast_ttl = c_addr_multicast_ttl; my_payload->c_addr_multicast_int = c_addr_multicast_int; my_payload->a_rtpmap = a_rtpmap; osip_list_add (config->audio_codec, my_payload, -1); return 0;}intosip_negotiation_add_support_for_video_codec (osip_negotiation_t * config, char *payload, char *number_of_port, char *proto, char *c_nettype, char *c_addrtype, char *c_addr, char *c_addr_multicast_ttl, char *c_addr_multicast_int, char *a_rtpmap){ int i; __payload_t *my_payload; i = __payload_init (&my_payload); if (i != 0) return -1; my_payload->payload = payload; my_payload->number_of_port = number_of_port; my_payload->proto = proto; my_payload->c_nettype = c_nettype; my_payload->c_addrtype = c_addrtype; my_payload->c_addr = c_addr; my_payload->c_addr_multicast_ttl = c_addr_multicast_ttl; my_payload->c_addr_multicast_int = c_addr_multicast_int; my_payload->a_rtpmap = a_rtpmap; osip_list_add (config->video_codec, my_payload, -1); return 0;}intosip_negotiation_add_support_for_other_codec (osip_negotiation_t * config, char *payload, char *number_of_port, char *proto, char *c_nettype, char *c_addrtype, char *c_addr, char *c_addr_multicast_ttl, char *c_addr_multicast_int, char *a_rtpmap){ int i; __payload_t *my_payload; i = __payload_init (&my_payload); if (i != 0) return -1; my_payload->payload = payload; my_payload->number_of_port = number_of_port; my_payload->proto = proto; my_payload->c_nettype = c_nettype; my_payload->c_addrtype = c_addrtype; my_payload->c_addr = c_addr; my_payload->c_addr_multicast_ttl = c_addr_multicast_ttl; my_payload->c_addr_multicast_int = c_addr_multicast_int; my_payload->a_rtpmap = a_rtpmap; osip_list_add (config->other_codec, my_payload, -1); return 0;}intosip_negotiation_remove_audio_payloads (osip_negotiation_t * config){ osip_list_special_free (config->audio_codec, (void *(*)(void *)) &__payload_free); config->audio_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->audio_codec); return 0;}intosip_negotiation_remove_video_payloads (osip_negotiation_t * config){ osip_list_special_free (config->video_codec, (void *(*)(void *)) &__payload_free); config->video_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->video_codec); return 0;}intosip_negotiation_remove_other_payloads (osip_negotiation_t * config){ osip_list_special_free (config->other_codec, (void *(*)(void *)) &__payload_free); config->other_codec = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); osip_list_init (config->other_codec); return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -