Modified: freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp (16432 => 16433)
--- freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp 2010-01-21 05:44:42 UTC (rev 16432)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/gsmopen_protocol.cpp 2010-01-21 14:56:46 UTC (rev 16433)
@@ -3729,7 +3729,7 @@
int gsmopen_sound_boost(void *data, int samples_num, double boost)
{
/* LUIGI RIZZO's magic */
- if (boost != 0) { /* scale and clip values */
+ if (boost != 0 && (boost < 511 || boost > 513)) { /* scale and clip values */
int i, x;
int16_t *ptr = (int16_t *) data;
@@ -3743,7 +3743,10 @@
}
ptr[i] = x;
}
+ } else {
+ //printf("BOOST=%f\n", boost);
}
+
return 0;
}
Modified: freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp (16432 => 16433)
--- freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp 2010-01-21 05:44:42 UTC (rev 16432)
+++ freeswitch/branches/gmaruzz/mod_gsmopen/mod_gsmopen.cpp 2010-01-21 14:56:46 UTC (rev 16433)
@@ -98,6 +98,8 @@
#define GSMOPEN_SYNTAX "interface_name gsmopen_API_msg"
#endif //0
+SWITCH_STANDARD_API(gsmopen_boost_audio_function);
+#define GSMOPEN_BOOST_AUDIO_SYNTAX "interface_name [<play|capt> <in decibels: -40 ... +40>]"
SWITCH_STANDARD_API(sendsms_function);
#define SENDSMS_SYNTAX "gsmopen_sendsms interface_name destination_number SMS_text"
/* BEGIN: Changes here */
@@ -2086,9 +2088,10 @@
if (running) {
#if 1
- SWITCH_ADD_API(commands_api_interface, "gsm", "GSMopen console AT_command", gsm_function, GSM_SYNTAX);
- SWITCH_ADD_API(commands_api_interface, "gsmopen", "GSMopen interface AT_command", gsmopen_function, GSMOPEN_SYNTAX);
+ SWITCH_ADD_API(commands_api_interface, "gsm", "gsm console AT_command", gsm_function, GSM_SYNTAX);
+ SWITCH_ADD_API(commands_api_interface, "gsmopen", "gsmopen interface AT_command", gsmopen_function, GSMOPEN_SYNTAX);
#endif //0
+ SWITCH_ADD_API(commands_api_interface, "gsmopen_boost_audio", "gsmopen_boost_audio interface AT_command", gsmopen_boost_audio_function, GSMOPEN_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "gsmopen_sendsms", "gsmopen_sendsms interface destination_number SMS_text", sendsms_function,
SENDSMS_SYNTAX);
SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send);
@@ -2571,7 +2574,61 @@
return SWITCH_STATUS_SUCCESS;
}
#endif //0
+SWITCH_STANDARD_API(gsmopen_boost_audio_function)
+{
+ char *mycmd = NULL, *argv[10] = { 0 };
+ int argc = 0;
+ private_t *tech_pvt = NULL;
+ if (!zstr(cmd) && (mycmd = strdup(cmd))) {
+ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+ }
+
+ if (argc == 1 || argc==3) {
+ int i;
+ int found = 0;
+
+ for (i = 0; !found && i < GSMOPEN_MAX_INTERFACES; i++) {
+ /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */
+ if (strlen(globals.GSMOPEN_INTERFACES[i].name)
+ && (strncmp(globals.GSMOPEN_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
+ tech_pvt = &globals.GSMOPEN_INTERFACES[i];
+ stream->write_function(stream, "Using interface: globals.GSMOPEN_INTERFACES[%d].name=|||%s|||\n", i, globals.GSMOPEN_INTERFACES[i].name);
+ found = 1;
+ break;
+ }
+
+ }
+ if (!found) {
+ stream->write_function(stream, "ERROR: A GSMopen interface with name='%s' was not found\n", argv[0]);
+
+ } else {
+ if (argc == 1) {
+ stream->write_function(stream,"[%s] capture boost is %f\n", globals.GSMOPEN_INTERFACES[i].name, globals.GSMOPEN_INTERFACES[i].capture_boost);
+ stream->write_function(stream,"[%s] playback boost is %f\n", globals.GSMOPEN_INTERFACES[i].name, globals.GSMOPEN_INTERFACES[i].playback_boost);
+ stream->write_function(stream, "%s usage: %s", argv[0], GSMOPEN_BOOST_AUDIO_SYNTAX);
+ goto end;
+ } else if ((strncmp("play", argv[1], strlen(argv[1])) == 0)) {
+ if (switch_is_number(argv[2])) {
+ gsmopen_store_boost(argv[2], &globals.GSMOPEN_INTERFACES[i].playback_boost); //FIXME
+ }
+ }else if ((strncmp("capt", argv[1], strlen(argv[1])) == 0)) {
+ if (switch_is_number(argv[2])) {
+ gsmopen_store_boost(argv[2], &globals.GSMOPEN_INTERFACES[i].capture_boost); //FIXME
+ }
+ } else {
+ stream->write_function(stream, "ERROR, usage: %s", GSMOPEN_BOOST_AUDIO_SYNTAX);
+ }
+ }
+ } else {
+ stream->write_function(stream, "ERROR, usage: %s", GSMOPEN_BOOST_AUDIO_SYNTAX);
+ }
+ end:
+ switch_safe_free(mycmd);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
#if 0
int gsmopen_transfer(private_t * tech_pvt, char *id, char *value)
{
@@ -2749,7 +2806,7 @@
if ((now_timestamp - tech_pvt->gsmopen_serial_synced_timestamp) > 30) { //TODO find a sensible period. 5min? in config?
gsmopen_serial_sync(tech_pvt);
- gsmopen_serial_getstatus_AT(tech_pvt);
+ //gsmopen_serial_getstatus_AT(tech_pvt);
}
}
WARNINGA("EXIT\n", GSMOPEN_P_LOG);