Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
1b612fec
提交
1b612fec
authored
9月 02, 2014
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-6757 FS-6713 #comment please try latest master that has a new patch in it to address this issue
上级
acb439ca
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
86 行增加
和
36 行删除
+86
-36
switch_core_pvt.h
src/include/private/switch_core_pvt.h
+3
-0
switch_core_io.c
src/switch_core_io.c
+52
-2
switch_ivr_async.c
src/switch_ivr_async.c
+31
-34
没有找到文件。
src/include/private/switch_core_pvt.h
浏览文件 @
1b612fec
...
...
@@ -179,6 +179,9 @@ struct switch_core_session {
switch_media_handle_t
*
media_handle
;
uint32_t
decoder_errors
;
switch_time_t
last_read_time
;
switch_time_t
last_write_time
;
};
struct
switch_media_bug
{
...
...
src/switch_core_io.c
浏览文件 @
1b612fec
...
...
@@ -762,11 +762,26 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
switch_media_bug_t
*
bp
;
switch_bool_t
ok
=
SWITCH_TRUE
;
int
prune
=
0
;
switch_time_t
now
=
switch_micro_time_now
();
switch_time_t
diff
=
0
;
switch_size_t
len
=
session
->
read_impl
.
decoded_bytes_per_packet
;
unsigned
char
fill_data
[
SWITCH_RECOMMENDED_BUFFER_SIZE
]
=
{
0
};
switch_thread_rwlock_rdlock
(
session
->
bug_rwlock
);
if
(
session
->
last_read_time
&&
session
->
last_read_time
<
now
)
{
diff
=
((
now
-
session
->
last_read_time
)
+
3000
)
/
session
->
read_impl
.
microseconds_per_packet
;
if
(
diff
>
1
)
{
memset
(
fill_data
,
255
,
len
);
}
}
session
->
last_read_time
=
switch_micro_time_now
();
for
(
bp
=
session
->
bugs
;
bp
;
bp
=
bp
->
next
)
{
ok
=
SWITCH_TRUE
;
if
(
switch_channel_test_flag
(
session
->
channel
,
CF_PAUSE_BUGS
)
&&
!
switch_core_media_bug_test_flag
(
bp
,
SMBF_NO_PAUSE
))
{
continue
;
}
...
...
@@ -786,6 +801,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
if
(
ok
&&
bp
->
ready
&&
switch_test_flag
(
bp
,
SMBF_READ_STREAM
))
{
switch_mutex_lock
(
bp
->
read_mutex
);
if
(
diff
>
1
)
{
switch_time_t
tdiff
=
diff
;
while
(
tdiff
>
1
)
{
switch_buffer_write
(
bp
->
raw_read_buffer
,
fill_data
,
len
);
tdiff
--
;
}
}
if
(
bp
->
read_demux_frame
)
{
uint8_t
data
[
SWITCH_RECOMMENDED_BUFFER_SIZE
];
int
bytes
=
read_frame
->
datalen
/
2
;
...
...
@@ -1341,8 +1367,23 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
if
(
session
->
bugs
)
{
switch_media_bug_t
*
bp
;
int
prune
=
0
;
switch_time_t
now
=
switch_micro_time_now
();
switch_time_t
diff
=
0
;
switch_size_t
len
=
session
->
read_impl
.
decoded_bytes_per_packet
;
unsigned
char
fill_data
[
SWITCH_RECOMMENDED_BUFFER_SIZE
]
=
{
0
};
switch_thread_rwlock_rdlock
(
session
->
bug_rwlock
);
if
(
session
->
last_write_time
&&
session
->
last_write_time
<
now
)
{
diff
=
((
now
-
session
->
last_write_time
)
+
3000
)
/
session
->
read_impl
.
microseconds_per_packet
;
if
(
diff
>
1
)
{
memset
(
fill_data
,
255
,
len
);
}
}
session
->
last_write_time
=
switch_micro_time_now
();
for
(
bp
=
session
->
bugs
;
bp
;
bp
=
bp
->
next
)
{
switch_bool_t
ok
=
SWITCH_TRUE
;
...
...
@@ -1365,6 +1406,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
if
(
switch_test_flag
(
bp
,
SMBF_WRITE_STREAM
))
{
switch_mutex_lock
(
bp
->
write_mutex
);
if
(
diff
>
1
)
{
switch_time_t
tdiff
=
diff
;
while
(
tdiff
>
1
)
{
switch_buffer_write
(
bp
->
raw_read_buffer
,
fill_data
,
len
);
tdiff
--
;
}
}
switch_buffer_write
(
bp
->
raw_write_buffer
,
write_frame
->
data
,
write_frame
->
datalen
);
switch_mutex_unlock
(
bp
->
write_mutex
);
...
...
src/switch_ivr_async.c
浏览文件 @
1b612fec
...
...
@@ -1268,47 +1268,44 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
frame
.
data
=
data
;
frame
.
buflen
=
SWITCH_RECOMMENDED_BUFFER_SIZE
;
for
(;;)
{
status
=
switch_core_media_bug_read
(
bug
,
&
frame
,
SWITCH_FALSE
);
if
(
status
==
SWITCH_STATUS_SUCCESS
||
status
==
SWITCH_STATUS_BREAK
)
{
status
=
switch_core_media_bug_read
(
bug
,
&
frame
,
SWITCH_FALSE
);
if
(
status
==
SWITCH_STATUS_SUCCESS
||
status
==
SWITCH_STATUS_BREAK
)
{
len
=
(
switch_size_t
)
frame
.
datalen
/
2
;
len
=
(
switch_size_t
)
frame
.
datalen
/
2
;
if
(
len
&&
switch_core_file_write
(
rh
->
fh
,
mask
?
null_data
:
data
,
&
len
)
!=
SWITCH_STATUS_SUCCESS
&&
rh
->
hangup_on_error
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Error writing %s
\n
"
,
rh
->
file
);
switch_channel_hangup
(
channel
,
SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER
);
switch_core_session_reset
(
session
,
SWITCH_TRUE
,
SWITCH_TRUE
);
return
SWITCH_FALSE
;
}
if
(
len
&&
switch_core_file_write
(
rh
->
fh
,
mask
?
null_data
:
data
,
&
len
)
!=
SWITCH_STATUS_SUCCESS
&&
rh
->
hangup_on_error
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Error writing %s
\n
"
,
rh
->
file
);
switch_channel_hangup
(
channel
,
SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER
);
switch_core_session_reset
(
session
,
SWITCH_TRUE
,
SWITCH_TRUE
);
return
SWITCH_FALSE
;
}
/* check for silence timeout */
if
(
rh
->
silence_threshold
)
{
switch_codec_implementation_t
read_impl
=
{
0
};
switch_core_session_get_read_impl
(
session
,
&
read_impl
);
if
(
is_silence_frame
(
&
frame
,
rh
->
silence_threshold
,
&
read_impl
))
{
if
(
!
rh
->
silence_time
)
{
/* start of silence */
rh
->
silence_time
=
switch_micro_time_now
();
}
else
{
/* continuing silence */
int
duration_ms
=
(
int
)((
switch_micro_time_now
()
-
rh
->
silence_time
)
/
1000
);
if
(
rh
->
silence_timeout_ms
>
0
&&
duration_ms
>=
rh
->
silence_timeout_ms
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Recording file %s timeout: %i >= %i
\n
"
,
rh
->
file
,
duration_ms
,
rh
->
silence_timeout_ms
);
switch_core_media_bug_set_flag
(
bug
,
SMBF_PRUNE
);
}
}
}
else
{
/* not silence */
if
(
rh
->
silence_time
)
{
/* end of silence */
rh
->
silence_time
=
0
;
/* switch from initial timeout to final timeout */
rh
->
silence_timeout_ms
=
rh
->
final_timeout_ms
;
/* check for silence timeout */
if
(
rh
->
silence_threshold
)
{
switch_codec_implementation_t
read_impl
=
{
0
};
switch_core_session_get_read_impl
(
session
,
&
read_impl
);
if
(
is_silence_frame
(
&
frame
,
rh
->
silence_threshold
,
&
read_impl
))
{
if
(
!
rh
->
silence_time
)
{
/* start of silence */
rh
->
silence_time
=
switch_micro_time_now
();
}
else
{
/* continuing silence */
int
duration_ms
=
(
int
)((
switch_micro_time_now
()
-
rh
->
silence_time
)
/
1000
);
if
(
rh
->
silence_timeout_ms
>
0
&&
duration_ms
>=
rh
->
silence_timeout_ms
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Recording file %s timeout: %i >= %i
\n
"
,
rh
->
file
,
duration_ms
,
rh
->
silence_timeout_ms
);
switch_core_media_bug_set_flag
(
bug
,
SMBF_PRUNE
);
}
}
}
else
{
/* not silence */
if
(
rh
->
silence_time
)
{
/* end of silence */
rh
->
silence_time
=
0
;
/* switch from initial timeout to final timeout */
rh
->
silence_timeout_ms
=
rh
->
final_timeout_ms
;
}
}
}
else
{
break
;
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论