Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
479c8a4a
提交
479c8a4a
authored
7月 23, 2018
作者:
Chris Rienzo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11316 [mod_rayo] Add dialplan app execution component
上级
a5776837
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
199 行增加
和
3 行删除
+199
-3
Makefile.am
src/mod/event_handlers/mod_rayo/Makefile.am
+1
-1
rayo_components.c
src/mod/event_handlers/mod_rayo/rayo_components.c
+3
-1
rayo_components.h
src/mod/event_handlers/mod_rayo/rayo_components.h
+7
-1
rayo_elements.c
src/mod/event_handlers/mod_rayo/rayo_elements.c
+11
-0
rayo_elements.h
src/mod/event_handlers/mod_rayo/rayo_elements.h
+1
-0
rayo_exec_component.c
src/mod/event_handlers/mod_rayo/rayo_exec_component.c
+176
-0
没有找到文件。
src/mod/event_handlers/mod_rayo/Makefile.am
浏览文件 @
479c8a4a
...
@@ -7,7 +7,7 @@ IKS_LA=$(IKS_BUILDDIR)/src/libiksemel.la
...
@@ -7,7 +7,7 @@ IKS_LA=$(IKS_BUILDDIR)/src/libiksemel.la
mod_LTLIBRARIES
=
mod_rayo.la
mod_LTLIBRARIES
=
mod_rayo.la
mod_rayo_la_SOURCES
=
mod_rayo.c iks_helpers.c nlsml.c rayo_components.c rayo_cpa_component.c rayo_cpa_detector.c rayo_elements.c rayo_fax_components.c
mod_rayo_la_SOURCES
=
mod_rayo.c iks_helpers.c nlsml.c rayo_components.c rayo_cpa_component.c rayo_cpa_detector.c rayo_elements.c rayo_fax_components.c
mod_rayo_la_SOURCES
+=
rayo_input_component.c rayo_output_component.c rayo_prompt_component.c rayo_record_component.c sasl.c srgs.c xmpp_streams.c
mod_rayo_la_SOURCES
+=
rayo_input_component.c rayo_output_component.c rayo_prompt_component.c rayo_record_component.c sasl.c srgs.c xmpp_streams.c
rayo_exec_component.c
mod_rayo_la_CFLAGS
=
$(AM_CFLAGS)
-I
$(IKS_DIR)
/include
$(PCRE_CFLAGS)
mod_rayo_la_CFLAGS
=
$(AM_CFLAGS)
-I
$(IKS_DIR)
/include
$(PCRE_CFLAGS)
mod_rayo_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
$(IKS_LA)
$(PCRE_LIBS)
mod_rayo_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
$(IKS_LA)
$(PCRE_LIBS)
mod_rayo_la_LDFLAGS
=
-avoid-version
-module
-no-undefined
-shared
mod_rayo_la_LDFLAGS
=
-avoid-version
-module
-no-undefined
-shared
...
...
src/mod/event_handlers/mod_rayo/rayo_components.c
浏览文件 @
479c8a4a
...
@@ -228,7 +228,8 @@ switch_status_t rayo_components_load(switch_loadable_module_interface_t **module
...
@@ -228,7 +228,8 @@ switch_status_t rayo_components_load(switch_loadable_module_interface_t **module
rayo_output_component_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
||
rayo_output_component_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
||
rayo_prompt_component_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
||
rayo_prompt_component_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
||
rayo_record_component_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
||
rayo_record_component_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
||
rayo_fax_components_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
)
{
rayo_fax_components_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
||
rayo_exec_component_load
(
module_interface
,
pool
,
config_file
)
!=
SWITCH_STATUS_SUCCESS
)
{
return
SWITCH_STATUS_TERM
;
return
SWITCH_STATUS_TERM
;
}
}
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
...
@@ -244,6 +245,7 @@ switch_status_t rayo_components_shutdown(void)
...
@@ -244,6 +245,7 @@ switch_status_t rayo_components_shutdown(void)
rayo_prompt_component_shutdown
();
rayo_prompt_component_shutdown
();
rayo_record_component_shutdown
();
rayo_record_component_shutdown
();
rayo_fax_components_shutdown
();
rayo_fax_components_shutdown
();
rayo_exec_component_shutdown
();
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
...
...
src/mod/event_handlers/mod_rayo/rayo_components.h
浏览文件 @
479c8a4a
/*
/*
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013, Grasshopper
* Copyright (C) 2013
-2018
, Grasshopper
*
*
* Version: MPL 1.1
* Version: MPL 1.1
*
*
...
@@ -52,9 +52,13 @@
...
@@ -52,9 +52,13 @@
#define RAYO_FAX_NS RAYO_BASE "fax:" RAYO_VERSION
#define RAYO_FAX_NS RAYO_BASE "fax:" RAYO_VERSION
#define RAYO_FAX_COMPLETE_NS RAYO_BASE "fax:complete:" RAYO_VERSION
#define RAYO_FAX_COMPLETE_NS RAYO_BASE "fax:complete:" RAYO_VERSION
#define RAYO_EXEC_NS RAYO_BASE "exec:" RAYO_VERSION
#define RAYO_EXEC_COMPLETE_NS RAYO_BASE "exec:complete:" RAYO_VERSION
#define COMPONENT_COMPLETE_STOP "stop", RAYO_EXT_COMPLETE_NS
#define COMPONENT_COMPLETE_STOP "stop", RAYO_EXT_COMPLETE_NS
#define COMPONENT_COMPLETE_ERROR "error", RAYO_EXT_COMPLETE_NS
#define COMPONENT_COMPLETE_ERROR "error", RAYO_EXT_COMPLETE_NS
#define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS
#define COMPONENT_COMPLETE_HANGUP "hangup", RAYO_EXT_COMPLETE_NS
#define COMPONENT_COMPLETE_DONE "done", RAYO_EXT_COMPLETE_NS
extern
switch_status_t
rayo_components_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_components_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_input_component_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_input_component_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
...
@@ -62,6 +66,7 @@ extern switch_status_t rayo_output_component_load(switch_loadable_module_interfa
...
@@ -62,6 +66,7 @@ extern switch_status_t rayo_output_component_load(switch_loadable_module_interfa
extern
switch_status_t
rayo_prompt_component_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_prompt_component_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_record_component_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_record_component_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_fax_components_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_fax_components_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_exec_component_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
);
extern
switch_status_t
rayo_components_shutdown
(
void
);
extern
switch_status_t
rayo_components_shutdown
(
void
);
extern
switch_status_t
rayo_input_component_shutdown
(
void
);
extern
switch_status_t
rayo_input_component_shutdown
(
void
);
...
@@ -69,6 +74,7 @@ extern switch_status_t rayo_output_component_shutdown(void);
...
@@ -69,6 +74,7 @@ extern switch_status_t rayo_output_component_shutdown(void);
extern
switch_status_t
rayo_prompt_component_shutdown
(
void
);
extern
switch_status_t
rayo_prompt_component_shutdown
(
void
);
extern
switch_status_t
rayo_record_component_shutdown
(
void
);
extern
switch_status_t
rayo_record_component_shutdown
(
void
);
extern
switch_status_t
rayo_fax_components_shutdown
(
void
);
extern
switch_status_t
rayo_fax_components_shutdown
(
void
);
extern
switch_status_t
rayo_exec_component_shutdown
(
void
);
extern
void
rayo_component_send_start
(
struct
rayo_component
*
component
,
iks
*
iq
);
extern
void
rayo_component_send_start
(
struct
rayo_component
*
component
,
iks
*
iq
);
extern
void
rayo_component_send_iq_error
(
struct
rayo_component
*
component
,
iks
*
iq
,
const
char
*
error_name
,
const
char
*
error_type
);
extern
void
rayo_component_send_iq_error
(
struct
rayo_component
*
component
,
iks
*
iq
,
const
char
*
error_name
,
const
char
*
error_type
);
...
...
src/mod/event_handlers/mod_rayo/rayo_elements.c
浏览文件 @
479c8a4a
...
@@ -121,6 +121,17 @@ ELEMENT(RAYO_SENDFAX)
...
@@ -121,6 +121,17 @@ ELEMENT(RAYO_SENDFAX)
ATTRIB
(
xmlns
,,
any
)
ATTRIB
(
xmlns
,,
any
)
ELEMENT_END
ELEMENT_END
/**
* <app> command validation
*/
ELEMENT
(
RAYO_APP
)
ATTRIB
(
xmlns
,,
any
)
ATTRIB
(
app
,,
any
)
OPTIONAL_ATTRIB
(
args
,,
any
)
ELEMENT_END
/* For Emacs:
/* For Emacs:
* Local Variables:
* Local Variables:
...
...
src/mod/event_handlers/mod_rayo/rayo_elements.h
浏览文件 @
479c8a4a
...
@@ -39,6 +39,7 @@ ELEMENT_DECL(RAYO_PROMPT)
...
@@ -39,6 +39,7 @@ ELEMENT_DECL(RAYO_PROMPT)
ELEMENT_DECL
(
RAYO_RECEIVEFAX
)
ELEMENT_DECL
(
RAYO_RECEIVEFAX
)
ELEMENT_DECL
(
RAYO_RECORD
)
ELEMENT_DECL
(
RAYO_RECORD
)
ELEMENT_DECL
(
RAYO_SENDFAX
)
ELEMENT_DECL
(
RAYO_SENDFAX
)
ELEMENT_DECL
(
RAYO_APP
)
#endif
#endif
...
...
src/mod/event_handlers/mod_rayo/rayo_exec_component.c
0 → 100644
浏览文件 @
479c8a4a
/*
* mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2018, Grasshopper
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_rayo for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is Grasshopper
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Rienzo <chris.rienzo@grasshopper.com>
*
* rayo_exec_component.c -- Rayo call application execution component
*
*/
#include "rayo_components.h"
#include "rayo_elements.h"
/**
* An exec component
*/
struct
exec_component
{
/** component base class */
struct
rayo_component
base
;
/** Dialplan app */
const
char
*
app
;
/** Dialplan app args */
char
*
args
;
};
#define EXEC_COMPONENT(x) ((struct exec_component *)x)
/**
* Wrapper for executing dialplan app
*/
SWITCH_STANDARD_APP
(
rayo_app_exec
)
{
if
(
!
zstr
(
data
))
{
struct
rayo_component
*
component
=
RAYO_COMPONENT_LOCATE
(
data
);
if
(
component
)
{
switch_status_t
status
;
switch_channel_set_variable
(
switch_core_session_get_channel
(
session
),
SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE
,
""
);
status
=
switch_core_session_execute_application
(
session
,
EXEC_COMPONENT
(
component
)
->
app
,
EXEC_COMPONENT
(
component
)
->
args
);
if
(
status
!=
SWITCH_STATUS_SUCCESS
)
{
rayo_component_send_complete
(
component
,
COMPONENT_COMPLETE_ERROR
);
}
else
{
const
char
*
resp
=
switch_channel_get_variable
(
switch_core_session_get_channel
(
session
),
SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE
);
if
(
zstr
(
resp
))
{
rayo_component_send_complete
(
component
,
COMPONENT_COMPLETE_DONE
);
}
else
{
/* send complete event to client */
iks
*
response
=
iks_new
(
"app"
);
iks_insert_attrib
(
response
,
"xmlns"
,
RAYO_EXEC_COMPLETE_NS
);
iks_insert_attrib
(
response
,
"response"
,
resp
);
rayo_component_send_complete_with_metadata
(
component
,
COMPONENT_COMPLETE_DONE
,
response
,
1
);
iks_delete
(
response
);
}
}
RAYO_RELEASE
(
component
);
}
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Missing rayo exec component JID
\n
"
);
}
switch_channel_set_variable
(
switch_core_session_get_channel
(
session
),
SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE
,
""
);
}
/**
* Create a record component
*/
static
struct
rayo_component
*
exec_component_create
(
struct
rayo_actor
*
call
,
const
char
*
client_jid
,
iks
*
exec
)
{
switch_memory_pool_t
*
pool
;
struct
exec_component
*
exec_component
=
NULL
;
switch_core_new_memory_pool
(
&
pool
);
exec_component
=
switch_core_alloc
(
pool
,
sizeof
(
*
exec_component
));
exec_component
=
EXEC_COMPONENT
(
rayo_component_init
(
RAYO_COMPONENT
(
exec_component
),
pool
,
RAT_CALL_COMPONENT
,
"exec"
,
NULL
,
call
,
client_jid
));
if
(
exec_component
)
{
exec_component
->
app
=
switch_core_strdup
(
pool
,
iks_find_attrib_soft
(
exec
,
"app"
));
exec_component
->
args
=
switch_core_strdup
(
pool
,
iks_find_attrib_soft
(
exec
,
"args"
));
}
else
{
switch_core_destroy_memory_pool
(
&
pool
);
return
NULL
;
}
return
RAYO_COMPONENT
(
exec_component
);
}
/**
* Execute dialplan APP on rayo call
*/
static
iks
*
start_exec_app_component
(
struct
rayo_actor
*
call
,
struct
rayo_message
*
msg
,
void
*
data
)
{
iks
*
iq
=
msg
->
payload
;
iks
*
exec
=
iks_find
(
iq
,
"app"
);
struct
rayo_component
*
exec_component
=
NULL
;
switch_core_session_t
*
session
=
NULL
;
/* validate record attributes */
if
(
!
VALIDATE_RAYO_APP
(
exec
))
{
return
iks_new_error
(
iq
,
STANZA_ERROR_BAD_REQUEST
);
}
exec_component
=
exec_component_create
(
call
,
iks_find_attrib
(
iq
,
"from"
),
exec
);
if
(
!
exec_component
)
{
return
iks_new_error_detailed
(
iq
,
STANZA_ERROR_INTERNAL_SERVER_ERROR
,
"Failed to create exec entity"
);
}
session
=
switch_core_session_locate
(
call
->
id
);
if
(
session
)
{
if
(
switch_core_session_execute_application_async
(
session
,
switch_core_session_strdup
(
session
,
"rayo-app-exec"
),
switch_core_session_strdup
(
session
,
RAYO_JID
(
exec_component
)))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_core_session_rwunlock
(
session
);
RAYO_RELEASE
(
exec_component
);
RAYO_DESTROY
(
exec_component
);
return
iks_new_error_detailed
(
iq
,
STANZA_ERROR_INTERNAL_SERVER_ERROR
,
"failed to execute app"
);
}
switch_core_session_rwunlock
(
session
);
}
else
{
RAYO_RELEASE
(
exec_component
);
RAYO_DESTROY
(
exec_component
);
return
iks_new_error_detailed
(
iq
,
STANZA_ERROR_INTERNAL_SERVER_ERROR
,
"Call is gone"
);
}
rayo_component_send_start
(
exec_component
,
iq
);
return
NULL
;
}
/**
* Initialize exec component
* @param module_interface
* @param pool memory pool to allocate from
* @param config_file to use
* @return SWITCH_STATUS_SUCCESS if successful
*/
switch_status_t
rayo_exec_component_load
(
switch_loadable_module_interface_t
**
module_interface
,
switch_memory_pool_t
*
pool
,
const
char
*
config_file
)
{
switch_application_interface_t
*
app_interface
;
SWITCH_ADD_APP
(
app_interface
,
"rayo-app-exec"
,
"Wrapper dialplan app for internal use only"
,
""
,
rayo_app_exec
,
""
,
SAF_SUPPORT_NOMEDIA
|
SAF_ZOMBIE_EXEC
);
rayo_actor_command_handler_add
(
RAT_CALL
,
""
,
"set:"
RAYO_EXEC_NS
":app"
,
start_exec_app_component
);
return
SWITCH_STATUS_SUCCESS
;
}
/**
* Shutdown exec component
* @return SWITCH_STATUS_SUCCESS if successful
*/
switch_status_t
rayo_exec_component_shutdown
(
void
)
{
return
SWITCH_STATUS_SUCCESS
;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet
*/
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论