Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
da8d9bc2
提交
da8d9bc2
authored
12月 15, 2007
作者:
Brian West
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@6802
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
3f581d06
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
172 行增加
和
61 行删除
+172
-61
default.xml
conf/directory/default.xml
+1
-1
nua_stack.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
+1
-1
mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.c
+5
-1
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+13
-1
sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_glue.c
+2
-0
sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_presence.c
+125
-53
switch_channel.c
src/switch_channel.c
+25
-4
没有找到文件。
conf/directory/default.xml
浏览文件 @
da8d9bc2
...
...
@@ -2,7 +2,7 @@
<!--the domain or ip (the right hand side of the @ in the addr-->
<domain
name=
"$${domain}"
>
<params>
<param
name=
"dial-string"
value=
"sofia/${dialed_domain}/${dialed_user}"
/>
<param
name=
"dial-string"
value=
"
{presence_id=${dialed_user}@${dialed_domain}}
sofia/${dialed_domain}/${dialed_user}"
/>
</params>
<X-PRE-PROCESS
cmd=
"include"
data=
"default/*.xml"
/>
...
...
libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
浏览文件 @
da8d9bc2
...
...
@@ -2125,7 +2125,7 @@ int nua_client_bind(nua_client_request_t *cr, nua_dialog_usage_t *du)
}
if
(
du
->
du_cr
&&
cr
!=
du
->
du_cr
)
{
assert
(
!
nua_client_is_queued
(
du
->
du_cr
));
if
(
nua_client_is_queued
(
du
->
du_cr
))
return
-
1
;
if
(
nua_client_is_reporting
(
du
->
du_cr
))
{
...
...
src/mod/endpoints/mod_sofia/mod_sofia.c
浏览文件 @
da8d9bc2
...
...
@@ -998,9 +998,13 @@ static int show_reg_callback(void *pArg, int argc, char **argv, char **columnNam
"Call-ID
\t
%s
\n
"
"User
\t
%s@%s
\n
"
"Contact
\t
%s
\n
"
"Agent
\t
%s
\n
"
"Status
\t
%s(%s) EXP(%s)
\n\n
"
,
switch_str_nil
(
argv
[
0
]),
switch_str_nil
(
argv
[
1
]),
switch_str_nil
(
argv
[
2
]),
switch_str_nil
(
argv
[
3
]),
switch_str_nil
(
argv
[
4
]),
switch_str_nil
(
argv
[
5
]),
exp_buf
);
switch_str_nil
(
argv
[
7
]),
switch_str_nil
(
argv
[
4
]),
switch_str_nil
(
argv
[
5
]),
exp_buf
);
return
0
;
}
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
da8d9bc2
...
...
@@ -58,6 +58,17 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status,
char
const
*
phrase
,
nua_t
*
nua
,
sofia_profile_t
*
profile
,
nua_handle_t
*
nh
,
sofia_private_t
*
sofia_private
,
sip_t
const
*
sip
,
tagi_t
tags
[])
{
if
(
status
==
481
&&
sip
)
{
const
char
*
call_id
=
sip
->
sip_call_id
->
i_id
;
char
*
sql
;
switch_core_hash_delete
(
profile
->
sub_hash
,
call_id
);
sql
=
switch_mprintf
(
"delete from sip_subscriptions where call_id='%q'"
,
call_id
);
switch_assert
(
sql
!=
NULL
);
sofia_glue_execute_sql
(
profile
,
SWITCH_FALSE
,
sql
,
profile
->
ireg_mutex
);
free
(
sql
);
nua_handle_destroy
(
nh
);
}
}
void
sofia_handle_sip_i_notify
(
switch_core_session_t
*
session
,
int
status
,
...
...
@@ -318,7 +329,7 @@ void event_handler(switch_event_t *event)
sofia_glue_execute_sql
(
profile
,
SWITCH_FALSE
,
sql
,
NULL
);
switch_safe_free
(
sql
);
sql
=
switch_mprintf
(
"insert into sip_registrations values ('%q', '%q','%q','%q','Reg
e
stered', '%q', %ld, '%q')"
,
sql
=
switch_mprintf
(
"insert into sip_registrations values ('%q', '%q','%q','%q','Reg
i
stered', '%q', %ld, '%q')"
,
call_id
,
from_user
,
from_host
,
contact_str
,
rpid
,
expires
,
user_agent
);
if
(
sql
)
{
...
...
@@ -398,6 +409,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
TAG_IF
((
profile
->
pflags
&
PFLAG_PRESENCE
),
NUTAG_ENABLEMESSAGE
(
1
)),
TAG_IF
((
profile
->
pflags
&
PFLAG_PRESENCE
),
NUTAG_ALLOW_EVENTS
(
"presence"
)),
TAG_IF
((
profile
->
pflags
&
PFLAG_PRESENCE
),
NUTAG_ALLOW_EVENTS
(
"dialog"
)),
TAG_IF
((
profile
->
pflags
&
PFLAG_PRESENCE
),
NUTAG_ALLOW_EVENTS
(
"call-info"
)),
TAG_IF
((
profile
->
pflags
&
PFLAG_PRESENCE
),
NUTAG_ALLOW_EVENTS
(
"presence.winfo"
)),
TAG_IF
((
profile
->
pflags
&
PFLAG_PRESENCE
),
NUTAG_ALLOW_EVENTS
(
"message-summary"
)),
SIPTAG_SUPPORTED_STR
(
"100rel, precondition, timer"
),
SIPTAG_USER_AGENT_STR
(
profile
->
user_agent
),
TAG_END
());
...
...
src/mod/endpoints/mod_sofia/sofia_glue.c
浏览文件 @
da8d9bc2
...
...
@@ -1233,6 +1233,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_SIP_HOLD
))
{
const
char
*
stream
;
switch_set_flag_locked
(
tech_pvt
,
TFLAG_SIP_HOLD
);
switch_channel_presence
(
tech_pvt
->
channel
,
"unknown"
,
"hold"
);
if
(
tech_pvt
->
max_missed_packets
)
{
switch_rtp_set_max_missed_packets
(
tech_pvt
->
rtp_session
,
tech_pvt
->
max_missed_packets
*
10
);
}
...
...
@@ -1251,6 +1252,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
}
switch_channel_set_flag_partner
(
tech_pvt
->
channel
,
CF_BREAK
);
switch_clear_flag_locked
(
tech_pvt
,
TFLAG_SIP_HOLD
);
switch_channel_presence
(
tech_pvt
->
channel
,
"unknown"
,
"unhold"
);
}
}
...
...
src/mod/endpoints/mod_sofia/sofia_presence.c
浏览文件 @
da8d9bc2
...
...
@@ -40,6 +40,11 @@ static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, ch
static
int
sofia_presence_resub_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
);
static
int
sofia_presence_sub_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
);
struct
presence_helper
{
sofia_profile_t
*
profile
;
switch_event_t
*
event
;
};
switch_status_t
sofia_presence_chat_send
(
char
*
proto
,
char
*
from
,
char
*
to
,
char
*
subject
,
char
*
body
,
char
*
hint
)
{
char
buf
[
256
];
...
...
@@ -117,6 +122,7 @@ void sofia_presence_cancel(void)
sofia_profile_t
*
profile
;
switch_hash_index_t
*
hi
;
void
*
val
;
struct
presence_helper
helper
;
if
((
sql
=
switch_mprintf
(
"select *,-1,'unavailable','unavailable' from sip_subscriptions where event='presence'"
)))
{
switch_mutex_lock
(
mod_sofia_globals
.
hash_mutex
);
...
...
@@ -126,8 +132,9 @@ void sofia_presence_cancel(void)
if
(
!
(
profile
->
pflags
&
PFLAG_PRESENCE
))
{
continue
;
}
if
(
sofia_glue_execute_sql_callback
(
profile
,
SWITCH_FALSE
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_sub_callback
,
profile
)
!=
SWITCH_TRUE
)
{
helper
.
profile
=
profile
;
helper
.
event
=
NULL
;
if
(
sofia_glue_execute_sql_callback
(
profile
,
SWITCH_FALSE
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_sub_callback
,
&
helper
)
!=
SWITCH_TRUE
)
{
continue
;
}
}
...
...
@@ -275,6 +282,7 @@ void sofia_presence_event_handler(switch_event_t *event)
char
*
rpid
=
switch_event_get_header
(
event
,
"rpid"
);
char
*
status
=
switch_event_get_header
(
event
,
"status"
);
char
*
event_type
=
switch_event_get_header
(
event
,
"event_type"
);
char
*
alt_event_type
=
switch_event_get_header
(
event
,
"alt_event_type"
);
char
*
sql
=
NULL
;
char
*
euser
=
NULL
,
*
user
=
NULL
,
*
host
=
NULL
;
...
...
@@ -309,6 +317,7 @@ void sofia_presence_event_handler(switch_event_t *event)
}
if
(
event
->
event_id
==
SWITCH_EVENT_ROSTER
)
{
struct
presence_helper
helper
;
if
(
from
)
{
sql
=
switch_mprintf
(
"select *,1,'%q','%q' from sip_subscriptions where event='presence' and full_from like '%%%q%%'"
,
status
,
rpid
,
from
);
...
...
@@ -324,13 +333,14 @@ void sofia_presence_event_handler(switch_event_t *event)
if
(
!
(
profile
->
pflags
&
PFLAG_PRESENCE
))
{
continue
;
}
helper
.
profile
=
profile
;
helper
.
event
=
NULL
;
sofia_glue_execute_sql_callback
(
profile
,
SWITCH_FALSE
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_sub_callback
,
profile
);
&
helper
);
}
switch_mutex_unlock
(
mod_sofia_globals
.
hash_mutex
);
free
(
sql
);
...
...
@@ -341,6 +351,10 @@ void sofia_presence_event_handler(switch_event_t *event)
event_type
=
"presence"
;
}
if
(
switch_strlen_zero
(
alt_event_type
))
{
alt_event_type
=
"presence"
;
}
if
((
user
=
strdup
(
from
)))
{
if
((
host
=
strchr
(
user
,
'@'
)))
{
char
*
p
;
...
...
@@ -399,14 +413,14 @@ void sofia_presence_event_handler(switch_event_t *event)
case
SWITCH_EVENT_PRESENCE_IN
:
sql
=
switch_mprintf
(
"select *,1,'%q','%q' from sip_subscriptions where proto='%q' and
event='%q'
and sub_to_user='%q' and sub_to_host='%q'"
,
status
,
rpid
,
proto
,
event_type
,
euser
,
host
);
(
"select *,1,'%q','%q' from sip_subscriptions where proto='%q' and
(event='%q' or event='%q')
and sub_to_user='%q' and sub_to_host='%q'"
,
status
,
rpid
,
proto
,
event_type
,
alt_event_type
,
euser
,
host
);
break
;
case
SWITCH_EVENT_PRESENCE_OUT
:
sql
=
switch_mprintf
(
"select *,0,'%q','%q' from sip_subscriptions where proto='%q' and
event='%q'
and sub_to_user='%q' and sub_to_host='%q'"
,
status
,
rpid
,
proto
,
event_type
,
euser
,
host
);
(
"select *,0,'%q','%q' from sip_subscriptions where proto='%q' and
(event='%q' or event='%q')
and sub_to_user='%q' and sub_to_host='%q'"
,
status
,
rpid
,
proto
,
event_type
,
alt_event_type
,
euser
,
host
);
break
;
default:
break
;
...
...
@@ -421,12 +435,15 @@ void sofia_presence_event_handler(switch_event_t *event)
}
if
(
sql
)
{
struct
presence_helper
helper
;
helper
.
profile
=
profile
;
helper
.
event
=
event
;
sofia_glue_execute_sql_callback
(
profile
,
SWITCH_FALSE
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_sub_callback
,
profile
);
&
helper
);
}
}
switch_mutex_unlock
(
mod_sofia_globals
.
hash_mutex
);
...
...
@@ -455,13 +472,14 @@ static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, ch
if
(
switch_strlen_zero
(
status
))
{
status
=
"Available"
;
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_
IN
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_
PROBE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
SOFIA_CHAT_PROTO
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
"%s"
,
profile
->
url
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
user
,
host
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"%s"
,
status
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_subtype"
,
"probe"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"proto-specific-event-name"
,
"%s"
,
event_name
);
switch_event_fire
(
&
event
);
}
...
...
@@ -529,7 +547,8 @@ static char *translate_rpid(char *in)
static
int
sofia_presence_sub_callback
(
void
*
pArg
,
int
argc
,
char
**
argv
,
char
**
columnNames
)
{
sofia_profile_t
*
profile
=
(
sofia_profile_t
*
)
pArg
;
struct
presence_helper
*
helper
=
(
struct
presence_helper
*
)
pArg
;
sofia_profile_t
*
profile
=
helper
->
profile
;
char
*
pl
;
char
*
id
,
*
note
;
uint32_t
in
=
atoi
(
argv
[
13
]);
...
...
@@ -584,6 +603,38 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
}
to
=
switch_mprintf
(
"sip:%s@%s"
,
user
,
host
);
if
(
!
strcmp
(
event
,
"dialog"
)
&&
helper
->
event
)
{
switch_stream_handle_t
stream
=
{
0
};
//const char *direction = switch_str_nil(switch_event_get_header(helper->event, "call-direction"));
const
char
*
uuid
=
switch_str_nil
(
switch_event_get_header
(
helper
->
event
,
"unique-id"
));
const
char
*
state
=
switch_str_nil
(
switch_event_get_header
(
helper
->
event
,
"channel-state"
));
const
char
*
status
=
switch_str_nil
(
switch_event_get_header
(
helper
->
event
,
"status"
));
SWITCH_STANDARD_STREAM
(
stream
);
stream
.
write_function
(
&
stream
,
"<?xml version=
\"
1.0
\"
?>
\n
"
"<dialog-info xmlns=
\"
urn:ietf:params:xml:ns:dialog-info
\"
"
"version=
\"
%s
\"
state=
\"
full
\"
entity=
\"
%s
\"
>
\n
"
,
switch_str_nil
(
switch_event_get_header
(
helper
->
event
,
"event_count"
)),
to
);
if
(
!
strcasecmp
(
state
,
"RING"
))
{
stream
.
write_function
(
&
stream
,
"<dialog id=
\"
%s
\"
direction=
\"
recipient
\"
>
\n
"
,
uuid
);
}
else
{
stream
.
write_function
(
&
stream
,
"<dialog id=
\"
%s
\"
>
\n
"
,
uuid
);
}
stream
.
write_function
(
&
stream
,
"<state>%s</state>
\n
"
,
switch_str_nil
(
switch_event_get_header
(
helper
->
event
,
"answer-state"
)));
if
(
!
strcasecmp
(
status
,
"hold"
))
{
stream
.
write_function
(
&
stream
,
"<local>
\n
<target uri=
\"
%s
\"
>
\n
"
"<param pname=
\"
+sip.rendering
\"
pvalue=
\"
no
\"
>
\n
"
"</target>
\n
</local>
\n
"
,
to
);
}
stream
.
write_function
(
&
stream
,
"</dialog>
\n
</dialog-info>
\n
"
);
pl
=
stream
.
data
;
}
else
{
pl
=
switch_mprintf
(
"<?xml version='1.0' encoding='UTF-8'?>
\r\n
"
"<presence xmlns='urn:ietf:params:xml:ns:pidf'
\r\n
"
"xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model'
\r\n
"
...
...
@@ -610,8 +661,10 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
"</presence>"
,
id
,
id
,
profile
->
url
,
open
,
status
,
prpid
,
open
,
rpid
,
note
);
}
nua_notify
(
nh
,
NUTAG_NEWSUB
(
1
),
SIPTAG_SUBSCRIPTION_STATE_STR
(
"active;expires=3600"
),
SIPTAG_EVENT_STR
(
event
),
SIPTAG_CONTENT_TYPE_STR
(
"application/pidf+xml"
),
SIPTAG_PAYLOAD_STR
(
pl
),
TAG_END
());
...
...
@@ -666,6 +719,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
exp
=
switch_mprintf
(
"active;expires=%ld"
,
expire_sec
);
nua_notify
(
nh
,
NUTAG_NEWSUB
(
1
),
SIPTAG_SUBSCRIPTION_STATE_STR
(
exp
),
SIPTAG_EVENT_STR
(
event
),
SIPTAG_CONTENT_TYPE_STR
(
"application/simple-message-summary"
),
SIPTAG_PAYLOAD_STR
(
body
),
TAG_END
());
...
...
@@ -745,10 +799,13 @@ void sofia_presence_handle_sip_i_subscribe(int status,
const
char
*
display
=
"
\"
user
\"
"
;
switch_event_t
*
sevent
;
int
sub_state
;
int
sent_reply
=
0
;
tl_gets
(
tags
,
NUTAG_SUBSTATE_REF
(
sub_state
),
TAG_END
());
event
=
sip_header_as_string
(
profile
->
home
,
(
void
*
)
sip
->
sip_event
);
if
(
contact
)
{
char
*
port
=
(
char
*
)
contact
->
m_url
->
url_port
;
...
...
@@ -818,7 +875,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"login"
,
"%s"
,
profile
->
name
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
from_user
,
from_host
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"to"
,
"%s@%s"
,
to_user
,
to_host
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"proto-specific-event-name"
,
"%s"
,
event
);
switch_event_fire
(
&
sevent
);
}
}
...
...
@@ -843,7 +900,6 @@ void sofia_presence_handle_sip_i_subscribe(int status,
}
call_id
=
sip
->
sip_call_id
->
i_id
;
event
=
sip_header_as_string
(
profile
->
home
,
(
void
*
)
sip
->
sip_event
);
full_from
=
sip_header_as_string
(
profile
->
home
,
(
void
*
)
sip
->
sip_from
);
full_via
=
sip_header_as_string
(
profile
->
home
,
(
void
*
)
sip
->
sip_via
);
...
...
@@ -881,9 +937,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_mutex_unlock
(
profile
->
ireg_mutex
);
sstr
=
switch_mprintf
(
"active;expires=%ld"
,
exp_raw
);
if
(
status
<
200
)
{
switch_core_hash_insert
(
profile
->
sub_hash
,
call_id
,
nh
);
}
}
if
(
status
<
200
)
{
nua_respond
(
nh
,
SIP_202_ACCEPTED
,
NUTAG_WITH_THIS
(
nua
),
SIPTAG_SUBSCRIPTION_STATE_STR
(
sstr
),
...
...
@@ -891,10 +950,18 @@ void sofia_presence_handle_sip_i_subscribe(int status,
SIPTAG_TO
(
sip
->
sip_from
),
SIPTAG_CONTACT_STR
(
contact_str
),
TAG_END
());
}
nua_notify
(
nh
,
SIPTAG_SUBSCRIPTION_STATE_STR
(
sstr
),
SIPTAG_EVENT_STR
(
event
),
SIPTAG_CONTENT_TYPE_STR
(
"application/octet-stream"
),
SIPTAG_PAYLOAD_STR
(
"Come to ClueCon http://www.cluecon.com
\n\n
"
),
sent_reply
++
;
#if 0
nua_notify(nh,
NUTAG_NEWSUB(1),
SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event),
SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
SIPTAG_PAYLOAD_STR("Note: Come to ClueCon http://www.cluecon.com\n\n"),
TAG_END());
#endif
switch_safe_free
(
sstr
);
...
...
@@ -930,7 +997,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_safe_free
(
d_user
);
switch_safe_free
(
to_str
);
switch_safe_free
(
contact_str
);
if
(
!
sent_reply
)
{
nua_respond
(
nh
,
481
,
"INVALID SUBSCRIPTION"
,
TAG_END
());
}
}
}
void
sofia_presence_handle_sip_r_subscribe
(
int
status
,
...
...
src/switch_channel.c
浏览文件 @
da8d9bc2
...
...
@@ -120,6 +120,7 @@ struct switch_channel {
switch_hash_t
*
private_hash
;
switch_call_cause_t
hangup_cause
;
int
vi
;
int
event_count
;
};
...
...
@@ -305,6 +306,7 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
}
if
(
switch_event_create
(
&
event
,
type
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
channel
,
event
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
"%s"
,
__FILE__
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
"%s"
,
__FILE__
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s"
,
id
);
...
...
@@ -316,6 +318,8 @@ SWITCH_DECLARE(void) switch_channel_presence(switch_channel_t *channel, const ch
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"%s"
,
status
);
}
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"alt_event_type"
,
"dialog"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_count"
,
"%d"
,
channel
->
event_count
++
);
switch_event_fire
(
&
event
);
}
...
...
@@ -588,6 +592,9 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
channel
->
name
,
state_names
[
channel
->
state
]);
channel
->
running_state
=
channel
->
state
;
if
(
channel
->
state
>=
CS_RING
)
{
switch_channel_presence
(
channel
,
"unknown"
,
(
char
*
)
state_names
[
channel
->
state
]);
}
if
(
channel
->
state
<
CS_HANGUP
)
{
switch_event_t
*
event
;
...
...
@@ -601,6 +608,14 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-State-Number"
,
"%s"
,
(
char
*
)
state_num
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Name"
,
"%s"
,
channel
->
name
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Unique-ID"
,
"%s"
,
switch_core_session_get_uuid
(
channel
->
session
));
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Call-Direction"
,
"%s"
,
switch_channel_test_flag
(
channel
,
CF_OUTBOUND
)
?
"outbound"
:
"inbound"
);
if
(
switch_channel_test_flag
(
channel
,
CF_ANSWERED
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Answer-State"
,
"confirmed"
);
}
else
if
(
switch_channel_test_flag
(
channel
,
CF_EARLY_MEDIA
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Answer-State"
,
"early"
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Answer-State"
,
"ringing"
);
}
}
switch_event_fire
(
&
event
);
}
...
...
@@ -799,9 +814,6 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
if
(
ok
)
{
if
(
state
>
CS_RING
)
{
switch_channel_presence
(
channel
,
"unknown"
,
(
char
*
)
state_names
[
state
]);
}
switch_log_printf
(
SWITCH_CHANNEL_ID_LOG
,
file
,
func
,
line
,
NULL
,
SWITCH_LOG_DEBUG
,
"%s State Change %s -> %s
\n
"
,
channel
->
name
,
state_names
[
last_state
],
state_names
[
state
]);
switch_mutex_lock
(
channel
->
flag_mutex
);
...
...
@@ -858,6 +870,15 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel_t *channel, sw
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Name"
,
"%s"
,
switch_channel_get_name
(
channel
));
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Unique-ID"
,
"%s"
,
switch_core_session_get_uuid
(
channel
->
session
));
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Call-Direction"
,
"%s"
,
switch_channel_test_flag
(
channel
,
CF_OUTBOUND
)
?
"outbound"
:
"inbound"
);
if
(
switch_channel_test_flag
(
channel
,
CF_ANSWERED
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Answer-State"
,
"answered"
);
}
else
if
(
switch_channel_test_flag
(
channel
,
CF_EARLY_MEDIA
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Answer-State"
,
"early"
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Answer-State"
,
"ringing"
);
}
if
((
codec
=
switch_core_session_get_read_codec
(
channel
->
session
))
&&
codec
->
implementation
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Read-Codec-Name"
,
"%s"
,
switch_str_nil
(
codec
->
implementation
->
iananame
));
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Read-Codec-Rate"
,
"%u"
,
codec
->
implementation
->
actual_samples_per_second
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论