Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c11d9728
提交
c11d9728
authored
5月 10, 2006
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@1420
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
9eb3de9b
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
1 行增加
和
410 行删除
+1
-410
modules.conf.in
modules.conf.in
+1
-2
Makefile
src/mod/endpoints/mod_opal/Makefile
+0
-14
mod_opal.c
src/mod/endpoints/mod_opal/mod_opal.c
+0
-394
没有找到文件。
modules.conf.in
浏览文件 @
c11d9728
...
...
@@ -20,9 +20,8 @@ dialplans/mod_dialplan_xml
endpoints/mod_exosip
endpoints/mod_iax
endpoints/mod_dingaling
endpoints/mod_opal
endpoints/mod_portaudio
endpoints/mod_wanpipe
#
endpoints/mod_wanpipe
endpoints/mod_woomera
#event_handlers/mod_event_multicast
#event_handlers/mod_event_test
...
...
src/mod/endpoints/mod_opal/Makefile
deleted
100644 → 0
浏览文件 @
9eb3de9b
#CFLAGS += -I/usr/src/common/src
LDFLAGS
+=
-liax
all
:
$(MODNAME).$(DYNAMIC_LIB_EXTEN)
$(MODNAME).$(DYNAMIC_LIB_EXTEN)
:
$(MODNAME).c
$(CC)
$(CFLAGS)
-fPIC
-c
$(MODNAME)
.c
-o
$(MODNAME)
.o
$(CC)
$(SOLINK)
-o
$(MODNAME)
.
$(DYNAMIC_LIB_EXTEN)
$(MODNAME)
.o
$(LDFLAGS)
clean
:
rm
-fr
*
.
$(DYNAMIC_LIB_EXTEN)
*
.o
*
~
install
:
cp
-f
$(MODNAME)
.
$(DYNAMIC_LIB_EXTEN)
$(PREFIX)
/mod
src/mod/endpoints/mod_opal/mod_opal.c
deleted
100644 → 0
浏览文件 @
9eb3de9b
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
*
* 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 FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthmct@yahoo.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Anthony Minessale II <anthmct@yahoo.com>
*
*
* mod_opalchan.c -- OPAL2 Endpoint Module
*
*/
#include <switch.h>
static
const
char
modname
[]
=
"mod_woomera"
;
static
switch_memory_pool_t
*
module_pool
=
NULL
;
typedef
enum
{
TFLAG_IO
=
(
1
<<
0
),
TFLAG_INBOUND
=
(
1
<<
1
),
TFLAG_OUTBOUND
=
(
1
<<
2
),
TFLAG_DTMF
=
(
1
<<
3
),
}
TFLAGS
;
static
struct
{
int
debug
;
int
port
;
}
globals
;
struct
private_object
{
unsigned
int
flags
;
struct
switch_frame
frame
;
unsigned
char
databuf
[
SWITCH_RECCOMMENDED_BUFFER_SIZE
];
switch_core_session_t
*
session
;
switch_caller_profile_t
*
caller_profile
;
};
static
const
switch_endpoint_interface_t
channel_endpoint_interface
;
static
switch_status_t
channel_on_init
(
switch_core_session_t
*
session
);
static
switch_status_t
channel_on_hangup
(
switch_core_session_t
*
session
);
static
switch_status_t
channel_on_ring
(
switch_core_session_t
*
session
);
static
switch_status_t
channel_on_loopback
(
switch_core_session_t
*
session
);
static
switch_status_t
channel_on_transmit
(
switch_core_session_t
*
session
);
static
switch_status_t
channel_outgoing_channel
(
switch_core_session_t
*
session
,
switch_caller_profile_t
*
outbound_profile
,
switch_core_session_t
**
new_session
);
static
switch_status_t
channel_read_frame
(
switch_core_session_t
*
session
,
struct
switch_frame
**
frame
,
int
timeout
,
switch_io_flag
flags
,
int
stream_id
);
static
switch_status_t
channel_write_frame
(
switch_core_session_t
*
session
,
struct
switch_frame
*
frame
,
int
timeout
,
switch_io_flag
flags
,
int
stream_id
);
static
switch_status_t
channel_kill_channel
(
switch_core_session_t
*
session
,
int
sig
);
/*
State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
static
switch_status_t
channel_on_init
(
switch_core_session_t
*
session
)
{
switch_channel_t
*
channel
;
struct
private_object
*
tech_pvt
=
NULL
;
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
tech_pvt
->
frame
.
data
=
tech_pvt
->
databuf
;
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_on_ring
(
switch_core_session_t
*
session
)
{
switch_channel_t
*
channel
=
NULL
;
struct
private_object
*
tech_pvt
=
NULL
;
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s CHANNEL RING
\n
"
,
switch_channel_get_name
(
channel
));
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_on_execute
(
switch_core_session_t
*
session
)
{
switch_channel_t
*
channel
=
NULL
;
struct
private_object
*
tech_pvt
=
NULL
;
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s CHANNEL EXECUTE
\n
"
,
switch_channel_get_name
(
channel
));
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_on_hangup
(
switch_core_session_t
*
session
)
{
switch_channel_t
*
channel
=
NULL
;
struct
private_object
*
tech_pvt
=
NULL
;
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s CHANNEL HANGUP
\n
"
,
switch_channel_get_name
(
channel
));
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_kill_channel
(
switch_core_session_t
*
session
,
int
sig
)
{
switch_channel_t
*
channel
=
NULL
;
struct
private_object
*
tech_pvt
=
NULL
;
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
switch_channel_hangup
(
channel
,
SWITCH_CAUSE_NORMAL_CLEARING
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%s CHANNEL KILL
\n
"
,
switch_channel_get_name
(
channel
));
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_on_loopback
(
switch_core_session_t
*
session
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"CHANNEL LOOPBACK
\n
"
);
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_on_transmit
(
switch_core_session_t
*
session
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"CHANNEL TRANSMIT
\n
"
);
return
SWITCH_STATUS_SUCCESS
;
}
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
*/
static
switch_status_t
channel_outgoing_channel
(
switch_core_session_t
*
session
,
switch_caller_profile_t
*
outbound_profile
,
switch_core_session_t
**
new_session
)
{
if
((
*
new_session
=
switch_core_session_request
(
&
channel_endpoint_interface
,
NULL
)))
{
struct
private_object
*
tech_pvt
;
switch_channel_t
*
channel
,
*
orig_channel
;
switch_caller_profile_t
*
caller_profile
,
*
originator_caller_profile
=
NULL
;
switch_core_session_add_stream
(
*
new_session
,
NULL
);
if
((
tech_pvt
=
(
struct
private_object
*
)
switch_core_session_alloc
(
*
new_session
,
sizeof
(
struct
private_object
))))
{
memset
(
tech_pvt
,
0
,
sizeof
(
*
tech_pvt
));
channel
=
switch_core_session_get_channel
(
*
new_session
);
switch_core_session_set_private
(
*
new_session
,
tech_pvt
);
tech_pvt
->
session
=
*
new_session
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Hey where is my memory pool?
\n
"
);
switch_core_session_destroy
(
new_session
);
return
SWITCH_STATUS_GENERR
;
}
if
(
outbound_profile
)
{
char
name
[
128
];
caller_profile
=
switch_caller_profile_clone
(
*
new_session
,
outbound_profile
);
switch_channel_set_caller_profile
(
channel
,
caller_profile
);
tech_pvt
->
caller_profile
=
caller_profile
;
snprintf
(
name
,
sizeof
(
name
),
"Opal/%s-%04x"
,
caller_profile
->
destination_number
,
rand
()
&
0xffff
);
switch_channel_set_name
(
channel
,
name
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Doh! no caller profile
\n
"
);
switch_core_session_destroy
(
new_session
);
return
SWITCH_STATUS_GENERR
;
}
/* (session == NULL) means it was originated from the core not from another channel */
if
(
session
&&
(
orig_channel
=
switch_core_session_get_channel
(
session
)))
{
switch_caller_profile_t
*
cloned_profile
;
if
((
originator_caller_profile
=
switch_channel_get_caller_profile
(
orig_channel
)))
{
cloned_profile
=
switch_caller_profile_clone
(
*
new_session
,
originator_caller_profile
);
switch_channel_set_originator_caller_profile
(
channel
,
cloned_profile
);
}
}
switch_channel_set_flag
(
channel
,
CF_OUTBOUND
);
switch_set_flag
(
tech_pvt
,
TFLAG_OUTBOUND
);
switch_channel_set_state
(
channel
,
CS_INIT
);
return
SWITCH_STATUS_SUCCESS
;
}
return
SWITCH_STATUS_GENERR
;
}
static
switch_status_t
channel_waitfor_read
(
switch_core_session_t
*
session
,
int
ms
,
int
stream_id
)
{
struct
private_object
*
tech_pvt
=
NULL
;
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_waitfor_write
(
switch_core_session_t
*
session
,
int
ms
,
int
stream_id
)
{
struct
private_object
*
tech_pvt
=
NULL
;
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_read_frame
(
switch_core_session_t
*
session
,
switch_frame
**
frame
,
int
timeout
,
switch_io_flag
flags
,
int
stream_id
)
{
switch_channel_t
*
channel
=
NULL
;
struct
private_object
*
tech_pvt
=
NULL
;
//switch_frame *pframe;
//switch_status_t status;
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_write_frame
(
switch_core_session_t
*
session
,
switch_frame
*
frame
,
int
timeout
,
switch_io_flag
flags
,
int
stream_id
)
{
switch_channel_t
*
channel
=
NULL
;
struct
private_object
*
tech_pvt
=
NULL
;
//switch_frame *pframe;
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
return
SWITCH_STATUS_SUCCESS
;
}
static
const
switch_event_handler_table
channel_event_handlers
=
{
/*.on_init */
channel_on_init
,
/*.on_ring */
channel_on_ring
,
/*.on_execute */
channel_on_execute
,
/*.on_hangup */
channel_on_hangup
,
/*.on_loopback */
channel_on_loopback
,
/*.on_transmit */
channel_on_transmit
};
static
const
switch_io_routines
channel_io_routines
=
{
/*.outgoing_channel */
channel_outgoing_channel
,
/*.answer_channel */
NULL
,
/*.read_frame */
channel_read_frame
,
/*.write_frame */
channel_write_frame
,
/*.kill_channel */
channel_kill_channel
,
/*.waitfor_read */
channel_waitfor_read
,
/*.waitfor_write */
channel_waitfor_write
};
static
const
switch_endpoint_interface
channel_endpoint_interface
=
{
/*.interface_name */
"opal"
,
/*.io_routines */
&
channel_io_routines
,
/*.event_handlers */
&
channel_event_handlers
,
/*.private */
NULL
,
/*.next */
NULL
};
static
const
switch_loadable_module_interface
channel_module_interface
=
{
/*.module_name */
modname
,
/*.endpoint_interface */
&
channel_endpoint_interface
,
/*.timer_interface */
NULL
,
/*.dialplan_interface */
NULL
,
/*.codec_interface */
NULL
,
/*.application_interface */
NULL
};
/*
SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
{
int x = 0;
opal_profile_thread_running(&default_profile, 1, 0);
while (!opal_profile_thread_running(&default_profile, 0, 0)) {
opal_socket_close(&default_profile.opal_socket);
if (x++ > 10) {
break;
}
switch_yield(1);
}
return SWITCH_STATUS_SUCCESS;
}
*/
SWITCH_MOD_DECLARE
(
switch_status_t
)
switch_module_load
(
const
switch_loadable_module_interface
**
interface
,
char
*
filename
)
{
char
*
cf
=
"opal.conf"
;
memset
(
&
globals
,
0
,
sizeof
(
globals
));
if
(
!
(
xml
=
switch_xml_open_cfg
(
cf
,
&
cfg
,
NULL
)))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"open of %s failed
\n
"
,
cf
);
return
SWITCH_STATUS_TERM
;
}
if
((
settings
=
switch_xml_child
(
cfg
,
"settings"
)))
{
for
(
param
=
switch_xml_child
(
settings
,
"param"
);
param
;
param
=
param
->
next
)
{
char
*
var
=
(
char
*
)
switch_xml_attr
(
param
,
"name"
);
char
*
val
=
(
char
*
)
switch_xml_attr
(
param
,
"value"
);
if
(
!
strcmp
(
var
,
"debug"
))
{
globals
.
debug
=
atoi
(
val
);
}
else
if
(
!
strcmp
(
var
,
"port"
))
{
globals
.
port
=
atoi
(
val
);
}
}
}
switch_xml_free
(
xml
);
if
(
switch_core_new_memory_pool
(
&
module_pool
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"OH OH no pool
\n
"
);
return
SWITCH_STATUS_TERM
;
}
/* connect my internal structure to the blank pointer passed to me */
*
interface
=
&
channel_module_interface
;
/* indicate that the module should continue to be loaded */
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_MOD_DECLARE
(
switch_status_t
)
switch_module_runtime
(
void
)
{
return
SWITCH_STATUS_TERM
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论