[Freeswitch-trunk] [commit] r14045 - in freeswitch/trunk/contrib/mod/endpoints/mod_khomp: . include src
FreeSWITCH SVN
raulfragoso at freeswitch.org
Tue Jun 30 02:09:23 PDT 2009
Author: raulfragoso
Date: Tue Jun 30 04:09:22 2009
New Revision: 14045
Log:
Moved the function definitions from the header to the cpp file to keep the compiler happy;
Included some flags to indicate when stream and audio callbacks are enabled or disabled;
Modified:
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/mod_khomp.h
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp
freeswitch/trunk/contrib/mod/endpoints/mod_khomp/src/khomp_pvt.cpp
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h Tue Jun 30 04:09:22 2009
@@ -2,6 +2,7 @@
#define _KHOMP_PVT_H_
#include "globals.h"
+#include "mod_khomp.h"
#define KHOMP_PACKET_SIZE 16
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/mod_khomp.h
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/mod_khomp.h (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/mod_khomp.h Tue Jun 30 04:09:22 2009
@@ -59,26 +59,6 @@
#include "opt.h"
/*!
- \brief Callback generated from K3L API for every new event on the board.
- \param[in] obj Object ID (could be a channel or a board, depends on device type) which generated the event.
- \param[in] e The event itself.
- \return ksSuccess if the event was treated
- \see K3L_EVENT Event specification
- */
-static int32 Kstdcall khomp_event_callback(int32 obj, K3L_EVENT * e);
-
-/*!
- \brief Callback generated from K3L API everytime audio is available on the board.
- @param[in] deviceid Board on which we get the event
- @param[in] objectid The channel we are getting the audio from
- @param[out] read_buffer The audio buffer itself (RAW)
- @param[in] read_size The buffer size, meaning the amount of data to be read
- \return ksSuccess if the event was treated
- */
-static void Kstdcall khomp_audio_listener(int32 deviceid, int32 objectid,
- byte * read_buffer, int32 read_size);
-
-/*!
\brief Defined by mod_reference, defines statuses for the switch_channel
\param TFLAG_IO Enables the IO state of a channel
\param TFLAG_INBOUND Sets a channel as inbound
@@ -94,105 +74,10 @@
TFLAG_HANGUP = (1 << 5),
TFLAG_LINEAR = (1 << 6),
TFLAG_CODEC = (1 << 7),
- TFLAG_BREAK = (1 << 8)
+ TFLAG_BREAK = (1 << 8),
+ TFLAG_STREAM = (1 << 9),
+ TFLAG_LISTEN = (1 << 10)
}
TFLAGS;
-/*!
- \brief Load the module. Expadend by a FreeSWITCH macro.
- Things we do here:
- \li Initialize a static structure on KhompPvt
- \li Load the configuration
- \li Start the K3L API, responsible for connecting to KServer
- \li Register mod APIs and APPs
- \li Register audio callback for KServer
- \li Register event callback for KServer
- \see Opt Where all the configs are handled
- \see khomp_event_callback To where we bind the event handler
- \see khomp_audio_listener To where we bind the audio handlers
- */
-SWITCH_MODULE_LOAD_FUNCTION(mod_khomp_load);
-SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_khomp_shutdown);
-SWITCH_MODULE_DEFINITION(mod_khomp, mod_khomp_load, mod_khomp_shutdown, NULL);
-
-/* State handlers for FreeSWITCH */
-static switch_status_t channel_on_init(switch_core_session_t *session);
-static switch_status_t channel_on_routing(switch_core_session_t *session);
-static switch_status_t channel_on_execute(switch_core_session_t *session);
-static switch_status_t channel_on_hangup(switch_core_session_t *session);
-static switch_status_t channel_on_exchange_media(
- switch_core_session_t *session);
-static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
-static switch_status_t channel_on_destroy(switch_core_session_t *session);
-
-switch_state_handler_table_t khomp_state_handlers = {
- /*.on_init */ channel_on_init,
- /*.on_routing */ channel_on_routing,
- /*.on_execute */ channel_on_execute,
- /*.on_hangup */ channel_on_hangup,
- /*.on_exchange_media */ channel_on_exchange_media,
- /*.on_soft_execute */ channel_on_soft_execute,
- /*.on_consume_media */ NULL,
- /*.on_hibernate */ NULL,
- /*.on_reset */ NULL,
- /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ channel_on_destroy
-};
-
-/* Callbacks for FreeSWITCH */
-static switch_call_cause_t channel_outgoing_channel(
- switch_core_session_t *session,
- switch_event_t *var_event,
- switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session,
- switch_memory_pool_t **pool,
- switch_originate_flag_t flags);
-static switch_status_t channel_read_frame(switch_core_session_t *session,
- switch_frame_t **frame,
- switch_io_flag_t flags,
- int stream_id);
-static switch_status_t channel_write_frame(switch_core_session_t *session,
- switch_frame_t *frame,
- switch_io_flag_t flags,
- int stream_id);
-static switch_status_t channel_kill_channel(switch_core_session_t *session,
- int sig);
-static switch_status_t channel_send_dtmf(switch_core_session_t *session,
- const switch_dtmf_t *dtmf);
-static switch_status_t channel_receive_message(switch_core_session_t *session,
- switch_core_session_message_t *msg);
-static switch_status_t channel_receive_event(switch_core_session_t *session,
- switch_event_t *event);
-
-
-switch_io_routines_t khomp_io_routines = {
- /*.outgoing_channel */ channel_outgoing_channel,
- /*.read_frame */ channel_read_frame,
- /*.write_frame */ channel_write_frame,
- /*.kill_channel */ channel_kill_channel,
- /*.send_dtmf */ channel_send_dtmf,
- /*.receive_message */ channel_receive_message,
- /*.receive_event */ channel_receive_event
-};
-
-/* Macros to define specific API functions */
-SWITCH_STANDARD_API(khomp);
-
-/*!
- \brief Print a system summary for all the boards. [khomp show info]
- */
-static void printSystemSummary(switch_stream_handle_t* stream);
-/*!
- \brief Print link status. [khomp show links]
- */
-static void printLinks(switch_stream_handle_t* stream, unsigned int device,
- unsigned int link);
-/*!
- \brief Print board channel status. [khomp show channels]
- */
-static void printChannels(switch_stream_handle_t* stream, unsigned int device,
- unsigned int link);
-
-
#endif /* _MOD_KHOMP_H_ */
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp Tue Jun 30 04:09:22 2009
@@ -43,6 +43,124 @@
#include "mod_khomp.h"
/*!
+ \brief Callback generated from K3L API for every new event on the board.
+ \param[in] obj Object ID (could be a channel or a board, depends on device type) which generated the event.
+ \param[in] e The event itself.
+ \return ksSuccess if the event was treated
+ \see K3L_EVENT Event specification
+ */
+static int32 Kstdcall khomp_event_callback(int32 obj, K3L_EVENT * e);
+
+/*!
+ \brief Callback generated from K3L API everytime audio is available on the board.
+ @param[in] deviceid Board on which we get the event
+ @param[in] objectid The channel we are getting the audio from
+ @param[out] read_buffer The audio buffer itself (RAW)
+ @param[in] read_size The buffer size, meaning the amount of data to be read
+ \return ksSuccess if the event was treated
+ */
+static void Kstdcall khomp_audio_listener(int32 deviceid, int32 objectid,
+ byte * read_buffer, int32 read_size);
+
+/*!
+ \brief Load the module. Expadend by a FreeSWITCH macro.
+ Things we do here:
+ \li Initialize a static structure on KhompPvt
+ \li Load the configuration
+ \li Start the K3L API, responsible for connecting to KServer
+ \li Register mod APIs and APPs
+ \li Register audio callback for KServer
+ \li Register event callback for KServer
+ \see Opt Where all the configs are handled
+ \see khomp_event_callback To where we bind the event handler
+ \see khomp_audio_listener To where we bind the audio handlers
+ */
+SWITCH_MODULE_LOAD_FUNCTION(mod_khomp_load);
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_khomp_shutdown);
+SWITCH_MODULE_DEFINITION(mod_khomp, mod_khomp_load, mod_khomp_shutdown, NULL);
+
+/* State handlers for FreeSWITCH */
+static switch_status_t channel_on_init(switch_core_session_t *session);
+static switch_status_t channel_on_routing(switch_core_session_t *session);
+static switch_status_t channel_on_execute(switch_core_session_t *session);
+static switch_status_t channel_on_hangup(switch_core_session_t *session);
+static switch_status_t channel_on_exchange_media(
+ switch_core_session_t *session);
+static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
+static switch_status_t channel_on_destroy(switch_core_session_t *session);
+
+switch_state_handler_table_t khomp_state_handlers = {
+ /*.on_init */ channel_on_init,
+ /*.on_routing */ channel_on_routing,
+ /*.on_execute */ channel_on_execute,
+ /*.on_hangup */ channel_on_hangup,
+ /*.on_exchange_media */ channel_on_exchange_media,
+ /*.on_soft_execute */ channel_on_soft_execute,
+ /*.on_consume_media */ NULL,
+ /*.on_hibernate */ NULL,
+ /*.on_reset */ NULL,
+ /*.on_park*/ NULL,
+ /*.on_reporting*/ NULL,
+ /*.on_destroy*/ channel_on_destroy
+};
+
+/* Callbacks for FreeSWITCH */
+static switch_call_cause_t channel_outgoing_channel(
+ switch_core_session_t *session,
+ switch_event_t *var_event,
+ switch_caller_profile_t *outbound_profile,
+ switch_core_session_t **new_session,
+ switch_memory_pool_t **pool,
+ switch_originate_flag_t flags);
+static switch_status_t channel_read_frame(switch_core_session_t *session,
+ switch_frame_t **frame,
+ switch_io_flag_t flags,
+ int stream_id);
+static switch_status_t channel_write_frame(switch_core_session_t *session,
+ switch_frame_t *frame,
+ switch_io_flag_t flags,
+ int stream_id);
+static switch_status_t channel_kill_channel(switch_core_session_t *session,
+ int sig);
+static switch_status_t channel_send_dtmf(switch_core_session_t *session,
+ const switch_dtmf_t *dtmf);
+static switch_status_t channel_receive_message(switch_core_session_t *session,
+ switch_core_session_message_t *msg);
+static switch_status_t channel_receive_event(switch_core_session_t *session,
+ switch_event_t *event);
+
+
+switch_io_routines_t khomp_io_routines = {
+ /*.outgoing_channel */ channel_outgoing_channel,
+ /*.read_frame */ channel_read_frame,
+ /*.write_frame */ channel_write_frame,
+ /*.kill_channel */ channel_kill_channel,
+ /*.send_dtmf */ channel_send_dtmf,
+ /*.receive_message */ channel_receive_message,
+ /*.receive_event */ channel_receive_event
+};
+
+/* Macros to define specific API functions */
+SWITCH_STANDARD_API(khomp);
+
+/*!
+ \brief Print a system summary for all the boards. [khomp show info]
+ */
+static void printSystemSummary(switch_stream_handle_t* stream);
+/*!
+ \brief Print link status. [khomp show links]
+ */
+static void printLinks(switch_stream_handle_t* stream, unsigned int device,
+ unsigned int link);
+/*!
+ \brief Print board channel status. [khomp show channels]
+ */
+static void printChannels(switch_stream_handle_t* stream, unsigned int device,
+ unsigned int link);
+
+
+
+/*!
\brief Will init part of our private structure and setup all the read/write
buffers along with the proper codecs. Right now, only PCMA.
*/
Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/src/khomp_pvt.cpp
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/src/khomp_pvt.cpp (original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/src/khomp_pvt.cpp Tue Jun 30 04:09:22 2009
@@ -245,12 +245,14 @@
{
Globals::_k3lapi.mixer(_KDeviceId, _KChannelId, 0, kmsPlay, _KChannelId);
Globals::_k3lapi.command(_KDeviceId, _KChannelId, CM_START_STREAM_BUFFER);
- //flags.set(kflags::STREAM_UP);
}
catch(...)
{
return false;
}
+
+ switch_set_flag_locked(this, TFLAG_STREAM);
+
return true;
}
@@ -260,13 +262,14 @@
{
Globals::_k3lapi.mixer(_KDeviceId, _KChannelId, 0, kmsGenerator, kmtSilence);
Globals::_k3lapi.command(_KDeviceId, _KChannelId, CM_STOP_STREAM_BUFFER);
- //flags.clear(kflags::STREAM_UP);
}
catch(...)
{
return false;
}
-
+
+ switch_clear_flag_locked(this, TFLAG_STREAM);
+
return true;
}
@@ -289,8 +292,7 @@
return false;
}
- /* always set this flag to avoid constant 'ksInvalidState' messages. */
- //flags.set(kflags::LISTEN_UP);
+ switch_set_flag_locked(this, TFLAG_LISTEN);
return true;
}
@@ -306,7 +308,7 @@
return false;
}
- //flags.clear(kflags::LISTEN_UP);
+ switch_clear_flag_locked(this, TFLAG_LISTEN);
return true;
}
More information about the Freeswitch-trunk
mailing list