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
- 14172 discussions
Author: anthm
Date: Thu Jan 15 10:54:13 2009
New Revision: 11225
Log:
refactor
Modified:
freeswitch/trunk/src/switch_core_io.c
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu Jan 15 10:54:13 2009
@@ -137,8 +137,8 @@
if (session->read_codec && !session->track_id && session->track_duration) {
if (session->read_frame_count == 0) {
switch_event_t *event;
- session->read_frame_count = (session->read_codec->implementation->actual_samples_per_second /
- session->read_codec->implementation->samples_per_packet) * session->track_duration;
+ session->read_frame_count = (session->read_impl.actual_samples_per_second /
+ session->read_impl.samples_per_packet) * session->track_duration;
switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT);
switch_channel_event_set_data(session->channel, event);
@@ -150,7 +150,7 @@
if (switch_channel_test_flag(session->channel, CF_HOLD)) {
- switch_yield(session->read_codec->implementation->microseconds_per_packet);
+ switch_yield(session->read_impl.microseconds_per_packet);
status = SWITCH_STATUS_BREAK;
goto even_more_done;
}
@@ -215,7 +215,7 @@
goto done;
}
- if ((*frame)->codec->implementation->actual_samples_per_second != session->read_codec->implementation->actual_samples_per_second) {
+ if ((*frame)->codec->implementation->actual_samples_per_second != session->read_impl.actual_samples_per_second) {
do_resample = 1;
}
@@ -257,7 +257,7 @@
session->read_codec,
read_frame->data,
read_frame->datalen,
- session->read_codec->implementation->actual_samples_per_second,
+ session->read_impl.actual_samples_per_second,
session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
}
@@ -272,8 +272,8 @@
status = switch_resample_create(&session->read_resampler,
read_frame->codec->implementation->actual_samples_per_second,
read_frame->codec->implementation->decoded_bytes_per_packet,
- session->read_codec->implementation->actual_samples_per_second,
- session->read_codec->implementation->decoded_bytes_per_packet, session->pool);
+ session->read_impl.actual_samples_per_second,
+ session->read_impl.decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
@@ -285,7 +285,7 @@
case SWITCH_STATUS_SUCCESS:
session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
session->raw_read_frame.rate = read_frame->rate;
- if (read_frame->codec->implementation->samples_per_packet != session->read_codec->implementation->samples_per_packet) {
+ if (read_frame->codec->implementation->samples_per_packet != session->read_impl.samples_per_packet) {
session->raw_read_frame.timestamp = 0;
} else {
session->raw_read_frame.timestamp = read_frame->timestamp;
@@ -398,11 +398,11 @@
}
- if (read_frame->datalen == session->read_codec->implementation->decoded_bytes_per_packet) {
+ if (read_frame->datalen == session->read_impl.decoded_bytes_per_packet) {
perfect = TRUE;
} else {
if (!session->raw_read_buffer) {
- switch_size_t bytes = session->read_codec->implementation->decoded_bytes_per_packet;
+ switch_size_t bytes = session->read_impl.decoded_bytes_per_packet;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engaging Read Buffer at %u bytes vs %u\n",
(uint32_t) bytes, (uint32_t) (*frame)->datalen);
switch_buffer_create_dynamic(&session->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, 0);
@@ -414,16 +414,16 @@
}
- if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_codec->implementation->decoded_bytes_per_packet) {
+ if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_impl.decoded_bytes_per_packet) {
if (perfect) {
enc_frame = read_frame;
session->raw_read_frame.rate = read_frame->rate;
} else {
session->raw_read_frame.datalen = (uint32_t) switch_buffer_read(session->raw_read_buffer,
session->raw_read_frame.data,
- session->read_codec->implementation->decoded_bytes_per_packet);
+ session->read_impl.decoded_bytes_per_packet);
- session->raw_read_frame.rate = session->read_codec->implementation->actual_samples_per_second;
+ session->raw_read_frame.rate = session->read_impl.actual_samples_per_second;
enc_frame = &session->raw_read_frame;
}
session->enc_read_frame.datalen = session->enc_read_frame.buflen;
@@ -436,16 +436,16 @@
enc_frame->codec,
enc_frame->data,
enc_frame->datalen,
- session->read_codec->implementation->actual_samples_per_second,
+ session->read_impl.actual_samples_per_second,
session->enc_read_frame.data, &session->enc_read_frame.datalen, &session->enc_read_frame.rate, &flag);
switch (status) {
case SWITCH_STATUS_RESAMPLE:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fixme 1\n");
case SWITCH_STATUS_SUCCESS:
- session->enc_read_frame.samples = session->read_codec->implementation->decoded_bytes_per_packet / sizeof(int16_t);
+ session->enc_read_frame.samples = session->read_impl.decoded_bytes_per_packet / sizeof(int16_t);
if (perfect) {
- if (enc_frame->codec->implementation->samples_per_packet != session->read_codec->implementation->samples_per_packet) {
+ if (enc_frame->codec->implementation->samples_per_packet != session->read_impl.samples_per_packet) {
session->enc_read_frame.timestamp = 0;
} else {
session->enc_read_frame.timestamp = read_frame->timestamp;
@@ -454,7 +454,7 @@
session->enc_read_frame.ssrc = read_frame->ssrc;
session->enc_read_frame.seq = read_frame->seq;
session->enc_read_frame.m = read_frame->m;
- session->enc_read_frame.payload = session->read_codec->implementation->ianacode;
+ session->enc_read_frame.payload = session->read_impl.ianacode;
}
*frame = &session->enc_read_frame;
break;
@@ -616,7 +616,7 @@
if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
- if (session->write_codec->implementation->codec_id == frame->codec->implementation->codec_id) {
+ if (session->write_impl.codec_id == frame->codec->implementation->codec_id) {
ptime_mismatch = TRUE;
if (switch_test_flag(frame->codec, SWITCH_CODEC_FLAG_PASSTHROUGH) || switch_test_flag(session->read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH)) {
status = perform_write(session, frame, flags, stream_id);
@@ -635,7 +635,7 @@
need_codec = TRUE;
}
- if (frame->codec->implementation->actual_samples_per_second != session->write_codec->implementation->actual_samples_per_second) {
+ if (frame->codec->implementation->actual_samples_per_second != session->write_impl.actual_samples_per_second) {
need_codec = TRUE;
do_resample = TRUE;
}
@@ -660,7 +660,7 @@
session->write_codec,
frame->data,
frame->datalen,
- session->write_codec->implementation->actual_samples_per_second,
+ session->write_impl.actual_samples_per_second,
session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &flag);
@@ -679,8 +679,8 @@
status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->actual_samples_per_second,
frame->codec->implementation->decoded_bytes_per_packet,
- session->write_codec->implementation->actual_samples_per_second,
- session->write_codec->implementation->decoded_bytes_per_packet, session->pool);
+ session->write_impl.actual_samples_per_second,
+ session->write_impl.decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
goto done;
@@ -807,33 +807,15 @@
if (session->write_codec) {
if (!ptime_mismatch &&
- write_frame->codec->implementation->decoded_bytes_per_packet == session->write_codec->implementation->decoded_bytes_per_packet) {
+ write_frame->codec->implementation->decoded_bytes_per_packet == session->write_impl.decoded_bytes_per_packet) {
perfect = TRUE;
- } else {
- if (!session->raw_write_buffer) {
- switch_size_t bytes = session->write_codec->implementation->decoded_bytes_per_packet;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "Engaging Write Buffer at %u bytes to accommodate %u->%u\n",
- (uint32_t) bytes, write_frame->datalen, session->write_codec->implementation->decoded_bytes_per_packet);
- if ((status = switch_buffer_create_dynamic(&session->raw_write_buffer,
- bytes * SWITCH_BUFFER_BLOCK_FRAMES,
- bytes * SWITCH_BUFFER_START_FRAMES, 0)) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer Failed!\n");
- goto error;
- }
- }
-
- if (!(switch_buffer_write(session->raw_write_buffer, write_frame->data, write_frame->datalen))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer %u bytes Failed!\n", write_frame->datalen);
- status = SWITCH_STATUS_MEMERR; goto error;
- }
}
-
+
if (perfect) {
- if (write_frame->datalen < session->write_codec->implementation->decoded_bytes_per_packet) {
- memset(write_frame->data, 255, session->write_codec->implementation->decoded_bytes_per_packet - write_frame->datalen);
- write_frame->datalen = session->write_codec->implementation->decoded_bytes_per_packet;
+ if (write_frame->datalen < session->write_impl.decoded_bytes_per_packet) {
+ memset(write_frame->data, 255, session->write_impl.decoded_bytes_per_packet - write_frame->datalen);
+ write_frame->datalen = session->write_impl.decoded_bytes_per_packet;
}
enc_frame = write_frame;
@@ -843,7 +825,7 @@
frame->codec,
enc_frame->data,
enc_frame->datalen,
- session->write_codec->implementation->actual_samples_per_second,
+ session->write_impl.actual_samples_per_second,
session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
switch (status) {
@@ -853,12 +835,12 @@
case SWITCH_STATUS_SUCCESS:
session->enc_write_frame.codec = session->write_codec;
session->enc_write_frame.samples = enc_frame->datalen / sizeof(int16_t);
- if (frame->codec->implementation->samples_per_packet != session->write_codec->implementation->samples_per_packet) {
+ if (frame->codec->implementation->samples_per_packet != session->write_impl.samples_per_packet) {
session->enc_write_frame.timestamp = 0;
} else {
session->enc_write_frame.timestamp = frame->timestamp;
}
- session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
+ session->enc_write_frame.payload = session->write_impl.ianacode;
session->enc_write_frame.m = frame->m;
session->enc_write_frame.ssrc = frame->ssrc;
session->enc_write_frame.seq = frame->seq;
@@ -891,9 +873,31 @@
status = perform_write(session, write_frame, flags, stream_id);
goto error;
} else {
- switch_size_t used = switch_buffer_inuse(session->raw_write_buffer);
- uint32_t bytes = session->write_codec->implementation->decoded_bytes_per_packet;
- switch_size_t frames = (used / bytes);
+ switch_size_t used;
+ uint32_t bytes;
+ switch_size_t frames;
+
+ if (!session->raw_write_buffer) {
+ switch_size_t bytes_per_packet = session->write_impl.decoded_bytes_per_packet;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "Engaging Write Buffer at %u bytes to accommodate %u->%u\n",
+ (uint32_t) bytes_per_packet, write_frame->datalen, session->write_impl.decoded_bytes_per_packet);
+ if ((status = switch_buffer_create_dynamic(&session->raw_write_buffer,
+ bytes_per_packet * SWITCH_BUFFER_BLOCK_FRAMES,
+ bytes_per_packet * SWITCH_BUFFER_START_FRAMES, 0)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer Failed!\n");
+ goto error;
+ }
+ }
+
+ if (!(switch_buffer_write(session->raw_write_buffer, write_frame->data, write_frame->datalen))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer %u bytes Failed!\n", write_frame->datalen);
+ status = SWITCH_STATUS_MEMERR; goto error;
+ }
+
+ used = switch_buffer_inuse(session->raw_write_buffer);
+ bytes = session->write_impl.decoded_bytes_per_packet;
+ frames = (used / bytes);
status = SWITCH_STATUS_SUCCESS;
if (!frames) {
@@ -905,13 +909,13 @@
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
int rate;
enc_frame = &session->raw_write_frame;
- session->raw_write_frame.rate = session->write_codec->implementation->actual_samples_per_second;
+ session->raw_write_frame.rate = session->write_impl.actual_samples_per_second;
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
if (frame->codec && frame->codec->implementation) {
rate = frame->codec->implementation->actual_samples_per_second;
} else {
- rate = session->write_codec->implementation->actual_samples_per_second;
+ rate = session->write_impl.actual_samples_per_second;
}
status = switch_core_codec_encode(session->write_codec,
@@ -928,15 +932,15 @@
session->enc_write_frame.samples = enc_frame->datalen / sizeof(int16_t);
session->enc_write_frame.m = frame->m;
session->enc_write_frame.ssrc = frame->ssrc;
- session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
+ session->enc_write_frame.payload = session->write_impl.ianacode;
write_frame = &session->enc_write_frame;
if (!session->write_resampler) {
switch_mutex_lock(session->resample_mutex);
status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->actual_samples_per_second,
frame->codec->implementation->decoded_bytes_per_packet,
- session->write_codec->implementation->actual_samples_per_second,
- session->write_codec->implementation->decoded_bytes_per_packet, session->pool);
+ session->write_impl.actual_samples_per_second,
+ session->write_impl.decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
@@ -949,7 +953,7 @@
session->enc_write_frame.samples = enc_frame->datalen / sizeof(int16_t);
session->enc_write_frame.m = frame->m;
session->enc_write_frame.ssrc = frame->ssrc;
- session->enc_write_frame.payload = session->write_codec->implementation->ianacode;
+ session->enc_write_frame.payload = session->write_impl.ianacode;
write_frame = &session->enc_write_frame;
break;
case SWITCH_STATUS_NOOP:
1
0
[commit] r11224 - in freeswitch/trunk/src: . include mod/languages/mod_java mod/languages/mod_java/src/org/freeswitch/swig mod/languages/mod_lua mod/languages/mod_managed mod/languages/mod_managed/managed mod/languages/mod_perl mod/languages/mod_python
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: brian
Date: Thu Jan 15 09:38:32 2009
New Revision: 11224
Log:
try not to break backwards and api compatibility refer to rev 11211
Modified:
freeswitch/trunk/src/include/switch_cpp.h
freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx
freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
freeswitch/trunk/src/switch_cpp.cpp
Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h (original)
+++ freeswitch/trunk/src/include/switch_cpp.h Thu Jan 15 09:38:32 2009
@@ -303,7 +303,7 @@
int max_digits,
int max_tries,
int timeout, char *terminators, char *audio_files, char *bad_input_audio_files,
- char *var_name, char *digits_regex);
+ char *digits_regex, const char *var_name = NULL);
/** \brief Play a file that resides on disk into the channel
*
Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java Thu Jan 15 09:38:32 2009
@@ -233,8 +233,12 @@
return freeswitchJNI.CoreSession_read(swigCPtr, this, min_digits, max_digits, prompt_audio_file, timeout, valid_terminators);
}
- public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String var_name, String digits_regex) {
- return freeswitchJNI.CoreSession_playAndGetDigits(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, var_name, digits_regex);
+ public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex, String var_name) {
+ return freeswitchJNI.CoreSession_playAndGetDigits__SWIG_0(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex, var_name);
+ }
+
+ public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex) {
+ return freeswitchJNI.CoreSession_playAndGetDigits__SWIG_1(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex);
}
public int streamFile(String file, int starting_sample_count) {
Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java Thu Jan 15 09:38:32 2009
@@ -133,7 +133,8 @@
public final static native int CoreSession_transfer__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
public final static native int CoreSession_transfer__SWIG_2(long jarg1, CoreSession jarg1_, String jarg2);
public final static native String CoreSession_read(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, String jarg4, int jarg5, String jarg6);
- public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10);
+ public final static native String CoreSession_playAndGetDigits__SWIG_0(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10);
+ public final static native String CoreSession_playAndGetDigits__SWIG_1(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9);
public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
public final static native int CoreSession_sleep__SWIG_0(long jarg1, CoreSession jarg1_, int jarg2, int jarg3);
Modified: freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp Thu Jan 15 09:38:32 2009
@@ -2577,7 +2577,7 @@
}
-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9, jstring jarg10) {
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9, jstring jarg10) {
jstring jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
@@ -2624,7 +2624,7 @@
arg10 = (char *)jenv->GetStringUTFChars(jarg10, 0);
if (!arg10) return 0;
}
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
if(result) jresult = jenv->NewStringUTF((const char *)result);
if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6);
if (arg7) jenv->ReleaseStringUTFChars(jarg7, (const char *)arg7);
@@ -2635,6 +2635,57 @@
}
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9) {
+ jstring jresult = 0 ;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ char *arg6 = (char *) 0 ;
+ char *arg7 = (char *) 0 ;
+ char *arg8 = (char *) 0 ;
+ char *arg9 = (char *) 0 ;
+ char *result = 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ (void)jarg1_;
+ arg1 = *(CoreSession **)&jarg1;
+ arg2 = (int)jarg2;
+ arg3 = (int)jarg3;
+ arg4 = (int)jarg4;
+ arg5 = (int)jarg5;
+ arg6 = 0;
+ if (jarg6) {
+ arg6 = (char *)jenv->GetStringUTFChars(jarg6, 0);
+ if (!arg6) return 0;
+ }
+ arg7 = 0;
+ if (jarg7) {
+ arg7 = (char *)jenv->GetStringUTFChars(jarg7, 0);
+ if (!arg7) return 0;
+ }
+ arg8 = 0;
+ if (jarg8) {
+ arg8 = (char *)jenv->GetStringUTFChars(jarg8, 0);
+ if (!arg8) return 0;
+ }
+ arg9 = 0;
+ if (jarg9) {
+ arg9 = (char *)jenv->GetStringUTFChars(jarg9, 0);
+ if (!arg9) return 0;
+ }
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ if(result) jresult = jenv->NewStringUTF((const char *)result);
+ if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6);
+ if (arg7) jenv->ReleaseStringUTFChars(jarg7, (const char *)arg7);
+ if (arg8) jenv->ReleaseStringUTFChars(jarg8, (const char *)arg8);
+ if (arg9) jenv->ReleaseStringUTFChars(jarg9, (const char *)arg9);
+ return jresult;
+}
+
+
SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1streamFile_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3) {
jint jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp Thu Jan 15 09:38:32 2009
@@ -5913,7 +5913,7 @@
}
-static int _wrap_CoreSession_playAndGetDigits(lua_State* L) {
+static int _wrap_CoreSession_playAndGetDigits__SWIG_0(lua_State* L) {
int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
@@ -5937,7 +5937,7 @@
if(!lua_isstring(L,7)) SWIG_fail_arg("playAndGetDigits",7,"char *");
if(!lua_isstring(L,8)) SWIG_fail_arg("playAndGetDigits",8,"char *");
if(!lua_isstring(L,9)) SWIG_fail_arg("playAndGetDigits",9,"char *");
- if(!lua_isstring(L,10)) SWIG_fail_arg("playAndGetDigits",10,"char *");
+ if(!lua_isstring(L,10)) SWIG_fail_arg("playAndGetDigits",10,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
SWIG_fail_ptr("CoreSession_playAndGetDigits",1,SWIGTYPE_p_CoreSession);
@@ -5952,7 +5952,7 @@
arg8 = (char *)lua_tostring(L, 8);
arg9 = (char *)lua_tostring(L, 9);
arg10 = (char *)lua_tostring(L, 10);
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
SWIG_arg=0;
lua_pushstring(L,(const char*)result); SWIG_arg++;
return SWIG_arg;
@@ -5965,6 +5965,181 @@
}
+static int _wrap_CoreSession_playAndGetDigits__SWIG_1(lua_State* L) {
+ int SWIG_arg = -1;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ char *arg6 = (char *) 0 ;
+ char *arg7 = (char *) 0 ;
+ char *arg8 = (char *) 0 ;
+ char *arg9 = (char *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("playAndGetDigits",9,9)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("playAndGetDigits",1,"CoreSession *");
+ if(!lua_isnumber(L,2)) SWIG_fail_arg("playAndGetDigits",2,"int");
+ if(!lua_isnumber(L,3)) SWIG_fail_arg("playAndGetDigits",3,"int");
+ if(!lua_isnumber(L,4)) SWIG_fail_arg("playAndGetDigits",4,"int");
+ if(!lua_isnumber(L,5)) SWIG_fail_arg("playAndGetDigits",5,"int");
+ if(!lua_isstring(L,6)) SWIG_fail_arg("playAndGetDigits",6,"char *");
+ if(!lua_isstring(L,7)) SWIG_fail_arg("playAndGetDigits",7,"char *");
+ if(!lua_isstring(L,8)) SWIG_fail_arg("playAndGetDigits",8,"char *");
+ if(!lua_isstring(L,9)) SWIG_fail_arg("playAndGetDigits",9,"char *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+ SWIG_fail_ptr("CoreSession_playAndGetDigits",1,SWIGTYPE_p_CoreSession);
+ }
+
+ arg2 = (int)lua_tonumber(L, 2);
+ arg3 = (int)lua_tonumber(L, 3);
+ arg4 = (int)lua_tonumber(L, 4);
+ arg5 = (int)lua_tonumber(L, 5);
+ arg6 = (char *)lua_tostring(L, 6);
+ arg7 = (char *)lua_tostring(L, 7);
+ arg8 = (char *)lua_tostring(L, 8);
+ arg9 = (char *)lua_tostring(L, 9);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ SWIG_arg=0;
+ lua_pushstring(L,(const char*)result); SWIG_arg++;
+ return SWIG_arg;
+
+ if(0) SWIG_fail;
+
+fail:
+ lua_error(L);
+ return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_playAndGetDigits(lua_State* L) {
+ int argc;
+ int argv[11]={
+ 1,2,3,4,5,6,7,8,9,10,11
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 9) {
+ int _v;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[3]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[4]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[5]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[6]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[7]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[8]);
+ }
+ if (_v) {
+ return _wrap_CoreSession_playAndGetDigits__SWIG_1(L);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 10) {
+ int _v;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[3]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[4]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[5]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[6]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[7]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[8]);
+ }
+ if (_v) {
+ {
+ _v = lua_isstring(L,argv[9]);
+ }
+ if (_v) {
+ return _wrap_CoreSession_playAndGetDigits__SWIG_0(L);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ lua_pushstring(L,"No matching function for overloaded 'CoreSession_playAndGetDigits'");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_CoreSession_streamFile__SWIG_0(lua_State* L) {
int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ;
Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx Thu Jan 15 09:38:32 2009
@@ -27368,7 +27368,7 @@
char *arg7 = (char *) 0 ;
char *arg8 = (char *) 0 ;
char *arg9 = (char *) 0 ;
- char *arg10 = (char *) 0 ;
+ char *arg10 = (char *) NULL ;
char *result = 0 ;
arg1 = (CoreSession *)jarg1;
@@ -27381,7 +27381,7 @@
arg8 = (char *)jarg8;
arg9 = (char *)jarg9;
arg10 = (char *)jarg10;
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
jresult = SWIG_csharp_string_callback((const char *)result);
return jresult;
}
Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs Thu Jan 15 09:38:32 2009
@@ -282,8 +282,8 @@
return ret;
}
- public string PlayAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, string terminators, string audio_files, string bad_input_audio_files, string var_name, string digits_regex) {
- string ret = freeswitchPINVOKE.CoreSession_PlayAndGetDigits(swigCPtr, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, var_name, digits_regex);
+ public string PlayAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, string terminators, string audio_files, string bad_input_audio_files, string digits_regex, string var_name) {
+ string ret = freeswitchPINVOKE.CoreSession_PlayAndGetDigits(swigCPtr, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex, var_name);
return ret;
}
Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp Thu Jan 15 09:38:32 2009
@@ -7858,7 +7858,7 @@
}
-XS(_wrap_CoreSession_playAndGetDigits) {
+XS(_wrap_CoreSession_playAndGetDigits__SWIG_0) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
@@ -7900,7 +7900,7 @@
dXSARGS;
if ((items < 10) || (items > 10)) {
- SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,var_name,digits_regex);");
+ SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,digits_regex,var_name);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
@@ -7949,10 +7949,10 @@
arg9 = reinterpret_cast< char * >(buf9);
res10 = SWIG_AsCharPtrAndSize(ST(9), &buf10, NULL, &alloc10);
if (!SWIG_IsOK(res10)) {
- SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'");
+ SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char const *""'");
}
arg10 = reinterpret_cast< char * >(buf10);
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
@@ -7981,6 +7981,332 @@
}
+XS(_wrap_CoreSession_playAndGetDigits__SWIG_1) {
+ {
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ char *arg6 = (char *) 0 ;
+ char *arg7 = (char *) 0 ;
+ char *arg8 = (char *) 0 ;
+ char *arg9 = (char *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ int res6 ;
+ char *buf6 = 0 ;
+ int alloc6 = 0 ;
+ int res7 ;
+ char *buf7 = 0 ;
+ int alloc7 = 0 ;
+ int res8 ;
+ char *buf8 = 0 ;
+ int alloc8 = 0 ;
+ int res9 ;
+ char *buf9 = 0 ;
+ int alloc9 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 9) || (items > 9)) {
+ SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,digits_regex);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_playAndGetDigits" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_playAndGetDigits" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_playAndGetDigits" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ ecode4 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "CoreSession_playAndGetDigits" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = static_cast< int >(val4);
+ ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_playAndGetDigits" "', argument " "5"" of type '" "int""'");
+ }
+ arg5 = static_cast< int >(val5);
+ res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6);
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_playAndGetDigits" "', argument " "6"" of type '" "char *""'");
+ }
+ arg6 = reinterpret_cast< char * >(buf6);
+ res7 = SWIG_AsCharPtrAndSize(ST(6), &buf7, NULL, &alloc7);
+ if (!SWIG_IsOK(res7)) {
+ SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "CoreSession_playAndGetDigits" "', argument " "7"" of type '" "char *""'");
+ }
+ arg7 = reinterpret_cast< char * >(buf7);
+ res8 = SWIG_AsCharPtrAndSize(ST(7), &buf8, NULL, &alloc8);
+ if (!SWIG_IsOK(res8)) {
+ SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "CoreSession_playAndGetDigits" "', argument " "8"" of type '" "char *""'");
+ }
+ arg8 = reinterpret_cast< char * >(buf8);
+ res9 = SWIG_AsCharPtrAndSize(ST(8), &buf9, NULL, &alloc9);
+ if (!SWIG_IsOK(res9)) {
+ SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'");
+ }
+ arg9 = reinterpret_cast< char * >(buf9);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
+
+
+
+
+
+ if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
+ XSRETURN(argvi);
+ fail:
+
+
+
+
+
+ if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_CoreSession_playAndGetDigits) {
+ dXSARGS;
+
+ {
+ unsigned long _index = 0;
+ SWIG_TypeRank _rank = 0;
+ if (items == 9) {
+ SWIG_TypeRank _ranki = 0;
+ SWIG_TypeRank _rankm = 0;
+ SWIG_TypeRank _pi = 1;
+ int _v = 0;
+ {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_CoreSession, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(5), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(6), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(7), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(8), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_1;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ if (!_index || (_ranki < _rank)) {
+ _rank = _ranki; _index = 1;
+ if (_rank == _rankm) goto dispatch;
+ }
+ }
+ check_1:
+
+ if (items == 10) {
+ SWIG_TypeRank _ranki = 0;
+ SWIG_TypeRank _rankm = 0;
+ SWIG_TypeRank _pi = 1;
+ int _v = 0;
+ {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr(ST(0), &vptr, SWIGTYPE_p_CoreSession, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(3), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ {
+ int res = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), NULL);
+ _v = SWIG_CheckState(res);
+ }
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(5), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(6), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(7), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(8), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ {
+ int res = SWIG_AsCharPtrAndSize(ST(9), 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ }
+ if (!_v) goto check_2;
+ _ranki += _v*_pi;
+ _rankm += _pi;
+ _pi *= SWIG_MAXCASTRANK;
+ if (!_index || (_ranki < _rank)) {
+ _rank = _ranki; _index = 2;
+ if (_rank == _rankm) goto dispatch;
+ }
+ }
+ check_2:
+
+ dispatch:
+ switch(_index) {
+ case 1:
+ ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_playAndGetDigits__SWIG_1); return;
+ case 2:
+ ++PL_markstack_ptr; SWIG_CALLXS(_wrap_CoreSession_playAndGetDigits__SWIG_0); return;
+ }
+ }
+
+ croak("No matching function for overloaded 'CoreSession_playAndGetDigits'");
+ XSRETURN(0);
+}
+
+
XS(_wrap_CoreSession_streamFile__SWIG_0) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Thu Jan 15 09:38:32 2009
@@ -7783,7 +7783,7 @@
}
-SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
@@ -7880,10 +7880,10 @@
arg9 = reinterpret_cast< char * >(buf9);
res10 = SWIG_AsCharPtrAndSize(obj9, &buf10, NULL, &alloc10);
if (!SWIG_IsOK(res10)) {
- SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'");
+ SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char const *""'");
}
arg10 = reinterpret_cast< char * >(buf10);
- result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10);
resultobj = SWIG_FromCharPtr((const char *)result);
if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
@@ -7901,6 +7901,234 @@
}
+SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int arg2 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ char *arg6 = (char *) 0 ;
+ char *arg7 = (char *) 0 ;
+ char *arg8 = (char *) 0 ;
+ char *arg9 = (char *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ int res6 ;
+ char *buf6 = 0 ;
+ int alloc6 = 0 ;
+ int res7 ;
+ char *buf7 = 0 ;
+ int alloc7 = 0 ;
+ int res8 ;
+ char *buf8 = 0 ;
+ int alloc8 = 0 ;
+ int res9 ;
+ char *buf9 = 0 ;
+ int alloc9 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+ PyObject * obj5 = 0 ;
+ PyObject * obj6 = 0 ;
+ PyObject * obj7 = 0 ;
+ PyObject * obj8 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:CoreSession_playAndGetDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_playAndGetDigits" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_playAndGetDigits" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_playAndGetDigits" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ ecode4 = SWIG_AsVal_int(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "CoreSession_playAndGetDigits" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = static_cast< int >(val4);
+ ecode5 = SWIG_AsVal_int(obj4, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_playAndGetDigits" "', argument " "5"" of type '" "int""'");
+ }
+ arg5 = static_cast< int >(val5);
+ res6 = SWIG_AsCharPtrAndSize(obj5, &buf6, NULL, &alloc6);
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_playAndGetDigits" "', argument " "6"" of type '" "char *""'");
+ }
+ arg6 = reinterpret_cast< char * >(buf6);
+ res7 = SWIG_AsCharPtrAndSize(obj6, &buf7, NULL, &alloc7);
+ if (!SWIG_IsOK(res7)) {
+ SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "CoreSession_playAndGetDigits" "', argument " "7"" of type '" "char *""'");
+ }
+ arg7 = reinterpret_cast< char * >(buf7);
+ res8 = SWIG_AsCharPtrAndSize(obj7, &buf8, NULL, &alloc8);
+ if (!SWIG_IsOK(res8)) {
+ SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "CoreSession_playAndGetDigits" "', argument " "8"" of type '" "char *""'");
+ }
+ arg8 = reinterpret_cast< char * >(buf8);
+ res9 = SWIG_AsCharPtrAndSize(obj8, &buf9, NULL, &alloc9);
+ if (!SWIG_IsOK(res9)) {
+ SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'");
+ }
+ arg9 = reinterpret_cast< char * >(buf9);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
+ return resultobj;
+fail:
+ if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *self, PyObject *args) {
+ int argc;
+ PyObject *argv[11];
+ int ii;
+
+ if (!PyTuple_Check(args)) SWIG_fail;
+ argc = (int)PyObject_Length(args);
+ for (ii = 0; (ii < argc) && (ii < 10); ii++) {
+ argv[ii] = PyTuple_GET_ITEM(args,ii);
+ }
+ if (argc == 9) {
+ int _v;
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CoreSession, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[2], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[3], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[4], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[5], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[6], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[7], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[8], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ return _wrap_CoreSession_playAndGetDigits__SWIG_1(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (argc == 10) {
+ int _v;
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CoreSession, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[1], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[2], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[3], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ {
+ int res = SWIG_AsVal_int(argv[4], NULL);
+ _v = SWIG_CheckState(res);
+ }
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[5], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[6], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[7], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[8], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ int res = SWIG_AsCharPtrAndSize(argv[9], 0, NULL, 0);
+ _v = SWIG_CheckState(res);
+ if (_v) {
+ return _wrap_CoreSession_playAndGetDigits__SWIG_0(self, args);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+fail:
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_playAndGetDigits'.\n"
+ " Possible C/C++ prototypes are:\n"
+ " playAndGetDigits(CoreSession *,int,int,int,int,char *,char *,char *,char *,char const *)\n"
+ " playAndGetDigits(CoreSession *,int,int,int,int,char *,char *,char *,char *)\n");
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_CoreSession_streamFile__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Thu Jan 15 09:38:32 2009
@@ -749,8 +749,8 @@
char *terminators,
char *audio_files,
char *bad_input_audio_files,
- char *var_name,
- char *digits_regex)
+ char *digits_regex,
+ const char *var_name)
{
switch_status_t status;
sanity_check((char *)"");
1
0
[commit] r11223 - freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: dschreiber
Date: Thu Jan 15 06:54:15 2009
New Revision: 11223
Log:
Fixed a bunch of seg-faults, finished implementing all commands from CLI, API and dialplan.
Still needs some cleanup and consolidation, but functions and seems stable. Tested everything I could :-)
Modified:
freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
Modified: freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
==============================================================================
--- freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c (original)
+++ freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c Thu Jan 15 06:54:15 2009
@@ -40,14 +40,11 @@
* Thanks go to bandwidth.com for funding this work.
*
*
- * TODO: Create an override flag so you can force a start-time for when billing should count *from*
* TODO: Fix what happens when the DB is not available
* TODO: Fix what happens when the DB queries fail (right now, all are acting like success)
* TODO: Make the actions function for when funds are depleted
- * TODO: Add app and CLI commands (pause, resume, reset, flush, deduct_funds, add_funds)
* TODO: Add buffering abilities
* TODO: Make error handling for database, such that when the database is down (or not installed) we just log to a text file
- * TODO: Make a sample .XML config file!
* FUTURE: Possibly make the hooks not tied per-channel, and instead just do this as a supervision style application with one thread that watches all calls
*/
@@ -274,19 +271,6 @@
}
-static switch_status_t sched_billing(switch_core_session_t *session)
-{
-
- if (globals.global_heartbeat > 0) {
- switch_core_session_enable_heartbeat(session, globals.global_heartbeat);
- }
-
- // Check account balance here
-
- return SWITCH_STATUS_SUCCESS;
-
-}
-
/* At this time, billing never succeeds if you don't have a database. */
static switch_status_t bill_event(float billamount, const char *billaccount)
{
@@ -397,7 +381,6 @@
/* Setup new billing data (based on call answer time, in case this module started late with active calls) */
nibble_data->lastts = profile->times->answered; /* Set the initial answer time to match when the call was really answered */
- nibble_data->pausets = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Beginning new billing on %s\n", uuid);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Last successful billing time was %s\n", date);
@@ -411,7 +394,7 @@
if ((ts - nibble_data->lastts) > 0) {
/* Convert billrate into microseconds and multiply by # of microseconds that have passed since last *successful* bill */
- billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts));
+ billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts)) - nibble_data->bill_adjustments;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Billing $%f to %s (Call: %s / %f so far)\n", billamount, billaccount, uuid, nibble_data->total);
@@ -420,6 +403,9 @@
/* Increment total cost */
nibble_data->total += billamount;
+ /* Reset manual billing adjustments from pausing */
+ nibble_data->bill_adjustments = 0;
+
/* Update channel variable with current billing */
tmp = switch_mprintf("%f", nibble_data->total);
switch_channel_set_variable(channel, "nibble_total_billed", tmp);
@@ -487,15 +473,14 @@
switch_core_session_rwunlock(session);
}
-
-static float nibblebill_check(switch_core_session_t *session)
+static void nibblebill_pause(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_time_t ts = switch_timestamp_now();
nibble_data_t *nibble_data;
- float amount = 0;
if (!channel) {
- return -99999;
+ return;
}
/* Lock this session's data for this module while we tinker with it */
@@ -506,30 +491,140 @@
/* Get our nibble data var. This will be NULL if it's our first call here for this session */
nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
- amount = nibble_data->total;
+ if (!nibble_data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Can't pause - channel is not initialized for billing!\n");
+ return;
+ }
+
+ /* Set pause counter if not already set */
+ if (nibble_data->pausets == 0)
+ nibble_data->pausets = ts;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Paused billing timestamp!\n");
/* Done checking - release lock */
if (globals.mutex) {
switch_mutex_unlock(globals.mutex);
}
- return amount;
}
-static void nibblebill_adjust(switch_core_session_t *session, float amount)
+static void nibblebill_resume(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- char *uuid;
+ switch_time_t ts = switch_timestamp_now();
+ nibble_data_t *nibble_data;
if (!channel) {
return;
}
- uuid = switch_core_session_get_uuid(session);
+ /* Get our nibble data var. This will be NULL if it's our first call here for this session */
+ nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
- /* Get channel var */
- if (!uuid || !channel) {
- switch_core_session_rwunlock(session);
+ if (!nibble_data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't resume - channel is not initialized for billing (This is expected at hangup time)!\n");
+ return;
+ }
+
+ if (nibble_data->pausets == 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't resume - channel is not paused! (This is expected at hangup time)\n");
+ return;
+ }
+
+ /* Lock this session's data for this module while we tinker with it */
+ if (globals.mutex) {
+ switch_mutex_lock(globals.mutex);
+ }
+
+ const char *billrate = switch_channel_get_variable(channel, "nibble_rate");
+
+ /* Calculate how much was "lost" to billings during pause - we do this here because you never know when the billrate may change during a call */
+ nibble_data->bill_adjustments += (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Resumed billing! Subtracted %f from this billing cycle.\n", (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets)));
+
+ nibble_data->pausets = 0;
+
+ /* Done checking - release lock */
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+
+}
+
+static void nibblebill_reset(switch_core_session_t *session)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_time_t ts = switch_timestamp_now();
+ nibble_data_t *nibble_data;
+
+ if (!channel) {
+ return;
+ }
+
+ /* Get our nibble data var. This will be NULL if it's our first call here for this session */
+ nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
+
+ if (!nibble_data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Can't reset - channel is not initialized for billing!\n");
+ return;
+ }
+
+ /* Lock this session's data for this module while we tinker with it */
+ if (globals.mutex) {
+ switch_mutex_lock(globals.mutex);
+ }
+
+ /* Update the last time we billed */
+ nibble_data->lastts = ts;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Reset last billing timestamp marker to right now!\n");
+
+ /* Done checking - release lock */
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+
+}
+
+static float nibblebill_check(switch_core_session_t *session)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ nibble_data_t *nibble_data;
+ float amount = 0;
+
+ if (!channel) {
+ return -99999;
+ }
+
+ /* Get our nibble data var. This will be NULL if it's our first call here for this session */
+ nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
+
+ if (!nibble_data) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Can't check - channel is not initialized for billing!\n");
+ return -99999;
+ }
+
+ /* Lock this session's data for this module while we tinker with it */
+ if (globals.mutex) {
+ switch_mutex_lock(globals.mutex);
+ }
+
+ amount = nibble_data->total;
+
+ /* Done checking - release lock */
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+
+ return amount;
+}
+
+static void nibblebill_adjust(switch_core_session_t *session, float amount)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+
+ if (!channel) {
return;
}
@@ -538,12 +633,11 @@
/* Return if there's no billing information on this session */
if (!billaccount) {
- switch_core_session_rwunlock(session);
return;
}
/* Add or remove amount from adjusted billing here. Note, we bill the OPPOSITE */
- if (bill_event(-amount, billaccount)) {
+ if (bill_event(-amount, billaccount) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recorded adjustment to %s for $%f\n", billaccount, amount);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to record adjustment to %s for $%f\n", billaccount, amount);
@@ -562,14 +656,16 @@
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
if (!strcasecmp(argv[0], "adjust") && argc == 2) {
nibblebill_adjust(session, atof(argv[1]));
-/* } else if (!strcasecmp(argv[0], "pause")) {
+ } else if (!strcasecmp(argv[0], "flush")) {
+ do_billing(session);
+ } else if (!strcasecmp(argv[0], "pause")) {
nibblebill_pause(session);
} else if (!strcasecmp(argv[0], "resume")) {
- nibblebill_resume(session);*/
+ nibblebill_resume(session);
} else if (!strcasecmp(argv[0], "check")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", nibblebill_check(session));
-/* } else if (!strcasecmp(argv[0], "reset")) {
- nibblebill_reset(session);*/
+ } else if (!strcasecmp(argv[0], "reset")) {
+ nibblebill_reset(session);
} else if (!strcasecmp(argv[0], "heartbeat") && argc == 2) {
switch_core_session_enable_heartbeat(session, atoi(argv[1]));
}
@@ -578,15 +674,74 @@
}
/* We get here from the API only (theoretically) */
-#define CHECK_API_SYNTAX "<uuid>"
-SWITCH_STANDARD_API(nibblebill_check_api_function)
+#define API_SYNTAX "<uuid> [pause | resume | reset | adjust <amount> | heartbeat <seconds> | check]"
+SWITCH_STANDARD_API(nibblebill_api_function)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "We made it!\n");
-
+ switch_core_session_t *psession = NULL;
+ char *mycmd = NULL, *argv[3] = { 0 };
+ int argc = 0;
+
+ if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
+ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+ if ((argc == 2 || argc == 3) && !switch_strlen_zero(argv[0])) {
+ char *uuid = argv[0];
+ if ((psession = switch_core_session_locate(uuid))) {
+ switch_channel_t *channel;
+ channel = switch_core_session_get_channel(psession);
+
+ if (!strcasecmp(argv[1], "adjust") && argc == 3) {
+ nibblebill_adjust(psession, atof(argv[2]));
+ } else if (!strcasecmp(argv[1], "flush")) {
+ do_billing(psession);
+ } else if (!strcasecmp(argv[1], "pause")) {
+ nibblebill_pause(psession);
+ } else if (!strcasecmp(argv[1], "resume")) {
+ nibblebill_resume(psession);
+ } else if (!strcasecmp(argv[1], "check")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", nibblebill_check(psession));
+ } else if (!strcasecmp(argv[1], "reset")) {
+ nibblebill_reset(psession);
+ } else if (!strcasecmp(argv[1], "heartbeat") && argc == 3) {
+ switch_core_session_enable_heartbeat(psession, atoi(argv[2]));
+ }
+
+ switch_core_session_rwunlock(psession);
+ } else {
+ stream->write_function(stream, "-ERR No Such Channel!\n");
+ }
+ } else {
+ stream->write_function(stream, "-USAGE: %s\n", API_SYNTAX);
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
/* Check if session has variable "billrate" set. If it does, activate the heartbeat variable
switch_core_session_enable_heartbeat(switch_core_session_t *session, uint32_t seconds)
switch_core_session_sched_heartbeat(switch_core_session_t *session, uint32_t seconds)*/
+static switch_status_t sched_billing(switch_core_session_t *session)
+{
+
+ if (globals.global_heartbeat > 0) {
+ switch_core_session_enable_heartbeat(session, globals.global_heartbeat);
+ }
+
+ /* TODO: Check account balance here */
+
+ return SWITCH_STATUS_SUCCESS;
+
+}
+
+static switch_status_t process_hangup(switch_core_session_t *session)
+{
+
+ /* Resume any paused billings, just in case */
+// nibblebill_resume(session);
+
+ /* Now go handle like normal billing */
+ do_billing(session);
return SWITCH_STATUS_SUCCESS;
@@ -597,7 +752,7 @@
/* on_init */ NULL,
/* on_routing */ NULL, /* Need to add a check here for anything in their account before routing */
/* on_execute */ sched_billing, /* Turn on heartbeat for this session and do an initial account check */
- /* on_hangup */ do_billing, /* On hangup - most important place to go bill */
+ /* on_hangup */ process_hangup, /* On hangup - most important place to go bill */
/* on_exch_media */ NULL,
/* on_soft_exec */ NULL,
/* on_consume_med */ NULL,
@@ -621,18 +776,9 @@
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
/* Add API and CLI commands */
-/* SWITCH_ADD_API(api_interface, "pause", "Pause billing on a session", nibblebill_pause_api_function, PAUSE_API_SYNTAX);
- SWITCH_ADD_API(api_interface, "resume", "Resume billing on a session", nibblebill_resume_api_function, RESUME_API_SYNTAX);
- SWITCH_ADD_API(api_interface, "reset", "Reset billing start time to right now - disregard any unbilled time thus far", nibblebill_reset_api_function, RESET_API_SYNTAX);
- SWITCH_ADD_API(api_interface, "adjust", "Add or deduct a dollar amount from a caller's account", nibblebill_adjust_api_function, ADJUST_API_SYNTAX);*/
- SWITCH_ADD_API(api_interface, "check", "Check the balance of a session", nibblebill_check_api_function, CHECK_API_SYNTAX);
+ SWITCH_ADD_API(api_interface, "nibblebill", "Manage billing parameters for a channel/call", nibblebill_api_function, API_SYNTAX);
/* Add dialplan applications */
-/* SWITCH_ADD_APP(app_interface, "nibble_pause", "Pause billing on a session", "Pause billing on a session", nibblebill_pause_app_function, PAUSE_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "nibble_resume", "Resume billing on a session", "Resume billing on a session", nibblebill_resume_app_function, RESUME_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "nibble_reset", "Check the balance of a session", "Check the balance of a session", nibblebill_reset_app_function, RESET_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "nibble_adjust", "Add or deduct a dollar amount from a caller's account", "Add or deduct a dollar amount from a callers' account (use negative numbers to deduct)", nibblebill_adjust_app_function, ADJUST_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "nibble_check", "Check the balance on an account", "Perform an account check for fund balance on a specific caller's account", nibblebill_check_app_function, CHECK_APP_SYNTAX, SAF_NONE);*/
SWITCH_ADD_APP(app_interface, "nibblebill", "Handle billing for the current channel/call", "Pause, resume, reset, adjust, flush, heartbeat commands to handle billing.", nibblebill_app_function, APP_SYNTAX, SAF_NONE);
/* register state handlers for billing */
1
0
[commit] r11222 - freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: dschreiber
Date: Thu Jan 15 05:31:57 2009
New Revision: 11222
Log:
Fixing a nasty bug that was resulting in channels not being released on hangup if no billing cycles had taken place.
Modified:
freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
Modified: freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
==============================================================================
--- freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c (original)
+++ freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c Thu Jan 15 05:31:57 2009
@@ -71,7 +71,6 @@
switch_time_t pausets; /* Timestamp of when a pause action started. 0 if not paused */
float bill_adjustments; /* Adjustments to make to the next billing, based on pause/resume events */
- float manual_adjustments; /* Manually added/deducted amounts from this account, to be committed at next database query */
} nibble_data_t;
@@ -87,6 +86,9 @@
/* Keep track of our config, event hooks and database connection variables, for this module only */
static struct
{
+ /* Memory */
+ switch_memory_pool_t *pool;
+
/* Event hooks */
switch_event_node_t *node;
@@ -285,6 +287,32 @@
}
+/* At this time, billing never succeeds if you don't have a database. */
+static switch_status_t bill_event(float billamount, const char *billaccount)
+{
+#ifdef SWITCH_HAVE_ODBC
+ char sql[1024] = "";
+ nibblebill_results_t pdata;
+
+ memset(&pdata, 0, sizeof(pdata));
+ snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, billamount, globals.db_column_account, billaccount);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
+
+ if (!(switch_odbc_handle_callback_exec(globals.master_odbc, sql, nibblebill_callback, &pdata) == SWITCH_ODBC_SUCCESS)){
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DB Error while updating cash!\n");
+
+ } else {
+#endif
+ /* TODO: Failover to a flat/text file if DB is unavailable */
+
+ return SWITCH_STATUS_SUCCESS;
+#ifdef SWITCH_HAVE_ODBC
+ }
+#endif
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
/* This is where we actually charge the guy
This can be called anytime a call is in progress or at the end of a call before the session is destroyed */
static switch_status_t do_billing(switch_core_session_t *session)
@@ -297,16 +325,16 @@
nibble_data_t *nibble_data;
switch_time_t ts = switch_timestamp_now();
float billamount;
- float adjustments = 0;
char date[80] = "";
char *tmp;
char *uuid;
switch_size_t retsize;
switch_time_exp_t tm;
+
if (!session) {
/* wtf? Why are we here? */
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_SUCCESS;
}
uuid = switch_core_session_get_uuid(session);
@@ -314,16 +342,17 @@
/* Get channel var */
channel = switch_core_session_get_channel(session);
if (!channel) {
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_SUCCESS;
}
/* Variables kept in FS but relevant only to this module */
const char *billrate = switch_channel_get_variable(channel, "nibble_rate");
const char *billaccount = switch_channel_get_variable(channel, "nibble_account");
+
/* Return if there's no billing information on this session */
if (!billrate || !billaccount) {
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_SUCCESS;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attempting to bill at $%s per minute to account %s\n", billrate, billaccount);
@@ -333,7 +362,7 @@
if (!profile) {
/* No caller profile (why would this happen?) */
- return SWITCH_STATUS_GENERR;
+ return SWITCH_STATUS_SUCCESS;
}
if (profile->times->answered < 1) {
@@ -350,7 +379,7 @@
nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
/* Are we in paused mode? If so, we don't do anything here - go back! */
- if (nibble_data->pausets > 0) {
+ if (nibble_data && (nibble_data->pausets > 0)) {
if (globals.mutex) {
switch_mutex_unlock(globals.mutex);
}
@@ -368,6 +397,7 @@
/* Setup new billing data (based on call answer time, in case this module started late with active calls) */
nibble_data->lastts = profile->times->answered; /* Set the initial answer time to match when the call was really answered */
+ nibble_data->pausets = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Beginning new billing on %s\n", uuid);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Last successful billing time was %s\n", date);
@@ -380,46 +410,23 @@
if ((ts - nibble_data->lastts) > 0) {
- /* Convert billrate into microseconds and multiply by # of microseconds that have passed */
+ /* Convert billrate into microseconds and multiply by # of microseconds that have passed since last *successful* bill */
billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts));
- adjustments = nibble_data->manual_adjustments + nibble_data->bill_adjustments;
- /* if ODBC call fails, we should return BEFORE updating the timestamp of last success! */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Billing $%f to %s (Call: %s / %f so far)\n", billamount, billaccount, uuid, nibble_data->total);
- if (adjustments > 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(Also adjusting the account by $%f)\n", adjustments);
- }
-
- /* DO ODBC BILLING HERE! */
-#ifdef SWITCH_HAVE_ODBC
- char sql[1024] = "";
- nibblebill_results_t pdata;
-
- memset(&pdata, 0, sizeof(pdata));
- snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, (billamount - adjustments), globals.db_column_account, billaccount);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
-
- if (!(switch_odbc_handle_callback_exec(globals.master_odbc, sql, nibblebill_callback, &pdata) == SWITCH_ODBC_SUCCESS)){
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DB Error while updating cash!\n");
-
- /* TODO: If this is a hangup event, we should store this billing in a text file while the DB is unavailable */
- } else {
-#endif
+ /* DO ODBC BILLING HERE and reset counters if it's successful! */
+ if (bill_event(billamount, billaccount) == SWITCH_STATUS_SUCCESS) {
/* Increment total cost */
nibble_data->total += billamount;
- /* Get rid of any manual adjustments that were just committed */
- nibble_data->manual_adjustments = 0;
- nibble_data->bill_adjustments = 0;
-
/* Update channel variable with current billing */
tmp = switch_mprintf("%f", nibble_data->total);
switch_channel_set_variable(channel, "nibble_total_billed", tmp);
switch_safe_free(tmp);
-#ifdef SWITCH_HAVE_ODBC
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to log to database!\n");
}
-#endif
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Just tried to bill %s negative minutes! wtf? That should be impossible.\n", uuid);
}
@@ -427,8 +434,10 @@
/* Update the last time we billed */
nibble_data->lastts = ts;
- /* Save everything back */
- switch_channel_set_private(channel, "_nibble_data_", nibble_data);
+ /* Save this location, but only if the channel/session are not hungup (otherwise, we're done) */
+ if (channel && switch_channel_get_state(channel) != CS_HANGUP) {
+ switch_channel_set_private(channel, "_nibble_data_", nibble_data);
+ }
/* Done changing - release lock */
if (globals.mutex) {
@@ -437,9 +446,6 @@
/* Go check if this call is allowed to continue */
- /* Release the session lock */
- switch_core_session_rwunlock(session);
-
return SWITCH_STATUS_SUCCESS;
}
@@ -477,6 +483,7 @@
/* Go bill */
do_billing(session);
+
switch_core_session_rwunlock(session);
}
@@ -512,7 +519,6 @@
static void nibblebill_adjust(switch_core_session_t *session, float amount)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- nibble_data_t *nibble_data;
char *uuid;
if (!channel) {
@@ -521,53 +527,54 @@
uuid = switch_core_session_get_uuid(session);
- /* Lock this session's data for this module while we tinker with it */
- if (globals.mutex) {
- switch_mutex_lock(globals.mutex);
+ /* Get channel var */
+ if (!uuid || !channel) {
+ switch_core_session_rwunlock(session);
+ return;
}
- /* Get our nibble data var. This will be NULL if it's our first call here for this session */
- nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
-
- /*Add or remove amount from adjusted billing here */
- nibble_data->manual_adjustments += amount;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current adjustment for %s is $%f\n", uuid, amount);
+ /* Variables kept in FS but relevant only to this module */
+ const char *billaccount = switch_channel_get_variable(channel, "nibble_account");
- /* Done changing - release lock */
- if (globals.mutex) {
- switch_mutex_unlock(globals.mutex);
+ /* Return if there's no billing information on this session */
+ if (!billaccount) {
+ switch_core_session_rwunlock(session);
+ return;
}
- /* Release the session lock */
- switch_core_session_rwunlock(session);
-}
-
-#define CHECK_APP_SYNTAX ""
-SWITCH_STANDARD_APP(nibblebill_check_app_function)
-{
- float amount;
-
- amount = nibblebill_check(session);
+ /* Add or remove amount from adjusted billing here. Note, we bill the OPPOSITE */
+ if (bill_event(-amount, billaccount)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recorded adjustment to %s for $%f\n", billaccount, amount);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to record adjustment to %s for $%f\n", billaccount, amount);
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", amount);
}
-#define ADJUST_APP_SYNTAX "<amount>"
-SWITCH_STANDARD_APP(nibblebill_adjust_app_function)
+#define APP_SYNTAX "pause | resume | reset | adjust <amount> | heartbeat <seconds> | check"
+SWITCH_STANDARD_APP(nibblebill_app_function)
{
- char *mydata = NULL;
int argc = 0;
- char *argv[4] = { 0 };
- float amount;
-
- if (!(mydata = switch_core_session_strdup(session, data))) {
- return;
- }
-
- if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
- amount = atof(argv[0]);
- nibblebill_adjust(session, amount);
+ char *lbuf = NULL;
+ char *argv[3] = { 0 };
+
+ if (!switch_strlen_zero(data) && (lbuf = switch_core_session_strdup(session, data))
+ && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+ if (!strcasecmp(argv[0], "adjust") && argc == 2) {
+ nibblebill_adjust(session, atof(argv[1]));
+/* } else if (!strcasecmp(argv[0], "pause")) {
+ nibblebill_pause(session);
+ } else if (!strcasecmp(argv[0], "resume")) {
+ nibblebill_resume(session);*/
+ } else if (!strcasecmp(argv[0], "check")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", nibblebill_check(session));
+/* } else if (!strcasecmp(argv[0], "reset")) {
+ nibblebill_reset(session);*/
+ } else if (!strcasecmp(argv[0], "heartbeat") && argc == 2) {
+ switch_core_session_enable_heartbeat(session, atoi(argv[1]));
+ }
}
+
}
/* We get here from the API only (theoretically) */
@@ -605,6 +612,9 @@
/* Set every byte in this structure to 0 */
memset(&globals, 0, sizeof(globals));
+ globals.pool = pool;
+ switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
+
load_config();
/* connect my internal structure to the blank pointer passed to me */
@@ -618,11 +628,12 @@
SWITCH_ADD_API(api_interface, "check", "Check the balance of a session", nibblebill_check_api_function, CHECK_API_SYNTAX);
/* Add dialplan applications */
-/* SWITCH_ADD_APP(app_interface, "pause", "Pause billing on a session", "Pause billing on a session", nibblebill_pause_app_function, PAUSE_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "resume", "Resume billing on a session", "Resume billing on a session", nibblebill_resume_app_function, RESUME_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "reset", "Check the balance of a session", "Check the balance of a session", nibblebill_reset_app_function, RESET_APP_SYNTAX, SAF_NONE);*/
- SWITCH_ADD_APP(app_interface, "adjust", "Add or deduct a dollar amount from a caller's account", "Add or deduct a dollar amount from a callers' account (use negative numbers to deduct)", nibblebill_adjust_app_function, ADJUST_APP_SYNTAX, SAF_NONE);
- SWITCH_ADD_APP(app_interface, "check", "Check the balance on an account", "Perform an account check for fund balance on a specific caller's account", nibblebill_check_app_function, CHECK_APP_SYNTAX, SAF_NONE);
+/* SWITCH_ADD_APP(app_interface, "nibble_pause", "Pause billing on a session", "Pause billing on a session", nibblebill_pause_app_function, PAUSE_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "nibble_resume", "Resume billing on a session", "Resume billing on a session", nibblebill_resume_app_function, RESUME_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "nibble_reset", "Check the balance of a session", "Check the balance of a session", nibblebill_reset_app_function, RESET_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "nibble_adjust", "Add or deduct a dollar amount from a caller's account", "Add or deduct a dollar amount from a callers' account (use negative numbers to deduct)", nibblebill_adjust_app_function, ADJUST_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "nibble_check", "Check the balance on an account", "Perform an account check for fund balance on a specific caller's account", nibblebill_check_app_function, CHECK_APP_SYNTAX, SAF_NONE);*/
+ SWITCH_ADD_APP(app_interface, "nibblebill", "Handle billing for the current channel/call", "Pause, resume, reset, adjust, flush, heartbeat commands to handle billing.", nibblebill_app_function, APP_SYNTAX, SAF_NONE);
/* register state handlers for billing */
switch_core_add_state_handler(&nibble_state_handler);
1
0
[commit] r11220 - freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: dschreiber
Date: Thu Jan 15 01:58:23 2009
New Revision: 11220
Log:
Checking in sample config file
Added:
freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/nibblebill.conf.xml
Added: freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/nibblebill.conf.xml
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/nibblebill.conf.xml Thu Jan 15 01:58:23 2009
@@ -0,0 +1,36 @@
+<configuration name="nibblebill.conf" description="Nibble Billing">
+ <settings>
+ <!-- See http://wiki.freeswitch.org/index.php?title=Mod_nibblebill for help with these options -->
+
+ <!-- Information for connecting to your database -->
+ <param name="db_username" value="bandwidth.com"/>
+ <param name="db_password" value="password"/>
+ <param name="db_dsn" value="bandwidth.com"/>
+
+ <!-- The database table where your CASH column is located -->
+ <param name="db_table" value="accounts"/>
+
+ <!-- The column name where we store the value of the account -->
+ <param name="db_column_cash" value="cash"/>
+
+ <!-- The column name for the unique ID identifying the account -->
+ <param name="db_column_account" value="id"/>
+
+
+ <!-- Default heartbeat interval. Set to 'off' for no heartbeat (i.e. bill only at end of call) -->
+ <param name="global_heartbeat" value="60"/>
+
+ <!-- By default, warn a caller when their balance is at $5.00. You can set this to a negative number. -->
+ <param name="lowbal_amt" value="5"/>
+ <param name="lowbal_action" value="play ding"/>
+
+ <!-- By default, terminate a caller when their balance hits $0.00. You can set this to a negative number. -->
+ <param name="nobal_amt" value="0"/>
+ <param name="nobal_action" value="hangup"/>
+
+ <!-- If a call goes beyond a certain dollar amount, flag or terminate it -->
+ <param name="percall_max_amt" value="100"/>
+ <param name="percall_action" value="hangup"/>
+
+ </settings>
+</configuration>
1
0
[commit] r11219 - freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: dschreiber
Date: Thu Jan 15 01:56:15 2009
New Revision: 11219
Log:
Updated nibblebill to add some dialplan applications
more to come
Modified:
freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
Modified: freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
==============================================================================
--- freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c (original)
+++ freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c Thu Jan 15 01:56:15 2009
@@ -29,9 +29,15 @@
* Darren Schreiber <d(a)d-man.org>
*
* mod_nibblebill.c - Nibble Billing
- * Set the session heartbeat on a call that has a billrate and deduct currency from
- * a database table each "tick" of the billing until funds are depleted.
- * Terminate the call upon depletion.
+ * Purpose is to allow real-time debiting of credit or cash from a database while calls are in progress. I had the following goals:
+ *
+ * Debit credit/cash from accounts real-time
+ * Allow for billing at different rates during a single call
+ * Allow for warning callers when their balance is low (via audio, in-channel)
+ * Allow for disconnecting or re-routing calls when balance is depleted
+ * Allow for billing to function as listed above with multiple concurrent calls
+ *
+ * Thanks go to bandwidth.com for funding this work.
*
*
* TODO: Create an override flag so you can force a start-time for when billing should count *from*
@@ -52,13 +58,20 @@
#endif
/* Defaults */
-/* static char SQL_LOOKUP[] = "SELECT cash FROM accounts WHERE id=\"%s\""; */
-static char SQL_SAVE[] = "UPDATE accounts SET cash=cash-%f WHERE id=\"%s\"";
+#ifdef SWITCH_HAVE_ODBC
+/*static char SQL_LOOKUP[] = "SELECT %s FROM %s WHERE %s=\"%s\"";*/
+static char SQL_SAVE[] = "UPDATE %s SET %s=%s-%f WHERE %s=\"%s\"";
+#endif
typedef struct
{
switch_time_t lastts; /* Last time we did any billing */
float total; /* Total amount billed so far */
+
+ switch_time_t pausets; /* Timestamp of when a pause action started. 0 if not paused */
+ float bill_adjustments; /* Adjustments to make to the next billing, based on pause/resume events */
+
+ float manual_adjustments; /* Manually added/deducted amounts from this account, to be committed at next database query */
} nibble_data_t;
@@ -88,12 +101,16 @@
float nobal_amt; /* Minimum amount that must remain in the account */
char *nobal_action; /* Drop action */
+ /* Other options */
+ int global_heartbeat; /* Supervise and bill every X seconds, 0 means off */
+
/* Database settings */
char *db_username;
char *db_password;
char *db_dsn;
- char *lookup_query;
- char *save_query;
+ char *db_table;
+ char *db_column_cash;
+ char *db_column_account;
#ifdef SWITCH_HAVE_ODBC
switch_odbc_handle_t *master_odbc;
#else
@@ -117,12 +134,14 @@
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_db_username, globals.db_username);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_db_password, globals.db_password);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_db_dsn, globals.db_dsn);
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_lookup_query, globals.lookup_query);
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_save_query, globals.save_query);
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_db_table, globals.db_table);
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_db_column_cash, globals.db_column_cash);
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_db_column_account, globals.db_column_account);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_percall_action, globals.percall_action);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_lowbal_action, globals.lowbal_action);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_nobal_action, globals.nobal_action);
+#ifdef SWITCH_HAVE_ODBC
static int nibblebill_callback(void *pArg, int argc, char **argv, char **columnNames)
{
nibblebill_results_t *cbt = (nibblebill_results_t *) pArg;
@@ -131,6 +150,7 @@
return 0;
}
+#endif
static switch_status_t load_config(void)
{
@@ -141,7 +161,7 @@
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
status = SWITCH_STATUS_SUCCESS; /* We don't fail because we can still write to a text file or buffer */
- goto done;
+ goto setdefaults;
}
if ((settings = switch_xml_child(cfg, "settings"))) {
@@ -149,35 +169,46 @@
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
- if (!strcasecmp(var, "db-username")) {
+ if (!strcasecmp(var, "db_username")) {
set_global_db_username(val);
- } else if (!strcasecmp(var, "db-password")) {
+ } else if (!strcasecmp(var, "db_password")) {
set_global_db_password(val);
- } else if (!strcasecmp(var, "db-dsn")) {
+ } else if (!strcasecmp(var, "db_dsn")) {
set_global_db_dsn(val);
- } else if (!strcasecmp(var, "lookup_query")) {
- set_global_lookup_query(val);
- } else if (!strcasecmp(var, "save_query")) {
- set_global_save_query(val);
+ } else if (!strcasecmp(var, "db_table")) {
+ set_global_db_table(val);
+ } else if (!strcasecmp(var, "db_column_cash")) {
+ set_global_db_column_cash(val);
+ } else if (!strcasecmp(var, "db_column_account")) {
+ set_global_db_column_account(val);
} else if (!strcasecmp(var, "percall_action")) {
set_global_percall_action(val);
+ } else if (!strcasecmp(var, "percall_max_amt")) {
+ globals.percall_max_amt = atof(val);
} else if (!strcasecmp(var, "lowbal_action")) {
set_global_lowbal_action(val);
+ } else if (!strcasecmp(var, "lowbal_amt")) {
+ globals.lowbal_amt = atof(val);
} else if (!strcasecmp(var, "nobal_action")) {
set_global_nobal_action(val);
+ } else if (!strcasecmp(var, "nobal_amt")) {
+ globals.nobal_amt = atof(val);
+ } else if (!strcasecmp(var, "global_heartbeat")) {
+ globals.global_heartbeat = atoi(val);
}
}
}
-done:
+/* Set defaults for any variables still not set */
+setdefaults:
if (switch_strlen_zero(globals.db_username)) {
- set_global_db_username("phonebooth");
+ set_global_db_username("bandwidth.com");
}
if (switch_strlen_zero(globals.db_password)) {
set_global_db_password("dev");
}
if (switch_strlen_zero(globals.db_dsn)) {
- set_global_db_dsn("phonebooth");
+ set_global_db_dsn("bandwidth.com");
}
if (switch_strlen_zero(globals.percall_action)) {
set_global_percall_action("hangup");
@@ -188,14 +219,13 @@
if (switch_strlen_zero(globals.nobal_action)) {
set_global_nobal_action("hangup");
}
- /* Need to add defaults for the integers! */
#ifdef SWITCH_HAVE_ODBC
if (globals.db_dsn) {
if (!(globals.master_odbc = switch_odbc_handle_new(globals.db_dsn, globals.db_username, globals.db_password))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot create handle to ODBC Database!\n");
status = SWITCH_STATUS_FALSE;
- goto reallydone;
+ goto done;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opened ODBC Database handle!\n");
}
@@ -203,7 +233,7 @@
if (switch_odbc_handle_connect(globals.master_odbc) != SWITCH_ODBC_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot connect to ODBC driver/database %s (user: %s / pass %s)!\n", globals.db_dsn, globals.db_username, globals.db_password);
status = SWITCH_STATUS_FALSE;
- goto reallydone;
+ goto done;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opened ODBC Database!\n");
}
@@ -216,7 +246,7 @@
#endif
#ifdef SWITCH_HAVE_ODBC
-reallydone:
+done:
#endif
if (xml) {
@@ -245,7 +275,11 @@
static switch_status_t sched_billing(switch_core_session_t *session)
{
- switch_core_session_enable_heartbeat(session, 60);
+ if (globals.global_heartbeat > 0) {
+ switch_core_session_enable_heartbeat(session, globals.global_heartbeat);
+ }
+
+ // Check account balance here
return SWITCH_STATUS_SUCCESS;
@@ -263,7 +297,9 @@
nibble_data_t *nibble_data;
switch_time_t ts = switch_timestamp_now();
float billamount;
+ float adjustments = 0;
char date[80] = "";
+ char *tmp;
char *uuid;
switch_size_t retsize;
switch_time_exp_t tm;
@@ -313,6 +349,15 @@
/* Get our nibble data var. This will be NULL if it's our first call here for this session */
nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
+ /* Are we in paused mode? If so, we don't do anything here - go back! */
+ if (nibble_data->pausets > 0) {
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Received heartbeat, but we're paused - ignoring\n");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
/* Have we done any billing on this channel yet? If no, set up vars for doing so */
if (!nibble_data) {
nibble_data = switch_core_session_alloc(session, sizeof(*nibble_data));
@@ -337,34 +382,46 @@
if ((ts - nibble_data->lastts) > 0) {
/* Convert billrate into microseconds and multiply by # of microseconds that have passed */
billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts));
+ adjustments = nibble_data->manual_adjustments + nibble_data->bill_adjustments;
/* if ODBC call fails, we should return BEFORE updating the timestamp of last success! */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Billing $%f to %s (Call: %s / %f so far)\n", billamount, billaccount, uuid, nibble_data->total);
+ if (adjustments > 0) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(Also adjusting the account by $%f)\n", adjustments);
+ }
+
/* DO ODBC BILLING HERE! */
#ifdef SWITCH_HAVE_ODBC
char sql[1024] = "";
nibblebill_results_t pdata;
memset(&pdata, 0, sizeof(pdata));
- if (!globals.save_query){
- snprintf(sql, 1024, SQL_SAVE, billamount, billaccount);
- } else {
- snprintf(sql, 1024, globals.save_query, billamount, billaccount);
- }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing static update query\n[%s]\n", sql);
+ snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, (billamount - adjustments), globals.db_column_account, billaccount);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
if (!(switch_odbc_handle_callback_exec(globals.master_odbc, sql, nibblebill_callback, &pdata) == SWITCH_ODBC_SUCCESS)){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DB Error while updating cash!\n");
/* TODO: If this is a hangup event, we should store this billing in a text file while the DB is unavailable */
- }
+ } else {
#endif
+ /* Increment total cost */
+ nibble_data->total += billamount;
- /* Increment total cost */
- nibble_data->total += billamount;
+ /* Get rid of any manual adjustments that were just committed */
+ nibble_data->manual_adjustments = 0;
+ nibble_data->bill_adjustments = 0;
+
+ /* Update channel variable with current billing */
+ tmp = switch_mprintf("%f", nibble_data->total);
+ switch_channel_set_variable(channel, "nibble_total_billed", tmp);
+ switch_safe_free(tmp);
+#ifdef SWITCH_HAVE_ODBC
+ }
+#endif
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Just tried to bill %s negative minutes! wtf?\n", uuid);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Just tried to bill %s negative minutes! wtf? That should be impossible.\n", uuid);
}
/* Update the last time we billed */
@@ -373,14 +430,16 @@
/* Save everything back */
switch_channel_set_private(channel, "_nibble_data_", nibble_data);
- /* Release the session lock */
- switch_core_session_rwunlock(session);
-
/* Done changing - release lock */
if (globals.mutex) {
switch_mutex_unlock(globals.mutex);
}
+ /* Go check if this call is allowed to continue */
+
+ /* Release the session lock */
+ switch_core_session_rwunlock(session);
+
return SWITCH_STATUS_SUCCESS;
}
@@ -421,28 +480,99 @@
switch_core_session_rwunlock(session);
}
-SWITCH_STANDARD_APP(nibblebill_app_function)
+
+static float nibblebill_check(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
+ nibble_data_t *nibble_data;
+ float amount = 0;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "We made it!\n");
+ if (!channel) {
+ return -99999;
+ }
+
+ /* Lock this session's data for this module while we tinker with it */
+ if (globals.mutex) {
+ switch_mutex_lock(globals.mutex);
+ }
+
+ /* Get our nibble data var. This will be NULL if it's our first call here for this session */
+ nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
+
+ amount = nibble_data->total;
+
+ /* Done checking - release lock */
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+
+ return amount;
+}
+
+static void nibblebill_adjust(switch_core_session_t *session, float amount)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ nibble_data_t *nibble_data;
+ char *uuid;
if (!channel) {
return;
}
+
+ uuid = switch_core_session_get_uuid(session);
+
+ /* Lock this session's data for this module while we tinker with it */
+ if (globals.mutex) {
+ switch_mutex_lock(globals.mutex);
+ }
+
+ /* Get our nibble data var. This will be NULL if it's our first call here for this session */
+ nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
+
+ /*Add or remove amount from adjusted billing here */
+ nibble_data->manual_adjustments += amount;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current adjustment for %s is $%f\n", uuid, amount);
+
+ /* Done changing - release lock */
+ if (globals.mutex) {
+ switch_mutex_unlock(globals.mutex);
+ }
+
+ /* Release the session lock */
+ switch_core_session_rwunlock(session);
+}
+
+#define CHECK_APP_SYNTAX ""
+SWITCH_STANDARD_APP(nibblebill_check_app_function)
+{
+ float amount;
+
+ amount = nibblebill_check(session);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Current billing is at $%f\n", amount);
+}
+
+#define ADJUST_APP_SYNTAX "<amount>"
+SWITCH_STANDARD_APP(nibblebill_adjust_app_function)
+{
+ char *mydata = NULL;
+ int argc = 0;
+ char *argv[4] = { 0 };
+ float amount;
-/* if (!(mydata = switch_core_session_strdup(session, data))) {
+ if (!(mydata = switch_core_session_strdup(session, data))) {
return;
}
if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
- destnum = argv[0];
- do_billing(session);
- }*/
+ amount = atof(argv[0]);
+ nibblebill_adjust(session, amount);
+ }
}
/* We get here from the API only (theoretically) */
-SWITCH_STANDARD_API(nibblebill_function)
+#define CHECK_API_SYNTAX "<uuid>"
+SWITCH_STANDARD_API(nibblebill_check_api_function)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "We made it!\n");
@@ -459,7 +589,7 @@
{
/* on_init */ NULL,
/* on_routing */ NULL, /* Need to add a check here for anything in their account before routing */
- /* on_execute */ sched_billing, /* Turn on heartbeat for this session */
+ /* on_execute */ sched_billing, /* Turn on heartbeat for this session and do an initial account check */
/* on_hangup */ do_billing, /* On hangup - most important place to go bill */
/* on_exch_media */ NULL,
/* on_soft_exec */ NULL,
@@ -479,8 +609,20 @@
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
- SWITCH_ADD_API(api_interface, "check", "Check the balance of an account", nibblebill_function, "");
- SWITCH_ADD_APP(app_interface, "check", "Check the balance on an account", "Perform an account check for fund balance", nibblebill_app_function, "<number>", SAF_SUPPORT_NOMEDIA);
+
+ /* Add API and CLI commands */
+/* SWITCH_ADD_API(api_interface, "pause", "Pause billing on a session", nibblebill_pause_api_function, PAUSE_API_SYNTAX);
+ SWITCH_ADD_API(api_interface, "resume", "Resume billing on a session", nibblebill_resume_api_function, RESUME_API_SYNTAX);
+ SWITCH_ADD_API(api_interface, "reset", "Reset billing start time to right now - disregard any unbilled time thus far", nibblebill_reset_api_function, RESET_API_SYNTAX);
+ SWITCH_ADD_API(api_interface, "adjust", "Add or deduct a dollar amount from a caller's account", nibblebill_adjust_api_function, ADJUST_API_SYNTAX);*/
+ SWITCH_ADD_API(api_interface, "check", "Check the balance of a session", nibblebill_check_api_function, CHECK_API_SYNTAX);
+
+ /* Add dialplan applications */
+/* SWITCH_ADD_APP(app_interface, "pause", "Pause billing on a session", "Pause billing on a session", nibblebill_pause_app_function, PAUSE_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "resume", "Resume billing on a session", "Resume billing on a session", nibblebill_resume_app_function, RESUME_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "reset", "Check the balance of a session", "Check the balance of a session", nibblebill_reset_app_function, RESET_APP_SYNTAX, SAF_NONE);*/
+ SWITCH_ADD_APP(app_interface, "adjust", "Add or deduct a dollar amount from a caller's account", "Add or deduct a dollar amount from a callers' account (use negative numbers to deduct)", nibblebill_adjust_app_function, ADJUST_APP_SYNTAX, SAF_NONE);
+ SWITCH_ADD_APP(app_interface, "check", "Check the balance on an account", "Perform an account check for fund balance on a specific caller's account", nibblebill_check_app_function, CHECK_APP_SYNTAX, SAF_NONE);
/* register state handlers for billing */
switch_core_add_state_handler(&nibble_state_handler);
1
0
[commit] r11218 - freeswitch/trunk/src/mod/languages/mod_managed/managed
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: michaelgg
Date: Wed Jan 14 23:36:45 2009
New Revision: 11218
Log:
Fix DLL name in Makefile
Modified:
freeswitch/trunk/src/mod/languages/mod_managed/managed/Makefile
Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/Makefile (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/Makefile Wed Jan 14 23:36:45 2009
@@ -1,14 +1,14 @@
-all: mod_managed_lib.dll
+all: FreeSWITCH.Managed.dll
clean:
- rm -fr mod_managed_lib.dll
+ rm -fr FreeSWITCH.Managed.dll
-mod_managed_lib.dll: Loader.cs ManagedSession.cs ApiFunction.cs AppFunction.cs Extensions.cs Log.cs Demo.cs swig.cs
- gmcs -target:library -out:mod_managed_lib.dll -d:DEBUG Loader.cs ManagedSession.cs ApiFunction.cs AppFunction.cs Extensions.cs Log.cs Demo.cs swig.cs
+FreeSWITCH.Managed.dll: Loader.cs ManagedSession.cs ApiFunction.cs AppFunction.cs Extensions.cs Log.cs Demo.cs swig.cs
+ gmcs -target:library -out:FreeSWITCH.Managed.dll -d:DEBUG Loader.cs ManagedSession.cs ApiFunction.cs AppFunction.cs Extensions.cs Log.cs Demo.cs swig.cs
-install: mod_managed_lib.dll
- $(INSTALL) mod_managed_lib.dll $(DESTDIR)$(MODINSTDIR)
+install: FreeSWITCH.Managed.dll
+ $(INSTALL) FreeSWITCH.Managed.dll $(DESTDIR)$(MODINSTDIR)
uninstall:
- $(UNINSTALL) $(MODINSTDIR)/mod_managed_lib.dll
+ $(UNINSTALL) $(MODINSTDIR)/FreeSWITCH.Managed.dll
1
0
15 Jan '09
Author: mrene
Date: Wed Jan 14 22:50:06 2009
New Revision: 11217
Log:
tweak
Modified:
freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Wed Jan 14 22:50:06 2009
@@ -806,7 +806,7 @@
char *id = NULL;
char *hashkey = NULL;
char *xfer_exten = NULL;
- int max = 0;
+ int max = -1;
int interval = 0;
char *szinterval = NULL;
limit_hash_item_t *item = NULL;
1
0
15 Jan '09
Author: mrene
Date: Wed Jan 14 22:46:58 2009
New Revision: 11216
Log:
tweak
Modified:
freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Wed Jan 14 22:46:58 2009
@@ -822,7 +822,7 @@
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
- if (argc < 3) {
+ if (argc < 2) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: limit_hash %s\n", LIMITHASH_USAGE);
return;
}
1
0
[commit] r11215 - freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill
by FreeSWITCH SVN 15 Jan '09
by FreeSWITCH SVN 15 Jan '09
15 Jan '09
Author: dschreiber
Date: Wed Jan 14 22:20:56 2009
New Revision: 11215
Log:
Removed more whitespaces
Modified:
freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
Modified: freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c
==============================================================================
--- freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c (original)
+++ freeswitch/trunk/scripts/contrib/dschreiber/mod_nibblebill/mod_nibblebill.c Wed Jan 14 22:20:56 2009
@@ -190,7 +190,6 @@
}
/* Need to add defaults for the integers! */
-
#ifdef SWITCH_HAVE_ODBC
if (globals.db_dsn) {
if (!(globals.master_odbc = switch_odbc_handle_new(globals.db_dsn, globals.db_username, globals.db_password))) {
@@ -209,14 +208,13 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opened ODBC Database!\n");
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", globals.db_dsn);
- } else {
+ } else {
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "ODBC does not appear to be installed in the core. You need to run ./configure --enable-core-odbc-support\n");
#ifdef SWITCH_HAVE_ODBC
}
#endif
-
#ifdef SWITCH_HAVE_ODBC
reallydone:
#endif
@@ -254,7 +252,7 @@
}
/* This is where we actually charge the guy
- This can be called anytime a call is in progress or at the end of a call before the session is destroyed */
+ This can be called anytime a call is in progress or at the end of a call before the session is destroyed */
static switch_status_t do_billing(switch_core_session_t *session)
{
/* FS vars we will use */
@@ -265,10 +263,10 @@
nibble_data_t *nibble_data;
switch_time_t ts = switch_timestamp_now();
float billamount;
- char date[80] = "";
+ char date[80] = "";
char *uuid;
- switch_size_t retsize;
- switch_time_exp_t tm;
+ switch_size_t retsize;
+ switch_time_exp_t tm;
if (!session) {
/* wtf? Why are we here? */
@@ -488,10 +486,10 @@
switch_core_add_state_handler(&nibble_state_handler);
/* bind to heartbeat events */
- if (switch_event_bind_removable(modname, SWITCH_EVENT_SESSION_HEARTBEAT, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event to monitor for session heartbeats!\n");
- return SWITCH_STATUS_GENERR;
- }
+ if (switch_event_bind_removable(modname, SWITCH_EVENT_SESSION_HEARTBEAT, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event to monitor for session heartbeats!\n");
+ return SWITCH_STATUS_GENERR;
+ }
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
1
0