From a9235b1b226a45f4f5d8a53260b90382df96f14d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 6 Mar 2008 03:11:20 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7800 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 5 +++++ src/include/switch_core_event_hook.h | 12 +++++++++++- src/include/switch_module_interfaces.h | 7 ++++++- src/switch_core_event_hook.c | 1 + src/switch_core_session.c | 15 +++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index afa939a6d4..0a00129c20 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -728,6 +728,11 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(_In_opt _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags); +SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ const char *endpoint_name, + _Inout_ switch_core_session_t **new_session, + _Inout_ switch_memory_pool_t **pool, + _In_ void *data); + /*! \brief Receive a message on a given session \param session the session to receive the message from diff --git a/src/include/switch_core_event_hook.h b/src/include/switch_core_event_hook.h index 41021c6218..71e6015f34 100644 --- a/src/include/switch_core_event_hook.h +++ b/src/include/switch_core_event_hook.h @@ -48,6 +48,7 @@ typedef struct switch_io_event_hook_waitfor_write switch_io_event_hook_waitfor_w typedef struct switch_io_event_hook_send_dtmf switch_io_event_hook_send_dtmf_t; typedef struct switch_io_event_hook_recv_dtmf switch_io_event_hook_recv_dtmf_t; typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t; +typedef struct switch_io_event_hook_resurrect_session switch_io_event_hook_resurrect_session_t; typedef switch_status_t (*switch_outgoing_channel_hook_t) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t); typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *); @@ -62,7 +63,7 @@ typedef switch_status_t (*switch_waitfor_write_hook_t) (switch_core_session_t *, typedef switch_status_t (*switch_send_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *); typedef switch_status_t (*switch_recv_dtmf_hook_t) (switch_core_session_t *, const switch_dtmf_t *); typedef switch_status_t (*switch_state_change_hook_t) (switch_core_session_t *); - +typedef switch_call_cause_t (*switch_resurrect_session_hook_t)(switch_core_session_t **, switch_memory_pool_t **, void *); /*! \brief Node in which to store custom receive message callback hooks */ struct switch_io_event_hook_outgoing_channel { @@ -154,6 +155,12 @@ struct switch_io_event_hook_state_change { struct switch_io_event_hook_state_change *next; }; + +struct switch_io_event_hook_resurrect_session { + switch_resurrect_session_hook_t resurrect_session; + struct switch_io_event_hook_resurrect_session *next; +}; + /*! \brief A table of lists of io_event_hooks to store the event hooks associated with a session */ struct switch_io_event_hooks { /*! a list of outgoing channel hooks */ @@ -182,6 +189,7 @@ struct switch_io_event_hooks { switch_io_event_hook_recv_dtmf_t *recv_dtmf; /*! a list of state change hooks */ switch_io_event_hook_state_change_t *state_change; + switch_io_event_hook_resurrect_session_t *resurrect_session; }; extern switch_io_event_hooks_t switch_core_session_get_event_hooks(switch_core_session_t *session); @@ -240,6 +248,7 @@ NEW_HOOK_DECL_ADD_P(waitfor_read); NEW_HOOK_DECL_ADD_P(waitfor_write); NEW_HOOK_DECL_ADD_P(send_dtmf); NEW_HOOK_DECL_ADD_P(recv_dtmf); +NEW_HOOK_DECL_ADD_P(resurrect_session); NEW_HOOK_DECL_REM_P(outgoing_channel); NEW_HOOK_DECL_REM_P(receive_message); @@ -254,6 +263,7 @@ NEW_HOOK_DECL_REM_P(waitfor_read); NEW_HOOK_DECL_REM_P(waitfor_write); NEW_HOOK_DECL_REM_P(send_dtmf); NEW_HOOK_DECL_REM_P(recv_dtmf); +NEW_HOOK_DECL_REM_P(resurrect_session); ///\} SWITCH_END_EXTERN_C diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index 3b277f64cb..e0994a3ba2 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -98,6 +98,7 @@ struct switch_stream_handle { struct switch_io_event_hooks; + typedef switch_call_cause_t (*switch_io_outgoing_channel_t) (switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t); typedef switch_status_t (*switch_io_read_frame_t) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int); @@ -111,6 +112,7 @@ typedef switch_status_t (*switch_io_receive_event_t) (switch_core_session_t *, s typedef switch_status_t (*switch_io_state_change_t) (switch_core_session_t *); typedef switch_status_t (*switch_io_read_video_frame_t) (switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int); typedef switch_status_t (*switch_io_write_video_frame_t) (switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int); +typedef switch_call_cause_t (*switch_io_resurrect_session_t)(switch_core_session_t **, switch_memory_pool_t **, void *); typedef enum { SWITCH_IO_OUTGOING_CHANNEL, @@ -124,7 +126,8 @@ typedef enum { SWITCH_IO_RECEIVE_EVENT, SWITCH_IO_STATE_CHANGE, SWITCH_IO_READ_VIDEO_FRAME, - SWITCH_IO_WRITE_VIDEO_FRAME + SWITCH_IO_WRITE_VIDEO_FRAME, + SWITCH_IO_RESURRECT_SESSION } switch_io_routine_name_t; /*! \brief A table of i/o routines that an endpoint interface can implement */ @@ -153,6 +156,8 @@ struct switch_io_routines { switch_io_read_video_frame_t read_video_frame; /*! write a video frame to a session */ switch_io_write_video_frame_t write_video_frame; + /*! resurrect a session */ + switch_io_resurrect_session_t resurrect_session; void *padding[10]; }; diff --git a/src/switch_core_event_hook.c b/src/switch_core_event_hook.c index eb53093cf3..c7ead6a60a 100644 --- a/src/switch_core_event_hook.c +++ b/src/switch_core_event_hook.c @@ -44,6 +44,7 @@ NEW_HOOK_DECL(waitfor_read) NEW_HOOK_DECL(waitfor_write) NEW_HOOK_DECL(send_dtmf) NEW_HOOK_DECL(recv_dtmf) +NEW_HOOK_DECL(resurrect_session) /* For Emacs: * Local Variables: diff --git a/src/switch_core_session.c b/src/switch_core_session.c index cad418fa15..dfb416c7fc 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -173,6 +173,21 @@ SWITCH_DECLARE(int) switch_core_session_get_stream_count(switch_core_session_t * return session->stream_count; } +SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(const char *endpoint_name, + switch_core_session_t **new_session, + switch_memory_pool_t **pool, + void *data) +{ + const switch_endpoint_interface_t *endpoint_interface; + + if ((endpoint_interface = switch_loadable_module_get_endpoint_interface(endpoint_name)) == 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not locate channel type %s\n", endpoint_name); + return SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED; + } + + return endpoint_interface->io_routines->resurrect_session(new_session, pool, data); +} + SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_core_session_t *session, const char *endpoint_name, switch_caller_profile_t *caller_profile,