Freeswitch-trunk
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
July 2006
- 4 participants
- 133 discussions
[commit] r1846 - in freeswitch/trunk/src: . include mod/applications/mod_ivrtest mod/applications/mod_playback mod/applications/mod_rss mod/endpoints/mod_dingaling mod/event_handlers/mod_xmpp_event mod/languages/mod_spidermonkey
by Freeswitch SVN 12 Jul '06
by Freeswitch SVN 12 Jul '06
12 Jul '06
Author: anthm
Date: Wed Jul 12 14:39:19 2006
New Revision: 1846
Modified:
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/include/switch_module_interfaces.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c
freeswitch/trunk/src/mod/applications/mod_playback/mod_playback.c
freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_ivr.c
Log:
rearrange the furnature
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Wed Jul 12 14:39:19 2006
@@ -335,9 +335,17 @@
\param event the event to send
\return the status returned by the message handler
*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t *event);
+SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event);
/*!
+ \brief Send an event to a session translating it to it's native message format
+ \param session the session to receive the event
+ \param event the event to receive
+ \return the status returned by the handler
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event);
+
+/*!
\brief Retrieve private user data from a session
\param session the session to retrieve from
\return a pointer to the private data
@@ -433,7 +441,16 @@
\param event the event to queue
\return the status returned by the message handler
*/
-SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t *event);
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event);
+
+/*!
+ \brief DE-Queue an event on a given session
+ \param session the session to de-queue the message on
+ \param event the de-queued event
+ \return the SWITCH_STATUS_SUCCESS if the event was de-queued
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event);
+
/*!
\brief Read a frame from a session
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Wed Jul 12 14:39:19 2006
@@ -59,7 +59,7 @@
\return SWITCH_STATUS_SUCCESS to keep the collection moving.
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen);
@@ -98,7 +98,7 @@
switch_file_handle_t *fh,
char *file,
char *timer_name,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen);
@@ -118,7 +118,7 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
switch_file_handle_t *fh,
char *file,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen);
@@ -127,7 +127,7 @@
switch_speech_handle_t *sh,
switch_codec_t *codec,
switch_timer_t *timer,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t dtmf_callback,
char *text,
void *buf,
unsigned int buflen);
@@ -150,7 +150,7 @@
char *voice_name,
char *timer_name,
uint32_t rate,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t dtmf_callback,
char *text,
void *buf,
unsigned int buflen);
@@ -169,7 +169,7 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
switch_core_session_t *peer_session,
unsigned int timelimit,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t dtmf_callback,
void *session_data,
void *peer_session_data);
Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h (original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h Wed Jul 12 14:39:19 2006
@@ -93,10 +93,10 @@
};
/*! \brief Node in which to store custom receive message callback hooks */
-struct switch_io_event_hook_queue_event {
+struct switch_io_event_hook_receive_event {
/*! the answer channel callback hook*/
- switch_queue_event_hook_t queue_event;
- struct switch_io_event_hook_queue_event *next;
+ switch_receive_event_hook_t receive_event;
+ struct switch_io_event_hook_receive_event *next;
};
/*! \brief Node in which to store custom read frame channel callback hooks */
@@ -150,7 +150,7 @@
/*! a list of receive message hooks */
switch_io_event_hook_receive_message_t *receive_message;
/*! a list of queue message hooks */
- switch_io_event_hook_queue_event_t *queue_event;
+ switch_io_event_hook_receive_event_t *receive_event;
/*! a list of read frame hooks */
switch_io_event_hook_read_frame_t *read_frame;
/*! a list of write frame hooks */
@@ -186,7 +186,7 @@
/*! receive a message from another session*/
switch_status_t (*receive_message)(switch_core_session_t *, switch_core_session_message_t *);
/*! queue a message for another session*/
- switch_status_t (*queue_event)(switch_core_session_t *, switch_event_t *);
+ switch_status_t (*receive_event)(switch_core_session_t *, switch_event_t *);
};
/*! \brief Abstraction of an module endpoint interface
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Wed Jul 12 14:39:19 2006
@@ -573,6 +573,10 @@
SWITCH_EVENT_ALL
} switch_event_types_t;
+typedef enum {
+ SWITCH_INPUT_TYPE_DTMF,
+ SWITCH_INPUT_TYPE_EVENT
+} switch_input_type_t;
typedef enum {
SWITCH_CAUSE_UNALLOCATED = 1,
@@ -651,7 +655,7 @@
typedef struct switch_io_event_hook_outgoing_channel switch_io_event_hook_outgoing_channel_t;
typedef struct switch_io_event_hook_answer_channel switch_io_event_hook_answer_channel_t;
typedef struct switch_io_event_hook_receive_message switch_io_event_hook_receive_message_t;
-typedef struct switch_io_event_hook_queue_event switch_io_event_hook_queue_event_t;
+typedef struct switch_io_event_hook_receive_event switch_io_event_hook_receive_event_t;
typedef struct switch_io_event_hook_read_frame switch_io_event_hook_read_frame_t;
typedef struct switch_io_event_hook_write_frame switch_io_event_hook_write_frame_t;
typedef struct switch_io_event_hook_kill_channel switch_io_event_hook_kill_channel_t;
@@ -682,7 +686,7 @@
typedef switch_status_t (*switch_outgoing_channel_hook_t)(switch_core_session_t *, switch_caller_profile_t *, switch_core_session_t *);
typedef switch_status_t (*switch_answer_channel_hook_t)(switch_core_session_t *);
typedef switch_status_t (*switch_receive_message_hook_t)(switch_core_session_t *, switch_core_session_message_t *);
-typedef switch_status_t (*switch_queue_event_hook_t)(switch_core_session_t *, switch_event_t *);
+typedef switch_status_t (*switch_receive_event_hook_t)(switch_core_session_t *, switch_event_t *);
typedef switch_status_t (*switch_read_frame_hook_t)(switch_core_session_t *, switch_frame_t **, int, switch_io_flag_t, int);
typedef switch_status_t (*switch_write_frame_hook_t)(switch_core_session_t *, switch_frame_t *, int, switch_io_flag_t, int);
typedef switch_status_t (*switch_kill_channel_hook_t)(switch_core_session_t *, int);
@@ -692,7 +696,11 @@
typedef struct switch_stream_handle switch_stream_handle_t;
typedef switch_status_t (*switch_stream_handle_write_function_t)(switch_stream_handle_t *handle, char *fmt, ...);
typedef switch_status_t (*switch_api_function_t)(char *in, switch_stream_handle_t *stream);
-typedef switch_status_t (*switch_dtmf_callback_function_t)(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen);
+typedef switch_status_t (*switch_input_callback_function_t)(switch_core_session_t *session,
+ void *input,
+ switch_input_type_t input_type,
+ void *buf,
+ unsigned int buflen);
typedef int (*switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames);
typedef switch_status_t (*switch_module_load_t) (switch_loadable_module_interface_t **, char *);
typedef switch_status_t (*switch_module_reload_t) (void);
Modified: freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_ivrtest/mod_ivrtest.c Wed Jul 12 14:39:19 2006
@@ -39,16 +39,23 @@
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
-static switch_status_t on_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF: {
+ char *dtmf = (char *) input;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
- switch_copy_string((char *)buf, dtmf, buflen);
- return SWITCH_STATUS_BREAK;
-
+ switch_copy_string((char *)buf, dtmf, buflen);
+ return SWITCH_STATUS_BREAK;
+ }
+ break;
+ default:
+ break;
+ }
+ return SWITCH_STATUS_SUCCESS;
}
-
static void disast_function(switch_core_session_t *session, char *data)
{
void *x = NULL;
@@ -107,13 +114,22 @@
}
-static switch_status_t show_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t show_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
-
- switch_copy_string((char *)buf, dtmf, buflen);
- return SWITCH_STATUS_SUCCESS;
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF: {
+ char *dtmf = (char *) input;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+
+ switch_copy_string((char *)buf, dtmf, buflen);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return SWITCH_STATUS_SUCCESS;
}
static void tts_function(switch_core_session_t *session, char *data)
Modified: freeswitch/trunk/src/mod/applications/mod_playback/mod_playback.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_playback/mod_playback.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_playback/mod_playback.c Wed Jul 12 14:39:19 2006
@@ -37,12 +37,22 @@
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
-static switch_status_t on_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
- if (*dtmf == '*') {
- return SWITCH_STATUS_FALSE;
+
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF: {
+ char *dtmf = (char *) input;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Digits %s\n", dtmf);
+
+ if (*dtmf == '*') {
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+ break;
+ default:
+ break;
}
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c Wed Jul 12 14:39:19 2006
@@ -85,68 +85,74 @@
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
-static switch_status_t on_dtmf(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
-{
+static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
- struct dtmf_buffer *dtb;
- dtb = (struct dtmf_buffer *) buf;
+{
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF: {
+ char *dtmf = (char *) input;
+ struct dtmf_buffer *dtb;
+ dtb = (struct dtmf_buffer *) buf;
- switch(*dtmf) {
- case '#':
- switch_set_flag(dtb, SFLAG_MAIN);
- return SWITCH_STATUS_BREAK;
- case '6':
- dtb->index++;
- return SWITCH_STATUS_BREAK;
- case '4':
- dtb->index--;
- return SWITCH_STATUS_BREAK;
- case '*':
- if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
- switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
- } else {
- switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
- }
- break;
- case '5':
- switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
- switch_set_flag(dtb, SFLAG_INFO);
- return SWITCH_STATUS_BREAK;
- break;
- case '9':
- switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
- switch_set_flag(dtb, SFLAG_INFO);
- return SWITCH_STATUS_BREAK;
- break;
- case '2':
- if (dtb->speed < 260) {
- dtb->speed += 30;
- switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
+ switch(*dtmf) {
+ case '#':
+ switch_set_flag(dtb, SFLAG_MAIN);
+ return SWITCH_STATUS_BREAK;
+ case '6':
+ dtb->index++;
+ return SWITCH_STATUS_BREAK;
+ case '4':
+ dtb->index--;
+ return SWITCH_STATUS_BREAK;
+ case '*':
+ if (switch_test_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE)) {
+ switch_clear_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
+ } else {
+ switch_set_flag(dtb->sh, SWITCH_SPEECH_FLAG_PAUSE);
+ }
+ break;
+ case '5':
+ switch_core_speech_text_param_tts(dtb->sh, "voice", "next");
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
- }
- break;
- case '7':
- dtb->speed = TTS_MEAN_SPEED;
- switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
- switch_set_flag(dtb, SFLAG_INFO);
- return SWITCH_STATUS_BREAK;
- case '8':
- if (dtb->speed > 80) {
- dtb->speed -= 30;
+ break;
+ case '9':
+ switch_core_speech_text_param_tts(dtb->sh, "voice", dtb->voice);
+ switch_set_flag(dtb, SFLAG_INFO);
+ return SWITCH_STATUS_BREAK;
+ break;
+ case '2':
+ if (dtb->speed < 260) {
+ dtb->speed += 30;
+ switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
+ switch_set_flag(dtb, SFLAG_INFO);
+ return SWITCH_STATUS_BREAK;
+ }
+ break;
+ case '7':
+ dtb->speed = TTS_MEAN_SPEED;
switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
switch_set_flag(dtb, SFLAG_INFO);
return SWITCH_STATUS_BREAK;
+ case '8':
+ if (dtb->speed > 80) {
+ dtb->speed -= 30;
+ switch_core_speech_numeric_param_tts(dtb->sh, "speech/rate", dtb->speed);
+ switch_set_flag(dtb, SFLAG_INFO);
+ return SWITCH_STATUS_BREAK;
+ }
+ break;
+ case '0':
+ switch_set_flag(dtb, SFLAG_INSTRUCT);
+ return SWITCH_STATUS_BREAK;
}
+ }
break;
- case '0':
- switch_set_flag(dtb, SFLAG_INSTRUCT);
- return SWITCH_STATUS_BREAK;
+ default:
+ break;
}
-
return SWITCH_STATUS_SUCCESS;
}
-
static void rss_function(switch_core_session_t *session, char *data)
{
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Wed Jul 12 14:39:19 2006
@@ -1509,7 +1509,9 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", from);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "subject", subject);
switch_event_add_body(event, msg);
- switch_event_fire(&event);
+ if (switch_core_session_queue_event(tech_pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
+ switch_event_fire(&event);
+ }
}
break;
Modified: freeswitch/trunk/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_xmpp_event/mod_xmpp_event.c Wed Jul 12 14:39:19 2006
@@ -239,6 +239,7 @@
stream.data = retbuf;
stream.end = stream.data;
stream.data_size = sizeof(retbuf);
+ stream.write_function = switch_console_stream_write;
switch_api_execute(cmd, arg, &stream);
return 0;
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Wed Jul 12 14:39:19 2006
@@ -175,218 +175,247 @@
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t js_stream_dtmf_callback(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t js_stream_dtmf_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
- char code[2048];
- struct dtmf_callback_state *cb_state = buf;
- struct js_session *jss = cb_state->session_state;
- switch_file_handle_t *fh = cb_state->extra;
- jsval rval;
- char *ret;
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF: {
+ char *dtmf = (char *) input;
+ char code[2048];
+ struct dtmf_callback_state *cb_state = buf;
+ struct js_session *jss = cb_state->session_state;
+ switch_file_handle_t *fh = cb_state->extra;
+ jsval rval;
+ char *ret;
- if (!jss) {
- return SWITCH_STATUS_FALSE;
- }
-
- if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
- char *d;
- if (!cb_state->digit_count) {
- cb_state->digit_count = atoi(cb_state->code_buffer);
+ if (!jss) {
+ return SWITCH_STATUS_FALSE;
}
+
+ if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
+ char *d;
+ if (!cb_state->digit_count) {
+ cb_state->digit_count = atoi(cb_state->code_buffer);
+ }
- for(d = dtmf; *d; d++) {
- cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
- if ((cb_state->ret_buffer_len > cb_state->digit_count)||
- (cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
- (cb_state->ret_buffer_len >= cb_state->digit_count)
- ) {
- return SWITCH_STATUS_FALSE;
+ for(d = dtmf; *d; d++) {
+ cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
+ if ((cb_state->ret_buffer_len > cb_state->digit_count)||
+ (cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
+ (cb_state->ret_buffer_len >= cb_state->digit_count)
+ ) {
+ return SWITCH_STATUS_FALSE;
+ }
}
- }
- return SWITCH_STATUS_SUCCESS;
- } else {
- snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
- eval_some_js(code, jss->cx, jss->obj, &rval);
- ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
+ return SWITCH_STATUS_SUCCESS;
+ } else {
+ snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
+ eval_some_js(code, jss->cx, jss->obj, &rval);
+ ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
- if (!strncasecmp(ret, "speed", 4)) {
- char *p;
+ if (!strncasecmp(ret, "speed", 4)) {
+ char *p;
- if ((p = strchr(ret, ':'))) {
- p++;
- if (*p == '+' || *p == '-') {
- int step;
- if (!(step = atoi(p))) {
- step = 1;
+ if ((p = strchr(ret, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1;
+ }
+ fh->speed += step;
+ } else {
+ int speed = atoi(p);
+ fh->speed = speed;
}
- fh->speed += step;
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+ } else if (!strcasecmp(ret, "pause")) {
+ if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+ switch_clear_flag(fh, SWITCH_FILE_PAUSE);
} else {
- int speed = atoi(p);
- fh->speed = speed;
+ switch_set_flag(fh, SWITCH_FILE_PAUSE);
}
return SWITCH_STATUS_SUCCESS;
- }
-
- return SWITCH_STATUS_FALSE;
- } else if (!strcasecmp(ret, "pause")) {
- if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
- switch_clear_flag(fh, SWITCH_FILE_PAUSE);
- } else {
- switch_set_flag(fh, SWITCH_FILE_PAUSE);
- }
- return SWITCH_STATUS_SUCCESS;
- } else if (!strcasecmp(ret, "restart")) {
- unsigned int pos = 0;
- fh->speed = 0;
- switch_core_file_seek(fh, &pos, 0, SEEK_SET);
- return SWITCH_STATUS_SUCCESS;
- } else if (!strncasecmp(ret, "seek", 4)) {
- switch_codec_t *codec;
- unsigned int samps = 0;
- unsigned int pos = 0;
- char *p;
- codec = switch_core_session_get_read_codec(jss->session);
+ } else if (!strcasecmp(ret, "restart")) {
+ unsigned int pos = 0;
+ fh->speed = 0;
+ switch_core_file_seek(fh, &pos, 0, SEEK_SET);
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strncasecmp(ret, "seek", 4)) {
+ switch_codec_t *codec;
+ unsigned int samps = 0;
+ unsigned int pos = 0;
+ char *p;
+ codec = switch_core_session_get_read_codec(jss->session);
- if ((p = strchr(ret, ':'))) {
- p++;
- if (*p == '+' || *p == '-') {
- int step;
- if (!(step = atoi(p))) {
- step = 1000;
- }
- if (step > 0) {
- samps = step * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
+ if ((p = strchr(ret, ':'))) {
+ p++;
+ if (*p == '+' || *p == '-') {
+ int step;
+ if (!(step = atoi(p))) {
+ step = 1000;
+ }
+ if (step > 0) {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
+ } else {
+ samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+ }
} else {
- samps = step * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+ samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
+ switch_core_file_seek(fh, &pos, samps, SEEK_SET);
}
- } else {
- samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
- switch_core_file_seek(fh, &pos, samps, SEEK_SET);
}
+
+ return SWITCH_STATUS_SUCCESS;
}
- return SWITCH_STATUS_SUCCESS;
- }
-
- if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
- return SWITCH_STATUS_SUCCESS;
- }
+ if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+ return SWITCH_STATUS_SUCCESS;
+ }
- if (ret) {
- switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+ if (ret) {
+ switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+ }
}
+
+ return SWITCH_STATUS_FALSE;
}
+ break;
+ default:
+ break;
+ }
+ return SWITCH_STATUS_SUCCESS;
- return SWITCH_STATUS_FALSE;
}
-
-static switch_status_t js_record_dtmf_callback(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t js_record_dtmf_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
- char code[2048];
- struct dtmf_callback_state *cb_state = buf;
- struct js_session *jss = cb_state->session_state;
- switch_file_handle_t *fh = cb_state->extra;
- jsval rval;
- char *ret;
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF: {
+ char *dtmf = (char *) input;
+ char code[2048];
+ struct dtmf_callback_state *cb_state = buf;
+ struct js_session *jss = cb_state->session_state;
+ switch_file_handle_t *fh = cb_state->extra;
+ jsval rval;
+ char *ret;
- if (!jss) {
- return SWITCH_STATUS_FALSE;
- }
-
- if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
- char *d;
- if (!cb_state->digit_count) {
- cb_state->digit_count = atoi(cb_state->code_buffer);
+ if (!jss) {
+ return SWITCH_STATUS_FALSE;
}
-
- for(d = dtmf; *d; d++) {
- cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
- if ((cb_state->ret_buffer_len > cb_state->digit_count)||
- (cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
- (cb_state->ret_buffer_len >= cb_state->digit_count)
- ) {
- return SWITCH_STATUS_FALSE;
+
+ if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
+ char *d;
+ if (!cb_state->digit_count) {
+ cb_state->digit_count = atoi(cb_state->code_buffer);
}
- }
- return SWITCH_STATUS_SUCCESS;
- } else {
- snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
- eval_some_js(code, jss->cx, jss->obj, &rval);
- ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
- if (!strcasecmp(ret, "pause")) {
- if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
- switch_clear_flag(fh, SWITCH_FILE_PAUSE);
- } else {
- switch_set_flag(fh, SWITCH_FILE_PAUSE);
+ for(d = dtmf; *d; d++) {
+ cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
+ if ((cb_state->ret_buffer_len > cb_state->digit_count)||
+ (cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
+ (cb_state->ret_buffer_len >= cb_state->digit_count)
+ ) {
+ return SWITCH_STATUS_FALSE;
+ }
}
return SWITCH_STATUS_SUCCESS;
- } else if (!strcasecmp(ret, "restart")) {
- unsigned int pos = 0;
- fh->speed = 0;
- switch_core_file_seek(fh, &pos, 0, SEEK_SET);
- return SWITCH_STATUS_SUCCESS;
- }
+ } else {
+ snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
+ eval_some_js(code, jss->cx, jss->obj, &rval);
+ ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
- if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
- return SWITCH_STATUS_SUCCESS;
- }
+ if (!strcasecmp(ret, "pause")) {
+ if (switch_test_flag(fh, SWITCH_FILE_PAUSE)) {
+ switch_clear_flag(fh, SWITCH_FILE_PAUSE);
+ } else {
+ switch_set_flag(fh, SWITCH_FILE_PAUSE);
+ }
+ return SWITCH_STATUS_SUCCESS;
+ } else if (!strcasecmp(ret, "restart")) {
+ unsigned int pos = 0;
+ fh->speed = 0;
+ switch_core_file_seek(fh, &pos, 0, SEEK_SET);
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+ return SWITCH_STATUS_SUCCESS;
+ }
- if (ret) {
- switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+ if (ret) {
+ switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+ }
}
+ return SWITCH_STATUS_FALSE;
}
+ break;
+ default:
+ break;
+ }
- return SWITCH_STATUS_FALSE;
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t js_speak_dtmf_callback(switch_core_session_t *session, char *dtmf, void *buf, unsigned int buflen)
+static switch_status_t js_speak_dtmf_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
{
- char code[2048];
- struct dtmf_callback_state *cb_state = buf;
- struct js_session *jss = cb_state->session_state;
- jsval rval;
- char *ret;
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF: {
+ char *dtmf = (char *) input;
+ char code[2048];
+ struct dtmf_callback_state *cb_state = buf;
+ struct js_session *jss = cb_state->session_state;
+ jsval rval;
+ char *ret;
- if (!jss) {
- return SWITCH_STATUS_FALSE;
- }
-
- if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
- char *d;
- if (!cb_state->digit_count) {
- cb_state->digit_count = atoi(cb_state->code_buffer);
+ if (!jss) {
+ return SWITCH_STATUS_FALSE;
}
-
- for(d = dtmf; *d; d++) {
- cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
- if ((cb_state->ret_buffer_len > cb_state->digit_count)||
- (cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
- (cb_state->ret_buffer_len >= cb_state->digit_count)
- ) {
- return SWITCH_STATUS_FALSE;
+
+ if (cb_state->digit_count || (cb_state->code_buffer[0] > 47 && cb_state->code_buffer[0] < 58)) {
+ char *d;
+ if (!cb_state->digit_count) {
+ cb_state->digit_count = atoi(cb_state->code_buffer);
}
- }
- return SWITCH_STATUS_SUCCESS;
- } else {
- snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
- eval_some_js(code, jss->cx, jss->obj, &rval);
- ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
- if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+ for(d = dtmf; *d; d++) {
+ cb_state->ret_buffer[cb_state->ret_buffer_len++] = *d;
+ if ((cb_state->ret_buffer_len > cb_state->digit_count)||
+ (cb_state->ret_buffer_len > sizeof(cb_state->ret_buffer))||
+ (cb_state->ret_buffer_len >= cb_state->digit_count)
+ ) {
+ return SWITCH_STATUS_FALSE;
+ }
+ }
return SWITCH_STATUS_SUCCESS;
- }
+ } else {
+ snprintf(code, sizeof(code), "~%s(\"%s\")", cb_state->code_buffer, dtmf);
+ eval_some_js(code, jss->cx, jss->obj, &rval);
+ ret = JS_GetStringBytes(JS_ValueToString(jss->cx, rval));
+
+ if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+ return SWITCH_STATUS_SUCCESS;
+ }
- if (ret) {
- switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+ if (ret) {
+ switch_copy_string(cb_state->ret_buffer, ret, sizeof(cb_state->ret_buffer));
+ }
}
+
+ return SWITCH_STATUS_FALSE;
}
+ break;
+ default:
+ break;
+ }
- return SWITCH_STATUS_FALSE;
+ return SWITCH_STATUS_SUCCESS;
+
}
static JSBool session_recordfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
@@ -397,7 +426,7 @@
char *dtmf_callback = NULL;
void *bp = NULL;
int len = 0;
- switch_dtmf_callback_function_t dtmf_func = NULL;
+ switch_input_callback_function_t dtmf_func = NULL;
struct dtmf_callback_state cb_state = {0};
switch_file_handle_t fh;
@@ -443,7 +472,7 @@
char *dtmf_callback = NULL;
void *bp = NULL;
int len = 0;
- switch_dtmf_callback_function_t dtmf_func = NULL;
+ switch_input_callback_function_t dtmf_func = NULL;
struct dtmf_callback_state cb_state = {0};
switch_file_handle_t fh;
@@ -499,7 +528,7 @@
void *bp = NULL;
int len = 0;
struct dtmf_callback_state cb_state = {0};
- switch_dtmf_callback_function_t dtmf_func = NULL;
+ switch_input_callback_function_t dtmf_func = NULL;
channel = switch_core_session_get_channel(jss->session);
assert(channel != NULL);
@@ -1804,6 +1833,8 @@
stream.end = stream.data;
stream.data_size = sizeof(retbuf);
switch_api_execute(cmd, arg, &stream);
+ stream.write_function = switch_console_stream_write;
+
*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, retbuf));
} else {
*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, ""));
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Wed Jul 12 14:39:19 2006
@@ -307,7 +307,7 @@
return status;
}
-SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t *event)
+SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event)
{
switch_core_session_t *session = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
@@ -1057,29 +1057,73 @@
return status;
}
-SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t *event)
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_receive_event(switch_core_session_t *session, switch_event_t **event)
{
- switch_io_event_hook_queue_event_t *ptr;
- switch_status_t status = SWITCH_STATUS_FALSE, istatus = SWITCH_STATUS_FALSE;;
+ switch_io_event_hook_receive_event_t *ptr;
+ switch_status_t status = SWITCH_STATUS_FALSE;
assert(session != NULL);
- if (session->endpoint_interface->io_routines->queue_event) {
- status = session->endpoint_interface->io_routines->queue_event(session, event);
- if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
- for (ptr = session->event_hooks.queue_event; ptr; ptr = ptr->next) {
- if ((istatus = ptr->queue_event(session, event)) != SWITCH_STATUS_SUCCESS) {
- break;
+ /* Acquire a read lock on the session or forget it the channel is dead */
+ if (switch_thread_rwlock_tryrdlock(session->rwlock) == SWITCH_STATUS_SUCCESS) {
+ if (switch_channel_get_state(session->channel) < CS_HANGUP) {
+ if (session->endpoint_interface->io_routines->receive_event) {
+ status = session->endpoint_interface->io_routines->receive_event(session, *event);
+ }
+
+ if (status == SWITCH_STATUS_SUCCESS) {
+ for (ptr = session->event_hooks.receive_event; ptr; ptr = ptr->next) {
+ if ((status = ptr->receive_event(session, *event)) != SWITCH_STATUS_SUCCESS) {
+ break;
+ }
}
}
- }
-
- if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) {
- if (!session->event_queue) {
- switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
+
+ if (status == SWITCH_STATUS_BREAK) {
+ status = SWITCH_STATUS_SUCCESS;
}
- switch_queue_push(session->event_queue, event);
+
+ if (status == SWITCH_STATUS_SUCCESS) {
+ switch_event_destroy(event);
+ }
+ }
+ switch_thread_rwlock_unlock(session->rwlock);
+ }
+
+ return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event)
+
+{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+ assert(session != NULL);
+
+ if (!session->event_queue) {
+ switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
+ }
+
+ if ((status = (switch_status_t) switch_queue_push(session->event_queue, *event) == SWITCH_STATUS_SUCCESS)) {
+ *event = NULL;
+ }
+
+ return status;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event)
+
+{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+ void *pop;
+
+ assert(session != NULL);
+
+ if (session->event_queue) {
+ if ((status = (switch_status_t) switch_queue_trypop(session->event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
+ *event = (switch_event_t *) pop;
}
}
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Wed Jul 12 14:39:19 2006
@@ -36,7 +36,7 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t input_callback,
void *buf,
unsigned int buflen)
{
@@ -46,19 +46,26 @@
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
- if (!dtmf_callback) {
+ if (!input_callback) {
return SWITCH_STATUS_GENERR;
}
while(switch_channel_ready(channel)) {
switch_frame_t *read_frame;
+ switch_event_t *event;
+
char dtmf[128];
if (switch_channel_has_dtmf(channel)) {
switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
- status = dtmf_callback(session, dtmf, buf, buflen);
+ status = input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, buf, buflen);
}
+ if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+ status = input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, buf, buflen);
+ switch_event_destroy(&event);
+ }
+
if (status != SWITCH_STATUS_SUCCESS) {
break;
}
@@ -156,7 +163,7 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *session,
switch_file_handle_t *fh,
char *file,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t input_callback,
void *buf,
unsigned int buflen)
{
@@ -216,22 +223,31 @@
while(switch_channel_ready(channel)) {
switch_size_t len;
+ switch_event_t *event;
- if (dtmf_callback || buf) {
+ if (input_callback || buf) {
/*
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
if (switch_channel_has_dtmf(channel)) {
switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
- if (dtmf_callback) {
- status = dtmf_callback(session, dtmf, buf, buflen);
+ if (input_callback) {
+ status = input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, buf, buflen);
} else {
switch_copy_string((char *)buf, dtmf, buflen);
status = SWITCH_STATUS_BREAK;
}
}
+ if (input_callback) {
+ if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+ status = input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, buf, buflen);
+ switch_event_destroy(&event);
+ }
+ }
+
+
if (status != SWITCH_STATUS_SUCCESS) {
break;
}
@@ -257,7 +273,7 @@
switch_file_handle_t *fh,
char *file,
char *timer_name,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t input_callback,
void *buf,
unsigned int buflen)
{
@@ -352,21 +368,29 @@
int done = 0;
int do_speed = 1;
int last_speed = -1;
+ switch_event_t *event;
- if (dtmf_callback || buf) {
+ if (input_callback || buf) {
/*
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
*/
if (switch_channel_has_dtmf(channel)) {
switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
- if (dtmf_callback) {
- status = dtmf_callback(session, dtmf, buf, buflen);
+ if (input_callback) {
+ status = input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, buf, buflen);
} else {
switch_copy_string((char *)buf, dtmf, buflen);
status = SWITCH_STATUS_BREAK;
}
}
+
+ if (input_callback) {
+ if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+ status = input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, buf, buflen);
+ switch_event_destroy(&event);
+ }
+ }
if (status != SWITCH_STATUS_SUCCESS) {
done = 1;
@@ -501,7 +525,7 @@
switch_speech_handle_t *sh,
switch_codec_t *codec,
switch_timer_t *timer,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t input_callback,
char *text,
void *buf,
unsigned int buflen)
@@ -559,8 +583,9 @@
ilen = len;
while(switch_channel_ready(channel)) {
+ switch_event_t *event;
- if (dtmf_callback || buf) {
+ if (input_callback || buf) {
/*
dtmf handler function you can hook up to be executed when a digit is dialed during playback
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
@@ -570,15 +595,22 @@
status = SWITCH_STATUS_BREAK;
} else {
switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
- if (dtmf_callback) {
- status = dtmf_callback(session, dtmf, buf, buflen);
+ if (input_callback) {
+ status = input_callback(session, dtmf, SWITCH_INPUT_TYPE_DTMF, buf, buflen);
} else {
switch_copy_string((char *)buf, dtmf, buflen);
status = SWITCH_STATUS_BREAK;
}
}
}
-
+
+ if (input_callback) {
+ if (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+ status = input_callback(session, event, SWITCH_INPUT_TYPE_EVENT, buf, buflen);
+ switch_event_destroy(&event);
+ }
+ }
+
if (status != SWITCH_STATUS_SUCCESS) {
done = 1;
break;
@@ -679,7 +711,7 @@
char *voice_name,
char *timer_name,
uint32_t rate,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t input_callback,
char *text,
void *buf,
unsigned int buflen)
@@ -761,7 +793,7 @@
}
}
- switch_ivr_speak_text_handle(session, &sh, &codec, timer_name ? &timer : NULL, dtmf_callback, text, buf, buflen);
+ switch_ivr_speak_text_handle(session, &sh, &codec, timer_name ? &timer : NULL, input_callback, text, buf, buflen);
flags = 0;
switch_core_speech_close(&sh, &flags);
switch_core_codec_destroy(&codec);
@@ -790,7 +822,7 @@
switch_core_thread_session_t *his_thread, *data = obj;
int *stream_id_p;
int stream_id = 0, ans_a = 0, ans_b = 0;
- switch_dtmf_callback_function_t dtmf_callback;
+ switch_input_callback_function_t input_callback;
switch_core_session_message_t msg = {0};
void *user_data;
@@ -804,7 +836,7 @@
session_b = data->objs[1];
stream_id_p = data->objs[2];
- dtmf_callback = (switch_dtmf_callback_function_t) data->objs[3];
+ input_callback = (switch_input_callback_function_t) data->objs[3];
user_data = data->objs[4];
his_thread = data->objs[5];
@@ -824,6 +856,7 @@
while (data->running > 0 && his_thread->running > 0) {
switch_channel_state_t b_state = switch_channel_get_state(chan_b);
switch_status_t status;
+ switch_event_t *event;
switch (b_state) {
case CS_HANGUP:
@@ -862,14 +895,26 @@
switch_channel_dequeue_dtmf(chan_a, dtmf, sizeof(dtmf));
switch_core_session_send_dtmf(session_b, dtmf);
- if (dtmf_callback) {
- if (dtmf_callback(session_a, dtmf, user_data, 0) != SWITCH_STATUS_SUCCESS) {
+ if (input_callback) {
+ if (input_callback(session_a, dtmf, SWITCH_INPUT_TYPE_DTMF, user_data, 0) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s ended call via DTMF\n", switch_channel_get_name(chan_a));
data->running = -1;
break;
}
}
- }
+ }
+
+ if (switch_core_session_dequeue_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
+ if (input_callback) {
+ status = input_callback(session_a, event, SWITCH_INPUT_TYPE_EVENT, user_data, 0);
+ }
+
+ if (switch_core_session_receive_event(session_b, &event) != SWITCH_STATUS_SUCCESS) {
+ switch_event_destroy(&event);
+ }
+
+ }
+
}
/* read audio from 1 channel and write it to the other */
@@ -973,7 +1018,7 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_session_t *session,
switch_core_session_t *peer_session,
unsigned int timelimit,
- switch_dtmf_callback_function_t dtmf_callback,
+ switch_input_callback_function_t input_callback,
void *session_data,
void *peer_session_data)
@@ -1002,7 +1047,7 @@
other_audio_thread->objs[0] = session;
other_audio_thread->objs[1] = peer_session;
other_audio_thread->objs[2] = &stream_id;
- other_audio_thread->objs[3] = (void *) dtmf_callback;
+ other_audio_thread->objs[3] = (void *) input_callback;
other_audio_thread->objs[4] = session_data;
other_audio_thread->objs[5] = this_audio_thread;
other_audio_thread->running = 5;
@@ -1010,7 +1055,7 @@
this_audio_thread->objs[0] = peer_session;
this_audio_thread->objs[1] = session;
this_audio_thread->objs[2] = &stream_id;
- this_audio_thread->objs[3] = (void *) dtmf_callback;
+ this_audio_thread->objs[3] = (void *) input_callback;
this_audio_thread->objs[4] = peer_session_data;
this_audio_thread->objs[5] = other_audio_thread;
this_audio_thread->running = 2;
1
0
[commit] r1833 - in freeswitch/trunk/src: . mod/applications/mod_conference
by Freeswitch SVN 11 Jul '06
by Freeswitch SVN 11 Jul '06
11 Jul '06
Author: mikej
Date: Tue Jul 11 16:59:07 2006
New Revision: 1833
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_loadable_module.c
Log:
fix windows build
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Tue Jul 11 16:59:07 2006
@@ -557,7 +557,7 @@
for (x = 0; x < imember->read / 2; x++) {
int32_t z = muxed[x] + bptr[x];
normalize_to_16bit(z);
- muxed[x] = z;
+ muxed[x] = (int16_t)z;
}
ready++;
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Tue Jul 11 16:59:07 2006
@@ -2870,9 +2870,9 @@
SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err)
{
+ switch_xml_t xml = NULL, cfg = NULL;
memset(&runtime, 0, sizeof(runtime));
runtime.session_limit = 1000;
- switch_xml_t xml = NULL, cfg = NULL;
switch_core_set_globals();
Modified: freeswitch/trunk/src/switch_loadable_module.c
==============================================================================
--- freeswitch/trunk/src/switch_loadable_module.c (original)
+++ freeswitch/trunk/src/switch_loadable_module.c Tue Jul 11 16:59:07 2006
@@ -668,7 +668,7 @@
name = prefs[x];
if ((p = strchr(name, '@'))) {
p++;
- len = p-name;
+ len = (uint32_t)(p-name);
if (len > sizeof(buf)) {
len = sizeof(buf);
@@ -683,7 +683,7 @@
for (imp = codec_interface->implementations; imp; imp = imp->next) {
if (!interval) {
array[i++] = imp;
- } else if ((imp->microseconds_per_frame / 1000) == interval) {
+ } else if ((uint32_t)(imp->microseconds_per_frame / 1000) == interval) {
array[i++] = imp;
}
}
1
0
11 Jul '06
Author: anthm
Date: Tue Jul 11 13:39:50 2006
New Revision: 1830
Modified:
freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c
Log:
fix logical error
Modified: freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c
==============================================================================
--- freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c (original)
+++ freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c Tue Jul 11 13:39:50 2006
@@ -106,12 +106,15 @@
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **interface, char *filename)
{
*interface = &console_module_interface;
+ switch_status_t status;
- switch_log_bind_logger(mod_syslog_logger, SWITCH_LOG_DEBUG);
+ if ((status=load_config()) != SWITCH_STATUS_SUCCESS) {
+ return status;
+ }
- load_config();
-
openlog(globals.ident, LOG_PID, LOG_USER);
+
+ switch_log_bind_logger(mod_syslog_logger, SWITCH_LOG_DEBUG);
return SWITCH_STATUS_SUCCESS;
}
@@ -129,27 +132,28 @@
char *var, *val;
char *cf = "syslog.conf";
- if (!switch_config_open_file(&cfg, cf)) {
+ memset(&globals, 0, sizeof(globals));
+
+ if (switch_config_open_file(&cfg, cf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
- return SWITCH_STATUS_TERM;
- }
- while (switch_config_next_pair(&cfg, &var, &val)) {
- if (!strcasecmp(cfg.category, "settings")) {
- if (!strcmp(var, "ident")) {
- set_global_ident(val);
- } else if (!strcmp(var, "facility")) {
- set_global_facility(val);
- } else if (!strcmp(var, "format")) {
- set_global_format(val);
- } else if (!strcmp(var, "level")) {
- set_global_level(val);;
+ while (switch_config_next_pair(&cfg, &var, &val)) {
+ if (!strcasecmp(cfg.category, "settings")) {
+ if (!strcmp(var, "ident")) {
+ set_global_ident(val);
+ } else if (!strcmp(var, "facility")) {
+ set_global_facility(val);
+ } else if (!strcmp(var, "format")) {
+ set_global_format(val);
+ } else if (!strcmp(var, "level")) {
+ set_global_level(val);;
+ }
}
}
+
+ switch_config_close_file(&cfg);
}
- switch_config_close_file(&cfg);
-
if (switch_strlen_zero(globals.ident)) {
set_global_ident(DEFAULT_IDENT);
}
1
0
Author: anthm
Date: Mon Jul 10 18:27:15 2006
New Revision: 1820
Modified:
freeswitch/trunk/conf/freeswitch.xml
Log:
update config
Modified: freeswitch/trunk/conf/freeswitch.xml
==============================================================================
--- freeswitch/trunk/conf/freeswitch.xml (original)
+++ freeswitch/trunk/conf/freeswitch.xml Mon Jul 10 18:27:15 2006
@@ -78,7 +78,7 @@
<!-- <param name="ip" value="1.2.3.4"> -->
<param name="port" value="4569"/>
<param name="dialplan" value="XML"/>
- <param name="codec-prefs" value="PCMU,PCMA,speex,L16"/>
+ <param name="codec-prefs" value="PCMU@20,PCMA,speex,L16"/>
<param name="codec-master" value="us"/>
<param name="codec-rates" value="8"/>
</settings>
@@ -116,7 +116,9 @@
<param name="port" value="5060"/>
<param name="dialplan" value="XML"/>
<param name="dtmf-duration" value="100"/>
- <param name="codec-prefs" value="PCMU,PCMA"/>
+ <!-- the @20 is optional number of ms you want to use. Use it only
+ if you know the codec supports it -->
+ <param name="codec-prefs" value="PCMU@20,PCMA@20"/>
<!-- Payload number to bind DTMF to-->
<param name="rfc2833-pt" value="101"/>
<!-- disable to trade async for more calls -->
1
0
Author: anthm
Date: Mon Jul 10 18:24:57 2006
New Revision: 1819
Modified:
freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
Log:
adj iax to use the intervals thing
Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c Mon Jul 10 18:24:57 2006
@@ -217,6 +217,7 @@
int num_codecs = 0;
unsigned int local_cap = 0, mixed_cap = 0, chosen = 0, leading = 0;
int x, srate = 8000;
+ uint32_t interval = 0;
if (globals.codec_string) {
if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs,
@@ -291,6 +292,7 @@
for (imp = codecs[z]; imp; imp = imp->next) {
if (prefs[x] == iana2ast(imp->ianacode)) {
dname = imp->iananame;
+ interval = imp->microseconds_per_frame / 1000;
break;
}
}
@@ -307,6 +309,7 @@
unsigned int cap = iana2ast(imp->ianacode);
if (cap == chosen) {
dname = imp->iananame;
+ interval = imp->microseconds_per_frame / 1000;
break;
}
}
@@ -319,6 +322,7 @@
if (cap & mixed_cap) {
chosen = cap;
dname = imp->iananame;
+ interval = imp->microseconds_per_frame / 1000;
break;
}
}
@@ -366,7 +370,7 @@
if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
srate,
- 0,
+ interval,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
@@ -376,7 +380,7 @@
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
srate,
- 0,
+ interval,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
1
0
[commit] r1818 - in freeswitch/trunk/src: . include mod/codecs/mod_g711 mod/codecs/mod_g729 mod/codecs/mod_gsm mod/codecs/mod_ilbc mod/codecs/mod_l16 mod/codecs/mod_speex mod/endpoints/mod_dingaling mod/endpoints/mod_exosip mod/endpoints/mod_iax
by Freeswitch SVN 10 Jul '06
by Freeswitch SVN 10 Jul '06
10 Jul '06
Author: anthm
Date: Mon Jul 10 18:08:02 2006
New Revision: 1818
Modified:
freeswitch/trunk/src/include/switch_loadable_module.h
freeswitch/trunk/src/include/switch_module_interfaces.h
freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c
freeswitch/trunk/src/mod/codecs/mod_gsm/mod_gsm.c
freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c
freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c
freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/trunk/src/switch_loadable_module.c
Log:
restructure codec code
Modified: freeswitch/trunk/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/trunk/src/include/switch_loadable_module.h (original)
+++ freeswitch/trunk/src/include/switch_loadable_module.h Mon Jul 10 18:08:02 2006
@@ -171,10 +171,10 @@
\param arraylen the max size in elements of the array
\return the number of elements added to the array
*/
-SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool,
- switch_codec_interface_t **array,
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, const switch_codec_implementation_t **array,
int arraylen);
+
/*!
\brief Retrieve the list of loaded codecs into an array based on another array showing the sorted order
\param array the array to populate
@@ -184,10 +184,8 @@
\return the number of elements added to the array
\note this function only considers codecs that are listed in the "prefs" array and ignores the rest.
*/
-SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_codec_interface_t **array,
- int arraylen,
- char **prefs,
- int preflen);
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array,
+ int arraylen, char **prefs, int preflen);
/*!
\brief Execute a registered API command
Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h (original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h Mon Jul 10 18:08:02 2006
@@ -444,6 +444,8 @@
/*! \brief A table of settings and callbacks that define a paticular implementation of a codec */
struct switch_codec_implementation {
+ /*! enumeration defining the type of the codec */
+ const switch_codec_type_t codec_type;
/*! the IANA code number */
switch_payload_t ianacode;
/*! the IANA code name */
@@ -497,8 +499,6 @@
struct switch_codec_interface {
/*! the name of the interface */
const char *interface_name;
- /*! enumeration defining the type of the codec */
- const switch_codec_type_t codec_type;
/*! a list of codec implementations related to the codec */
const switch_codec_implementation_t *implementations;
const struct switch_codec_interface *next;
Modified: freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g711/mod_g711.c Mon Jul 10 18:08:02 2006
@@ -190,6 +190,7 @@
#if 0
static const switch_codec_implementation_t g711u_8k_60ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.samples_per_second */ 8000,
@@ -206,9 +207,10 @@
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy
};
+#endif
-
static const switch_codec_implementation_t g711u_8k_30ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.samples_per_second */ 8000,
@@ -224,11 +226,11 @@
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
- /*.next */ &g711u_8k_60ms_implementation
+ /*.next */ NULL
};
-#endif
static const switch_codec_implementation_t g711u_16k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.samples_per_second */ 16000,
@@ -244,9 +246,11 @@
/*.encode */ switch_g711u_encode,
/*.decode */ switch_g711u_decode,
/*.destroy */ switch_g711u_destroy,
+ /*.next */ &g711u_8k_30ms_implementation
};
static const switch_codec_implementation_t g711u_8k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 0,
/*.iananame */ "PCMU",
/*.samples_per_second */ 8000,
@@ -267,6 +271,7 @@
static const switch_codec_implementation_t g711a_8k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 8,
/*.iananame */ "PCMA",
/*.samples_per_second */ 8000,
@@ -287,13 +292,11 @@
static const switch_codec_interface_t g711a_codec_interface = {
/*.interface_name */ "g711 alaw",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &g711a_8k_implementation
};
static const switch_codec_interface_t g711u_codec_interface = {
/*.interface_name */ "g711 ulaw",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &g711u_8k_implementation,
/*.next */ &g711a_codec_interface
};
Modified: freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c Mon Jul 10 18:08:02 2006
@@ -219,6 +219,7 @@
/* Registration */
static const switch_codec_implementation_t g729_10ms_8k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
/*.samples_per_second */ 8000,
@@ -237,6 +238,7 @@
};
static const switch_codec_implementation_t g729_8k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 18,
/*.iananame */ "G729",
/*.samples_per_second */ 8000,
@@ -258,7 +260,6 @@
static const switch_codec_interface_t g729_codec_interface = {
/*.interface_name */ "g729",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &g729_8k_implementation,
};
Modified: freeswitch/trunk/src/mod/codecs/mod_gsm/mod_gsm.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_gsm/mod_gsm.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_gsm/mod_gsm.c Mon Jul 10 18:08:02 2006
@@ -133,6 +133,7 @@
/* Registration */
static const switch_codec_implementation_t gsm_8k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 3,
/*.iananame */ "gsm",
/*.samples_per_second */ 8000,
@@ -151,7 +152,6 @@
};
static const switch_codec_interface_t gsm_codec_interface = {
/*.interface_name */ "gsm",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &gsm_8k_implementation,
};
static switch_loadable_module_interface_t gsm_module_interface = {
Modified: freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c Mon Jul 10 18:08:02 2006
@@ -186,6 +186,7 @@
/* Registration */
static const switch_codec_implementation_t ilbc_8k_30ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC",
/*.samples_per_second */ 8000,
@@ -204,6 +205,7 @@
};
static const switch_codec_implementation_t ilbc_8k_20ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC",
/*.samples_per_second */ 8000,
@@ -225,6 +227,7 @@
static const switch_codec_implementation_t ilbc_102_8k_30ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "iLBC",
/*.samples_per_second */ 8000,
@@ -243,6 +246,7 @@
};
static const switch_codec_implementation_t ilbc_102_8k_20ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 102,
/*.iananame */ "iLBC102",
/*.samples_per_second */ 8000,
@@ -263,6 +267,7 @@
static const switch_codec_implementation_t ilbc_8k_20ms_nonext_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 97,
/*.iananame */ "iLBC20ms",
/*.samples_per_second */ 8000,
@@ -283,20 +288,17 @@
static const switch_codec_interface_t ilbc_20ms_codec_interface = {
/*.interface_name */ "ilbc",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &ilbc_8k_20ms_nonext_implementation
};
static const switch_codec_interface_t ilbc_102_codec_interface = {
/*.interface_name */ "ilbc",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &ilbc_102_8k_20ms_implementation,
/*.next*/ &ilbc_20ms_codec_interface
};
static const switch_codec_interface_t ilbc_codec_interface = {
/*.interface_name */ "ilbc",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &ilbc_8k_20ms_implementation,
/*.next*/ &ilbc_102_codec_interface
};
Modified: freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c Mon Jul 10 18:08:02 2006
@@ -90,6 +90,7 @@
}
static const switch_codec_implementation_t raw_32k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 10,
/*.iananame */ "L16",
/*.samples_per_second = */ 32000,
@@ -108,6 +109,7 @@
};
static const switch_codec_implementation_t raw_22k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 10,
/*.iananame */ "L16",
/*.samples_per_second = */ 22050,
@@ -127,6 +129,7 @@
};
static const switch_codec_implementation_t raw_16k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 10,
/*.iananame */ "L16",
/*.samples_per_second = */ 16000,
@@ -146,6 +149,7 @@
};
static const switch_codec_implementation_t raw_8k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 10,
/*.iananame */ "L16",
/*.samples_per_second = */ 8000,
@@ -166,6 +170,7 @@
static const switch_codec_implementation_t raw_8k_30ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 10,
/*.iananame */ "L16",
/*.samples_per_second */ 8000,
@@ -186,6 +191,7 @@
static const switch_codec_implementation_t raw_8k_60ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 10,
/*.iananame */ "L16",
/*.samples_per_second */ 8000,
@@ -205,6 +211,7 @@
};
static const switch_codec_implementation_t raw_8k_120ms_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 10,
/*.iananame */ "L16",
/*.samples_per_second */ 8000,
@@ -226,7 +233,6 @@
static const switch_codec_interface_t raw_codec_interface = {
/*.interface_name */ "raw signed linear (16 bit)",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &raw_8k_120ms_implementation
};
Modified: freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c Mon Jul 10 18:08:02 2006
@@ -268,6 +268,7 @@
/* Registration */
static const switch_codec_implementation_t speex_32k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 98,
/*.iananame */ "speex",
/*.samples_per_second */ 32000,
@@ -286,6 +287,7 @@
};
static const switch_codec_implementation_t speex_16k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 98,
/*.iananame */ "speex",
/*.samples_per_second */ 16000,
@@ -305,6 +307,7 @@
};
static const switch_codec_implementation_t speex_8k_implementation = {
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.ianacode */ 98,
/*.iananame */ "speex",
/*.samples_per_second */ 8000,
@@ -325,7 +328,6 @@
static const switch_codec_interface_t speex_codec_interface = {
/*.interface_name */ "speex",
- /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
/*.implementations */ &speex_8k_implementation
};
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Mon Jul 10 18:08:02 2006
@@ -113,7 +113,7 @@
switch_caller_profile_t *caller_profile;
unsigned short samprate;
switch_mutex_t *mutex;
- switch_codec_interface_t *codecs[SWITCH_MAX_CODECS];
+ const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
unsigned int num_codecs;
int codec_index;
switch_rtp_t *rtp_session;
@@ -440,16 +440,16 @@
if (force || !switch_test_flag(tech_pvt, TFLAG_CODEC_READY)) {
if (tech_pvt->codec_index < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Don't have my codec yet here's one\n");
- tech_pvt->codec_name = lame(tech_pvt->codecs[0]->implementations->iananame);
- tech_pvt->codec_num = tech_pvt->codecs[0]->implementations->ianacode;
+ tech_pvt->codec_name = lame(tech_pvt->codecs[0]->iananame);
+ tech_pvt->codec_num = tech_pvt->codecs[0]->ianacode;
tech_pvt->codec_index = 0;
- payloads[0].name = lame(tech_pvt->codecs[0]->implementations->iananame);
- payloads[0].id = tech_pvt->codecs[0]->implementations->ianacode;
+ payloads[0].name = lame(tech_pvt->codecs[0]->iananame);
+ payloads[0].id = tech_pvt->codecs[0]->ianacode;
} else {
- payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->implementations->iananame);
- payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->implementations->ianacode;
+ payloads[0].name = lame(tech_pvt->codecs[tech_pvt->codec_index]->iananame);
+ payloads[0].id = tech_pvt->codecs[tech_pvt->codec_index]->ianacode;
}
@@ -1546,22 +1546,22 @@
for(x = 0; x < len; x++) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name, payloads[x].id);
for(y = 0; y < tech_pvt->num_codecs; y++) {
- char *name = tech_pvt->codecs[y]->implementations->iananame;
+ char *name = tech_pvt->codecs[y]->iananame;
if (!strncasecmp(name, "ilbc", 4)) {
name = "ilbc";
}
- if (tech_pvt->codecs[y]->implementations->ianacode > 96) {
+ if (tech_pvt->codecs[y]->ianacode > 96) {
match = strcasecmp(name, payloads[x].name) ? 0 : 1;
} else {
- match = (payloads[x].id == tech_pvt->codecs[y]->implementations->ianacode) ? 1 : 0;
+ match = (payloads[x].id == tech_pvt->codecs[y]->ianacode) ? 1 : 0;
}
if (match) {
tech_pvt->codec_index = y;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y, payloads[x].name, payloads[x].id);
- tech_pvt->codec_name = tech_pvt->codecs[y]->implementations->iananame;
- tech_pvt->codec_num = tech_pvt->codecs[y]->implementations->ianacode;
+ tech_pvt->codec_name = tech_pvt->codecs[y]->iananame;
+ tech_pvt->codec_num = tech_pvt->codecs[y]->ianacode;
if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
do_describe(tech_pvt, 0);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c Mon Jul 10 18:08:02 2006
@@ -138,7 +138,7 @@
int ssrc;
switch_time_t last_read;
char *realm;
- switch_codec_interface_t *codecs[SWITCH_MAX_CODECS];
+ const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
int num_codecs;
switch_payload_t te;
switch_mutex_t *flag_mutex;
@@ -173,7 +173,13 @@
static switch_status_t exosip_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout,
switch_io_flag_t flags, int stream_id);
static int config_exosip(int reload);
-static switch_status_t parse_sdp_media(struct private_object *tech_pvt, sdp_media_t * media, char **dname, char **drate, char **dpayload);
+static switch_status_t parse_sdp_media(struct private_object *tech_pvt,
+ sdp_media_t * media,
+ char **dname,
+ char **drate,
+ char **dpayload,
+ const switch_codec_implementation_t **impp);
+
static switch_status_t exosip_kill_channel(switch_core_session_t *session, int sig);
static switch_status_t activate_rtp(struct private_object *tech_pvt);
static void deactivate_rtp(struct private_object *tech_pvt);
@@ -356,7 +362,7 @@
static const switch_codec_implementation_t *imp;
for (i = 0; i < tech_pvt->num_codecs; i++) {
- imp = tech_pvt->codecs[i]->implementations;
+ imp = tech_pvt->codecs[i];
while(NULL != imp) {
uint32_t sps = imp->samples_per_second;
@@ -1178,6 +1184,7 @@
char *displayname, *username;
osip_header_t *tedious;
char *val;
+ const switch_codec_implementation_t *imp = NULL;
switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
@@ -1310,10 +1317,10 @@
if (tech_pvt->num_codecs > 0) {
int i;
- static const switch_codec_implementation_t *imp;
+ static const switch_codec_implementation_t *imp = NULL;
for (i = 0; i < tech_pvt->num_codecs; i++) {
- for (imp = tech_pvt->codecs[i]->implementations; imp; imp = imp->next) {
+ for (imp = tech_pvt->codecs[i]; imp; imp = imp->next) {
sdp_add_codec(tech_pvt->sdp_config, tech_pvt->codecs[i]->codec_type, imp->ianacode, imp->iananame,
imp->samples_per_second, 0);
@@ -1341,7 +1348,7 @@
for (pos = 0; audio_tab[pos] != NULL; pos++) {
osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos],
mline);
- if (parse_sdp_media(tech_pvt, audio_tab[pos], &dname, &drate, &dpayload) == SWITCH_STATUS_SUCCESS) {
+ if (parse_sdp_media(tech_pvt, audio_tab[pos], &dname, &drate, &dpayload, &imp) == SWITCH_STATUS_SUCCESS) {
tech_pvt->payload_num = atoi(dpayload);
goto done;
}
@@ -1381,6 +1388,12 @@
{
int rate = atoi(drate);
int ms = globals.codec_ms;
+
+
+ if (imp) {
+ ms = imp->microseconds_per_frame / 1000;
+ }
+
if (!strcasecmp(dname, "ilbc")) {
ms = 30;
}
@@ -1487,13 +1500,19 @@
}
-static switch_status_t parse_sdp_media(struct private_object *tech_pvt, sdp_media_t * media, char **dname, char **drate, char **dpayload)
+static switch_status_t parse_sdp_media(struct private_object *tech_pvt,
+ sdp_media_t * media,
+ char **dname,
+ char **drate,
+ char **dpayload,
+ const switch_codec_implementation_t **impp)
{
int pos = 0;
sdp_attribute_t *attr = NULL;
char *name, *payload, *rate;
switch_status_t status = SWITCH_STATUS_GENERR;
char workspace[512];
+ const switch_codec_implementation_t *imp = NULL;
while (osip_list_eol(media->a_attributes, pos) == 0) {
attr = (sdp_attribute_t *) osip_list_get(media->a_attributes, pos);
@@ -1523,11 +1542,9 @@
}
for(i = 0; !match && i < tech_pvt->num_codecs; i++) {
- const switch_codec_implementation_t *imp;
-
-
- for (imp = tech_pvt->codecs[i]->implementations; imp; imp = imp->next) {
+ for (imp = tech_pvt->codecs[i]; imp; imp = imp->next) {
+
if (pt < 97) {
match = (pt == imp->ianacode) ? 1 : 0;
} else {
@@ -1545,6 +1562,7 @@
*dname = strdup(name);
*drate = strdup(rate);
*dpayload = strdup(payload);
+ *impp = imp;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Found negotiated codec Payload: %s Name: %s Rate: %s\n",
*dpayload, *dname, *drate);
return SWITCH_STATUS_SUCCESS;
@@ -1654,8 +1672,8 @@
struct private_object *tech_pvt;
char *dpayload = NULL, *dname = NULL, *drate = NULL;
switch_channel_t *channel;
+ const switch_codec_implementation_t *imp = NULL;
-
if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cannot answer nonexistant call [%d]!\n", event->cid);
return;
@@ -1686,20 +1704,23 @@
snprintf(tech_pvt->remote_sdp_audio_ip, 50, conn->c_addr);
/* Grab codec elements */
- if (parse_sdp_media(tech_pvt, remote_med, &dname, &drate, &dpayload) == SWITCH_STATUS_SUCCESS) {
+ if (parse_sdp_media(tech_pvt, remote_med, &dname, &drate, &dpayload, &imp) == SWITCH_STATUS_SUCCESS) {
tech_pvt->payload_num = atoi(dpayload);
}
/* Assign them thar IDs */
tech_pvt->did = event->did;
tech_pvt->tid = event->tid;
-
-
{
int rate = atoi(drate);
int ms = globals.codec_ms;
+
if (!strcasecmp(dname, "ilbc")) {
ms = 30;
+ }
+
+ if (imp) {
+ ms = imp->microseconds_per_frame / 1000;
}
if (switch_core_codec_init(&tech_pvt->read_codec,
Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c Mon Jul 10 18:08:02 2006
@@ -213,7 +213,7 @@
//int rate = 8000;
//int codec_ms = 20;
switch_channel_t *channel;
- switch_codec_interface_t *codecs[SWITCH_MAX_CODECS];
+ const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
int num_codecs = 0;
unsigned int local_cap = 0, mixed_cap = 0, chosen = 0, leading = 0;
int x, srate = 8000;
@@ -235,7 +235,7 @@
for (x = 0; x < num_codecs; x++) {
static const switch_codec_implementation_t *imp;
- for (imp = codecs[x]->implementations; imp; imp = imp->next) {
+ for (imp = codecs[x]; imp; imp = imp->next) {
unsigned int codec = iana2ast(imp->ianacode);
if (io == IAX_QUERY) {
@@ -251,7 +251,7 @@
mixed_cap = local_cap;
}
- leading = iana2ast(codecs[0]->implementations->ianacode);
+ leading = iana2ast(codecs[0]->ianacode);
if (io == IAX_QUERY) {
chosen = leading;
*format = chosen;
@@ -263,7 +263,7 @@
return SWITCH_STATUS_SUCCESS;
} else if (switch_test_flag(&globals, GFLAG_MY_CODEC_PREFS) && (leading & mixed_cap)) {
chosen = leading;
- dname = codecs[0]->implementations->iananame;
+ dname = codecs[0]->iananame;
} else {
unsigned int prefs[32];
int len = 0;
@@ -288,7 +288,7 @@
chosen = prefs[x];
for (z = 0; z < num_codecs; z++) {
static const switch_codec_implementation_t *imp;
- for (imp = codecs[z]->implementations; imp; imp = imp->next) {
+ for (imp = codecs[z]; imp; imp = imp->next) {
if (prefs[x] == iana2ast(imp->ianacode)) {
dname = imp->iananame;
break;
@@ -303,7 +303,7 @@
chosen = *format;
for (x = 0; x < num_codecs; x++) {
static const switch_codec_implementation_t *imp;
- for (imp = codecs[x]->implementations; imp; imp = imp->next) {
+ for (imp = codecs[x]; imp; imp = imp->next) {
unsigned int cap = iana2ast(imp->ianacode);
if (cap == chosen) {
dname = imp->iananame;
@@ -314,7 +314,7 @@
} else { /* c'mon there has to be SOMETHING... */
for (x = 0; x < num_codecs; x++) {
static const switch_codec_implementation_t *imp;
- for (imp = codecs[x]->implementations; imp; imp = imp->next) {
+ for (imp = codecs[x]; imp; imp = imp->next) {
unsigned int cap = iana2ast(imp->ianacode);
if (cap & mixed_cap) {
chosen = cap;
Modified: freeswitch/trunk/src/switch_loadable_module.c
==============================================================================
--- freeswitch/trunk/src/switch_loadable_module.c (original)
+++ freeswitch/trunk/src/switch_loadable_module.c Mon Jul 10 18:08:02 2006
@@ -633,16 +633,18 @@
return switch_core_hash_find(loadable_modules.directory_hash, name);
}
-SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, switch_codec_interface_t **array,
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, const switch_codec_implementation_t **array,
int arraylen)
{
switch_hash_index_t *hi;
void *val;
+ switch_codec_interface_t *codec_interface;
int i = 0;
for (hi = switch_hash_first(pool, loadable_modules.codec_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, NULL, NULL, &val);
- array[i++] = val;
+ codec_interface = (switch_codec_interface_t *) val;
+ array[i++] = codec_interface->implementations;
if (i > arraylen) {
break;
}
@@ -652,20 +654,44 @@
}
-SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_codec_interface_t **array,
+SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array,
int arraylen, char **prefs, int preflen)
{
int x, i = 0;
switch_codec_interface_t *codec_interface;
+ const switch_codec_implementation_t *imp;
- for (x = 0; x < preflen; x++) {
- if ((codec_interface = switch_loadable_module_get_codec_interface(prefs[x])) != 0 ) {
- array[i++] = codec_interface;
- if (i > arraylen) {
- break;
+ for (x = 0; x < preflen; x++) {
+ char *name, *p, buf[128];
+ uint32_t interval = 0, len = 0;
+
+ name = prefs[x];
+ if ((p = strchr(name, '@'))) {
+ p++;
+ len = p-name;
+
+ if (len > sizeof(buf)) {
+ len = sizeof(buf);
+ }
+ switch_copy_string(buf, name, len);
+ *(buf + len) = '\0';
+ interval = atoi(p);
+ name = buf;
+ }
+
+ if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0 ) {
+ for (imp = codec_interface->implementations; imp; imp = imp->next) {
+ if (!interval) {
+ array[i++] = imp;
+ } else if ((imp->microseconds_per_frame / 1000) == interval) {
+ array[i++] = imp;
+ }
}
- }
- }
+ if (i > arraylen) {
+ break;
+ }
+ }
+ }
return i;
}
1
0
[commit] r1816 - in freeswitch/trunk/src/mod: applications/mod_conference endpoints/mod_exosip
by Freeswitch SVN 10 Jul '06
by Freeswitch SVN 10 Jul '06
10 Jul '06
Author: brian
Date: Mon Jul 10 16:28:22 2006
New Revision: 1816
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
Log:
tweak (work in progress)
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Mon Jul 10 16:28:22 2006
@@ -2233,7 +2233,7 @@
if (switch_core_codec_init(&member.read_codec,
"L16",
read_codec->implementation->samples_per_second,
- conference->interval,
+ read_codec->implementation->microseconds_per_frame / 1000,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
@@ -2251,7 +2251,7 @@
if (switch_core_codec_init(&member.write_codec,
"L16",
read_codec->implementation->samples_per_second,
- conference->interval,
+ read_codec->implementation->microseconds_per_frame / 1000,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c Mon Jul 10 16:28:22 2006
@@ -1336,18 +1336,20 @@
if (audio_tab[0] == NULL && video_tab[0] == NULL && t38_tab[0] == NULL && app_tab[0] == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Got no compatible codecs!\n");
- break;
+ goto done;
}
for (pos = 0; audio_tab[pos] != NULL; pos++) {
osip_rfc3264_complete_answer(tech_pvt->sdp_config, remote_sdp, tech_pvt->local_sdp, audio_tab[pos],
mline);
if (parse_sdp_media(tech_pvt, audio_tab[pos], &dname, &drate, &dpayload) == SWITCH_STATUS_SUCCESS) {
- tech_pvt->payload_num = atoi(dpayload);
- break;
+ tech_pvt->payload_num = atoi(dpayload);
+ goto done;
}
}
mline++;
}
+ done:
+
free(remote_sdp_str);
sdp_message_o_origin_set(tech_pvt->local_sdp, "FreeSWITCH", "0", "0", "IN", "IP4", ip);
@@ -1545,7 +1547,7 @@
*dpayload = strdup(payload);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Found negotiated codec Payload: %s Name: %s Rate: %s\n",
*dpayload, *dname, *drate);
- goto done;
+ return SWITCH_STATUS_SUCCESS;
}
}
@@ -1553,7 +1555,6 @@
attr = NULL;
pos++;
}
- done:
return status;
}
1
0
Author: brian
Date: Mon Jul 10 15:51:19 2006
New Revision: 1814
Modified:
freeswitch/trunk/src/switch_channel.c
Log:
dont pre_answer after actual answer
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Mon Jul 10 15:51:19 2006
@@ -849,6 +849,10 @@
return SWITCH_STATUS_FALSE;
}
+ if (switch_channel_test_flag(channel, CF_ANSWERED)) {
+ return SWITCH_STATUS_SUCCESS;
+ }
+
msg.message_id = SWITCH_MESSAGE_INDICATE_PROGRESS;
msg.from = channel->name;
status = switch_core_session_message_send(uuid, &msg);
1
0
10 Jul '06
Author: anthm
Date: Mon Jul 10 13:10:40 2006
New Revision: 1813
Modified:
freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
Log:
break 2 loops instead of 1
Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c Mon Jul 10 13:10:40 2006
@@ -1545,7 +1545,7 @@
*dpayload = strdup(payload);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Found negotiated codec Payload: %s Name: %s Rate: %s\n",
*dpayload, *dname, *drate);
- break;
+ goto done;
}
}
@@ -1553,6 +1553,7 @@
attr = NULL;
pos++;
}
+ done:
return status;
}
1
0
10 Jul '06
Author: anthm
Date: Mon Jul 10 12:28:54 2006
New Revision: 1811
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
add ability to set mute and deaf flag from the dialplan +flags{<mute>|<deaf>}
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Mon Jul 10 12:28:54 2006
@@ -676,8 +676,6 @@
char *digit;
char msg[512];
- switch_core_timer_next(&timer);
-
if (switch_channel_has_dtmf(channel)) {
switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
}
@@ -863,28 +861,33 @@
switch_buffer_zero(member->mux_buffer);
switch_mutex_unlock(member->audio_out_mutex);
}
+ switch_core_timer_next(&timer);
}
}
} else {
- /* Flush the output buffer and write all the data (presumably muxed) back to the channel */
- switch_mutex_lock(member->audio_out_mutex);
- write_frame.data = data;
- while ((write_frame.datalen = (uint32_t)switch_buffer_read(member->mux_buffer, write_frame.data, bytes))) {
- if (write_frame.datalen && switch_test_flag(member, MFLAG_CAN_HEAR)) {
- write_frame.samples = write_frame.datalen / 2;
+ if (switch_buffer_inuse(member->mux_buffer)) {
+ /* Flush the output buffer and write all the data (presumably muxed) back to the channel */
+ switch_mutex_lock(member->audio_out_mutex);
+ write_frame.data = data;
+ while ((write_frame.datalen = (uint32_t)switch_buffer_read(member->mux_buffer, write_frame.data, bytes))) {
+ if (write_frame.datalen && switch_test_flag(member, MFLAG_CAN_HEAR)) {
+ write_frame.samples = write_frame.datalen / 2;
+
+ /* Check for output volume adjustments */
+ if (member->volume_out_level) {
+ switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level);
+ }
- /* Check for output volume adjustments */
- if (member->volume_out_level) {
- switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level);
+ switch_core_session_write_frame(member->session, &write_frame, -1, 0);
}
-
- switch_core_session_write_frame(member->session, &write_frame, -1, 0);
}
+ switch_mutex_unlock(member->audio_out_mutex);
+ } else {
+ switch_core_timer_next(&timer);
}
- switch_mutex_unlock(member->audio_out_mutex);
}
} /* Rinse ... Repeat */
-
+
switch_clear_flag_locked(member, MFLAG_RUNNING);
switch_core_timer_destroy(&timer);
@@ -2076,10 +2079,13 @@
char *mydata = switch_core_session_strdup(session, data);
char *conf_name = NULL;
char *bridge_prefix = "bridge:";
+ char *flags_prefix = "+flags{";
char *bridgeto = NULL;
char *profile_name = NULL;
switch_xml_t cxml = NULL, cfg = NULL, profile = NULL, profiles = NULL;
-
+ char *flags_str;
+ member_flag_t uflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
+
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -2094,6 +2100,23 @@
return;
}
+
+ if ((flags_str=strstr(mydata, flags_prefix))) {
+ char *p;
+
+ *flags_str = '\0';
+ flags_str += strlen(flags_prefix);
+ if ((p = strchr(flags_str, '}'))) {
+ *p = '\0';
+ }
+
+ if (strstr(flags_str, "mute")) {
+ uflags &= ~MFLAG_CAN_SPEAK;
+ } else if (strstr(flags_str, "deaf")) {
+ uflags &= ~MFLAG_CAN_HEAR;
+ }
+ }
+
if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
char *uuid = switch_core_session_get_uuid(session);
@@ -2269,7 +2292,7 @@
if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) {
goto codec_done1;
}
- switch_set_flag_locked((&member), MFLAG_RUNNING | MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR);
+ switch_set_flag_locked((&member), MFLAG_RUNNING | uflags);
/* Run the confernece loop */
conference_loop(&member);
1
0