mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 12:42:02 +00:00
Adding bugs to the core
This is the primary commit to add bugs to the core (media bugs that is)
Media bugs are kind of like what ChanSpy is in Asterisk only cooler (I wrote ChanSpy too so I can say that)
Here is an example of using them to record a call by the higher level switch_ivr functionality passed
up to the dialplan via mod_playback.
The call will be recorded while the some.wav plays then stop for the rest of the call (when some_other.wav plays)
The bugs may have bugs since this is 1 day's work so happy hunting ......
<extension name="42">
<condition field="destination_number" expression="^42$">
<action application="set" data="RECORD_TITLE=recording test"/>
<action application="set" data="RECORD_ARTIST=FreeSWITCH"/>
<action application="record_session" data="/tmp/rtest.wav"/>
<action application="playback" data="/tmp/some.wav"/>
<action application="stop_record_session" data="/tmp/rtest.wav"/>
<action application="playback" data="/tmp/some_other.wav"/>
</condition>
</extension>
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2588 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -107,6 +107,50 @@ struct switch_core_port_allocator;
|
||||
\{
|
||||
*/
|
||||
|
||||
|
||||
///\defgroup pa1 Media Bugs
|
||||
///\ingroup core1
|
||||
///\{
|
||||
|
||||
/*!
|
||||
\brief Add a media bug to the session
|
||||
\param session the session to add the bug to
|
||||
\param callback a callback for events
|
||||
\param user_data arbitrary user data
|
||||
\param new_bug pointer to assign new bug to
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was a success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session,
|
||||
switch_media_bug_callback_t callback,
|
||||
void *user_data,
|
||||
switch_media_bug_t **new_bug);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Remove a media bug from the session
|
||||
\param session the session to remove the bug from
|
||||
\param bug bug to remove
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was a success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session_t *session, switch_media_bug_t **bug);
|
||||
|
||||
/*!
|
||||
\brief Remove all media bugs from the session
|
||||
\param session the session to remove the bugs from
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was a success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_all(switch_core_session_t *session);
|
||||
|
||||
/*!
|
||||
\brief Read a frame from the bug
|
||||
\param bug the bug to read from
|
||||
\param frame the frame to write the data to
|
||||
\return the amount of data
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *bug, switch_frame_t *frame);
|
||||
|
||||
///\}
|
||||
|
||||
///\defgroup pa1 Port Allocation
|
||||
///\ingroup core1
|
||||
///\{
|
||||
@@ -119,7 +163,10 @@ struct switch_core_port_allocator;
|
||||
\param new pointer for the return value
|
||||
\return SWITCH_STATUS_SUCCESS if the operation was a success
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(switch_port_t start, switch_port_t end, uint8_t inc, switch_core_port_allocator_t **new_allocator);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_new(switch_port_t start,
|
||||
switch_port_t end,
|
||||
uint8_t inc,
|
||||
switch_core_port_allocator_t **new_allocator);
|
||||
|
||||
/*!
|
||||
\brief Get a port from the port allocator
|
||||
|
||||
@@ -94,7 +94,24 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
|
||||
const char *terminators,
|
||||
char *terminator,
|
||||
unsigned int timeout);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Record a session to disk
|
||||
\param session the session to record
|
||||
\param file the path to the file
|
||||
\param fh file handle to use (NULL for builtin one)
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, switch_file_handle_t *fh);
|
||||
|
||||
/*!
|
||||
\brief Stop Recording a session
|
||||
\param session the session to stop recording
|
||||
\param file the path to the file
|
||||
\return SWITCH_STATUS_SUCCESS if all is well
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_record_session(switch_core_session_t *session, char *file);
|
||||
|
||||
/*!
|
||||
\brief play a file from the disk to the session
|
||||
\param session the session to play the file too
|
||||
|
||||
@@ -80,6 +80,12 @@ typedef enum {
|
||||
SWITCH_BITPACK_MODE_AAL2
|
||||
} switch_bitpack_mode_t;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_ABC_TYPE_INIT,
|
||||
SWITCH_ABC_TYPE_READ,
|
||||
SWITCH_ABC_TYPE_WRITE,
|
||||
SWITCH_ABC_TYPE_CLOSE,
|
||||
} switch_abc_type_t;
|
||||
|
||||
typedef struct {
|
||||
switch_byte_t *buf;
|
||||
@@ -739,9 +745,8 @@ typedef struct switch_file_interface switch_file_interface_t;
|
||||
typedef struct switch_speech_interface switch_speech_interface_t;
|
||||
typedef struct switch_directory_interface switch_directory_interface_t;
|
||||
typedef struct switch_core_port_allocator switch_core_port_allocator_t;
|
||||
typedef struct switch_audio_bug switch_audio_bug_t;
|
||||
typedef void (*switch_audio_bug_read_callback_t)(switch_audio_bug_t *);
|
||||
typedef void (*switch_audio_bug_write_callback_t)(switch_audio_bug_t *);
|
||||
typedef struct switch_media_bug switch_media_bug_t;
|
||||
typedef void (*switch_media_bug_callback_t)(switch_media_bug_t *, void *, switch_abc_type_t);
|
||||
typedef void (*switch_application_function_t)(switch_core_session_t *, char *);
|
||||
typedef void (*switch_event_callback_t)(switch_event_t *);
|
||||
typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t)(switch_core_session_t *);
|
||||
@@ -787,7 +792,7 @@ struct switch_channel;
|
||||
/*! \brief A core session representing a call and all of it's resources */
|
||||
struct switch_core_session;
|
||||
/*! \brief An audio bug */
|
||||
struct switch_audio_bug;
|
||||
struct switch_media_bug;
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
|
||||
@@ -50,6 +50,12 @@ SWITCH_BEGIN_EXTERN_C
|
||||
#endif
|
||||
|
||||
|
||||
#define SWITCH_SMAX 32767
|
||||
#define SWITCH_SMIN -32768
|
||||
#define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\brief Evaluate the truthfullness of a string expression
|
||||
\param expr a string expression
|
||||
|
||||
Reference in New Issue
Block a user