diff --git a/apps/app_record.c b/apps/app_record.c index 732922ebf9..29d98f7601 100755 --- a/apps/app_record.c +++ b/apps/app_record.c @@ -30,13 +30,13 @@ static char *app = "Record"; static char *synopsis = "Record to a file"; static char *descrip = -" Record(filename:extension|silence): Records from the channel into a given\n" +" Record(filename:format|silence): Records from the channel into a given\n" "filename. If the file exists it will be overwritten. \n" -"- 'extension' is the extension of the file type to be recorded (wav, gsm, etc).\n" +"- 'format' is the format of the file type to be recorded (wav, gsm, etc).\n" "- 'silence' is the number of seconds of silence to allow before returning.\n\n" "If filename contains '%d', these characters will be replaced with a number\n" "incremented by one each time the file is recorded. \n\n" -"Extensions: g723, g729, gsm, h263, ulaw, alaw, vox, wav, WAV\n\n" +"Formats: g723, g729, gsm, h263, ulaw, alaw, vox, wav, WAV\n\n" "Returns -1 when the user hangs up.\n"; STANDARD_LOCAL_USER; diff --git a/file.c b/file.c index f9a421ed4c..9cdaec5756 100755 --- a/file.c +++ b/file.c @@ -287,6 +287,22 @@ static char *build_filename(char *filename, char *ext) } +static int exts_compare(char *exts, char *type) +{ + char *stringp = NULL, *ext; + char tmp[256]; + + strncpy(tmp, exts, sizeof(tmp) - 1); + stringp = tmp; + while ((ext = strsep(&stringp, "|"))) { + if (!strcmp(ext, type)) { + return 1; + } + } + + return 0; +} + #define ACTION_EXISTS 1 #define ACTION_DELETE 2 #define ACTION_RENAME 3 @@ -319,7 +335,7 @@ static int ast_filehelper(char *filename, char *filename2, char *fmt, int action } f = formats; while(f) { - if (!fmt || !strcasecmp(f->name, fmt)) { + if (!fmt || exts_compare(f->exts, fmt)) { char *stringp=NULL; exts = strdup(f->exts); /* Try each kind of extension */ @@ -376,7 +392,7 @@ static int ast_filehelper(char *filename, char *filename2, char *fmt, int action chan->vstream = s; } else { close(ret); - ast_log(LOG_WARNING, "Unable to open fd on %s\n", filename); + ast_log(LOG_WARNING, "Unable to open fd on %s\n", fn); } } else ast_log(LOG_WARNING, "Couldn't open file %s\n", fn); @@ -748,7 +764,7 @@ struct ast_filestream *ast_readfile(char *filename, char *type, char *comment, i } f = formats; while(f) { - if (!strcasecmp(f->name, type)) { + if (exts_compare(f->exts, type)) { char *stringp=NULL; /* XXX Implement check XXX */ ext = strdup(f->exts); @@ -803,7 +819,7 @@ struct ast_filestream *ast_writefile(char *filename, char *type, char *comment, f = formats; while(f) { - if (!strcasecmp(f->name, type)) { + if (exts_compare(f->exts, type)) { char *stringp=NULL; /* XXX Implement check XXX */ ext = strdup(f->exts); diff --git a/formats/format_g723.c b/formats/format_g723.c index 2431d3dee2..1b610f1f0c 100755 --- a/formats/format_g723.c +++ b/formats/format_g723.c @@ -47,7 +47,7 @@ static int glistcnt = 0; static char *name = "g723sf"; static char *desc = "G.723.1 Simple Timestamp File Format"; -static char *exts = "g723"; +static char *exts = "g723|g723sf"; static struct ast_filestream *g723_open(int fd) { diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c index 5b502ff32f..7a20791b30 100755 --- a/formats/format_wav_gsm.c +++ b/formats/format_wav_gsm.c @@ -68,7 +68,7 @@ static int glistcnt = 0; static char *name = "wav49"; static char *desc = "Microsoft WAV format (Proprietary GSM)"; -static char *exts = "WAV"; +static char *exts = "WAV|wav49"; #if __BYTE_ORDER == __LITTLE_ENDIAN #define htoll(b) (b) @@ -199,10 +199,12 @@ static int check_header(int fd) ast_log(LOG_WARNING, "Read failed (data)\n"); return -1; } +#if 0 /* Does this header actually exist? It doesn't appear to in the files that are created with ast_writefile using this format */ if (memcmp(&data, "data", 4)) { ast_log(LOG_WARNING, "Does not say data\n"); return -1; } +#endif /* Ignore the data length */ if (read(fd, &data, 4) != 4) { ast_log(LOG_WARNING, "Read failed (data)\n"); diff --git a/include/asterisk/file.h b/include/asterisk/file.h index 316e471121..55c0eaa7f9 100755 --- a/include/asterisk/file.h +++ b/include/asterisk/file.h @@ -142,19 +142,19 @@ char ast_waitstream_full(struct ast_channel *c, char *breakon, int audiofd, int //! Starts reading from a file /*! - * \param filename the name of the file to write to - * \param type format of file you wish to write out to + * \param filename the name of the file to read from + * \param type format of file you wish to read from * \param comment comment to go with - * \param oflags output file flags + * \param flags file flags * \param check (unimplemented, hence negligible) * \param mode Open mode - * Open an incoming file stream. oflags are flags for the open() command, and - * if check is non-zero, then it will not write a file if there are any files that + * Open an incoming file stream. flags are flags for the open() command, and + * if check is non-zero, then it will not read a file if there are any files that * start with that name and have an extension * Please note, this is a blocking function. Program execution will not return until ast_waitstream completes it's execution. * Returns a struct ast_filestream on success, NULL on failure */ -struct ast_filestream *ast_readfile(char *filename, char *type, char *comment, int oflags, int check, mode_t mode); +struct ast_filestream *ast_readfile(char *filename, char *type, char *comment, int flags, int check, mode_t mode); //! Starts writing a file /*! @@ -170,7 +170,7 @@ struct ast_filestream *ast_readfile(char *filename, char *type, char *comment, i * Please note, this is a blocking function. Program execution will not return until ast_waitstream completes it's execution. * Returns a struct ast_filestream on success, NULL on failure */ -struct ast_filestream *ast_writefile(char *filename, char *type, char *comment, int oflags, int check, mode_t mode); +struct ast_filestream *ast_writefile(char *filename, char *type, char *comment, int flags, int check, mode_t mode); //! Writes a frame to a stream /*!