Asterisk - The Open Source Telephony Project  18.5.0
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 <[email protected]>
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 /*! \page ast_smooth The AST Frame Smoother
42 The ast_smoother interface was designed specifically
43 to take frames of variant sizes and produce frames of a single expected
44 size, precisely what you want to do.
45 
46 The basic interface is:
47 
48 - Initialize with ast_smoother_new()
49 - Queue input frames with ast_smoother_feed()
50 - Get output frames with ast_smoother_read()
51 - when you're done, free the structure with ast_smoother_free()
52 - Also see ast_smoother_test_flag(), ast_smoother_set_flags(), ast_smoother_get_flags(), ast_smoother_reset()
53 */
54 struct ast_smoother;
55 
56 struct ast_frame;
57 
58 struct ast_smoother *ast_smoother_new(int bytes);
59 void ast_smoother_set_flags(struct ast_smoother *smoother, int flags);
60 int ast_smoother_get_flags(struct ast_smoother *smoother);
61 int ast_smoother_test_flag(struct ast_smoother *s, int flag);
62 void ast_smoother_free(struct ast_smoother *s);
63 void ast_smoother_reset(struct ast_smoother *s, int bytes);
64 
65 /*!
66  * \brief Reconfigure an existing smoother to output a different number of bytes per frame
67  * \param s the smoother to reconfigure
68  * \param bytes the desired number of bytes per output frame
69  * \return nothing
70  *
71  */
72 void ast_smoother_reconfigure(struct ast_smoother *s, int bytes);
73 
74 int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap);
75 struct ast_frame *ast_smoother_read(struct ast_smoother *s);
76 #define ast_smoother_feed(s,f) __ast_smoother_feed(s, f, 0)
77 #if __BYTE_ORDER == __LITTLE_ENDIAN
78 #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 1)
79 #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 0)
80 #else
81 #define ast_smoother_feed_be(s,f) __ast_smoother_feed(s, f, 0)
82 #define ast_smoother_feed_le(s,f) __ast_smoother_feed(s, f, 1)
83 #endif
84 /*@} Doxygen marker */
85 
86 #if defined(__cplusplus) || defined(c_plusplus)
87 }
88 #endif
89 
90 #endif /* _ASTERISK_SMOOTHER_H */
struct ast_smoother * ast_smoother_new(int bytes)
Definition: smoother.c:108
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
int ast_smoother_get_flags(struct ast_smoother *smoother)
Definition: smoother.c:118
struct ast_frame f
Definition: smoother.c:49
void ast_smoother_free(struct ast_smoother *s)
Definition: smoother.c:220
Asterisk architecture endianess compatibility definitions.
void ast_smoother_reset(struct ast_smoother *s, int bytes)
Definition: smoother.c:79
long int flag
Definition: f2c.h:83
int ast_smoother_test_flag(struct ast_smoother *s, int flag)
Definition: smoother.c:128
void ast_smoother_set_flags(struct ast_smoother *smoother, int flags)
Definition: smoother.c:123
struct ast_frame * ast_smoother_read(struct ast_smoother *s)
Definition: smoother.c:169
Data structure associated with a single frame of data.
int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap)
Definition: smoother.c:133