mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-09 09:05:51 +00:00
update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4223 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
489354037d
commit
cf24c21e86
@ -58,7 +58,6 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, char *pat
|
|||||||
sndfile_context *context;
|
sndfile_context *context;
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
char *ext;
|
char *ext;
|
||||||
int ready = 0;
|
|
||||||
struct format_map *map = NULL;
|
struct format_map *map = NULL;
|
||||||
|
|
||||||
if ((ext = strrchr(path, '.')) == 0) {
|
if ((ext = strrchr(path, '.')) == 0) {
|
||||||
@ -101,54 +100,41 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, char *pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
sf_command (context->handle, SFC_FILE_TRUNCATE, &frames, sizeof (frames));
|
sf_command (context->handle, SFC_FILE_TRUNCATE, &frames, sizeof (frames));
|
||||||
|
}
|
||||||
if (map) {
|
|
||||||
context->sfinfo.format |= map->format;
|
if (map) {
|
||||||
ready = 1;
|
context->sfinfo.format |= map->format;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ready = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ready) {
|
if (!strcmp(ext, "r8") || !strcmp(ext, "raw")) {
|
||||||
ready = 1;
|
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
|
||||||
if (!strcmp(ext, "r8") || !strcmp(ext, "raw")) {
|
context->sfinfo.channels = 1;
|
||||||
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
|
context->sfinfo.samplerate = 8000;
|
||||||
context->sfinfo.channels = 1;
|
} else if (!strcmp(ext, "r16")) {
|
||||||
context->sfinfo.samplerate = 8000;
|
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
|
||||||
} else if (!strcmp(ext, "r16")) {
|
context->sfinfo.channels = 1;
|
||||||
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
|
context->sfinfo.samplerate = 16000;
|
||||||
context->sfinfo.channels = 1;
|
} else if (!strcmp(ext, "r24")) {
|
||||||
context->sfinfo.samplerate = 16000;
|
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_24;
|
||||||
} else if (!strcmp(ext, "r24")) {
|
context->sfinfo.channels = 1;
|
||||||
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_24;
|
context->sfinfo.samplerate = 24000;
|
||||||
context->sfinfo.channels = 1;
|
} else if (!strcmp(ext, "r32")) {
|
||||||
context->sfinfo.samplerate = 24000;
|
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_32;
|
||||||
} else if (!strcmp(ext, "r32")) {
|
context->sfinfo.channels = 1;
|
||||||
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_32;
|
context->sfinfo.samplerate = 32000;
|
||||||
context->sfinfo.channels = 1;
|
} else if (!strcmp(ext, "gsm")) {
|
||||||
context->sfinfo.samplerate = 32000;
|
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_GSM610;
|
||||||
} else if (!strcmp(ext, "gsm")) {
|
context->sfinfo.channels = 1;
|
||||||
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_GSM610;
|
context->sfinfo.samplerate = 8000;
|
||||||
context->sfinfo.channels = 1;
|
} else if (!strcmp(ext, "ul")) {
|
||||||
context->sfinfo.samplerate = 8000;
|
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ULAW;
|
||||||
} else if (!strcmp(ext, "ul")) {
|
context->sfinfo.channels = 1;
|
||||||
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ULAW;
|
context->sfinfo.samplerate = 8000;
|
||||||
context->sfinfo.channels = 1;
|
} else if (!strcmp(ext, "al")) {
|
||||||
context->sfinfo.samplerate = 8000;
|
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ALAW;
|
||||||
} else if (!strcmp(ext, "al")) {
|
context->sfinfo.channels = 1;
|
||||||
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ALAW;
|
context->sfinfo.samplerate = 8000;
|
||||||
context->sfinfo.channels = 1;
|
}
|
||||||
context->sfinfo.samplerate = 8000;
|
|
||||||
} else {
|
|
||||||
ready = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ready) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening File [%s] [%s]\n", path);
|
|
||||||
return SWITCH_STATUS_GENERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mode & SFM_WRITE) && sf_format_check (&context->sfinfo) == 0) {
|
if ((mode & SFM_WRITE) && sf_format_check (&context->sfinfo) == 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error : file format is invalid (0x%08X).\n", context->sfinfo.format);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error : file format is invalid (0x%08X).\n", context->sfinfo.format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user