Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

translate.h

Go to the documentation of this file.
00001 /* 00002 * Asterisk -- A telephony toolkit for Linux. 00003 * 00004 * Translate via the use of pseudo channels 00005 * 00006 * Copyright (C) 1999, Mark Spencer 00007 * 00008 * Mark Spencer <markster@linux-support.net> 00009 * 00010 * This program is free software, distributed under the terms of 00011 * the GNU General Public License 00012 */ 00013 00014 #ifndef _ASTERISK_TRANSLATE_H 00015 #define _ASTERISK_TRANSLATE_H 00016 00017 #define MAX_FORMAT 32 00018 00019 #if defined(__cplusplus) || defined(c_plusplus) 00020 extern "C" { 00021 #endif 00022 00023 #include <asterisk/frame.h> 00024 00025 /* Declared by individual translators */ 00026 struct ast_translator_pvt; 00027 00028 //! data structure associated with a translator 00029 struct ast_translator { 00030 /*! Name of translator */ 00031 char name[80]; 00032 /*! Source format */ 00033 int srcfmt; 00034 /*! Destination format */ 00035 int dstfmt; 00036 /*! Private data associated with the translator */ 00037 struct ast_translator_pvt *(*new)(void); 00038 /*! Input frame callback */ 00039 int (*framein)(struct ast_translator_pvt *pvt, struct ast_frame *in); 00040 /*! Output frame callback */ 00041 struct ast_frame * (*frameout)(struct ast_translator_pvt *pvt); 00042 /*! Destroy translator callback */ 00043 void (*destroy)(struct ast_translator_pvt *pvt); 00044 /* For performance measurements */ 00045 /*! Generate an example frame */ 00046 struct ast_frame * (*sample)(void); 00047 /*! Cost in milliseconds for encoding/decoding 1 second of sound */ 00048 int cost; 00049 /*! For linking, not to be modified by the translator */ 00050 struct ast_translator *next; 00051 }; 00052 00053 struct ast_trans_pvt; 00054 00055 //! Register a translator 00056 /*! 00057 * \param t populated ast_translator structure 00058 * This registers a codec translator with asterisk 00059 * Returns 0 on success, -1 on failure 00060 */ 00061 extern int ast_register_translator(struct ast_translator *t); 00062 00063 //! Unregister a translator 00064 /*! 00065 * \param t translator to unregister 00066 * Unregisters the given tranlator 00067 * Returns 0 on success, -1 on failure 00068 */ 00069 extern int ast_unregister_translator(struct ast_translator *t); 00070 00071 //! Chooses the best translation path 00072 /*! 00073 * Given a list of sources, and a designed destination format, which should 00074 I choose? Returns 0 on success, -1 if no path could be found. Modifies 00075 dests and srcs in place 00076 */ 00077 extern int ast_translator_best_choice(int *dsts, int *srcs); 00078 00079 //!Builds a translator path 00080 /*! 00081 * \param dest destination format 00082 * \param source source format 00083 * Build a path (possibly NULL) from source to dest 00084 * Returns ast_trans_pvt on success, NULL on failure 00085 * */ 00086 extern struct ast_trans_pvt *ast_translator_build_path(int dest, int source); 00087 00088 //! Frees a translator path 00089 /*! 00090 * \param tr translator path to get rid of 00091 * Frees the given translator path structure 00092 */ 00093 extern void ast_translator_free_path(struct ast_trans_pvt *tr); 00094 00095 //! translates one or more frames 00096 /*! 00097 * \param tr translator structure to use for translation 00098 * \param f frame to translate 00099 * \param consume Whether or not to free the original frame 00100 * Apply an input frame into the translator and receive zero or one output frames. Consume 00101 * determines whether the original frame should be freed 00102 * Returns an ast_frame of the new translation format on success, NULL on failure 00103 */ 00104 extern struct ast_frame *ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume); 00105 00106 00107 #if defined(__cplusplus) || defined(c_plusplus) 00108 } 00109 #endif 00110 00111 #endif

Generated on Sat Jun 12 16:40:59 2004 for Asterisk by doxygen 1.3.7