add some commands to portaudio
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4297 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
9af074316f
commit
4ddc9e1681
|
@ -1139,6 +1139,23 @@ static void PrintSupportedStandardSampleRates(const PaStreamParameters *inputPar
|
||||||
}
|
}
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
|
|
||||||
|
static switch_status_t devlist(char **argv, int argc, switch_stream_handle_t *stream)
|
||||||
|
{
|
||||||
|
int i, numDevices;
|
||||||
|
const PaDeviceInfo *deviceInfo;
|
||||||
|
|
||||||
|
numDevices = Pa_GetDeviceCount();
|
||||||
|
if (numDevices < 0) {
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
for(i=0; i<numDevices; i++) {
|
||||||
|
deviceInfo = Pa_GetDeviceInfo(i);
|
||||||
|
stream->write_function(stream, "%d;%s;%d;%d\n", i, deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int dump_info(void)
|
static int dump_info(void)
|
||||||
{
|
{
|
||||||
int i, numDevices, defaultDisplayed;
|
int i, numDevices, defaultDisplayed;
|
||||||
|
@ -1151,7 +1168,10 @@ static int dump_info(void)
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "PortAudio version number = %d\nPortAudio version text = '%s'\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "PortAudio version number = %d\nPortAudio version text = '%s'\n",
|
||||||
Pa_GetVersion(), Pa_GetVersionText());
|
Pa_GetVersion(), Pa_GetVersionText());
|
||||||
|
if (globals.audio_stream) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
numDevices = Pa_GetDeviceCount();
|
numDevices = Pa_GetDeviceCount();
|
||||||
if (numDevices < 0) {
|
if (numDevices < 0) {
|
||||||
|
@ -1695,10 +1715,10 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch
|
||||||
{
|
{
|
||||||
char *argv[1024] = {0};
|
char *argv[1024] = {0};
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char *mycmd = NULL;
|
char *mycmd = NULL, *devname = NULL;
|
||||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
pa_command_t func = NULL;
|
pa_command_t func = NULL;
|
||||||
int lead = 1;
|
int lead = 1, devval = 0;
|
||||||
const char *usage_string = "USAGE:\n"
|
const char *usage_string = "USAGE:\n"
|
||||||
"--------------------------------------------------------------------------------\n"
|
"--------------------------------------------------------------------------------\n"
|
||||||
"pa help\n"
|
"pa help\n"
|
||||||
|
@ -1710,6 +1730,10 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch
|
||||||
"pa switch [<call_id>|none]\n"
|
"pa switch [<call_id>|none]\n"
|
||||||
"pa dtmf <digit string>\n"
|
"pa dtmf <digit string>\n"
|
||||||
"pa flags [on|off] [ear] [mouth]\n"
|
"pa flags [on|off] [ear] [mouth]\n"
|
||||||
|
"pa devlist\n"
|
||||||
|
"pa indev [#<num>|<partial name>\n"
|
||||||
|
"pa outdev [#<num>|<partial name>\n"
|
||||||
|
"pa ringdev [#<num>|<partial name>\n"
|
||||||
"--------------------------------------------------------------------------------\n";
|
"--------------------------------------------------------------------------------\n";
|
||||||
|
|
||||||
if (switch_strlen_zero(cmd)) {
|
if (switch_strlen_zero(cmd)) {
|
||||||
|
@ -1732,6 +1756,8 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch
|
||||||
} else if (!strcasecmp(argv[0], "help")) {
|
} else if (!strcasecmp(argv[0], "help")) {
|
||||||
stream->write_function(stream, "%s", usage_string);
|
stream->write_function(stream, "%s", usage_string);
|
||||||
goto done;
|
goto done;
|
||||||
|
} else if (!strcasecmp(argv[0], "devlist")) {
|
||||||
|
func = devlist;
|
||||||
} else if (!strcasecmp(argv[0], "dump")) {
|
} else if (!strcasecmp(argv[0], "dump")) {
|
||||||
dump_info();
|
dump_info();
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1747,12 +1773,50 @@ static switch_status_t pa_cmd(char *cmd, switch_core_session_t *isession, switch
|
||||||
func = switch_call;
|
func = switch_call;
|
||||||
} else if (!strcasecmp(argv[0], "dtmf")) {
|
} else if (!strcasecmp(argv[0], "dtmf")) {
|
||||||
func = dtmf_call;
|
func = dtmf_call;
|
||||||
|
} else if (argv[1] && !strcmp(argv[0], "indev")) {
|
||||||
|
if (*argv[1] == '#') {
|
||||||
|
devval = get_dev_by_number(atoi(argv[1] + 1), 1);
|
||||||
|
} else {
|
||||||
|
devval = get_dev_by_name(argv[1], 1);
|
||||||
|
}
|
||||||
|
devname = "indev";
|
||||||
|
if (devval > 0) {
|
||||||
|
globals.indev = devval;
|
||||||
|
}
|
||||||
|
} else if (argv[1] && !strcmp(argv[0], "outdev")) {
|
||||||
|
if (*argv[1] == '#') {
|
||||||
|
devval = get_dev_by_number(atoi(argv[1] + 1), 0);
|
||||||
|
} else {
|
||||||
|
devval = get_dev_by_name(argv[1], 0);
|
||||||
|
}
|
||||||
|
devname = "outdev";
|
||||||
|
if (devval > 0) {
|
||||||
|
globals.outdev = devval;
|
||||||
|
}
|
||||||
|
} else if (argv[1] && !strcmp(argv[0], "ringdev")) {
|
||||||
|
if (*argv[1] == '#') {
|
||||||
|
devval = get_dev_by_number(atoi(argv[1] + 1), 0);
|
||||||
|
} else {
|
||||||
|
devval = get_dev_by_name(argv[1], 0);
|
||||||
|
}
|
||||||
|
devname = "ringdev";
|
||||||
|
if (devval > 0) {
|
||||||
|
globals.ringdev = devval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (func) {
|
if (func) {
|
||||||
status = func(&argv[lead], argc - lead, stream);
|
status = func(&argv[lead], argc - lead, stream);
|
||||||
} else {
|
} else {
|
||||||
stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
|
if (devname) {
|
||||||
|
if (devval > 0) {
|
||||||
|
stream->write_function(stream, "%s set to %d\n", devname, devval);
|
||||||
|
} else {
|
||||||
|
stream->write_function(stream, "%s not set (invalid value)\n", devname);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
Loading…
Reference in New Issue