Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
8aa901c4
提交
8aa901c4
authored
8月 09, 2012
作者:
Mathieu Rene
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add spandsp cng-tone detect
上级
83e0d9c3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
75 行删除
+27
-75
media_gateway.c
src/mod/endpoints/mod_media_gateway/media_gateway.c
+7
-5
mod_media_gateway.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.c
+18
-70
mod_media_gateway.h
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h
+2
-0
没有找到文件。
src/mod/endpoints/mod_media_gateway/media_gateway.c
浏览文件 @
8aa901c4
...
...
@@ -84,7 +84,7 @@ megaco_profile_t* megaco_get_profile_by_suId(SuId suId)
static
switch_status_t
mg_on_dtmf
(
switch_core_session_t
*
session
,
const
switch_dtmf_t
*
dtmf
,
switch_dtmf_direction_t
direction
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
mg_termination_t
*
term
=
switch_channel_get_private
(
channel
,
"_mg_term_"
);
mg_termination_t
*
term
=
switch_channel_get_private
(
channel
,
PVT_MG_TERM
);
//char digit[2] = { dtmf->digit };
if
(
!
term
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Cannot find termination structure for session [%s]
\n
"
,
...
...
@@ -158,7 +158,7 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
}
if
(
zstr
(
term
->
uuid
))
{
switch_channel_t
*
channel
;
switch_channel_t
*
channel
;
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
));
status
=
SWITCH_STATUS_FALSE
;
...
...
@@ -167,9 +167,11 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
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
));
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_set_private
(
channel
,
"_mg_term_"
,
term
);
switch_core_event_hook_add_recv_dtmf
(
session
,
mg_on_dtmf
);
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_set_private
(
channel
,
PVT_MG_TERM
,
term
);
switch_core_event_hook_add_recv_dtmf
(
session
,
mg_on_dtmf
);
switch_core_session_execute_application_async
(
session
,
"spandsp_start_fax_detect"
,
"mg_notify cng 120 cng"
);
}
switch_set_flag
(
term
,
MGT_ACTIVE
);
...
...
src/mod/endpoints/mod_media_gateway/mod_media_gateway.c
浏览文件 @
8aa901c4
...
...
@@ -26,6 +26,22 @@ SWITCH_STANDARD_API(megaco_function)
return
mg_process_cli_cmd
(
cmd
,
stream
);
}
SWITCH_STANDARD_APP
(
mg_notify_function
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
mg_termination_t
*
term
=
switch_channel_get_private
(
channel
,
PVT_MG_TERM
);
if
(
!
term
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"mg_notify called on a non-supported channel.
\n
"
);
return
;
}
if
(
!
strcmp
(
data
,
"cng"
))
{
mg_send_t38_cng_notify
(
term
->
profile
,
term
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Sent CNG notify
\n
"
);
}
}
static
switch_status_t
console_complete_hashtable
(
switch_hash_t
*
hash
,
const
char
*
line
,
const
char
*
cursor
,
switch_console_callback_match_t
**
matches
)
{
switch_hash_index_t
*
hi
;
...
...
@@ -92,6 +108,7 @@ static void mg_event_handler(switch_event_t *event)
SWITCH_MODULE_LOAD_FUNCTION
(
mod_media_gateway_load
)
{
switch_api_interface_t
*
api_interface
;
switch_application_interface_t
*
app_interface
;
memset
(
&
megaco_globals
,
0
,
sizeof
(
megaco_globals
));
megaco_globals
.
pool
=
pool
;
...
...
@@ -105,6 +122,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_media_gateway_load)
switch_thread_rwlock_create
(
&
megaco_globals
.
peer_profile_rwlock
,
pool
);
SWITCH_ADD_API
(
api_interface
,
"mg"
,
"media_gateway"
,
megaco_function
,
MEGACO_FUNCTION_SYNTAX
);
SWITCH_ADD_APP
(
app_interface
,
"mg_notify"
,
"<type>"
,
"sends a notify to the mgc"
,
mg_notify_function
,
""
,
0
);
switch_console_set_complete
(
"add mg profile ::mg::list_profiles start"
);
switch_console_set_complete
(
"add mg profile ::mg::list_profiles stop"
);
...
...
@@ -246,77 +264,7 @@ void handle_sng_log(uint8_t level, char *fmt, ...)
va_end
(
ptr
);
}
/*****************************************************************************************************************************/
#if 0
static switch_status_t mgco_parse_local_sdp(mg_termination_t *term, CmSdpInfoSet *sdp)
{
int i;
CmSdpInfoSet *local_sdp;
/* Parse the local SDP while copying the important bits over to our local structure,
* while taking care of editing choose request and replacing them by real values */
if (!term->u.rtp.local_sdp) {
local_sdp = term->u.rtp.local_sdp = switch_core_alloc(term->context->pool, sizeof *term->u.rtp.local_sdp);
}
if (sdp->numComp.pres == NOTPRSNT) {
return SWITCH_STATUS_FALSE;
}
for (i = 0; i < sdp->numComp.val; i++) {
CmSdpInfo *s = sdp->info[i];
int mediaId;
local_sdp->info[i] = switch_core_alloc(term->context->pool, sizeof *(local_sdp->info[i]));
*(local_sdp->info[i]) = *(sdp->info[i]);
if (s->conn.addrType.pres && s->conn.addrType.val == CM_SDP_ADDR_TYPE_IPV4 &&
s->conn.netType.type.val == CM_SDP_NET_TYPE_IN &&
s->conn.u.ip4.addrType.val == CM_SDP_IPV4_IP_UNI) {
if (s->conn.u.ip4.addrType.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local address: %d.%d.%d.%d\n",
s->conn.u.ip4.u.uniIp.b[0].val,
s->conn.u.ip4.u.uniIp.b[1].val,
s->conn.u.ip4.u.uniIp.b[2].val,
s->conn.u.ip4.u.uniIp.b[3].val);
/* TODO: Double-check bind address for this profile */
}
if (s->attrSet.numComp.pres) {
for (mediaId = 0; mediaId < s->attrSet.numComp.val; mediaId++) {
CmSdpAttr *a = s->attrSet.attr[mediaId];
local_sdp->info[i]->attrSet.attr[mediaId] = switch_core_alloc(term->context->pool, sizeof(CmSdpAttr));
*(local_sdp->info[i]->attrSet.attr[mediaId]) = *a;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Media %p\n", (void*)a);
}
}
if (s->mediaDescSet.numComp.pres) {
for (mediaId = 0; mediaId < s->mediaDescSet.numComp.val; mediaId++) {
CmSdpMediaDesc *desc = s->mediaDescSet.mediaDesc[mediaId];
local_sdp->info[i]->mediaDescSet.mediaDesc[mediaId] = switch_core_alloc(term->context->pool, sizeof(CmSdpMediaDesc));
*(local_sdp->info[i]->mediaDescSet.mediaDesc[mediaId]) = *desc;
if (desc->field.mediaType.val == CM_SDP_MEDIA_AUDIO &&
desc->field.id.type.val == CM_SDP_VCID_PORT &&
desc->field.id.u.port.type.val == CM_SDP_PORT_INT &&
desc->field.id.u.port.u.portInt.port.type.val == CM_SDP_SPEC) {
int port = desc->field.id.u.port.u.portInt.port.val.val;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Port: %d\n", port);
}
}
}
}
}
return SWITCH_STATUS_SUCCESS;
}
#endif
/* KAPIL- NOTE : We are using Command mode operation of MEGACO stack, so we will always get command indication instead of transaction */
/* Below API is not useful ... just leaving as it is...*/
...
...
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h
浏览文件 @
8aa901c4
...
...
@@ -22,6 +22,8 @@
#define MEGACO_LOGGING_CLI_SYNTAX "logging [enable|disable]"
#define MEGACO_FUNCTION_SYNTAX "profile [name] [start | stop] [status] [xmlstatus] [peerxmlstatus]"
#define PVT_MG_TERM "_mg_term_"
struct
megaco_globals
{
switch_memory_pool_t
*
pool
;
switch_hash_t
*
profile_hash
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论