Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
5891951e
提交
5891951e
authored
1月 30, 2014
作者:
Chris Rienzo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod_rayo: fixed output start-offset and max-time
上级
e0b1dcdf
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
37 行增加
和
12 行删除
+37
-12
rayo_output_component.c
src/mod/event_handlers/mod_rayo/rayo_output_component.c
+37
-12
没有找到文件。
src/mod/event_handlers/mod_rayo/rayo_output_component.c
浏览文件 @
5891951e
...
@@ -37,10 +37,12 @@ struct output_component {
...
@@ -37,10 +37,12 @@ struct output_component {
struct
rayo_component
base
;
struct
rayo_component
base
;
/** document to play */
/** document to play */
iks
*
document
;
iks
*
document
;
/** where to start playing in document */
int
start_offset_ms
;
/** maximum time to play */
/** maximum time to play */
int
max_time
;
int
max_time
_ms
;
/** silence between repeats */
/** silence between repeats */
int
repeat_interval
;
int
repeat_interval
_ms
;
/** number of times to repeat */
/** number of times to repeat */
int
repeat_times
;
int
repeat_times
;
/** true if started paused */
/** true if started paused */
...
@@ -69,9 +71,10 @@ static struct rayo_component *create_output_component(struct rayo_actor *actor,
...
@@ -69,9 +71,10 @@ static struct rayo_component *create_output_component(struct rayo_actor *actor,
rayo_component_init
((
struct
rayo_component
*
)
output_component
,
pool
,
type
,
"output"
,
NULL
,
actor
,
client_jid
);
rayo_component_init
((
struct
rayo_component
*
)
output_component
,
pool
,
type
,
"output"
,
NULL
,
actor
,
client_jid
);
output_component
->
document
=
iks_copy
(
output
);
output_component
->
document
=
iks_copy
(
output
);
output_component
->
repeat_interval
=
iks_find_int_attrib
(
output
,
"repeat-interval"
);
output_component
->
start_offset_ms
=
iks_find_int_attrib
(
output
,
"start-offset"
);
output_component
->
repeat_interval_ms
=
iks_find_int_attrib
(
output
,
"repeat-interval"
);
output_component
->
repeat_times
=
iks_find_int_attrib
(
output
,
"repeat-times"
);
output_component
->
repeat_times
=
iks_find_int_attrib
(
output
,
"repeat-times"
);
output_component
->
max_time
=
iks_find_int_attrib
(
output
,
"max-time"
);
output_component
->
max_time
_ms
=
iks_find_int_attrib
(
output
,
"max-time"
);
output_component
->
start_paused
=
iks_find_bool_attrib
(
output
,
"start-paused"
);
output_component
->
start_paused
=
iks_find_bool_attrib
(
output
,
"start-paused"
);
output_component
->
renderer
=
iks_find_attrib
(
output
,
"renderer"
);
output_component
->
renderer
=
iks_find_attrib
(
output
,
"renderer"
);
...
@@ -97,8 +100,11 @@ static iks *start_call_output(struct rayo_component *component, switch_core_sess
...
@@ -97,8 +100,11 @@ static iks *start_call_output(struct rayo_component *component, switch_core_sess
stream
.
write_function
(
&
stream
,
"{id=%s,session=%s,pause=%s"
,
stream
.
write_function
(
&
stream
,
"{id=%s,session=%s,pause=%s"
,
RAYO_JID
(
component
),
switch_core_session_get_uuid
(
session
),
RAYO_JID
(
component
),
switch_core_session_get_uuid
(
session
),
OUTPUT_COMPONENT
(
component
)
->
start_paused
?
"true"
:
"false"
);
OUTPUT_COMPONENT
(
component
)
->
start_paused
?
"true"
:
"false"
);
if
(
OUTPUT_COMPONENT
(
component
)
->
max_time
>
0
)
{
if
(
OUTPUT_COMPONENT
(
component
)
->
max_time_ms
>
0
)
{
stream
.
write_function
(
&
stream
,
",timeout=%i"
,
OUTPUT_COMPONENT
(
component
)
->
max_time
*
1000
);
stream
.
write_function
(
&
stream
,
",timeout=%i"
,
OUTPUT_COMPONENT
(
component
)
->
max_time_ms
);
}
if
(
OUTPUT_COMPONENT
(
component
)
->
start_offset_ms
>
0
)
{
stream
.
write_function
(
&
stream
,
",start_offset_ms=%i"
,
OUTPUT_COMPONENT
(
component
)
->
start_offset_ms
);
}
}
stream
.
write_function
(
&
stream
,
"}fileman://rayo://%s"
,
RAYO_JID
(
component
));
stream
.
write_function
(
&
stream
,
"}fileman://rayo://%s"
,
RAYO_JID
(
component
));
...
@@ -181,8 +187,11 @@ static iks *start_mixer_output_component(struct rayo_actor *mixer, struct rayo_m
...
@@ -181,8 +187,11 @@ static iks *start_mixer_output_component(struct rayo_actor *mixer, struct rayo_m
stream
.
write_function
(
&
stream
,
"{id=%s,pause=%s"
,
stream
.
write_function
(
&
stream
,
"{id=%s,pause=%s"
,
RAYO_JID
(
component
),
RAYO_JID
(
component
),
OUTPUT_COMPONENT
(
component
)
->
start_paused
?
"true"
:
"false"
);
OUTPUT_COMPONENT
(
component
)
->
start_paused
?
"true"
:
"false"
);
if
(
OUTPUT_COMPONENT
(
component
)
->
max_time
>
0
)
{
if
(
OUTPUT_COMPONENT
(
component
)
->
max_time_ms
>
0
)
{
stream
.
write_function
(
&
stream
,
",timeout=%i"
,
OUTPUT_COMPONENT
(
component
)
->
max_time
*
1000
);
stream
.
write_function
(
&
stream
,
",timeout=%i"
,
OUTPUT_COMPONENT
(
component
)
->
max_time_ms
);
}
if
(
OUTPUT_COMPONENT
(
component
)
->
start_offset_ms
>
0
)
{
stream
.
write_function
(
&
stream
,
",start_offset_ms=%i"
,
OUTPUT_COMPONENT
(
component
)
->
start_offset_ms
);
}
}
stream
.
write_function
(
&
stream
,
"}fileman://rayo://%s"
,
RAYO_JID
(
component
));
stream
.
write_function
(
&
stream
,
"}fileman://rayo://%s"
,
RAYO_JID
(
component
));
...
@@ -388,7 +397,7 @@ static switch_status_t next_file(switch_file_handle_t *handle)
...
@@ -388,7 +397,7 @@ static switch_status_t next_file(switch_file_handle_t *handle)
if
(
!
context
->
cur_doc
)
{
if
(
!
context
->
cur_doc
)
{
if
(
output
->
repeat_times
==
0
||
++
context
->
play_count
<
output
->
repeat_times
)
{
if
(
output
->
repeat_times
==
0
||
++
context
->
play_count
<
output
->
repeat_times
)
{
/* repeat all document(s) */
/* repeat all document(s) */
if
(
!
output
->
repeat_interval
)
{
if
(
!
output
->
repeat_interval
_ms
)
{
goto
top
;
goto
top
;
}
}
}
else
{
}
else
{
...
@@ -401,7 +410,7 @@ static switch_status_t next_file(switch_file_handle_t *handle)
...
@@ -401,7 +410,7 @@ static switch_status_t next_file(switch_file_handle_t *handle)
if
(
!
context
->
cur_doc
)
{
if
(
!
context
->
cur_doc
)
{
/* play silence between repeats */
/* play silence between repeats */
switch_safe_free
(
context
->
ssml
);
switch_safe_free
(
context
->
ssml
);
context
->
ssml
=
switch_mprintf
(
"silence_stream://%i"
,
output
->
repeat_interval
);
context
->
ssml
=
switch_mprintf
(
"silence_stream://%i"
,
output
->
repeat_interval
_ms
);
}
else
{
}
else
{
/* play next document */
/* play next document */
iks
*
speak
=
NULL
;
iks
*
speak
=
NULL
;
...
@@ -645,6 +654,7 @@ struct fileman_file_context {
...
@@ -645,6 +654,7 @@ struct fileman_file_context {
*/
*/
static
switch_status_t
fileman_file_open
(
switch_file_handle_t
*
handle
,
const
char
*
path
)
static
switch_status_t
fileman_file_open
(
switch_file_handle_t
*
handle
,
const
char
*
path
)
{
{
int
start_offset_ms
=
0
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
struct
fileman_file_context
*
context
=
switch_core_alloc
(
handle
->
memory_pool
,
sizeof
(
*
context
));
struct
fileman_file_context
*
context
=
switch_core_alloc
(
handle
->
memory_pool
,
sizeof
(
*
context
));
handle
->
private_info
=
context
;
handle
->
private_info
=
context
;
...
@@ -652,12 +662,19 @@ static switch_status_t fileman_file_open(switch_file_handle_t *handle, const cha
...
@@ -652,12 +662,19 @@ static switch_status_t fileman_file_open(switch_file_handle_t *handle, const cha
if
(
handle
->
params
)
{
if
(
handle
->
params
)
{
const
char
*
id
=
switch_event_get_header
(
handle
->
params
,
"id"
);
const
char
*
id
=
switch_event_get_header
(
handle
->
params
,
"id"
);
const
char
*
uuid
=
switch_event_get_header
(
handle
->
params
,
"session"
);
const
char
*
uuid
=
switch_event_get_header
(
handle
->
params
,
"session"
);
const
char
*
start_offset_ms_str
=
switch_event_get_header
(
handle
->
params
,
"start_offset_ms"
);
if
(
!
zstr
(
id
))
{
if
(
!
zstr
(
id
))
{
context
->
id
=
switch_core_strdup
(
handle
->
memory_pool
,
id
);
context
->
id
=
switch_core_strdup
(
handle
->
memory_pool
,
id
);
}
}
if
(
!
zstr
(
uuid
))
{
if
(
!
zstr
(
uuid
))
{
context
->
uuid
=
switch_core_strdup
(
handle
->
memory_pool
,
uuid
);
context
->
uuid
=
switch_core_strdup
(
handle
->
memory_pool
,
uuid
);
}
}
if
(
!
zstr
(
start_offset_ms_str
)
&&
switch_is_number
(
start_offset_ms_str
))
{
start_offset_ms
=
atoi
(
start_offset_ms_str
);
if
(
start_offset_ms
<
0
)
{
start_offset_ms
=
0
;
}
}
}
}
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
context
->
uuid
),
SWITCH_LOG_DEBUG
,
"Got path %s
\n
"
,
path
);
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
context
->
uuid
),
SWITCH_LOG_DEBUG
,
"Got path %s
\n
"
,
path
);
...
@@ -708,6 +725,13 @@ static switch_status_t fileman_file_open(switch_file_handle_t *handle, const cha
...
@@ -708,6 +725,13 @@ static switch_status_t fileman_file_open(switch_file_handle_t *handle, const cha
switch_set_flag
(
handle
,
SWITCH_FILE_PAUSE
);
switch_set_flag
(
handle
,
SWITCH_FILE_PAUSE
);
}
}
if
(
handle
->
seekable
&&
start_offset_ms
)
{
unsigned
int
pos
=
0
;
int32_t
target
=
start_offset_ms
*
(
handle
->
samplerate
/
1000
);
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
context
->
uuid
),
SWITCH_LOG_DEBUG
,
"seek to position %d
\n
"
,
target
);
switch_core_file_seek
(
&
context
->
fh
,
&
pos
,
target
,
SEEK_SET
);
}
return
status
;
return
status
;
}
}
...
@@ -976,6 +1000,7 @@ static switch_status_t fileman_process_cmd(const char *cmd, switch_file_handle_t
...
@@ -976,6 +1000,7 @@ static switch_status_t fileman_process_cmd(const char *cmd, switch_file_handle_t
}
}
if
(
fhp
)
{
if
(
fhp
)
{
struct
fileman_file_context
*
context
=
(
struct
fileman_file_context
*
)
fhp
->
private_info
;
if
(
!
switch_test_flag
(
fhp
,
SWITCH_FILE_OPEN
))
{
if
(
!
switch_test_flag
(
fhp
,
SWITCH_FILE_OPEN
))
{
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
...
@@ -1072,12 +1097,12 @@ static switch_status_t fileman_process_cmd(const char *cmd, switch_file_handle_t
...
@@ -1072,12 +1097,12 @@ static switch_status_t fileman_process_cmd(const char *cmd, switch_file_handle_t
target
=
0
;
target
=
0
;
}
}
switch_log_printf
(
SWITCH_CHANNEL_
LOG
,
SWITCH_LOG_DEBUG
,
"seek to position %d
\n
"
,
target
);
switch_log_printf
(
SWITCH_CHANNEL_
UUID_LOG
(
context
->
uuid
)
,
SWITCH_LOG_DEBUG
,
"seek to position %d
\n
"
,
target
);
switch_core_file_seek
(
fhp
,
&
pos
,
target
,
SEEK_SET
);
switch_core_file_seek
(
fhp
,
&
pos
,
target
,
SEEK_SET
);
}
else
{
}
else
{
samps
=
switch_atoui
(
p
)
*
(
fhp
->
samplerate
/
1000
);
samps
=
switch_atoui
(
p
)
*
(
fhp
->
samplerate
/
1000
);
switch_log_printf
(
SWITCH_CHANNEL_
LOG
,
SWITCH_LOG_DEBUG
,
"seek to position %d
\n
"
,
samps
);
switch_log_printf
(
SWITCH_CHANNEL_
UUID_LOG
(
context
->
uuid
)
,
SWITCH_LOG_DEBUG
,
"seek to position %d
\n
"
,
samps
);
switch_core_file_seek
(
fhp
,
&
pos
,
samps
,
SEEK_SET
);
switch_core_file_seek
(
fhp
,
&
pos
,
samps
,
SEEK_SET
);
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论