Freeswitch结构之switch_caller_profile_t

本文介绍了一个用于电话交换系统的呼叫配置结构。该结构包含了呼叫者的用户名、拨号计划名称、呼叫者ID、被叫ID等详细信息,并定义了多个指针以追踪呼叫过程中的不同阶段。此外还介绍了通道类型、唯一标识符以及其他关键属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

struct switch_caller_profile {
 /*! The Call's User Name */
 const char *username;
 /*! The name of the dialplan */
 const char *dialplan;
 /*! Caller ID Name */
 const char *caller_id_name;
 /*! Caller ID Number */
 const char *caller_id_number;
 /*! Original Caller ID Name */
 const char *orig_caller_id_name;
 /*! Original Caller ID Number */
 const char *orig_caller_id_number;
 /*! Callee ID Name */
 const char *callee_id_name;
 /*! Callee ID Number */
 const char *callee_id_number;
 uint8_t caller_ton;
 uint8_t caller_numplan;
 /*! Caller Network Address (when applicable) */
 const char *network_addr;
 /*! ANI (when applicable) */
 const char *ani;
 uint8_t ani_ton;
 uint8_t ani_numplan;
 /*! ANI II (when applicable) */
 const char *aniii;
 /*! RDNIS */
 const char *rdnis;
 uint8_t rdnis_ton;
 uint8_t rdnis_numplan;
 /*! Destination Number */
 char *destination_number;
 uint8_t destination_number_ton;
 uint8_t destination_number_numplan;
 /*! channel type */
 const char *source;
 /*! channel name */
 char *chan_name;
 /*! unique id */
 char *uuid;
 /*! context */
 const char *context;
 /*! profile index */
 const char *profile_index;
 /*! flags */
 switch_caller_profile_flag_t flags;
 struct switch_caller_profile *originator_caller_profile;
 struct switch_caller_profile *originatee_caller_profile;
 struct switch_caller_profile *origination_caller_profile;
 struct switch_caller_profile *hunt_caller_profile;
 struct switch_channel_timetable *times;
 struct switch_channel_timetable *old_times;
 struct switch_caller_extension *caller_extension;
 switch_memory_pool_t *pool;
 struct switch_caller_profile *next;
 switch_call_direction_t direction;
 switch_call_direction_t logical_direction;
 profile_node_t *soft;
 char *uuid_str;
 char *clone_of;
 char *transfer_source;
};
FreeSWITCH中,要将SIP中的INFO参照INVITE发送,可以通过以下步骤实现: 1. 在FreeSWITCH中创建一个SIP会话,即建立一个SIP通道。 2. 在SIP通道中发送一个INVITE请求。 3. 在SIP通道中等待对方的响应,如果对方接受了INVITE请求,则会发送一个200 OK响应。如果对方拒绝了INVITE请求,则会发送一个4xx或5xx的响应。 4. 在SIP通道中发送一个INFO请求,该请求需要参照之前发送的INVITE请求,即要使用相同的Call-ID、From、To等头部信息,并在INFO请求的Content-Type头部中指定应用程序类型和版本号。 5. 在SIP通道中等待对方对INFO请求的响应,如果对方接受了INFO请求,则会发送一个200 OK响应。如果对方拒绝了INFO请求,则会发送一个4xx或5xx的响应。 在FreeSWITCH中,可以使用mod_sofia模块来实现SIP通道的创建和INVITE请求的发送。可以使用SIP API来发送INFO请求,具体实现步骤如下: 1. 创建一个SIP会话: ``` session = sofia_glue_session_create(switch_core_session_get_pool(session), "sofia/external/username@sip.provider.com", NULL, NULL, NULL); ``` 2. 发送一个INVITE请求: ``` switch_channel_set_variable(session->channel, "sip_auto_answer", "true"); switch_channel_set_variable(session->channel, "sip_force_contact", "sip:username@sip.provider.com"); switch_channel_set_variable(session->channel, "sip_force_expires", "1800"); switch_channel_set_variable(session->channel, "sip_callee_id_number", "1000"); switch_channel_set_variable(session->channel, "sip_callee_id_name", "Alice"); switch_channel_set_variable(session->channel, "sip_caller_id_number", "2000"); switch_channel_set_variable(session->channel, "sip_caller_id_name", "Bob"); switch_channel_set_variable(session->channel, "sip_auth_username", "username"); switch_channel_set_variable(session->channel, "sip_auth_password", "password"); switch_channel_set_variable(session->channel, "sip_profile", "external"); switch_channel_set_variable(session->channel, "sip_invite_stamp", switch_channel_get_var(session->channel, "last_sent_cseq")); switch_channel_set_variable(session->channel, "sip_call_id", switch_channel_get_variable(session->channel, "sip_call_id")); switch_channel_set_variable(session->channel, "sip_full_from", switch_channel_get_variable(session->channel, "sip_full_from")); switch_channel_set_variable(session->channel, "sip_full_to", switch_channel_get_variable(session->channel, "sip_full_to")); switch_channel_set_variable(session->channel, "sip_req_uri", "sip:1000@sip.provider.com"); switch_channel_set_variable(session->channel, "sip_req_user", "1000"); switch_channel_set_variable(session->channel, "sip_req_host", "sip.provider.com"); switch_channel_set_variable(session->channel, "sip_req_port", "5060"); switch_channel_set_variable(session->channel, "sip_req_method", "INVITE"); switch_channel_set_variable(session->channel, "sip_req_user_agent", "FreeSWITCH"); switch_channel_set_variable(session->channel, "sip_req_contact", "<sip:1000@127.0.0.1:5080;transport=udp>"); switch_channel_set_variable(session->channel, "sip_req_accept", "application/sdp"); switch_channel_set_variable(session->channel, "sip_req_content_type", "application/sdp"); switch_channel_set_variable(session->channel, "sip_req_content_length", "0"); switch_channel_set_variable(session->channel, "sip_req_via_protocol", "udp"); switch_channel_set_variable(session->channel, "sip_req_via_port", "5060"); switch_channel_set_variable(session->channel, "sip_req_via_host", "127.0.0.1"); switch_channel_set_variable(session->channel, "sip_req_via_branch", "z9hG4bK-1234-5678"); switch_channel_set_variable(session->channel, "sip_req_via_rport", "5060"); switch_channel_set_variable(session->channel, "sip_req_via_received", "127.0.0.1"); switch_channel_set_variable(session->channel, "sip_req_via_protocol_id", "1"); switch_channel_set_variable(session->channel, "sip_req_via_secure", "false"); switch_channel_set_variable(session->channel, "sip_req_via_transport", "udp"); switch_channel_set_variable(session->channel, "sip_req_user_info", "<sip:1000@127.0.0.1>"); switch_channel_set_variable(session->channel, "sip_req_uri_user", "1000"); switch_channel_set_variable(session->channel, "sip_req_uri_host", "sip.provider.com"); switch_core_session_receive_message(session, "mod_sofia", "sip", "INVITE"); ``` 3. 等待对方的响应: ``` while (switch_channel_up(session->channel) && !switch_channel_test_flag(session->channel, CF_BRIDGE)) { switch_yield(1000000); } ``` 4. 发送一个INFO请求: ``` switch_channel_set_variable(session->channel, "sip_req_method", "INFO"); switch_channel_set_variable(session->channel, "sip_req_content_type", "application/vnd.3gpp.sms"); switch_channel_set_variable(session->channel, "sip_req_content_length", "10"); switch_channel_set_variable(session->channel, "sip_req_accept", "application/sdp"); switch_channel_set_variable(session->channel, "sip_req_contact", "<sip:1000@127.0.0.1:5080;transport=udp>"); switch_channel_set_variable(session->channel, "sip_req_uri", "sip:1000@sip.provider.com"); switch_channel_set_variable(session->channel, "sip_req_user", "1000"); switch_channel_set_variable(session->channel, "sip_req_host", "sip.provider.com"); switch_channel_set_variable(session->channel, "sip_req_port", "5060"); switch_channel_set_variable(session->channel, "sip_req_user_info", "<sip:1000@127.0.0.1>"); switch_core_session_receive_message(session, "mod_sofia", "sip", "INFO"); ``` 5. 等待对方对INFO请求的响应: ``` while (switch_channel_up(session->channel) && !switch_channel_test_flag(session->channel, CF_BRIDGE)) { switch_yield(1000000); } ``` 通过以上步骤,就可以在FreeSWITCH中将SIP中的INFO参照INVITE发送。需要注意的是,在发送INFO请求时,需要参照之前发送的INVITE请求,并且在Content-Type头部中指定应用程序类型和版本号。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值