Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
fbce9061
提交
fbce9061
authored
3月 19, 2011
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod_portaudio: implement endpoint reads
上级
877b4cf5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
58 行增加
和
1 行删除
+58
-1
mod_portaudio.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
+58
-1
没有找到文件。
src/mod/endpoints/mod_portaudio/mod_portaudio.c
浏览文件 @
fbce9061
...
@@ -137,9 +137,13 @@ typedef struct _audio_endpoint {
...
@@ -137,9 +137,13 @@ typedef struct _audio_endpoint {
/*! Associated private information if involved in a call */
/*! Associated private information if involved in a call */
private_t
*
master
;
private_t
*
master
;
/*! For timed writes */
/*! For timed read and writes */
switch_timer_t
read_timer
;
switch_timer_t
write_timer
;
switch_timer_t
write_timer
;
/* We need our own read frame */
switch_frame_t
read_frame
;
/*! Let's be safe */
/*! Let's be safe */
switch_mutex_t
*
mutex
;
switch_mutex_t
*
mutex
;
}
audio_endpoint_t
;
}
audio_endpoint_t
;
...
@@ -725,11 +729,21 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
...
@@ -725,11 +729,21 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
static
int
release_stream_channel
(
shared_audio_stream_t
*
stream
,
int
index
,
int
input
);
static
switch_status_t
channel_on_hangup
(
switch_core_session_t
*
session
)
static
switch_status_t
channel_on_hangup
(
switch_core_session_t
*
session
)
{
{
private_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
private_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
switch_assert
(
tech_pvt
!=
NULL
);
switch_assert
(
tech_pvt
!=
NULL
);
if
(
tech_pvt
->
audio_endpoint
)
{
audio_endpoint_t
*
endpoint
=
tech_pvt
->
audio_endpoint
;
switch_mutex_lock
(
endpoint
->
mutex
);
/* release the stream channels */
release_stream_channel
(
endpoint
->
in_stream
,
endpoint
->
inchan
,
1
);
release_stream_channel
(
endpoint
->
out_stream
,
endpoint
->
outchan
,
0
);
switch_mutex_unlock
(
endpoint
->
mutex
);
}
switch_mutex_lock
(
globals
.
pa_mutex
);
switch_mutex_lock
(
globals
.
pa_mutex
);
switch_core_hash_delete
(
globals
.
call_hash
,
tech_pvt
->
call_id
);
switch_core_hash_delete
(
globals
.
call_hash
,
tech_pvt
->
call_id
);
switch_mutex_unlock
(
globals
.
pa_mutex
);
switch_mutex_unlock
(
globals
.
pa_mutex
);
...
@@ -789,12 +803,40 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, const s
...
@@ -789,12 +803,40 @@ static switch_status_t channel_send_dtmf(switch_core_session_t *session, const s
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
static
switch_status_t
channel_endpoint_read
(
audio_endpoint_t
*
endpoint
,
switch_frame_t
**
frame
)
{
int
samples
=
0
;
if
(
!
endpoint
->
in_stream
)
{
*
frame
=
&
globals
.
cng_frame
;
return
SWITCH_STATUS_SUCCESS
;
}
samples
=
ReadAudioStream
(
endpoint
->
in_stream
->
stream
,
endpoint
->
read_frame
.
data
,
STREAM_SAMPLES_PER_PACKET
(
endpoint
->
in_stream
),
&
endpoint
->
read_timer
);
if
(
!
samples
)
{
*
frame
=
&
globals
.
cng_frame
;
return
SWITCH_STATUS_SUCCESS
;
}
endpoint
->
read_frame
.
datalen
=
(
samples
*
sizeof
(
int16_t
));
endpoint
->
read_frame
.
samples
=
samples
;
*
frame
=
&
endpoint
->
read_frame
;
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_read_frame
(
switch_core_session_t
*
session
,
switch_frame_t
**
frame
,
switch_io_flag_t
flags
,
int
stream_id
)
static
switch_status_t
channel_read_frame
(
switch_core_session_t
*
session
,
switch_frame_t
**
frame
,
switch_io_flag_t
flags
,
int
stream_id
)
{
{
private_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
private_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
int
samples
=
0
;
int
samples
=
0
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_assert
(
tech_pvt
!=
NULL
);
switch_assert
(
tech_pvt
!=
NULL
);
if
(
tech_pvt
->
audio_endpoint
)
{
return
channel_endpoint_read
(
tech_pvt
->
audio_endpoint
,
frame
);
}
if
(
!
globals
.
main_stream
)
{
if
(
!
globals
.
main_stream
)
{
goto
normal_return
;
goto
normal_return
;
...
@@ -1462,6 +1504,21 @@ static switch_status_t load_endpoints(switch_xml_t endpoints)
...
@@ -1462,6 +1504,21 @@ static switch_status_t load_endpoints(switch_xml_t endpoints)
"Incomatible input and output streams for endpoint '%s'
\n
"
,
endpoint_name
);
"Incomatible input and output streams for endpoint '%s'
\n
"
,
endpoint_name
);
continue
;
continue
;
}
}
if
(
switch_core_timer_init
(
&
endpoint
->
read_timer
,
globals
.
timer_name
,
endpoint
->
in_stream
->
codec_ms
,
STREAM_SAMPLES_PER_PACKET
(
endpoint
->
in_stream
),
module_pool
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"failed to setup read timer for endpoint '%s'!
\n
"
,
endpoint_name
);
continue
;
}
if
(
switch_core_timer_init
(
&
endpoint
->
write_timer
,
globals
.
timer_name
,
endpoint
->
out_stream
->
codec_ms
,
STREAM_SAMPLES_PER_PACKET
(
endpoint
->
in_stream
),
module_pool
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"failed to setup read timer for endpoint '%s'!
\n
"
,
endpoint_name
);
continue
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Created endpoint '%s', instream = %s, outstream = %s
\n
"
,
endpoint
->
name
,
"Created endpoint '%s', instream = %s, outstream = %s
\n
"
,
endpoint
->
name
,
endpoint
->
in_stream
?
endpoint
->
in_stream
->
name
:
"(none)"
,
endpoint
->
in_stream
?
endpoint
->
in_stream
->
name
:
"(none)"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论