Asterisk - The Open Source Telephony Project  21.4.1
smoother.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  * \brief Asterisk internal frame definitions.
21  * \arg For an explanation of frames, see \ref Def_Frame
22  * \arg Frames are send of Asterisk channels, see \ref Def_Channel
23  */
24 
25 #ifndef _ASTERISK_SMOOTHER_H
26 #define _ASTERISK_SMOOTHER_H
27 
28 #if defined(__cplusplus) || defined(c_plusplus)
29 extern "C" {
30 #endif
31 
32 #include "asterisk/endian.h"
33 
34 #define AST_SMOOTHER_FLAG_G729 (1 << 0)
35 #define AST_SMOOTHER_FLAG_BE (1 << 1)
36 #define AST_SMOOTHER_FLAG_FORCED (1 << 2)
37 
38 /*! \name AST_Smoother
39  *
40  * @{
41  */
42 /*! \page ast_smooth The AST Frame Smoother
43 The ast_smoother interface was designed specifically
44 to take frames of variant sizes and produce frames of a single expected
45 size, precisely what you want to do.
46 
47 The basic interface is:
48 
49 - Initialize with ast_smoother_new()
50 - Queue input frames with ast_smoother_feed()
51 - Get output frames with ast_smoother_read()
52 - when you're done, free the structure with ast_smoother_free()
53 - Also see ast_smoother_test_flag(), ast_smoother_set_flags(), ast_smoother_get_flags(), ast_smoother_reset()
54 */
55 struct ast_smoother;
56 
57 struct ast_frame;
58 
59 struct ast_smoother *ast_smoother_new(int bytes);
60 void ast_smoother_set_flags(struct ast_smoother *smoother, int flags);
61 int ast_smoother_get_flags(struct ast_smoother *smoother);
62 int ast_smoother_test_flag(struct ast_smoother *s, int flag);
63 void ast_smoother_free(struct ast_smoother *s);
64 void ast_smoother_reset(struct ast_smoother *s, int bytes);
65 
66 /*!
67  * \brief Reconfigure an existing smoother to output a different number of bytes per frame
68  * \param s the smoother to reconfigure
69  * \param bytes the desired number of bytes per output frame
70  */
71 void ast_smoother_reconfigure(struct ast_smoother *s, int bytes);
72 
73 int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap);
74 struct ast_frame *ast_smoother_read(struct ast_smoother *s);
75 #define ast_smoother_feed(s,f) __ast_smoother_feed(s, f, 0)
76 #if __BYTE_ORDER == __LITTLE_ENDIAN
77 #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 1)
78 #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 0)
79 #else
80 #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 0)
81 #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 1)
82 #endif
83 
84 /*! @} */
85 
86 #if defined(__cplusplus) || defined(c_plusplus)
87 }
88 #endif
89 
90 #endif /* _ASTERISK_SMOOTHER_H */
void ast_smoother_reconfigure(struct ast_smoother *s, int bytes)
Reconfigure an existing smoother to output a different number of bytes per frame. ...
Definition: smoother.c:86
Asterisk architecture endianess compatibility definitions.
Data structure associated with a single frame of data.