Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
5dc8412f
提交
5dc8412f
authored
7月 26, 2012
作者:
David Yat Sin
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'nsg-4.3' of
ssh://git.sangoma.com/smg_freeswitch
into nsg-4.3
上级
a4bb0002
43e39619
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
58 行增加
和
13 行删除
+58
-13
tdm.c
libs/freetdm/mod_freetdm/tdm.c
+15
-1
media_gateway.c
src/mod/endpoints/mod_media_gateway/media_gateway.c
+6
-1
rtp.c
src/mod/endpoints/mod_sofia/rtp.c
+31
-9
switch_rtp.c
src/switch_rtp.c
+6
-2
没有找到文件。
libs/freetdm/mod_freetdm/tdm.c
浏览文件 @
5dc8412f
...
@@ -52,6 +52,8 @@ typedef struct {
...
@@ -52,6 +52,8 @@ typedef struct {
switch_core_session_t
*
session
;
switch_core_session_t
*
session
;
switch_codec_t
read_codec
,
write_codec
;
switch_codec_t
read_codec
,
write_codec
;
switch_frame_t
read_frame
;
switch_frame_t
read_frame
;
unsigned
char
databuf
[
SWITCH_RECOMMENDED_BUFFER_SIZE
];
}
ctdm_private_t
;
}
ctdm_private_t
;
static
switch_status_t
channel_on_init
(
switch_core_session_t
*
session
);
static
switch_status_t
channel_on_init
(
switch_core_session_t
*
session
);
...
@@ -101,7 +103,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
...
@@ -101,7 +103,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
*
span_name
=
switch_event_get_header
(
var_event
,
kSPAN_NAME
);
*
span_name
=
switch_event_get_header
(
var_event
,
kSPAN_NAME
);
int
chan_id
;
int
chan_id
;
int
span_id
;
int
span_id
;
switch_caller_profile_t
*
caller_profile
;
ftdm_span_t
*
span
;
ftdm_span_t
*
span
;
ftdm_channel_t
*
chan
;
ftdm_channel_t
*
chan
;
switch_channel_t
*
channel
;
switch_channel_t
*
channel
;
...
@@ -147,8 +149,14 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
...
@@ -147,8 +149,14 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
tech_pvt
->
span_id
=
span_id
;
tech_pvt
->
span_id
=
span_id
;
tech_pvt
->
ftdm_channel
=
chan
;
tech_pvt
->
ftdm_channel
=
chan
;
tech_pvt
->
session
=
*
new_session
;
tech_pvt
->
session
=
*
new_session
;
tech_pvt
->
read_frame
.
buflen
=
sizeof
(
tech_pvt
->
databuf
);
tech_pvt
->
read_frame
.
data
=
tech_pvt
->
databuf
;
switch_core_session_set_private
(
*
new_session
,
tech_pvt
);
switch_core_session_set_private
(
*
new_session
,
tech_pvt
);
caller_profile
=
switch_caller_profile_clone
(
*
new_session
,
outbound_profile
);
switch_channel_set_caller_profile
(
channel
,
caller_profile
);
snprintf
(
name
,
sizeof
(
name
),
"tdm/%d:%d"
,
span_id
,
chan_id
);
snprintf
(
name
,
sizeof
(
name
),
"tdm/%d:%d"
,
span_id
,
chan_id
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Connect outbound channel %s
\n
"
,
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Connect outbound channel %s
\n
"
,
name
);
switch_channel_set_name
(
channel
,
name
);
switch_channel_set_name
(
channel
,
name
);
...
@@ -228,6 +236,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
...
@@ -228,6 +236,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
goto
fail
;
goto
fail
;
}
}
switch_channel_mark_answered
(
channel
);
return
SWITCH_CAUSE_SUCCESS
;
return
SWITCH_CAUSE_SUCCESS
;
fail:
fail:
...
@@ -254,6 +264,9 @@ fail:
...
@@ -254,6 +264,9 @@ fail:
static
switch_status_t
channel_on_init
(
switch_core_session_t
*
session
)
static
switch_status_t
channel_on_init
(
switch_core_session_t
*
session
)
{
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_set_state
(
channel
,
CS_CONSUME_MEDIA
);
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
@@ -328,6 +341,7 @@ top:
...
@@ -328,6 +341,7 @@ top:
*
frame
=
&
tech_pvt
->
read_frame
;
*
frame
=
&
tech_pvt
->
read_frame
;
tech_pvt
->
read_frame
.
datalen
=
(
uint32_t
)
len
;
tech_pvt
->
read_frame
.
datalen
=
(
uint32_t
)
len
;
tech_pvt
->
read_frame
.
samples
=
tech_pvt
->
read_frame
.
datalen
;
tech_pvt
->
read_frame
.
samples
=
tech_pvt
->
read_frame
.
datalen
;
tech_pvt
->
read_frame
.
codec
=
&
tech_pvt
->
read_codec
;
if
(
ftdm_channel_get_codec
(
tech_pvt
->
ftdm_channel
)
==
FTDM_CODEC_SLIN
)
{
if
(
ftdm_channel_get_codec
(
tech_pvt
->
ftdm_channel
)
==
FTDM_CODEC_SLIN
)
{
tech_pvt
->
read_frame
.
samples
/=
2
;
tech_pvt
->
read_frame
.
samples
/=
2
;
...
...
src/mod/endpoints/mod_media_gateway/media_gateway.c
浏览文件 @
5dc8412f
...
@@ -134,12 +134,13 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
...
@@ -134,12 +134,13 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
}
}
if
(
zstr
(
term
->
uuid
))
{
if
(
zstr
(
term
->
uuid
))
{
if
(
switch_ivr_originate
(
NULL
,
&
session
,
&
cause
,
dialstring
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
var_event
,
0
,
NULL
)
!=
SWITCH_
CAUSE
_SUCCESS
)
{
if
(
switch_ivr_originate
(
NULL
,
&
session
,
&
cause
,
dialstring
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
var_event
,
0
,
NULL
)
!=
SWITCH_
STATUS
_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to instanciate termination [%s]: %s
\n
"
,
term
->
name
,
switch_channel_cause2str
(
cause
));
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Failed to instanciate termination [%s]: %s
\n
"
,
term
->
name
,
switch_channel_cause2str
(
cause
));
status
=
SWITCH_STATUS_FALSE
;
status
=
SWITCH_STATUS_FALSE
;
goto
done
;
goto
done
;
}
}
term
->
uuid
=
switch_core_strdup
(
term
->
pool
,
switch_core_session_get_uuid
(
session
));
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Termination [%s] successfully instanciated as [%s] [%s]
\n
"
,
term
->
name
,
dialstring
,
switch_core_session_get_uuid
(
session
));
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Termination [%s] successfully instanciated as [%s] [%s]
\n
"
,
term
->
name
,
dialstring
,
switch_core_session_get_uuid
(
session
));
}
}
...
@@ -285,6 +286,10 @@ switch_status_t megaco_context_add_termination(mg_context_t *ctx, mg_termination
...
@@ -285,6 +286,10 @@ switch_status_t megaco_context_add_termination(mg_context_t *ctx, mg_termination
megaco_activate_termination
(
ctx
->
terminations
[
1
]);
megaco_activate_termination
(
ctx
->
terminations
[
1
]);
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Bridging: %s (%s) <> %s (%s)
\n
"
,
ctx
->
terminations
[
0
]
->
name
,
ctx
->
terminations
[
0
]
->
uuid
,
ctx
->
terminations
[
1
]
->
name
,
ctx
->
terminations
[
1
]
->
uuid
);
switch_ivr_uuid_bridge
(
ctx
->
terminations
[
0
]
->
uuid
,
ctx
->
terminations
[
1
]
->
uuid
);
switch_ivr_uuid_bridge
(
ctx
->
terminations
[
0
]
->
uuid
,
ctx
->
terminations
[
1
]
->
uuid
);
}
}
...
...
src/mod/endpoints/mod_sofia/rtp.c
浏览文件 @
5dc8412f
...
@@ -188,11 +188,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
...
@@ -188,11 +188,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
tech_pvt
->
dtmf_type
=
DTMF_2833
;
/* XXX */
tech_pvt
->
dtmf_type
=
DTMF_2833
;
/* XXX */
if
(
zstr
(
local_addr
)
||
local_port
==
0
)
{
if
(
zstr
(
local_addr
)
||
local_port
==
0
)
{
tech_pvt
->
mode
=
RTP_SENDONLY
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"The local address and port must be set
\n
"
);
goto
fail
;
}
else
if
(
zstr
(
remote_addr
)
||
remote_port
==
0
)
{
}
else
if
(
zstr
(
remote_addr
)
||
remote_port
==
0
)
{
tech_pvt
->
mode
=
RTP_
SENDRECV
;
tech_pvt
->
mode
=
RTP_
RECVONLY
;
}
else
{
}
else
{
tech_pvt
->
mode
=
RTP_SENDRECV
;
}
}
switch_core_session_set_private
(
*
new_session
,
tech_pvt
);
switch_core_session_set_private
(
*
new_session
,
tech_pvt
);
...
@@ -314,7 +315,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
...
@@ -314,7 +315,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
tech_pvt
=
switch_core_session_get_private
(
session
);
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
assert
(
tech_pvt
!=
NULL
);
if
(
!
tech_pvt
->
rtp_session
)
{
if
(
!
tech_pvt
->
rtp_session
||
tech_pvt
->
mode
==
RTP_RECVONLY
)
{
goto
cng
;
goto
cng
;
}
}
...
@@ -325,6 +326,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
...
@@ -325,6 +326,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
}
}
tech_pvt
->
read_frame
.
flags
=
SFF_NONE
;
tech_pvt
->
read_frame
.
flags
=
SFF_NONE
;
tech_pvt
->
read_frame
.
codec
=
&
tech_pvt
->
read_codec
;
status
=
switch_rtp_zerocopy_read_frame
(
tech_pvt
->
rtp_session
,
&
tech_pvt
->
read_frame
,
flags
);
status
=
switch_rtp_zerocopy_read_frame
(
tech_pvt
->
rtp_session
,
&
tech_pvt
->
read_frame
,
flags
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
&&
status
!=
SWITCH_STATUS_BREAK
)
{
if
(
status
!=
SWITCH_STATUS_SUCCESS
&&
status
!=
SWITCH_STATUS_BREAK
)
{
...
@@ -409,15 +411,27 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
...
@@ -409,15 +411,27 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
{
{
const
char
*
command
=
switch_event_get_header
(
event
,
"command"
);
const
char
*
command
=
switch_event_get_header
(
event
,
"command"
);
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
crtp_private_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
if
(
!
zstr
(
command
)
&&
!
strcasecmp
(
command
,
"media_modify"
))
{
if
(
!
zstr
(
command
)
&&
!
strcasecmp
(
command
,
"media_modify"
))
{
/* Compare parameters */
/* Compare parameters */
if
(
compare_var
(
event
,
channel
,
kREMOTEADDR
)
||
if
(
compare_var
(
event
,
channel
,
kREMOTEADDR
)
||
compare_var
(
event
,
channel
,
kREMOTEPORT
)
||
compare_var
(
event
,
channel
,
kREMOTEPORT
))
{
compare_var
(
event
,
channel
,
kLOCALADDR
)
||
char
*
remote_addr
=
switch_event_get_header
(
event
,
kREMOTEADDR
);
compare_var
(
event
,
channel
,
kLOCALPORT
))
{
char
*
szremote_port
=
switch_event_get_header
(
event
,
kREMOTEADDR
);
/* We need to reset the rtp session */
switch_port_t
remote_port
=
!
zstr
(
szremote_port
)
?
atoi
(
szremote_port
)
:
0
;
const
char
*
err
;
switch_channel_set_variable
(
channel
,
kREMOTEADDR
,
remote_addr
);
switch_channel_set_variable
(
channel
,
kREMOTEPORT
,
szremote_port
);
if
(
switch_rtp_set_remote_address
(
tech_pvt
->
rtp_session
,
remote_addr
,
remote_port
,
0
,
SWITCH_TRUE
,
&
err
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Error setting RTP remote address: %s
\n
"
,
err
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Set RTP remote: %s:%d
\n
"
,
remote_addr
,
(
int
)
remote_port
);
tech_pvt
->
mode
=
RTP_SENDRECV
;
}
}
}
if
(
compare_var
(
event
,
channel
,
kCODEC
)
||
if
(
compare_var
(
event
,
channel
,
kCODEC
)
||
...
@@ -425,9 +439,17 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
...
@@ -425,9 +439,17 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
compare_var
(
event
,
channel
,
kPT
)
||
compare_var
(
event
,
channel
,
kPT
)
||
compare_var
(
event
,
channel
,
kRATE
))
{
compare_var
(
event
,
channel
,
kRATE
))
{
/* Reset codec */
/* Reset codec */
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_CRIT
,
"Switching codec not yet implemented
\n
"
);
}
}
if
(
compare_var
(
event
,
channel
,
kRFC2833PT
))
{
const
char
*
szpt
=
switch_channel_get_variable
(
channel
,
kRFC2833PT
);
int
pt
=
!
zstr
(
szpt
)
?
atoi
(
szpt
)
:
0
;
switch_channel_set_variable
(
channel
,
kRFC2833PT
,
szpt
);
switch_rtp_set_telephony_event
(
tech_pvt
->
rtp_session
,
pt
);
}
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Received unknown command [%s] in event.
\n
"
,
!
command
?
"null"
:
command
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Received unknown command [%s] in event.
\n
"
,
!
command
?
"null"
:
command
);
}
}
...
...
src/switch_rtp.c
浏览文件 @
5dc8412f
...
@@ -34,6 +34,8 @@
...
@@ -34,6 +34,8 @@
//#define RTP_DEBUG_WRITE_DELTA
//#define RTP_DEBUG_WRITE_DELTA
//#define DEBUG_MISSED_SEQ
//#define DEBUG_MISSED_SEQ
typedef
unsigned
long
u_long
;
#include <switch.h>
#include <switch.h>
#include <switch_stun.h>
#include <switch_stun.h>
#include <apr_network_io.h>
#include <apr_network_io.h>
...
@@ -1451,7 +1453,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
...
@@ -1451,7 +1453,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_sess
uint32_t
index
,
switch_rtp_crypto_key_type_t
type
,
unsigned
char
*
key
,
switch_size_t
keylen
)
uint32_t
index
,
switch_rtp_crypto_key_type_t
type
,
unsigned
char
*
key
,
switch_size_t
keylen
)
{
{
#ifndef ENABLE_SRTP
#ifndef ENABLE_SRTP
switch_log_printf
(
SWITCH_CHANNEL_
SESSION_LOG
(
session
)
,
SWITCH_LOG_CRIT
,
"SRTP NOT SUPPORTED IN THIS BUILD!
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_
LOG
,
SWITCH_LOG_CRIT
,
"SRTP NOT SUPPORTED IN THIS BUILD!
\n
"
);
return
SWITCH_STATUS_FALSE
;
return
SWITCH_STATUS_FALSE
;
#else
#else
switch_rtp_crypto_key_t
*
crypto_key
;
switch_rtp_crypto_key_t
*
crypto_key
;
...
@@ -1832,6 +1834,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
...
@@ -1832,6 +1834,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
goto
end
;
goto
end
;
}
}
#if 0
if (zstr(tx_host)) {
if (zstr(tx_host)) {
*err = "Missing remote host";
*err = "Missing remote host";
goto end;
goto end;
...
@@ -1841,6 +1844,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
...
@@ -1841,6 +1844,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
*err = "Missing remote port";
*err = "Missing remote port";
goto end;
goto end;
}
}
#endif
if
(
switch_rtp_create
(
&
rtp_session
,
payload
,
samples_per_interval
,
ms_per_packet
,
flags
,
timer_name
,
err
,
pool
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_rtp_create
(
&
rtp_session
,
payload
,
samples_per_interval
,
ms_per_packet
,
flags
,
timer_name
,
err
,
pool
)
!=
SWITCH_STATUS_SUCCESS
)
{
goto
end
;
goto
end
;
...
@@ -1854,7 +1858,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
...
@@ -1854,7 +1858,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
goto
end
;
goto
end
;
}
}
if
(
switch_rtp_set_remote_address
(
rtp_session
,
tx_host
,
tx_port
,
0
,
SWITCH_TRUE
,
err
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
!
zstr
(
tx_host
)
&&
switch_rtp_set_remote_address
(
rtp_session
,
tx_host
,
tx_port
,
0
,
SWITCH_TRUE
,
err
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_mutex_unlock
(
rtp_session
->
flag_mutex
);
switch_mutex_unlock
(
rtp_session
->
flag_mutex
);
rtp_session
=
NULL
;
rtp_session
=
NULL
;
goto
end
;
goto
end
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论