Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
db9c908f
提交
db9c908f
authored
12月 04, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add vars
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@6499
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
58c43fc8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
67 行增加
和
18 行删除
+67
-18
mod_commands.c
src/mod/applications/mod_commands/mod_commands.c
+51
-18
switch_core_codec.c
src/switch_core_codec.c
+16
-0
没有找到文件。
src/mod/applications/mod_commands/mod_commands.c
浏览文件 @
db9c908f
...
...
@@ -48,23 +48,31 @@ SWITCH_STANDARD_API(find_user_function)
char
*
mydata
=
NULL
,
*
argv
[
3
];
char
*
key
,
*
user
,
*
domain
;
char
*
xmlstr
;
if
(
stream
->
event
&&
switch_event_get_header
(
stream
->
event
,
"http-host"
))
{
char
*
path_info
=
NULL
;
char
delim
=
' '
;
char
*
host
=
NULL
;
const
char
*
err
=
NULL
;
if
(
stream
->
event
&&
(
host
=
switch_event_get_header
(
stream
->
event
,
"http-host"
)))
{
stream
->
write_function
(
stream
,
"Content-Type: text/xml
\r\n\r\n
"
);
if
((
path_info
=
switch_event_get_header
(
stream
->
event
,
"http-path-info"
)))
{
cmd
=
path_info
;
delim
=
'/'
;
}
}
if
(
!
cmd
)
{
stream
->
write_function
(
stream
,
"-ERR bad args
\n
"
)
;
err
=
"bad args"
;
goto
end
;
}
mydata
=
strdup
(
cmd
);
assert
(
mydata
);
argc
=
switch_separate_string
(
mydata
,
' '
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])));
argc
=
switch_separate_string
(
mydata
,
delim
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])));
if
(
argc
<
3
)
{
stream
->
write_function
(
stream
,
"-ERR bad args
\n
"
)
;
err
=
"bad args"
;
goto
end
;
}
...
...
@@ -73,18 +81,26 @@ SWITCH_STANDARD_API(find_user_function)
domain
=
argv
[
2
];
if
(
!
(
key
&&
user
&&
domain
))
{
stream
->
write_function
(
stream
,
"-ERR bad args
\n
"
)
;
err
=
"bad args"
;
goto
end
;
}
if
(
switch_xml_locate_user
(
key
,
user
,
domain
,
NULL
,
&
xml
,
&
x_domain
,
&
x_user
,
NULL
)
!=
SWITCH_STATUS_SUCCESS
)
{
stream
->
write_function
(
stream
,
"-ERR can't find user [%s@%s]
\n
"
,
user
,
domain
)
;
err
=
"can't find user"
;
goto
end
;
}
end
:
if
(
err
)
{
if
(
host
)
{
stream
->
write_function
(
stream
,
"<error>%s</error>
\n
"
,
err
);
}
else
{
stream
->
write_function
(
stream
,
"-Error %s
\n
"
,
err
);
}
}
if
(
xml
&&
x_user
)
{
xmlstr
=
switch_xml_toxml
(
x_user
,
SWITCH_FALSE
);
assert
(
xmlstr
);
...
...
@@ -108,21 +124,28 @@ SWITCH_STANDARD_API(xml_locate_function)
char
*
mydata
=
NULL
,
*
argv
[
4
];
char
*
section
,
*
tag
,
*
tag_attr_name
,
*
tag_attr_val
,
*
params
=
NULL
;
char
*
xmlstr
;
char
*
path_info
,
delim
=
' '
;
char
*
host
=
NULL
;
const
char
*
err
=
NULL
;
if
(
stream
->
event
&&
(
host
=
switch_event_get_header
(
stream
->
event
,
"http-host"
)))
{
stream
->
write_function
(
stream
,
"Content-Type: text/xml
\r\n\r\n
"
);
if
((
path_info
=
switch_event_get_header
(
stream
->
event
,
"http-path-info"
)))
{
cmd
=
path_info
;
delim
=
'/'
;
}
}
if
(
!
cmd
)
{
stream
->
write_function
(
stream
,
"-ERR bad args
\n
"
)
;
err
=
"bad args"
;
goto
end
;
}
if
(
stream
->
event
&&
switch_event_get_header
(
stream
->
event
,
"http-host"
))
{
stream
->
write_function
(
stream
,
"Content-Type: text/xml
\r\n\r\n
"
);
}
mydata
=
strdup
(
cmd
);
assert
(
mydata
);
argc
=
switch_separate_string
(
mydata
,
' '
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])));
argc
=
switch_separate_string
(
mydata
,
delim
,
argv
,
(
sizeof
(
argv
)
/
sizeof
(
argv
[
0
])));
if
(
argc
==
1
&&
!
strcasecmp
(
argv
[
0
],
"root"
))
{
const
char
*
err
;
...
...
@@ -132,7 +155,7 @@ SWITCH_STANDARD_API(xml_locate_function)
}
if
(
argc
<
4
)
{
stream
->
write_function
(
stream
,
"-ERR bad args
\n
"
)
;
err
=
"bad args"
;
goto
end
;
}
...
...
@@ -144,13 +167,21 @@ SWITCH_STANDARD_API(xml_locate_function)
params
=
switch_mprintf
(
"section=%s&tag=%s&tag_attr_name=%s&tag_attr_val=%s"
,
section
,
tag
,
tag_attr_name
,
tag_attr_val
);
assert
(
params
);
if
(
switch_xml_locate
(
section
,
tag
,
tag_attr_name
,
tag_attr_val
,
&
xml
,
&
obj
,
params
)
!=
SWITCH_STATUS_SUCCESS
)
{
stream
->
write_function
(
stream
,
"
-ERR
can't find anything
\n
"
);
stream
->
write_function
(
stream
,
"can't find anything
\n
"
);
goto
end
;
}
end
:
if
(
err
)
{
if
(
host
)
{
stream
->
write_function
(
stream
,
"<error>%s</error>
\n
"
,
err
);
}
else
{
stream
->
write_function
(
stream
,
"-Error %s
\n
"
,
err
);
}
}
switch_safe_free
(
params
);
if
(
xml
&&
obj
)
{
...
...
@@ -168,7 +199,6 @@ SWITCH_STANDARD_API(xml_locate_function)
}
SWITCH_STANDARD_API
(
regex_function
)
{
switch_regex_t
*
re
=
NULL
;
...
...
@@ -652,7 +682,8 @@ SWITCH_STANDARD_API(tone_detect_session_function)
char
*
mydata
=
NULL
;
time_t
to
=
0
;
switch_core_session_t
*
rsession
;
if
(
!
cmd
)
{
stream
->
write_function
(
stream
,
"-USAGE: %s
\n
"
,
TONE_DETECT_SYNTAX
);
return
SWITCH_STATUS_SUCCESS
;
...
...
@@ -665,11 +696,13 @@ SWITCH_STANDARD_API(tone_detect_session_function)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"-ERR INVALID ARGS!
\n
"
);
}
if
(
!
(
rsession
=
switch_core_session_locate
(
argv
[
0
])))
{
stream
->
write_function
(
stream
,
"-ERR Error Cannot locate session!
\n
"
);
return
SWITCH_STATUS_SUCCESS
;
}
if
(
argv
[
4
])
{
uint32_t
mto
;
if
(
*
argv
[
4
]
==
'+'
)
{
...
...
src/switch_core_codec.c
浏览文件 @
db9c908f
...
...
@@ -37,8 +37,11 @@
SWITCH_DECLARE
(
switch_status_t
)
switch_core_session_set_read_codec
(
switch_core_session_t
*
session
,
switch_codec_t
*
codec
)
{
switch_event_t
*
event
;
switch_channel_t
*
channel
;
char
tmp
[
30
];
assert
(
session
!=
NULL
);
channel
=
switch_core_session_get_channel
(
session
);
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_CODEC
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
session
->
channel
,
event
);
...
...
@@ -50,6 +53,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
switch_event_fire
(
&
event
);
}
switch_channel_set_variable
(
channel
,
"read_codec"
,
codec
->
implementation
->
iananame
);
snprintf
(
tmp
,
sizeof
(
tmp
),
"%d"
,
codec
->
implementation
->
actual_samples_per_second
);
switch_channel_set_variable
(
channel
,
"read_rate"
,
tmp
);
session
->
read_codec
=
codec
;
session
->
raw_read_frame
.
codec
=
session
->
read_codec
;
session
->
raw_write_frame
.
codec
=
session
->
read_codec
;
...
...
@@ -67,7 +74,12 @@ SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(switch_core_
SWITCH_DECLARE
(
switch_status_t
)
switch_core_session_set_write_codec
(
switch_core_session_t
*
session
,
switch_codec_t
*
codec
)
{
switch_event_t
*
event
;
switch_channel_t
*
channel
;
char
tmp
[
30
];
assert
(
session
!=
NULL
);
channel
=
switch_core_session_get_channel
(
session
);
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_CODEC
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_channel_event_set_data
(
session
->
channel
,
event
);
...
...
@@ -79,6 +91,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_
switch_event_fire
(
&
event
);
}
switch_channel_set_variable
(
channel
,
"write_codec"
,
codec
->
implementation
->
iananame
);
snprintf
(
tmp
,
sizeof
(
tmp
),
"%d"
,
codec
->
implementation
->
actual_samples_per_second
);
switch_channel_set_variable
(
channel
,
"write_rate"
,
tmp
);
session
->
write_codec
=
codec
;
return
SWITCH_STATUS_SUCCESS
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论