2 * Asterisk -- A telephony toolkit for Linux.
4 * Translate via the use of pseudo channels
6 * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC
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_TRANSLATE_H
15 #define _ASTERISK_TRANSLATE_H
19 #if defined(__cplusplus) || defined(c_plusplus)
23 #include <asterisk/frame.h>
25 /* Declared by individual translators */
26 struct ast_translator_pvt;
28 struct ast_translator {
32 struct ast_translator_pvt *(*new)();
33 int (*framein)(struct ast_translator_pvt *pvt, struct ast_frame *in);
34 struct ast_frame * (*frameout)(struct ast_translator_pvt *pvt);
35 void (*destroy)(struct ast_translator_pvt *pvt);
36 /* For performance measurements */
37 /* Generate an example frame */
38 struct ast_frame * (*sample)(void);
39 /* Cost in milliseconds for encoding/decoding 1 second of sound */
41 /* For linking, not to be modified by the translator */
42 struct ast_translator *next;
47 /* Create a pseudo channel which translates from a real channel into our
48 desired format. When a translator is installed, you should not use the
49 sub channel until you have stopped the translator. For all other
50 actions, use the real channel. Generally, translators should be created
51 when needed and immediately destroyed when no longer needed. */
54 #define AST_DIRECTION_OUT 1
55 #define AST_DIRECTION_IN 2
56 #define AST_DIRECTION_BOTH 3
58 extern struct ast_channel *ast_translator_create(struct ast_channel *real, int format, int direction);
59 extern void ast_translator_destroy(struct ast_channel *tran);
60 /* Register a Codec translator */
61 extern int ast_register_translator(struct ast_translator *t);
63 extern int ast_unregister_translator(struct ast_translator *t);
64 /* Given a list of sources, and a designed destination format, which should
66 extern int ast_translator_best_choice(int dst, int srcs);
67 extern struct ast_trans_pvt *ast_translator_build_path(int source, int dest);
68 extern void ast_translator_free_path(struct ast_trans_pvt *tr);
69 extern struct ast_frame_chain *ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f);
72 #if defined(__cplusplus) || defined(c_plusplus)