[asterisk-commits] rizzo: trunk r89515 - in /trunk: formats/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 21 18:53:50 CST 2007


Author: rizzo
Date: Wed Nov 21 18:53:49 2007
New Revision: 89515

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89515
Log:
implement the split of file.h and mod_format.h


Modified:
    trunk/formats/format_g723.c
    trunk/formats/format_g726.c
    trunk/formats/format_g729.c
    trunk/formats/format_gsm.c
    trunk/formats/format_h263.c
    trunk/formats/format_h264.c
    trunk/formats/format_ilbc.c
    trunk/formats/format_jpeg.c
    trunk/formats/format_ogg_vorbis.c
    trunk/formats/format_pcm.c
    trunk/formats/format_sln.c
    trunk/formats/format_vox.c
    trunk/formats/format_wav.c
    trunk/formats/format_wav_gsm.c
    trunk/include/asterisk/_private.h
    trunk/include/asterisk/file.h
    trunk/include/asterisk/frame.h
    trunk/main/file.c

Modified: trunk/formats/format_g723.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_g723.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_g723.c (original)
+++ trunk/formats/format_g723.c Wed Nov 21 18:53:49 2007
@@ -29,7 +29,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 
 #define G723_MAX_SIZE 1024

Modified: trunk/formats/format_g726.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_g726.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_g726.c (original)
+++ trunk/formats/format_g726.c Wed Nov 21 18:53:49 2007
@@ -32,7 +32,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_g729.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_g729.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_g729.c (original)
+++ trunk/formats/format_g729.c Wed Nov 21 18:53:49 2007
@@ -30,7 +30,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_gsm.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_gsm.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_gsm.c (original)
+++ trunk/formats/format_gsm.c Wed Nov 21 18:53:49 2007
@@ -27,7 +27,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_h263.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_h263.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_h263.c (original)
+++ trunk/formats/format_h263.c Wed Nov 21 18:53:49 2007
@@ -28,7 +28,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_h264.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_h264.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_h264.c (original)
+++ trunk/formats/format_h264.c Wed Nov 21 18:53:49 2007
@@ -28,7 +28,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_ilbc.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_ilbc.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_ilbc.c (original)
+++ trunk/formats/format_ilbc.c Wed Nov 21 18:53:49 2007
@@ -29,7 +29,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_jpeg.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_jpeg.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_jpeg.c (original)
+++ trunk/formats/format_jpeg.c Wed Nov 21 18:53:49 2007
@@ -28,7 +28,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/image.h"
 #include "asterisk/endian.h"

Modified: trunk/formats/format_ogg_vorbis.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_ogg_vorbis.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_ogg_vorbis.c (original)
+++ trunk/formats/format_ogg_vorbis.c Wed Nov 21 18:53:49 2007
@@ -42,7 +42,7 @@
 #include <fcntl.h>
 #endif
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 
 /*

Modified: trunk/formats/format_pcm.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_pcm.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_pcm.c (original)
+++ trunk/formats/format_pcm.c Wed Nov 21 18:53:49 2007
@@ -28,7 +28,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 #include "asterisk/ulaw.h"

Modified: trunk/formats/format_sln.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_sln.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_sln.c (original)
+++ trunk/formats/format_sln.c Wed Nov 21 18:53:49 2007
@@ -26,7 +26,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_vox.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_vox.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_vox.c (original)
+++ trunk/formats/format_vox.c Wed Nov 21 18:53:49 2007
@@ -28,7 +28,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_wav.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_wav.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_wav.c (original)
+++ trunk/formats/format_wav.c Wed Nov 21 18:53:49 2007
@@ -28,7 +28,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/formats/format_wav_gsm.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_wav_gsm.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/formats/format_wav_gsm.c (original)
+++ trunk/formats/format_wav_gsm.c Wed Nov 21 18:53:49 2007
@@ -31,7 +31,7 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
 

Modified: trunk/include/asterisk/_private.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/_private.h?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/include/asterisk/_private.h (original)
+++ trunk/include/asterisk/_private.h Wed Nov 21 18:53:49 2007
@@ -22,7 +22,8 @@
 void threadstorage_init(void);		/*!< Provided by threadstorage.c */
 void ast_event_init(void);		/*!< Provided by event.c */
 int ast_device_state_engine_init(void);	/*!< Provided by devicestate.c */
