Ringback (sponsored by Front Logic)

This addition lets you set artifical ringback on a channel
that is waiting for an originated call to be answered.

the syntax is 

<action application="set" data="ringback=[data]"/>

where data is either the full path to an audio file
or a teletone generation script..


syntax of teletone scripts

LEGEND:

0-9,a-d,*,# (standard dtmf tones)

variables: c,r,d,v,>,<,+,w,l,L,%

c (channels)        - Sets the number of channels.
r (rate)            - Sets the sample rate.
d (duration)        - Sets the default tone duration.
v (volume)          - Sets the default volume.
> (decrease vol)    - factor to decrease volume by per frame (0 for even decrease across duration).
< (increase vol)    - factor to increase volume by per frame (0 for even increase across duration).
+ (step)            - factor to step by used by < and >.
w (wait)            - default silence after each tone.
l (loops)           - number of times to repeat each tone in the script.
L (LOOPS)           - number of times to repeat the the whole script.
% (manual tone)     - a generic tone specified by a duration, a wait and a list of frequencies.

standard tones can have custom duration per use with the () modifier
7(1000, 500) to generate DTMF 7 for 1 second then pause .5 seconds

EXAMPLES

UK Ring Tone [400+450 hz on for 400ms off for 200ms then 400+450 hz on for 400ms off for 2200ms]
%(400,200,400,450);%(400,2200,400,450)

US Ring Tone [440+480 hz on for 2000ms off for 4000ms]
%(2000,4000,440,480)

ATT BONG [volume level 4000, even decay, step by 2, # key for 60ms with no wait, volume level 2000, 350+440hz {us dialtone} for 940ms
v=4000;>=0;+=2;#(60,0);v=2000;%(940,0,350,440)

SIT Tone 913.8 hz for 274 ms with no wait, 1370.6 hz for 274 ms with no wait, 1776.7 hz for 380ms with no wait
%(274,0,913.8);%(274,0,1370.6);%(380,0,1776.7)

ATTN TONE (phone's off the hook!) 1400+2060+2450+2600 hz for 100ms with 100ms wait
%(100,100,1400,2060,2450,2600)



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3408 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2006-11-19 01:05:06 +00:00
parent 0984933c36
commit d7baa16132
12 changed files with 273 additions and 50 deletions
@@ -151,7 +151,7 @@ static switch_caller_extension_t *directory_dialplan_hunt(switch_core_session_t
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
} else {
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
switch_channel_hangup(channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
}
return extension;
@@ -296,7 +296,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", context))) {
if (!(xcontext = switch_xml_find_child(cfg, "context", "name", "global"))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "context %s not found\n", context);
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
switch_channel_hangup(channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
switch_xml_free(xml);
return NULL;
}
@@ -325,7 +325,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session)
if (extension) {
switch_channel_set_state(channel, CS_EXECUTE);
} else {
switch_channel_hangup(channel, SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST);
switch_channel_hangup(channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
}
return extension;
@@ -75,7 +75,7 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, char
handle->channels = 1;
handle->format = 0;
handle->sections = 0;
handle->seekable = 0;
handle->seekable = 1;
handle->speed = 0;
handle->private_info = context;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate);
@@ -98,8 +98,10 @@ static switch_status_t native_file_file_close(switch_file_handle_t *handle)
static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
{
//native_file_context *context = handle->private_info;
native_file_context *context = handle->private_info;
switch_file_seek(context->fd, whence, &samples);
return SWITCH_STATUS_FALSE;
}
@@ -75,7 +75,6 @@ static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map
/*********************************************************************************/
static JSBool teletone_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
int32 memory = 65535;
JSObject *session_obj;
struct teletone_obj *tto = NULL;
struct js_session *jss = NULL;
@@ -101,12 +100,6 @@ static JSBool teletone_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
timer_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
}
if (argc > 2) {
if (!JS_ValueToInt32(cx, argv[2], &memory)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Convert to INT\n");
return JS_FALSE;
}
}
switch_core_new_memory_pool(&pool);
if (!(tto = switch_core_alloc(pool, sizeof(*tto)))) {
@@ -149,7 +142,7 @@ static JSBool teletone_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
tto->obj = obj;
tto->cx = cx;
tto->session = jss->session;
teletone_init_session(&tto->ts, memory, teletone_handler, tto);
teletone_init_session(&tto->ts, 0, teletone_handler, tto);
JS_SetPrivate(cx, obj, tto);
return JS_TRUE;