diff --git a/formats/format_g723.c b/formats/format_g723.c
index b9be03039e9c35f2db405ea911e338d38fb17747..6e57b4fa8561af76e23492c84d174865e06cc0e9 100644
--- a/formats/format_g723.c
+++ b/formats/format_g723.c
@@ -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
diff --git a/formats/format_g726.c b/formats/format_g726.c
index 35b5e9ced4f2ff600ea163371d133ab12fa0a2ff..ecde39e769863243c21cd3da50e9e583e0faaeb4 100644
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -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"
 
diff --git a/formats/format_g729.c b/formats/format_g729.c
index 143b2b26f3c501498c3933c76d36f33f12e50084..8df463d81a3f38e27e85288592cfc1755ffd00bf 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -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"
 
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index bab20e217d5d64cd5af656a7b9dceb7329ccb8dd..d43844e64651f444af7dcec65d762f51f9431876 100644
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -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"
 
diff --git a/formats/format_h263.c b/formats/format_h263.c
index 3d1766f7e7c7245ecf7605e69b6d5adcf94e3a47..92b794b1655ce89e5bfaaac369fbeca27666af70 100644
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -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"
 
diff --git a/formats/format_h264.c b/formats/format_h264.c
index ceafadf142058e9f79a566abef46c4beeeb1de71..519a90636b494e6247f5ce93193f9b43f97e8c13 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -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"
 
diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c
index b55e16c29db42ba18b7cb640baf49b1004951c03..aaddc6c383dac4165b81704b6a8bf06e21c410ac 100644
--- a/formats/format_ilbc.c
+++ b/formats/format_ilbc.c
@@ -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"
 
diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c
index 9bbb9172462414b5faf3c57cd67d0afc0f25071a..50bd549b79e92c09adb2dd746e80f9993e0bfc64 100644
--- a/formats/format_jpeg.c
+++ b/formats/format_jpeg.c
@@ -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"
diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c
index 89d31e35cdbf8d64e06a01a5999b4bd47d5e5950..8134d98ef73cdc9ff45411b61145809eb0bd5c02 100644
--- a/formats/format_ogg_vorbis.c
+++ b/formats/format_ogg_vorbis.c
@@ -42,7 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <fcntl.h>
 #endif
 
-#include "asterisk/file.h"
+#include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 
 /*
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 0ec158ef6befc318ea821f8af9be672fdbcf6fd1..ded3d6b897ca60347ee2d4709d99c6df5827a971 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -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"
diff --git a/formats/format_sln.c b/formats/format_sln.c
index 18a4dea9635fc9bf7f8d4b12d23a1378ab7f263c..51f796271ee3a9b018b986ee908abe9506ef17ca 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -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"
 
diff --git a/formats/format_vox.c b/formats/format_vox.c
index 601df8df421fb4587383f26a0520c2341cc0d694..f22b4881a850a656291a403607f3311469f58ca1 100644
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -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"
 
diff --git a/formats/format_wav.c b/formats/format_wav.c
index 46ba4c76a9735ac77132e27357820e3baf06e065..238c1128801c879f85d679f2b5d4c3c3d301cd6c 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -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"
 
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index 7b7a0e37f2f6ed8351e203f62eeb84b12fbb2fc2..627e841300073e1900b5ca54f712357d9e0bf9b7 100644
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -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"
 
diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h
index ad4ca721400c42cbab4ba1422ea576eccec98b2d..a936bea9e98515c51175bb1a6a10bed3a7aa7b50 100644
--- a/include/asterisk/_private.h
+++ b/include/asterisk/_private.h
@@ -22,7 +22,8 @@ int dnsmgr_reload(void);		/*!< Provided by dnsmgr.c */
 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.
diff --git a/include/asterisk/file.h b/include/asterisk/file.h
index 994b7b94355268191ed57b260a8bdcbe10dd15e3..1fc496fdbee6f70d931ef76e7b0276b8546d7e9f 100644
--- a/include/asterisk/file.h
+++ b/include/asterisk/file.h
@@ -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 @@ off_t ast_tellstream(struct ast_filestream *fs);
  */ 
 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
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 07072d1351b6ef6f2ca4d042e4e31f563f0a8d87..cc32d701fa35f7987338b627868a5fef94962fe0 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -29,7 +29,6 @@
 extern "C" {
 #endif
 
-#include <sys/types.h>
 #include <sys/time.h>
 
 #include "asterisk/endian.h"
diff --git a/main/file.c b/main/file.c
index 145932e6cb7cd8f4a91a2b711e065325f2dbcefa..35a5d28616f38e8092a2ad88b1df58cd12f2b98b 100644
--- a/main/file.c
+++ b/main/file.c
@@ -31,9 +31,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #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"