2 * Asterisk -- A telephony toolkit for Linux.
4 * Generic File Format Support.
6 * Copyright (C) 1999, Mark Spencer
8 * Mark Spencer <markster@linux-support.net>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
14 #ifndef _ASTERISK_FILE_H
15 #define _ASTERISK_FILE_H
17 #include <asterisk/channel.h>
18 #include <asterisk/frame.h>
22 #if defined(__cplusplus) || defined(c_plusplus)
27 /* Convenient for waiting */
28 #define AST_DIGIT_ANY "0123456789#*"
30 /* Defined by individual formats. First item MUST be a
31 pointer for use by the stream manager */
32 struct ast_filestream;
34 /* Register a new file format capability */
35 int ast_format_register(char *name, char *exts, int format,
36 struct ast_filestream * (*open)(int fd),
37 struct ast_filestream * (*rewrite)(int fd, char *comment),
38 int (*apply)(struct ast_channel *, struct ast_filestream *),
39 int (*write)(struct ast_filestream *, struct ast_frame *),
40 struct ast_frame * (*read)(struct ast_filestream *),
41 void (*close)(struct ast_filestream *),
42 char * (*getcomment)(struct ast_filestream *));
44 int ast_format_unregister(char *name);
46 /* Start streaming a file, in the preferred language if possible */
47 int ast_streamfile(struct ast_channel *c, char *filename, char *preflang);
49 /* Stop playback of a stream */
50 int ast_stopstream(struct ast_channel *c);
52 /* See if a given file exists in a given format. If fmt is NULL, any format is accepted.*/
53 int ast_fileexists(char *filename, char *fmt, char *preflang);
55 /* Rename a given file in a given format, or if fmt is NULL, then do so for all */
56 int ast_filerename(char *oldname, char *newname, char *fmt);
58 /* Delete a given file in a given format, or if fmt is NULL, then do so for all */
59 int ast_filedelete(char *filename, char *fmt);
61 /* Wait for a stream to stop or for any one of a given digit to arrive, Returns
62 0 if the stream finishes, the character if it was interrupted, and -1 on error */
63 char ast_waitstream(struct ast_channel *c, char *breakon);
65 /* Create an outgoing file stream. oflags are flags for the open() command, and
66 if check is non-zero, then it will not write a file if there are any files that
67 start with that name and have an extension */
68 struct ast_filestream *ast_writefile(char *filename, char *type, char *comment, int oflags, int check, mode_t mode);
70 /* Send a frame to a filestream -- note: does NOT free the frame, call ast_frfree manually */
71 int ast_writestream(struct ast_filestream *fs, struct ast_frame *f);
73 /* Close a playback or recording stream */
74 int ast_closestream(struct ast_filestream *f);
76 #define AST_RESERVED_POINTERS 4
78 #if defined(__cplusplus) || defined(c_plusplus)