make test 'record' app in app_playback.c

You are best off doing wav (trust me) 
It can record at 8 16 22 and 32 khz if you can manage to have a channel at that speed.

syntax [record /tmp/blah.wav] 

dial * to end (dtmf only works in iax and portaudio {beg file to add it to mod_exosip})



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@453 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2006-01-27 01:46:14 +00:00
1 parent 954fe31140
commit 48ae14726b
6 files changed
+196 -32

No files matched your search

+46 -25
View File
@@ -46,7 +46,8 @@ switch_status sndfile_file_open(switch_file_handle *handle, char *path)
sndfile_context *context;
int mode = 0;
char *ext;
int ready = 1;
if (!(ext = strrchr(path, '.'))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Format\n");
return SWITCH_STATUS_GENERR;
@@ -67,40 +68,60 @@ switch_status sndfile_file_open(switch_file_handle *handle, char *path)
return SWITCH_STATUS_GENERR;
}
if (!(context = switch_core_alloc(handle->memory_pool, sizeof(*context)))) {
return SWITCH_STATUS_MEMERR;
}
if (!strcmp(ext, "r8") || !strcmp(ext, "raw")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 8000;
if (mode & SFM_WRITE) {
context->sfinfo.channels = handle->channels;
context->sfinfo.samplerate = handle->samplerate;
if (handle->samplerate == 8000 || handle->samplerate == 16000) {
context->sfinfo.format |= SF_FORMAT_PCM_16;
} else if (handle->samplerate == 24000) {
context->sfinfo.format |= SF_FORMAT_PCM_24;
} else if (handle->samplerate == 32000) {
context->sfinfo.format |= SF_FORMAT_PCM_32;
}
/* Could add more else if() but i am too lazy atm.. */
if (!strcasecmp(ext, "wav")) {
context->sfinfo.format |= SF_FORMAT_WAV;
} else {
ready = 0;
}
}
if (!strcmp(ext, "r16")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 16000;
if (!ready) {
if (!strcmp(ext, "r8") || !strcmp(ext, "raw")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 8000;
} else if (!strcmp(ext, "r16")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 16000;
} else if (!strcmp(ext, "r24")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_24;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 24000;
} else if (!strcmp(ext, "r32")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_32;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 32000;
} else if (!strcmp(ext, "gsm")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_GSM610;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 8000;
}
}
if (!strcmp(ext, "r24")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_24;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 24000;
}
if (!strcmp(ext, "r32")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_32;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 32000;
}
if ((mode & SFM_WRITE) && sf_format_check (&context->sfinfo) == 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error : file format is invalid (0x%08X).\n", context->sfinfo.format);
return SWITCH_STATUS_GENERR;
};
if (!strcmp(ext, "gsm")) {
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_GSM610;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 8000;
}
if (!(context->handle = sf_open(path, mode, &context->sfinfo))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error Opening File [%s] [%s]\n", path,