git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6066 d0543943-73ff-0310-b7d9-9358b9ac24b2

This commit is contained in:
Łukasz Zwierko committed 2007-10-27 10:41:52 +00:00
1 parent ec6310f56b
commit 4c589c7a16
3 files changed
+387 -36

No files matched your search

+98 -36
View File
@@ -32,13 +32,68 @@
#include "mod_opalh323.h"
/* All gluer frontend function for Freeswitch must be
* "C" functions. Because OPAL is written in C++
* I implemented module gluer functions as extern "C"
#inlcude "opalh323_backend.h"
#include <switch.h>
/*
* IO routines handlers definitions
*/
extern "C" {
static switch_call_cause_t opalh323_outgoing_channel(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **);
static switch_status_t opalh323_read_frame(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
static switch_status_t opalh323_write_frame(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
static switch_status_t opalh323_kill_channel(switch_core_session_t *, int);
static switch_status_t opalh323_waitfor_read(switch_core_session_t *, int, int);
static switch_status_t opalh323_waitfor_write(switch_core_session_t *, int, int);
static switch_status_t opalh323_send_dtmf(switch_core_session_t *, char *);
static switch_status_t opalh323_receive_message(switch_core_session_t *, switch_core_session_message_t *);
static switch_status_t opalh323_receive_event(switch_core_session_t *, switch_event_t *);
static switch_status_t opalh323_state_change(switch_core_session_t *);
static switch_status_t opalh323_read_video_frame(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
static switch_status_t opalh323_write_video_frame(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
/*
* Event handlers declaration
*/
static switch_status_t opalh323_on_init(switch_core_session_t *session);
static switch_status_t opalh323_on_ring(switch_core_session_t *session);
static switch_status_t opalh323_on_execute(switch_core_session_t *session);
static switch_status_t opalh323_on_hangup(switch_core_session_t *session);
static switch_status_t opalh323_on_loopback(switch_core_session_t *session);
static switch_status_t opalh323_on_transmit(switch_core_session_t *session);
/**
* Declaration of private variables
*/
static FSOpalManager *opalh323_manager = NULL;
static switch_memory_pool_t *opalh323_pool = NULL;
static switch_endpoint_interface_t *opalh323_endpoint_interface;
/*
* IO routines handlers set declaration
*/
static switch_io_routines_t opalh323_io_routines = {
/*.outgoing_channel */ opalh323_outgoing_channel,
/*.read_frame */ opalh323_read_frame,
/*.write_frame */ opalh323_write_frame,
/*.kill_channel */ opalh323_kill_channel,
/*.waitfor_read */ opalh323_waitfor_read,
/*.waitfor_read */ opalh323_waitfor_write,
/*.send_dtmf */ opalh323_send_dtmf,
/*.receive_message */ opalh323_receive_message,
/*.receive_event */ opalh323_receive_event,
/*.state_change*/ opalh323_state_change,
/*.read_video_frame*/ opalh323_read_video_frame,
/*.write_video_frame*/ opalh323_write_video_frame
};
static switch_state_handler_table_t opalh323_event_handlers = {
/*.on_init */ opalh323_on_init,
/*.on_ring */ opalh323_on_ring,
/*.on_execute */ opalh323_on_execute,
/*.on_hangup */ opalh323_on_hangup,
/*.on_loopback */ opalh323_on_loopback,
/*.on_transmit */ opalh323_on_transmit
};
/*
* Loadable FreeSWITCH module functions declaration
*/
@@ -61,6 +116,35 @@ switch_endpoint_interface_t *opalh323_endpoint_interface;
*/
SWITCH_MODULE_LOAD_FUNCTION(mod_opalh323_load)
{
/* frontend initialization*/
*module_interface =NULL;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
assert(*module_interface);
if(!module_interface)
{
return SWITCH_STATUS_MEMERR;
}
opalh323_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
opalh323_endpoint_interface->interface_name = "OPALH323";
opalh323_endpoint_interface->io_routines = &opalh323_io_routines;
opalh323_endpoint_interface->state_handler = &opalh323_event_handlers;
/* backend initialization */
opalh323_manager = new FSOpalManager();
assert(opalh323_manager);
if(!opalh323_manager)
{
return SWITCH_STATUS_MEMERR;
}
if(!opalh323_manager->initialize(pool))
{
delete opalh323_manager;
return SWITCH_STATUS_FALSE; /* if can't initialize return general error */
}
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
@@ -71,29 +155,19 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_opalh323_load)
* it dealocates OPAL core
*
*/
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_opalh323_shutdown)
{
/* deallocate OPAL manager */
delete opalh323_manager;
return SWITCH_STATUS_SUCCESS;
}
/*
* IO routines handlers
*/
static switch_io_routines_t opalh323_io_routines = {
/*.outgoing_channel */ opalh323_outgoing_channel,
/*.read_frame */ opalh323_read_frame,
/*.write_frame */ opalh323_write_frame,
/*.kill_channel */ opalh323_kill_channel,
/*.waitfor_read */ opalh323_waitfor_read,
/*.waitfor_read */ opalh323_waitfor_write,
/*.send_dtmf */ opalh323_send_dtmf,
/*.receive_message */ opalh323_receive_message,
/*.receive_event */ opalh323_receive_event,
/*.state_change*/ opalh323_state_change,
/*.read_video_frame*/ opalh323_read_video_frame,
/*.write_video_frame*/ opalh323_write_video_frame
};
/*
* IO routines handlers definitions
*/
static switch_call_cause_t opalh323_outgoing_channel(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **)
{
return 0;
@@ -157,14 +231,6 @@ static switch_status_t opalh323_write_video_frame(switch_core_session_t *, switc
/*
* Event handlers
*/
static switch_state_handler_table_t opalh323_event_handlers = {
/*.on_init */ opalh323_on_init,
/*.on_ring */ opalh323_on_ring,
/*.on_execute */ opalh323_on_execute,
/*.on_hangup */ opalh323_on_hangup,
/*.on_loopback */ opalh323_on_loopback,
/*.on_transmit */ opalh323_on_transmit
};
static switch_status_t opalh323_on_init(switch_core_session_t *session)
{
@@ -195,7 +261,3 @@ static switch_status_t opalh323_on_transmit(switch_core_session_t *session)
{
return SWITCH_STATUS_SUCCESS;
}
}