Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
8ec9e214
提交
8ec9e214
authored
8月 24, 2010
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod_sangoma_codec: add SOAP server configuration
上级
812a275f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
51 行增加
和
51 行删除
+51
-51
mod_sangoma_codec.c
src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c
+51
-51
没有找到文件。
src/mod/codecs/mod_sangoma_codec/mod_sangoma_codec.c
浏览文件 @
8ec9e214
...
@@ -54,6 +54,8 @@ static sngtc_init_cfg_t g_init_cfg;
...
@@ -54,6 +54,8 @@ static sngtc_init_cfg_t g_init_cfg;
/* configured RTP IP */
/* configured RTP IP */
static
int
g_rtpip
=
0
;
static
int
g_rtpip
=
0
;
static
char
g_soap_url
[
255
]
=
""
;
/* \brief protect vocallo session creation and destroy */
/* \brief protect vocallo session creation and destroy */
static
switch_mutex_t
*
g_sessions_lock
=
NULL
;
static
switch_mutex_t
*
g_sessions_lock
=
NULL
;
...
@@ -126,9 +128,6 @@ struct codec_data {
...
@@ -126,9 +128,6 @@ struct codec_data {
long
lastrxseqno
;
long
lastrxseqno
;
unsigned
long
rxlost
;
unsigned
long
rxlost
;
/* discarded silence packets */
unsigned
long
rxdiscarded
;
/* avg Rx time */
/* avg Rx time */
switch_time_t
avgrxus
;
switch_time_t
avgrxus
;
switch_time_t
last_rx_time
;
switch_time_t
last_rx_time
;
...
@@ -366,6 +365,7 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
...
@@ -366,6 +365,7 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
switch_mutex_lock
(
g_sessions_lock
);
switch_mutex_lock
(
g_sessions_lock
);
err
=
sngtc_create_transcoding_session
(
&
sess
->
encoder
.
request
,
&
sess
->
encoder
.
reply
,
0
);
err
=
sngtc_create_transcoding_session
(
&
sess
->
encoder
.
request
,
&
sess
->
encoder
.
reply
,
0
);
if
(
err
)
{
if
(
err
)
{
memset
(
&
sess
->
encoder
,
0
,
sizeof
(
sess
->
encoder
));
switch_mutex_unlock
(
g_sessions_lock
);
switch_mutex_unlock
(
g_sessions_lock
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to create Sangoma encoding session.
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to create Sangoma encoding session.
\n
"
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
...
@@ -403,31 +403,26 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
...
@@ -403,31 +403,26 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
sess
->
encoder
.
tx
++
;
sess
->
encoder
.
tx
++
;
/* do the reading */
/* do the reading */
for
(
;
;
)
{
memset
(
&
encoded_frame
,
0
,
sizeof
(
encoded_frame
));
sres
=
switch_rtp_zerocopy_read_frame
(
sess
->
encoder
.
rxrtp
,
&
encoded_frame
,
SWITCH_IO_FLAG_NOBLOCK
);
sres
=
switch_rtp_zerocopy_read_frame
(
sess
->
encoder
.
rxrtp
,
&
encoded_frame
,
SWITCH_IO_FLAG_NOBLOCK
);
if
(
sres
==
SWITCH_STATUS_GENERR
)
{
if
(
sres
==
SWITCH_STATUS_GENERR
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to read on Sangoma encoder RTP session: %d
\n
"
,
sres
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to read on Sangoma encoder RTP session: %d
\n
"
,
sres
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
if
(
0
==
encoded_frame
.
datalen
)
{
break
;
}
if
(
encoded_frame
.
payload
!=
codec
->
implementation
->
ianacode
&&
encoded_frame
.
payload
!=
IANACODE_CN
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Read unexpected payload %d in Sangoma encoder RTP session, expecting %d
\n
"
,
encoded_frame
.
payload
,
codec
->
implementation
->
ianacode
);
break
;
}
if
(
*
encoded_data_len
)
{
if
(
0
==
encoded_frame
.
datalen
)
{
sess
->
encoder
.
rxdiscarded
++
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"No output on Sangoma encoder RTP session.
\n
"
);
}
return
SWITCH_STATUS_SUCCESS
;
}
memcpy
(
encoded_data
,
encoded_frame
.
data
,
encoded_frame
.
datalen
);
if
(
encoded_frame
.
payload
!=
codec
->
implementation
->
ianacode
*
encoded_data_len
=
encoded_frame
.
datalen
;
&&
encoded_frame
.
payload
!=
IANACODE_CN
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Read unexpected payload %d in Sangoma encoder RTP session, expecting %d
\n
"
,
encoded_frame
.
payload
,
codec
->
implementation
->
ianacode
);
return
SWITCH_STATUS_FALSE
;
}
}
memcpy
(
encoded_data
,
encoded_frame
.
data
,
encoded_frame
.
datalen
);
*
encoded_data_len
=
encoded_frame
.
datalen
;
/* update encoding stats */
/* update encoding stats */
sess
->
encoder
.
rx
++
;
sess
->
encoder
.
rx
++
;
...
@@ -490,6 +485,7 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
...
@@ -490,6 +485,7 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
switch_mutex_lock
(
g_sessions_lock
);
switch_mutex_lock
(
g_sessions_lock
);
err
=
sngtc_create_transcoding_session
(
&
sess
->
decoder
.
request
,
&
sess
->
decoder
.
reply
,
0
);
err
=
sngtc_create_transcoding_session
(
&
sess
->
decoder
.
request
,
&
sess
->
decoder
.
reply
,
0
);
if
(
err
)
{
if
(
err
)
{
memset
(
&
sess
->
decoder
,
0
,
sizeof
(
sess
->
decoder
));
switch_mutex_unlock
(
g_sessions_lock
);
switch_mutex_unlock
(
g_sessions_lock
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to create Sangoma decoding session.
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to create Sangoma decoding session.
\n
"
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
...
@@ -521,34 +517,30 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
...
@@ -521,34 +517,30 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
sess
->
decoder
.
tx
++
;
sess
->
decoder
.
tx
++
;
/* do the reading */
/* do the reading */
for
(
;
;
)
{
memset
(
&
ulaw_frame
,
0
,
sizeof
(
ulaw_frame
));
sres
=
switch_rtp_zerocopy_read_frame
(
sess
->
decoder
.
rxrtp
,
&
ulaw_frame
,
SWITCH_IO_FLAG_NOBLOCK
);
sres
=
switch_rtp_zerocopy_read_frame
(
sess
->
decoder
.
rxrtp
,
&
ulaw_frame
,
SWITCH_IO_FLAG_NOBLOCK
);
if
(
sres
==
SWITCH_STATUS_GENERR
)
{
if
(
sres
==
SWITCH_STATUS_GENERR
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to read on Sangoma decoder RTP session: %d
\n
"
,
sres
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to read on Sangoma decoder RTP session: %d
\n
"
,
sres
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
}
}
if
(
0
==
ulaw_frame
.
datalen
)
{
break
;
}
if
(
ulaw_frame
.
payload
!=
IANA_ULAW
if
(
0
==
ulaw_frame
.
datalen
)
{
&&
ulaw_frame
.
payload
!=
IANACODE_CN
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"No output on Sangoma decoder RTP session.
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Read unexpected payload %d in Sangoma decoder RTP session, expecting %d
\n
"
,
return
SWITCH_STATUS_SUCCESS
;
ulaw_frame
.
payload
,
IANA_ULAW
);
}
break
;
}
if
(
*
decoded_data_len
)
{
if
(
ulaw_frame
.
payload
!=
IANA_ULAW
sess
->
decoder
.
rxdiscarded
++
;
&&
ulaw_frame
.
payload
!=
IANACODE_CN
)
{
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Read unexpected payload %d in Sangoma decoder RTP session, expecting %d
\n
"
,
ulaw_frame
.
payload
,
IANA_ULAW
);
return
SWITCH_STATUS_FALSE
;
}
/* transcode to linear */
/* transcode to linear */
for
(
i
=
0
;
i
<
ulaw_frame
.
datalen
;
i
++
)
{
for
(
i
=
0
;
i
<
ulaw_frame
.
datalen
;
i
++
)
{
dbuf_linear
[
i
]
=
ulaw_to_linear
(((
char
*
)
ulaw_frame
.
data
)[
i
]);
dbuf_linear
[
i
]
=
ulaw_to_linear
(((
char
*
)
ulaw_frame
.
data
)[
i
]);
}
*
decoded_data_len
=
i
*
2
;
}
}
*
decoded_data_len
=
i
*
2
;
/* update decoding stats */
/* update decoding stats */
sess
->
decoder
.
rx
++
;
sess
->
decoder
.
rx
++
;
...
@@ -584,9 +576,11 @@ static switch_status_t switch_sangoma_destroy(switch_codec_t *codec)
...
@@ -584,9 +576,11 @@ static switch_status_t switch_sangoma_destroy(switch_codec_t *codec)
if
(
sess
->
encoder
.
txrtp
)
{
if
(
sess
->
encoder
.
txrtp
)
{
sngtc_free_transcoding_session
(
&
sess
->
encoder
.
reply
);
sngtc_free_transcoding_session
(
&
sess
->
encoder
.
reply
);
memset
(
&
sess
->
encoder
,
0
,
sizeof
(
sess
->
encoder
));
}
}
if
(
sess
->
decoder
.
txrtp
)
{
if
(
sess
->
decoder
.
txrtp
)
{
sngtc_free_transcoding_session
(
&
sess
->
decoder
.
reply
);
sngtc_free_transcoding_session
(
&
sess
->
decoder
.
reply
);
memset
(
&
sess
->
decoder
,
0
,
sizeof
(
sess
->
decoder
));
}
}
switch_core_hash_delete
(
g_sessions_hash
,
sess
->
hashkey
);
switch_core_hash_delete
(
g_sessions_hash
,
sess
->
hashkey
);
...
@@ -720,7 +714,6 @@ SWITCH_STANDARD_API(sangoma_function)
...
@@ -720,7 +714,6 @@ SWITCH_STANDARD_API(sangoma_function)
if
(
sess
->
encoder
.
rxrtp
)
{
if
(
sess
->
encoder
.
rxrtp
)
{
stats
=
switch_rtp_get_stats
(
sess
->
encoder
.
rxrtp
,
NULL
);
stats
=
switch_rtp_get_stats
(
sess
->
encoder
.
rxrtp
,
NULL
);
stream
->
write_function
(
stream
,
"-- Encoder Inbound Stats --
\n
"
);
stream
->
write_function
(
stream
,
"-- Encoder Inbound Stats --
\n
"
);
stream
->
write_function
(
stream
,
"Rx Discarded: %lu
\n
"
,
sess
->
encoder
.
rxdiscarded
);
sangoma_print_stats
(
stream
,
&
stats
->
inbound
);
sangoma_print_stats
(
stream
,
&
stats
->
inbound
);
...
@@ -732,7 +725,6 @@ SWITCH_STANDARD_API(sangoma_function)
...
@@ -732,7 +725,6 @@ SWITCH_STANDARD_API(sangoma_function)
if
(
sess
->
decoder
.
rxrtp
)
{
if
(
sess
->
decoder
.
rxrtp
)
{
stats
=
switch_rtp_get_stats
(
sess
->
decoder
.
rxrtp
,
NULL
);
stats
=
switch_rtp_get_stats
(
sess
->
decoder
.
rxrtp
,
NULL
);
stream
->
write_function
(
stream
,
"-- Decoder Inbound Stats --
\n
"
);
stream
->
write_function
(
stream
,
"-- Decoder Inbound Stats --
\n
"
);
stream
->
write_function
(
stream
,
"Rx Discarded: %lu
\n
"
,
sess
->
decoder
.
rxdiscarded
);
sangoma_print_stats
(
stream
,
&
stats
->
inbound
);
sangoma_print_stats
(
stream
,
&
stats
->
inbound
);
stats
=
switch_rtp_get_stats
(
sess
->
decoder
.
txrtp
,
NULL
);
stats
=
switch_rtp_get_stats
(
sess
->
decoder
.
txrtp
,
NULL
);
...
@@ -816,6 +808,9 @@ static int sangoma_parse_config(void)
...
@@ -816,6 +808,9 @@ static int sangoma_parse_config(void)
}
else
if
(
!
strcasecmp
(
var
,
"noregister"
))
{
}
else
if
(
!
strcasecmp
(
var
,
"noregister"
))
{
strncpy
(
g_codec_noregister_list
,
val
,
sizeof
(
g_codec_noregister_list
)
-
1
);
strncpy
(
g_codec_noregister_list
,
val
,
sizeof
(
g_codec_noregister_list
)
-
1
);
g_codec_noregister_list
[
sizeof
(
g_codec_noregister_list
)
-
1
]
=
0
;
g_codec_noregister_list
[
sizeof
(
g_codec_noregister_list
)
-
1
]
=
0
;
}
else
if
(
!
strcasecmp
(
var
,
"soapserver"
))
{
strncpy
(
g_soap_url
,
val
,
sizeof
(
g_soap_url
)
-
1
);
g_soap_url
[
sizeof
(
g_soap_url
)
-
1
]
=
0
;
}
else
if
(
!
strcasecmp
(
var
,
"rtpip"
))
{
}
else
if
(
!
strcasecmp
(
var
,
"rtpip"
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Found Sangoma RTP IP %s
\n
"
,
val
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Found Sangoma RTP IP %s
\n
"
,
val
);
if
(
switch_inet_pton
(
AF_INET
,
val
,
&
rtpaddr
)
<=
0
)
{
if
(
switch_inet_pton
(
AF_INET
,
val
,
&
rtpaddr
)
<=
0
)
{
...
@@ -884,6 +879,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sangoma_codec_load)
...
@@ -884,6 +879,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sangoma_codec_load)
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Detected %d and activated %d Sangoma codec vocallo modules
\n
"
,
detected
,
activated
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Detected %d and activated %d Sangoma codec vocallo modules
\n
"
,
detected
,
activated
);
if
(
strlen
(
g_soap_url
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Using %s SOAP server
\n
"
,
g_soap_url
);
sngtc_set_soap_server_url
(
g_soap_url
);
}
switch_mutex_init
(
&
g_sessions_lock
,
SWITCH_MUTEX_UNNESTED
,
pool
);
switch_mutex_init
(
&
g_sessions_lock
,
SWITCH_MUTEX_UNNESTED
,
pool
);
switch_core_hash_init
(
&
g_sessions_hash
,
pool
);
switch_core_hash_init
(
&
g_sessions_hash
,
pool
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论