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;
}
+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
}
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 */
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);
}
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);
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);
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)
{
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)
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");
//! 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
/*!
* 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
/*!