Asterisk - The Open Source Telephony Project  18.5.0
include/asterisk/format_compatibility.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2014, Digium, Inc.
5  *
6  * Joshua Colp <[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 /*!
20  * \file
21  * \brief Media Format Bitfield Compatibility API
22  *
23  * \author Joshua Colp <[email protected]>
24  */
25 
26 #ifndef _AST_FORMAT_COMPATIBILITY_H_
27 #define _AST_FORMAT_COMPATIBILITY_H_
28 
29 struct ast_format;
30 struct ast_codec;
31 
32 /*
33  * Legacy bitfields for specific formats
34  */
35 
36 /*! G.723.1 compression */
37 #define AST_FORMAT_G723 (1ULL << 0)
38 /*! GSM compression */
39 #define AST_FORMAT_GSM (1ULL << 1)
40 /*! Raw mu-law data (G.711) */
41 #define AST_FORMAT_ULAW (1ULL << 2)
42 /*! Raw A-law data (G.711) */
43 #define AST_FORMAT_ALAW (1ULL << 3)
44 /*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
45 #define AST_FORMAT_G726_AAL2 (1ULL << 4)
46 /*! ADPCM (IMA) */
47 #define AST_FORMAT_ADPCM (1ULL << 5)
48 /*! Raw 16-bit Signed Linear (8000 Hz) PCM */
49 #define AST_FORMAT_SLIN (1ULL << 6)
50 /*! LPC10, 180 samples/frame */
51 #define AST_FORMAT_LPC10 (1ULL << 7)
52 /*! G.729A audio */
53 #define AST_FORMAT_G729 (1ULL << 8)
54 /*! SpeeX Free Compression */
55 #define AST_FORMAT_SPEEX (1ULL << 9)
56 /*! iLBC Free Compression */
57 #define AST_FORMAT_ILBC (1ULL << 10)
58 /*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
59 #define AST_FORMAT_G726 (1ULL << 11)
60 /*! G.722 */
61 #define AST_FORMAT_G722 (1ULL << 12)
62 /*! G.722.1 (also known as Siren7, 32kbps assumed) */
63 #define AST_FORMAT_SIREN7 (1ULL << 13)
64 /*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
65 #define AST_FORMAT_SIREN14 (1ULL << 14)
66 /*! Raw 16-bit Signed Linear (16000 Hz) PCM */
67 #define AST_FORMAT_SLIN16 (1ULL << 15)
68 /*! G.719 (64 kbps assumed) */
69 #define AST_FORMAT_G719 (1ULL << 32)
70 /*! SpeeX Wideband (16kHz) Free Compression */
71 #define AST_FORMAT_SPEEX16 (1ULL << 33)
72 /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */
73 #define AST_FORMAT_OPUS (1ULL << 34)
74 /*! Raw testing-law data (G.711) */
75 #define AST_FORMAT_TESTLAW (1ULL << 47)
76 /*! H.261 Video */
77 #define AST_FORMAT_H261 (1ULL << 18)
78 /*! H.263 Video */
79 #define AST_FORMAT_H263 (1ULL << 19)
80 /*! H.263+ Video */
81 #define AST_FORMAT_H263P (1ULL << 20)
82 /*! H.264 Video */
83 #define AST_FORMAT_H264 (1ULL << 21)
84 /*! MPEG4 Video */
85 #define AST_FORMAT_MP4 (1ULL << 22)
86 /*! VP8 Video */
87 #define AST_FORMAT_VP8 (1ULL << 23)
88 /*! JPEG Images */
89 #define AST_FORMAT_JPEG (1ULL << 16)
90 /*! PNG Images */
91 #define AST_FORMAT_PNG (1ULL << 17)
92 /*! T.140 RED Text format RFC 4103 */
93 #define AST_FORMAT_T140_RED (1ULL << 26)
94 /*! T.140 Text format - ITU T.140, RFC 4103 */
95 #define AST_FORMAT_T140 (1ULL << 27)
96 
97 /*!
98  * \brief Convert a format structure to its respective bitfield
99  *
100  * \param format The media format
101  *
102  * \retval non-zero success
103  * \retval zero format not supported
104  */
106 
107 /*!
108  * \brief Convert a codec structure to its respective bitfield
109  *
110  * \param codec The media codec
111  *
112  * \retval non-zero success
113  * \retval zero format not supported
114  */
115 uint64_t ast_format_compatibility_codec2bitfield(const struct ast_codec *codec);
116 
117 /*!
118  * \brief Convert a bitfield to its respective format structure
119  *
120  * \param bitfield The bitfield for the media format
121  *
122  * \retval non-NULL success
123  * \retval NULL failure (The format bitfield value is not supported)
124  *
125  * \note The reference count of the returned format is NOT incremented
126  */
127 struct ast_format *ast_format_compatibility_bitfield2format(uint64_t bitfield);
128 
129 #endif /* _AST_FORMAT_COMPATIBILITY_H */
uint64_t ast_format_compatibility_codec2bitfield(const struct ast_codec *codec)
Convert a codec structure to its respective bitfield.
struct ast_format * ast_format_compatibility_bitfield2format(uint64_t bitfield)
Convert a bitfield to its respective format structure.
uint64_t ast_format_compatibility_format2bitfield(const struct ast_format *format)
Convert a format structure to its respective bitfield.
Definition of a media format.
Definition: format.c:43
static snd_pcm_format_t format
Definition: chan_alsa.c:102
Represents a media codec within Asterisk.
Definition: codec.h:42