1 /*!
2  * \file        sccp_codec.h
3  * \brief       SCCP Codec Header
4  * \author      Diederik de Groot < ddegroot@users.sourceforge.net >
5  * \note        This program is free software and may be modified and distributed under the terms of the GNU Public License.
6  *              See the LICENSE file at the top of the source tree.
7  */
8 #pragma once
9 #include "define.h"
10 
11 #define SKINNY_MAX_CAPABILITIES       18 /*!< max capabilities allowed in Cap response message */
12 #define SKINNY_MAX_VIDEO_CAPABILITIES 10
13 #define SKINNY_MAX_DATA_CAPABILITIES  5
14 
15 __BEGIN_C_EXTERN__
16 
17 /*!
18  * \brief SKINNY Codecs (ENUM)
19  */
20 typedef enum
21 {
22 	/* *INDENT-OFF* */
23 	SKINNY_CODEC_NONE                = 0x0000,
24 	SKINNY_CODEC_NONSTANDARD         = 0x0001,
25 	SKINNY_CODEC_G711_ALAW_64K       = 0x0002,
26 	SKINNY_CODEC_G711_ALAW_56K       = 0x0003,
27 	SKINNY_CODEC_G711_ULAW_64K       = 0x0004,
28 	SKINNY_CODEC_G711_ULAW_56K       = 0x0005,
29 	SKINNY_CODEC_G722_64K            = 0x0006,
30 	SKINNY_CODEC_G722_56K            = 0x0007,
31 	SKINNY_CODEC_G722_48K            = 0x0008,
32 	SKINNY_CODEC_G723_1              = 0x0009,
33 	SKINNY_CODEC_G728                = 0x000A,
34 	SKINNY_CODEC_G729                = 0x000B,
35 	SKINNY_CODEC_G729_A              = 0x000C,
36 	SKINNY_CODEC_IS11172             = 0x000D,
37 	SKINNY_CODEC_IS13818             = 0x000E,
38 	SKINNY_CODEC_G729_B              = 0x000F,
39 	SKINNY_CODEC_G729_AB             = 0x0010,
40 	SKINNY_CODEC_GSM_FULLRATE        = 0x0012,
41 	SKINNY_CODEC_GSM_HALFRATE        = 0x0013,
42 	SKINNY_CODEC_GSM_ENH_FULLRATE    = 0x0014,
43 	SKINNY_CODEC_WIDEBAND_256K       = 0x0019,
44 	SKINNY_CODEC_DATA_64K            = 0x0020,
45 	SKINNY_CODEC_DATA_56K            = 0x0021,
46 	SKINNY_CODEC_G722_1_32K          = 0x0028,
47 	SKINNY_CODEC_G722_1_24K          = 0x0029,
48 	SKINNY_CODEC_AAC                 = 0x002A,
49 	SKINNY_CODEC_MP4A_LATM_128       = 0x002B,                                        // AAC-LD
50 	SKINNY_CODEC_MP4A_LATM_64        = 0x002C,
51 	SKINNY_CODEC_MP4A_LATM_56        = 0x002D,
52 	SKINNY_CODEC_MP4A_LATM_48        = 0x002E,
53 	SKINNY_CODEC_MP4A_LATM_32        = 0x002F,
54 	SKINNY_CODEC_MP4A_LATM_24        = 0x0030,
55 	SKINNY_CODEC_MP4A_LATM_NA        = 0x0031,
56 	SKINNY_CODEC_GSM                 = 0x0050,
57 	SKINNY_CODEC_ACTIVEVOICE         = 0x0051,
58 	SKINNY_CODEC_G726_32K            = 0x0052,
59 	SKINNY_CODEC_G726_24K            = 0x0053,
60 	SKINNY_CODEC_G726_16K            = 0x0054,
61 	SKINNY_CODEC_G729_ANNEX_B        = 0x0055,
62 	SKINNY_CODEC_G729_B_LOW          = 0x0056,                                        // ILBC
63 	SKINNY_CODEC_ISAC                = 0x0059,
64 	SKINNY_CODEC_OPUS                = 0x005a,                                        // New
65 	SKINNY_CODEC_AMR                 = 0x0061,
66 	SKINNY_CODEC_AMR_WB              = 0x0062,
67 	SKINNY_CODEC_H261                = 0x0064,
68 	SKINNY_CODEC_H263                = 0x0065,
69 	SKINNY_CODEC_H263P               = 0x0066,
70 	SKINNY_CODEC_H264                = 0x0067,
71 	SKINNY_CODEC_H264_SVC            = 0x0068,
72 	SKINNY_CODEC_T120                = 0x0069,
73 	SKINNY_CODEC_H224                = 0x006A,
74 	SKINNY_CODEC_T38FAX              = 0x006B,
75 	SKINNY_CODEC_TOTE                = 0x006C,
76 	SKINNY_CODEC_H265                = 0x006D,
77 	SKINNY_CODEC_H264_UC             = 0x006E,
78 	SKINNY_CODEC_XV150_MR_711U       = 0x006F,
79 	SKINNY_CODEC_NSE_VBD_711U        = 0x0070,
80 	SKINNY_CODEC_XV150_MR_729A       = 0x0071,
81 	SKINNY_CODEC_NSE_VBD_729A        = 0x0072,
82 	SKINNY_CODEC_H264_FEC            = 0x0073,
83 	SKINNY_CODEC_CLEAR_CHAN          = 0x0078,
84 	SKINNY_CODEC_UNIVERSAL_XCODER    = 0x00DE,
85 	SKINNY_CODEC_DTMF_OOB_RFC2833    = 0x0101,                                        // OUTOFBAND / DTMF 0x101 / RFC2833_DYNAMIC_PAYLOAD
86 	SKINNY_CODEC_DTMF_PASSTHROUGH    = 0x0102,
87 	SKINNY_CODEC_DTMF_DYNAMIC        = 0x0103,
88 	SKINNY_CODEC_DTMF_OOB            = 0x0104,                                        // OUTOFBAND
89 	SKINNY_CODEC_DTMF_IB_RFC2833     = 0x0105,                                        // INBAND
90 	SKINNY_CODEC_CFB_TONES           = 0x0106,
91 	SKINNY_CODEC_DTMF_NOAUDIO        = 0x012B,
92 	SKINNY_CODEC_V150_LC_MODEM_RELAY = 0x012C,
93 	SKINNY_CODEC_V150_LC_SPRT        = 0x012D,
94 	SKINNY_CODEC_V150_LC_SSE         = 0x012E,
95 	/* *INDENT-ON* */
96 } skinny_codec_t;
97 
98 /*!
99  * \brief SKINNY Codec Types (ENUM)
100  */
101 typedef enum
102 {
103 	/* *INDENT-OFF* */
104 	SKINNY_CODEC_TYPE_UNKNOWN = 0,
105 	SKINNY_CODEC_TYPE_AUDIO   = 1,
106 	SKINNY_CODEC_TYPE_VIDEO   = 2,
107 	SKINNY_CODEC_TYPE_TEXT    = 3,
108 	SKINNY_CODEC_TYPE_DATA    = 4,
109 	SKINNY_CODEC_TYPE_MIXED   = 5,
110 	/* *INDENT-ON* */
111 } skinny_payload_type_t;
112 
113 /*!
114  * \brief SKINNY Codec Structure
115  */
116 struct skinny_codec {
117 	skinny_codec_t        codec;
118 	skinny_payload_type_t codec_type;
119 	const char * const    key;                                                // used in sccp.conf
120 	const char * const    name;                                               // used in sccp.conf
121 	const char * const    text;                                               // used to display the codec name
122 	const char *          mimesubtype;                                        // rfc mime sub-type e.g. L16
123 	uint32_t              sample_rate;
124 	uint32_t              sound_quality;
125 	int32_t               rtp_payload_type;
126 };
127 
128 typedef struct {
129 	skinny_codec_t audio[SKINNY_MAX_CAPABILITIES]; /*!< SCCP Audio Codec Preferences */
130 	skinny_codec_t video[SKINNY_MAX_CAPABILITIES]; /*!< SCCP Video Codec Preferences */
131 	boolean_t      audio_inherited;                /*!< (Temp) If audio codecs were inherited from global */
132 	boolean_t      video_inherited;                /*!< (Temp) If video codecs were inherited from global */
133 } skinny_capabilities_t;
134 
135 extern const struct skinny_codec        skinny_codecs[];
136 SCCP_API uint8_t __CONST__ SCCP_CALL    sccp_codec_getArrayLen(void);
137 SCCP_INLINE const char * SCCP_CALL      codec2str(skinny_codec_t value);
138 SCCP_INLINE const char * SCCP_CALL      codec2name(skinny_codec_t value);
139 SCCP_INLINE const skinny_payload_type_t codec2type(skinny_codec_t value);
140 SCCP_INLINE const int32_t               codec2rtp_payload_type(skinny_codec_t value);
141 SCCP_API char * SCCP_CALL               sccp_codec_multiple2str(char * buf, size_t size, const skinny_codec_t * codecs, const uint clength);
142 SCCP_API int SCCP_CALL                  sccp_codec_parseAllowDisallow(skinny_codec_t * skinny_codec_prefs, const char * list, int allowing);
143 SCCP_API int SCCP_CALL                  sccp_get_codecs_bytype(const skinny_codec_t * in_codecs, skinny_codec_t * out_codecs, skinny_payload_type_t type);
144 SCCP_API boolean_t __PURE__ SCCP_CALL   sccp_codec_isCompatible(skinny_codec_t codec, const skinny_codec_t capabilities[], uint8_t length);
145 SCCP_API int SCCP_CALL            sccp_codec_getReducedSet(const skinny_codec_t base[SKINNY_MAX_CAPABILITIES], const skinny_codec_t reduceByCodecs[SKINNY_MAX_CAPABILITIES], skinny_codec_t result[SKINNY_MAX_CAPABILITIES]);
146 SCCP_API void SCCP_CALL           sccp_codec_reduceSet(skinny_codec_t base[SKINNY_MAX_CAPABILITIES], const skinny_codec_t reduceByCodecs[SKINNY_MAX_CAPABILITIES]);
147 SCCP_API void SCCP_CALL           sccp_codec_combineSets(skinny_codec_t base[SKINNY_MAX_CAPABILITIES], const skinny_codec_t addCodecs[SKINNY_MAX_CAPABILITIES]);
148 SCCP_API skinny_codec_t SCCP_CALL sccp_codec_findBestJoint(constChannelPtr c, const skinny_codec_t ourPreferences[], const skinny_codec_t remotePeerPreferences[], boolean_t fallback);
149 
150 __END_C_EXTERN__
151 // kate: indent-width 8; replace-tabs off; indent-mode cstyle; auto-insert-doxygen on; line-numbers on; tab-indents on; keep-extra-spaces off; auto-brackets off;
152