2 * Asterisk -- A telephony toolkit for Linux.
4 * Translate via the use of pseudo channels
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_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)(void);
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 /* Register a Codec translator */
48 extern int ast_register_translator(struct ast_translator *t);
50 extern int ast_unregister_translator(struct ast_translator *t);
51 /* Given a list of sources, and a designed destination format, which should
52 I choose? Returns 0 on success, -1 if no path could be found. Modifies
53 dests and srcs in place */
54 extern int ast_translator_best_choice(int *dsts, int *srcs);
56 /* Build a path (possibly NULL) from source to dest */
57 extern struct ast_trans_pvt *ast_translator_build_path(int dest, int source);
58 extern void ast_translator_free_path(struct ast_trans_pvt *tr);
60 /* Apply an input frame into the translator and receive zero or one output frames. Consume
61 determines whether the original frame should be freed */
62 extern struct ast_frame *ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume);
65 #if defined(__cplusplus) || defined(c_plusplus)