-int astobj2_init(void);			/*! Provided by astobj2.c */
+int astobj2_init(void);			/*!< Provided by astobj2.c */
+int ast_file_init(void);		/*!< Provided by file.c */
 
 /*!
  * \brief Reload asterisk modules.

Modified: trunk/include/asterisk/file.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/file.h?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/include/asterisk/file.h (original)
+++ trunk/include/asterisk/file.h Wed Nov 21 18:53:49 2007
@@ -18,13 +18,13 @@
 
 /*! \file
  * \brief Generic File Format Support.
+ * Should be included by clients of the file handling routines.
+ * File service providers should instead include mod_format.h
  */
 
 #ifndef _ASTERISK_FILE_H
 #define _ASTERISK_FILE_H
 
-#include "asterisk/channel.h"
-#include "asterisk/frame.h"
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
@@ -33,131 +33,15 @@
 extern "C" {
 #endif
 
+struct ast_filestream;
+struct ast_format;
 
 /*! Convenient for waiting */
 #define AST_DIGIT_ANY "0123456789#*ABCD"
 #define AST_DIGIT_ANYNUM "0123456789"
 
-/*! structure used for lock and refcount of format handlers.
- * Should not be here, but this is a temporary workaround
- * until we implement a more general mechanism.
- * The format handler should include a pointer to
- * this structure.
- * As a trick, if usecnt is initialized with -1,
- * ast_format_register will init the mutex for you.
- */
-struct ast_format_lock {
-	ast_mutex_t lock;
-	int usecnt;	/* number of active clients */
-};
-
-/*!
- * Each supported file format is described by the following fields.
- * Not all are necessary, the support routine implement default
- * values for some of them.
- * A handler typically fills a structure initializing the desired
- * fields, and then calls ast_format_register() with the (readonly)
- * structure as an argument.
- */
-struct ast_format {
-	char name[80];		/*!< Name of format */
-	char exts[80];		/*!< Extensions (separated by | if more than one) 
-	    			this format can read.  First is assumed for writing (e.g. .mp3) */
-	int format;		/*!< Format of frames it uses/provides (one only) */
-	/*! 
-	 * \brief Prepare an input stream for playback. 
-	 * \return 0 on success, -1 on error.
-	 * The FILE is already open (in s->f) so this function only needs to perform
-	 * any applicable validity checks on the file. If none is required, the
-	 * function can be omitted.
-	 */
-	int (*open)(struct ast_filestream *s);
-	/*! 
-	 * \brief Prepare a stream for output, and comment it appropriately if applicable.
-	 * \return 0 on success, -1 on error. 
-	 * Same as the open, the FILE is already open so the function just needs to 
-	 * prepare any header and other fields, if any. 
-	 * The function can be omitted if nothing is needed.
-	 */
-	int (*rewrite)(struct ast_filestream *s, const char *comment);
-	/*! Write a frame to a channel */
-	int (*write)(struct ast_filestream *, struct ast_frame *);
-	/*! seek num samples into file, whence - like a normal seek but with offset in samples */
-	int (*seek)(struct ast_filestream *, off_t, int);
-	int (*trunc)(struct ast_filestream *fs);	/*!< trunc file to current position */
-	off_t (*tell)(struct ast_filestream *fs);	/*!< tell current position */
-	/*! Read the next frame from the filestream (if available) and report
-	 * when to get next frame (in samples)
-	 */
-	struct ast_frame * (*read)(struct ast_filestream *, int *whennext);
-	/*! Do any closing actions, if any. The descriptor and structure are closed
-	 * and destroyed by the generic routines, so they must not be done here. */
-	void (*close)(struct ast_filestream *);
-	char * (*getcomment)(struct ast_filestream *);		/*!< Retrieve file comment */
-
-	AST_LIST_ENTRY(ast_format) list;			/*!< Link */
-
-	/*!
-	 * If the handler needs a buffer (for read, typically)
-	 * and/or a private descriptor, put here the
-	 * required size (in bytes) and the support routine will allocate them
-	 * for you, pointed by s->buf and s->private, respectively.
-	 * When allocating a buffer, remember to leave AST_FRIENDLY_OFFSET
-	 * spare bytes at the bginning.
-	 */
-	int buf_size;			/*!< size of frame buffer, if any, aligned to 8 bytes. */
-	int desc_size;			/*!< size of private descriptor, if any */
-
-	struct ast_module *module;
-};
-
-/*!
- * This structure is allocated by file.c in one chunk,
- * together with buf_size and desc_size bytes of memory
- * to be used for private purposes (e.g. buffers etc.)
- */
-struct ast_filestream {
-	/*! Everybody reserves a block of AST_RESERVED_POINTERS pointers for us */
-	struct ast_format *fmt;	/* need to write to the lock and usecnt */
-	int flags;
-	mode_t mode;
-	char *filename;
-	char *realfilename;
-	/*! Video file stream */
-	struct ast_filestream *vfs;
-	/*! Transparently translate from another format -- just once */
-	struct ast_trans_pvt *trans;
-	struct ast_tranlator_pvt *tr;
-	int lastwriteformat;
-	int lasttimeout;
-	struct ast_channel *owner;
-	FILE *f;
-	struct ast_frame fr;	/*!< frame produced by read, typically */
-	char *buf;		/*!< buffer pointed to by ast_frame; */
-	void *private;	/*!< pointer to private buffer */
-	const char *orig_chan_name;
-};
-
 #define SEEK_FORCECUR	10
 	
-/*! 
- * \brief Register a new file format capability.
- * Adds a format to Asterisk's format abilities.
- * \retval 0 on success
- * \retval -1 on failure
- */
-int __ast_format_register(const struct ast_format *f, struct ast_module *mod);
-#define ast_format_register(f) __ast_format_register(f, ast_module_info->self)
-
-/*! 
- * \brief Unregisters a file format 
- * \param name the name of the format you wish to unregister
- * Unregisters a format based on the name of the format.
- * \retval 0 on success
- * \retval -1 on failure to unregister
- */
-int ast_format_unregister(const char *name);
-
 /*! 
  * \brief Streams a file 
  * \param c channel to stream the file to
@@ -422,16 +306,6 @@
  */ 
 struct ast_frame *ast_readframe(struct ast_filestream *s);
 
-/*! 
- * \brief Initialize file stuff 
- * Initializes all the various file stuff.  Basically just registers the cli stuff
- * \return 0 all the time
- */
-int ast_file_init(void);
-
-
-#define AST_RESERVED_POINTERS 20
-
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: trunk/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/frame.h?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/include/asterisk/frame.h (original)
+++ trunk/include/asterisk/frame.h Wed Nov 21 18:53:49 2007
@@ -29,7 +29,6 @@
 extern "C" {
 #endif
 
-#include <sys/types.h>
 #include <sys/time.h>
 
 #include "asterisk/endian.h"

Modified: trunk/main/file.c
URL: http://svn.digium.com/view/asterisk/trunk/main/file.c?view=diff&rev=89515&r1=89514&r2=89515
==============================================================================
--- trunk/main/file.c (original)
+++ trunk/main/file.c Wed Nov 21 18:53:49 2007
@@ -31,9 +31,9 @@
 #include <dirent.h>
 #include <sys/stat.h>
 
+#include "asterisk/_private.h"	/* declare ast_file_init() */
 #include "asterisk/paths.h"	/* use ast_config_AST_DATA_DIR */
-#include "asterisk/frame.h"
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/cli.h"
 #include "asterisk/channel.h"
 #include "asterisk/sched.h"




More information about the asterisk-commits mailing list