Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c54f42d7
提交
c54f42d7
authored
1月 12, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more changes to recording code
上级
c37c0298
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
66 行增加
和
9 行删除
+66
-9
switch_core_pvt.h
src/include/private/switch_core_pvt.h
+3
-0
switch_core_io.c
src/switch_core_io.c
+2
-0
switch_core_media_bug.c
src/switch_core_media_bug.c
+50
-6
switch_ivr_async.c
src/switch_ivr_async.c
+11
-3
没有找到文件。
src/include/private/switch_core_pvt.h
浏览文件 @
c54f42d7
...
@@ -196,6 +196,9 @@ struct switch_media_bug {
...
@@ -196,6 +196,9 @@ struct switch_media_bug {
switch_codec_implementation_t
read_impl
;
switch_codec_implementation_t
read_impl
;
switch_codec_implementation_t
write_impl
;
switch_codec_implementation_t
write_impl
;
switch_timer_t
timer
;
switch_timer_t
timer
;
uint32_t
last_read_ts
;
uint32_t
last_write_ts
;
switch_frame_t
*
ping_frame
;
struct
switch_media_bug
*
next
;
struct
switch_media_bug
*
next
;
};
};
...
...
src/switch_core_io.c
浏览文件 @
c54f42d7
...
@@ -658,12 +658,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
...
@@ -658,12 +658,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
if
(
bp
->
ready
&&
switch_test_flag
(
bp
,
SMBF_READ_PING
))
{
if
(
bp
->
ready
&&
switch_test_flag
(
bp
,
SMBF_READ_PING
))
{
switch_mutex_lock
(
bp
->
read_mutex
);
switch_mutex_lock
(
bp
->
read_mutex
);
bp
->
ping_frame
=
*
frame
;
if
(
bp
->
callback
)
{
if
(
bp
->
callback
)
{
if
(
bp
->
callback
(
bp
,
bp
->
user_data
,
SWITCH_ABC_TYPE_READ_PING
)
==
SWITCH_FALSE
if
(
bp
->
callback
(
bp
,
bp
->
user_data
,
SWITCH_ABC_TYPE_READ_PING
)
==
SWITCH_FALSE
||
(
bp
->
stop_time
&&
bp
->
stop_time
<=
switch_epoch_time_now
(
NULL
)))
{
||
(
bp
->
stop_time
&&
bp
->
stop_time
<=
switch_epoch_time_now
(
NULL
)))
{
ok
=
SWITCH_FALSE
;
ok
=
SWITCH_FALSE
;
}
}
}
}
bp
->
ping_frame
=
NULL
;;
switch_mutex_unlock
(
bp
->
read_mutex
);
switch_mutex_unlock
(
bp
->
read_mutex
);
}
}
...
...
src/switch_core_media_bug.c
浏览文件 @
c54f42d7
...
@@ -117,11 +117,15 @@ SWITCH_DECLARE(void *) switch_core_media_bug_get_user_data(switch_media_bug_t *b
...
@@ -117,11 +117,15 @@ SWITCH_DECLARE(void *) switch_core_media_bug_get_user_data(switch_media_bug_t *b
SWITCH_DECLARE
(
void
)
switch_core_media_bug_flush
(
switch_media_bug_t
*
bug
)
SWITCH_DECLARE
(
void
)
switch_core_media_bug_flush
(
switch_media_bug_t
*
bug
)
{
{
if
(
bug
->
raw_read_buffer
)
{
if
(
bug
->
raw_read_buffer
)
{
switch_mutex_lock
(
bug
->
read_mutex
);
switch_buffer_zero
(
bug
->
raw_read_buffer
);
switch_buffer_zero
(
bug
->
raw_read_buffer
);
switch_mutex_unlock
(
bug
->
read_mutex
);
}
}
if
(
bug
->
raw_write_buffer
)
{
if
(
bug
->
raw_write_buffer
)
{
switch_mutex_lock
(
bug
->
write_mutex
);
switch_buffer_zero
(
bug
->
raw_write_buffer
);
switch_buffer_zero
(
bug
->
raw_write_buffer
);
switch_mutex_unlock
(
bug
->
write_mutex
);
}
}
}
}
...
@@ -169,7 +173,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
...
@@ -169,7 +173,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
switch_codec_implementation_t
read_impl
=
{
0
};
switch_codec_implementation_t
read_impl
=
{
0
};
int16_t
*
tp
;
int16_t
*
tp
;
audio_buffer_header_t
rh
=
{
0
},
wh
=
{
0
};
audio_buffer_header_t
rh
=
{
0
},
wh
=
{
0
};
int
do_read
=
0
,
do_write
=
0
;
int
do_read
=
0
,
do_write
=
0
,
fill_read
=
0
,
fill_write
=
0
;
switch_core_session_get_read_impl
(
bug
->
session
,
&
read_impl
);
switch_core_session_get_read_impl
(
bug
->
session
,
&
read_impl
);
...
@@ -187,8 +192,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
...
@@ -187,8 +192,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
frame
->
flags
=
0
;
frame
->
flags
=
0
;
frame
->
datalen
=
0
;
frame
->
datalen
=
0
;
...
@@ -204,24 +207,61 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
...
@@ -204,24 +207,61 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
switch_mutex_unlock
(
bug
->
write_mutex
);
switch_mutex_unlock
(
bug
->
write_mutex
);
}
}
if
(
!
(
do_read
&&
do_write
))
{
if
((
do_read
&&
rh
.
len
>
SWITCH_RECOMMENDED_BUFFER_SIZE
)
||
(
do_write
&&
wh
.
len
>
SWITCH_RECOMMENDED_BUFFER_SIZE
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
switch_core_media_bug_get_session
(
bug
)),
SWITCH_LOG_ERROR
,
"Framing Error!
\n
"
);
switch_core_media_bug_flush
(
bug
);
return
SWITCH_STATUS_FALSE
;
}
if
(
!
((
bug
->
last_read_ts
&&
bug
->
last_write_ts
)
||
(
do_read
&&
do_write
)))
{
return
SWITCH_STATUS_FALSE
;
}
if
(
fill
)
{
fill_read
=
!
do_read
;
fill_write
=
!
do_write
;
}
if
(
fill
&&
fill_read
&&
fill_write
)
{
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
if
(
!
((
do_read
||
fill_read
)
&&
(
do_write
||
fill_write
)))
{
return
SWITCH_STATUS_FALSE
;
}
if
(
do_read
)
{
if
(
do_read
)
{
switch_mutex_lock
(
bug
->
read_mutex
);
switch_mutex_lock
(
bug
->
read_mutex
);
switch_buffer_read
(
bug
->
raw_read_buffer
,
&
rh
,
sizeof
(
rh
));
switch_buffer_read
(
bug
->
raw_read_buffer
,
&
rh
,
sizeof
(
rh
));
bug
->
last_read_ts
=
rh
.
ts
;
frame
->
datalen
=
(
uint32_t
)
switch_buffer_read
(
bug
->
raw_read_buffer
,
frame
->
data
,
rh
.
len
);
frame
->
datalen
=
(
uint32_t
)
switch_buffer_read
(
bug
->
raw_read_buffer
,
frame
->
data
,
rh
.
len
);
if
(
frame
->
datalen
!=
rh
.
len
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
switch_core_media_bug_get_session
(
bug
)),
SWITCH_LOG_ERROR
,
"Framing Error Reading!
\n
"
);
switch_core_media_bug_flush
(
bug
);
return
SWITCH_STATUS_FALSE
;
}
switch_mutex_unlock
(
bug
->
read_mutex
);
switch_mutex_unlock
(
bug
->
read_mutex
);
}
else
if
(
fill_read
)
{
frame
->
datalen
=
bytes
;
memset
(
frame
->
data
,
255
,
frame
->
datalen
);
}
}
if
(
do_write
)
{
if
(
do_write
)
{
switch_assert
(
bug
->
raw_write_buffer
);
switch_assert
(
bug
->
raw_write_buffer
);
switch_mutex_lock
(
bug
->
write_mutex
);
switch_mutex_lock
(
bug
->
write_mutex
);
switch_buffer_read
(
bug
->
raw_write_buffer
,
&
wh
,
sizeof
(
wh
));
switch_buffer_read
(
bug
->
raw_write_buffer
,
&
wh
,
sizeof
(
wh
));
bug
->
last_write_ts
=
wh
.
ts
;
datalen
=
(
uint32_t
)
switch_buffer_read
(
bug
->
raw_write_buffer
,
bug
->
data
,
wh
.
len
);
datalen
=
(
uint32_t
)
switch_buffer_read
(
bug
->
raw_write_buffer
,
bug
->
data
,
wh
.
len
);
if
(
datalen
!=
wh
.
len
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
switch_core_media_bug_get_session
(
bug
)),
SWITCH_LOG_ERROR
,
"Framing Error Writing!
\n
"
);
switch_core_media_bug_flush
(
bug
);
return
SWITCH_STATUS_FALSE
;
}
switch_mutex_unlock
(
bug
->
write_mutex
);
switch_mutex_unlock
(
bug
->
write_mutex
);
}
else
if
(
fill_write
)
{
datalen
=
bytes
;
memset
(
bug
->
data
,
255
,
datalen
);
}
}
tp
=
bug
->
tmp
;
tp
=
bug
->
tmp
;
...
@@ -279,7 +319,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
...
@@ -279,7 +319,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
switch_normalize_to_16bit
(
z
);
switch_normalize_to_16bit
(
z
);
*
(
fp
+
x
)
=
(
int16_t
)
z
/
2
;
*
(
fp
+
x
)
=
(
int16_t
)
z
;
}
}
}
}
...
@@ -288,6 +328,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
...
@@ -288,6 +328,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
frame
->
rate
=
read_impl
.
actual_samples_per_second
;
frame
->
rate
=
read_impl
.
actual_samples_per_second
;
frame
->
codec
=
NULL
;
frame
->
codec
=
NULL
;
if
(
fill_read
&&
fill_write
)
{
return
SWITCH_STATUS_BREAK
;
}
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
...
src/switch_ivr_async.c
浏览文件 @
c54f42d7
...
@@ -1101,7 +1101,13 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
...
@@ -1101,7 +1101,13 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
frame
.
data
=
data
;
frame
.
data
=
data
;
frame
.
buflen
=
SWITCH_RECOMMENDED_BUFFER_SIZE
;
frame
.
buflen
=
SWITCH_RECOMMENDED_BUFFER_SIZE
;
while
(
switch_core_media_bug_read
(
bug
,
&
frame
,
SWITCH_TRUE
)
==
SWITCH_STATUS_SUCCESS
&&
!
switch_test_flag
((
&
frame
),
SFF_CNG
))
{
for
(;;)
{
switch_status_t
status
=
switch_core_media_bug_read
(
bug
,
&
frame
,
SWITCH_FALSE
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
&&
status
!=
SWITCH_STATUS_BREAK
)
{
break
;
}
len
=
(
switch_size_t
)
frame
.
datalen
/
2
;
len
=
(
switch_size_t
)
frame
.
datalen
/
2
;
if
(
len
&&
switch_core_file_write
(
rh
->
fh
,
data
,
&
len
)
!=
SWITCH_STATUS_SUCCESS
&&
rh
->
hangup_on_error
)
{
if
(
len
&&
switch_core_file_write
(
rh
->
fh
,
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_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Error writing %s
\n
"
,
rh
->
file
);
...
@@ -1109,6 +1115,8 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
...
@@ -1109,6 +1115,8 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
switch_core_session_reset
(
session
,
SWITCH_TRUE
,
SWITCH_TRUE
);
switch_core_session_reset
(
session
,
SWITCH_TRUE
,
SWITCH_TRUE
);
return
SWITCH_FALSE
;
return
SWITCH_FALSE
;
}
}
if
(
status
==
SWITCH_STATUS_BREAK
)
break
;
}
}
}
}
...
@@ -1163,7 +1171,7 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data
...
@@ -1163,7 +1171,7 @@ static switch_bool_t eavesdrop_callback(switch_media_bug_t *bug, void *user_data
break
;
break
;
case
SWITCH_ABC_TYPE_READ_PING
:
case
SWITCH_ABC_TYPE_READ_PING
:
if
(
ep
->
buffer
)
{
if
(
ep
->
buffer
)
{
if
(
switch_core_media_bug_read
(
bug
,
&
frame
,
SWITCH_
TRU
E
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_media_bug_read
(
bug
,
&
frame
,
SWITCH_
FALS
E
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_buffer_lock
(
ep
->
buffer
);
switch_buffer_lock
(
ep
->
buffer
);
switch_buffer_zwrite
(
ep
->
buffer
,
frame
.
data
,
frame
.
datalen
);
switch_buffer_zwrite
(
ep
->
buffer
,
frame
.
data
,
frame
.
datalen
);
switch_buffer_unlock
(
ep
->
buffer
);
switch_buffer_unlock
(
ep
->
buffer
);
...
@@ -3465,7 +3473,7 @@ static switch_bool_t speech_callback(switch_media_bug_t *bug, void *user_data, s
...
@@ -3465,7 +3473,7 @@ static switch_bool_t speech_callback(switch_media_bug_t *bug, void *user_data, s
break
;
break
;
case
SWITCH_ABC_TYPE_READ
:
case
SWITCH_ABC_TYPE_READ
:
if
(
sth
->
ah
)
{
if
(
sth
->
ah
)
{
if
(
switch_core_media_bug_read
(
bug
,
&
frame
,
SWITCH_
TRU
E
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_media_bug_read
(
bug
,
&
frame
,
SWITCH_
FALS
E
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_asr_feed
(
sth
->
ah
,
frame
.
data
,
frame
.
datalen
,
&
flags
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_asr_feed
(
sth
->
ah
,
frame
.
data
,
frame
.
datalen
,
&
flags
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
switch_core_media_bug_get_session
(
bug
)),
SWITCH_LOG_DEBUG
,
"Error Feeding Data
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
switch_core_media_bug_get_session
(
bug
)),
SWITCH_LOG_DEBUG
,
"Error Feeding Data
\n
"
);
return
SWITCH_FALSE
;
return
SWITCH_FALSE
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论