File: 2012_amr_codec.patch

package info (click to toggle)
asterisk 1%3A22.6.0~dfsg%2B~cs6.15.60671435-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 105,828 kB
  • sloc: ansic: 1,005,009; cpp: 81,042; cs: 21,705; python: 16,883; xml: 15,387; sh: 14,677; makefile: 5,579; objc: 3,912; perl: 3,046; javascript: 3,018; java: 2,522; sql: 2,227; yacc: 2,160; tcl: 113; php: 62; asm: 56
file content (277 lines) | stat: -rw-r--r-- 7,373 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
Description: integrate amr module with asterisk
 Original patch adapted by Jonas Smedegaard to fit Debian packaging,
 and to remove original patch file to help detect later upstream changes.
Author: Alexander Traud <pabstraud@compuserve.com>
Author: Jonas Smedegaard <dr@jones.dk>
Source: https://github.com/traud/asterisk-amr/blob/master/codec_amr.patch
Forwarded: not-needed
Last-Update: 2023-08-27
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/include/asterisk/format_cache.h
+++ b/include/asterisk/format_cache.h
@@ -247,6 +247,16 @@
 extern struct ast_format *ast_format_silk24;
 
 /*!
+ * \brief Built-in cached AMR format.
+ */
+extern struct ast_format *ast_format_amr;
+
+/*!
+ * \brief Built-in cached AMR-WB format.
+ */
+extern struct ast_format *ast_format_amrwb;
+
+/*!
  * \brief Initialize format cache support within the core.
  *
  * \retval 0 success
--- a/main/codec_builtin.c
+++ b/main/codec_builtin.c
@@ -925,6 +925,54 @@
 	.samples_count = silk_samples
 };
 
+static int amr_samples(struct ast_frame *frame)
+{
+	return 160;
+}
+
+static int amr_length(unsigned int samples)
+{
+	ast_log(LOG_NOTICE, "untested; please report failure or success: %u\n", samples); return samples / 8;
+}
+
+static struct ast_codec amr = {
+	.name = "amr",
+	.description = "AMR",
+	.type = AST_MEDIA_TYPE_AUDIO,
+	.sample_rate = 8000,
+	.minimum_ms = 20,
+	.maximum_ms = 20,
+	.default_ms = 20,
+	.minimum_bytes = 0, /* no smooth */
+	.samples_count = amr_samples,
+	.get_length = amr_length,
+	.smooth = 0,
+};
+
+static int amrwb_samples(struct ast_frame *frame)
+{
+	return 320;
+}
+
+static int amrwb_length(unsigned int samples)
+{
+	ast_log(LOG_NOTICE, "untested; please report failure or success: %u\n", samples); return samples / 16;
+}
+
+static struct ast_codec amrwb = {
+	.name = "amrwb",
+	.description = "AMR-WB",
+	.type = AST_MEDIA_TYPE_AUDIO,
+	.sample_rate = 16000,
+	.minimum_ms = 20,
+	.maximum_ms = 20,
+	.default_ms = 20,
+	.minimum_bytes = 0, /* no smooth */
+	.samples_count = amrwb_samples,
+	.get_length = amrwb_length,
+	.smooth = 0,
+};
+
 #define CODEC_REGISTER_AND_CACHE(codec) \
 	({ \
 		int __res_ ## __LINE__ = 0; \
@@ -957,6 +1005,9 @@
 {
 	int res = 0;
 
+	res |= CODEC_REGISTER_AND_CACHE(amr);
+	res |= CODEC_REGISTER_AND_CACHE(amrwb);
+
 	res |= CODEC_REGISTER_AND_CACHE(codec2);
 	res |= CODEC_REGISTER_AND_CACHE(g723);
 	res |= CODEC_REGISTER_AND_CACHE(ulaw);
--- a/main/format_cache.c
+++ b/main/format_cache.c
@@ -226,6 +226,16 @@
 struct ast_format *ast_format_codec2;
 
 /*!
+ * \brief Built-in cached AMR format.
+ */
+struct ast_format *ast_format_amr;
+
+/*!
+ * \brief Built-in cached AMR-WB format.
+ */
+struct ast_format *ast_format_amrwb;
+
+/*!
  * \brief Built-in cached t140 format.
  */
 struct ast_format *ast_format_t140;
@@ -313,6 +323,9 @@
 	ao2_cleanup(formats);
 	formats = NULL;
 
+	ao2_replace(ast_format_amr, NULL);
+	ao2_replace(ast_format_amrwb, NULL);
+
 	ao2_replace(ast_format_g723, NULL);
 	ao2_replace(ast_format_ulaw, NULL);
 	ao2_replace(ast_format_alaw, NULL);
@@ -432,6 +445,10 @@
 		ao2_replace(ast_format_g719, format);
 	} else if (!strcmp(name, "opus")) {
 		ao2_replace(ast_format_opus, format);
+	} else if (!strcmp(name, "amr")) {
+		ao2_replace(ast_format_amr, format);
+	} else if (!strcmp(name, "amrwb")) {
+		ao2_replace(ast_format_amrwb, format);
 	} else if (!strcmp(name, "jpeg")) {
 		ao2_replace(ast_format_jpeg, format);
 	} else if (!strcmp(name, "png")) {
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -3912,6 +3912,9 @@
 	set_next_mime_type(ast_format_vp8, 0,  "video", "VP8", 90000);
 	set_next_mime_type(ast_format_vp9, 0, "video", "VP9", 90000);
 
+	set_next_mime_type(ast_format_amr, 0,  "audio", "AMR", 8000);
+	set_next_mime_type(ast_format_amrwb, 0,  "audio", "AMR-WB", 16000);
+
 	/* Define the static rtp payload mappings */
 	add_static_payload(0, ast_format_ulaw, 0);
 	#ifdef USE_DEPRECATED_G726
@@ -3955,6 +3958,9 @@
 	add_static_payload(109, ast_format_h265, 0);
 
 	add_static_payload(110, ast_format_speex, 0);
+
+	add_static_payload(-1, ast_format_amr, 0);
+	add_static_payload(-1, ast_format_amrwb, 0);
 	add_static_payload(111, ast_format_g726, 0);
 	add_static_payload(112, ast_format_g726_aal2, 0);
 
--- a/Xamr/codec_amr.patch
+++ /dev/null
@@ -1,116 +0,0 @@
---- include/asterisk/format_cache.h	(Asterisk 13.10.0)
-+++ include/asterisk/format_cache.h	(working copy)
-@@ -226,2 +226,12 @@
- /*!
-+ * \brief Built-in cached AMR format.
-+ */
-+extern struct ast_format *ast_format_amr;
-+
-+/*!
-+ * \brief Built-in cached AMR-WB format.
-+ */
-+extern struct ast_format *ast_format_amrwb;
-+
-+/*!
-  * \brief Initialize format cache support within the core.
---- main/codec_builtin.c	(Asterisk 13.10.0)
-+++ main/codec_builtin.c	(working copy)
-@@ -774,2 +774,50 @@
- 
-+static int amr_samples(struct ast_frame *frame)
-+{
-+	return 160;
-+}
-+
-+static int amr_length(unsigned int samples)
-+{
-+	ast_log(LOG_NOTICE, "untested; please report failure or success: %u\n", samples); return samples / 8;
-+}
-+
-+static struct ast_codec amr = {
-+	.name = "amr",
-+	.description = "AMR",
-+	.type = AST_MEDIA_TYPE_AUDIO,
-+	.sample_rate = 8000,
-+	.minimum_ms = 20,
-+	.maximum_ms = 20,
-+	.default_ms = 20,
-+	.minimum_bytes = 0, /* no smooth */
-+	.samples_count = amr_samples,
-+	.get_length = amr_length,
-+	.smooth = 0,
-+};
-+
-+static int amrwb_samples(struct ast_frame *frame)
-+{
-+	return 320;
-+}
-+
-+static int amrwb_length(unsigned int samples)
-+{
-+	ast_log(LOG_NOTICE, "untested; please report failure or success: %u\n", samples); return samples / 16;
-+}
-+
-+static struct ast_codec amrwb = {
-+	.name = "amrwb",
-+	.description = "AMR-WB",
-+	.type = AST_MEDIA_TYPE_AUDIO,
-+	.sample_rate = 16000,
-+	.minimum_ms = 20,
-+	.maximum_ms = 20,
-+	.default_ms = 20,
-+	.minimum_bytes = 0, /* no smooth */
-+	.samples_count = amrwb_samples,
-+	.get_length = amrwb_length,
-+	.smooth = 0,
-+};
-+
- #define CODEC_REGISTER_AND_CACHE(codec) \
-@@ -806,2 +854,5 @@
-
-+	res |= CODEC_REGISTER_AND_CACHE(amr);
-+	res |= CODEC_REGISTER_AND_CACHE(amrwb);
-+
- 	res |= CODEC_REGISTER_AND_CACHE(g723);
---- main/format_cache.c	(Asterisk 13.10.0)
-+++ main/format_cache.c	(working copy)
-@@ -220,2 +220,12 @@
- /*!
-+ * \brief Built-in cached AMR format.
-+ */
-+struct ast_format *ast_format_amr;
-+
-+/*!
-+ * \brief Built-in cached AMR-WB format.
-+ */
-+struct ast_format *ast_format_amrwb;
-+
-+/*!
-  * \brief Built-in cached t140 format.
-@@ -294,2 +304,5 @@
-
-+	ao2_replace(ast_format_amr, NULL);
-+	ao2_replace(ast_format_amrwb, NULL);
-+
- 	ao2_replace(ast_format_g723, NULL);
-@@ -406,2 +419,6 @@
- 		ao2_replace(ast_format_opus, format);
-+	} else if (!strcmp(name, "amr")) {
-+		ao2_replace(ast_format_amr, format);
-+	} else if (!strcmp(name, "amrwb")) {
-+		ao2_replace(ast_format_amrwb, format);
- 	} else if (!strcmp(name, "jpeg")) {
---- main/rtp_engine.c	(Asterisk 13.10.0)
-+++ main/rtp_engine.c	(working copy)
-@@ -2201,2 +2201,5 @@
- 
-+	set_next_mime_type(ast_format_amr, 0,  "audio", "AMR", 8000);
-+	set_next_mime_type(ast_format_amrwb, 0,  "audio", "AMR-WB", 16000);
-+
-	/* Define the static rtp payload mappings */
-@@ -2244,2 +2247,5 @@
- 	add_static_payload(107, ast_format_opus, 0);
-+
-+	add_static_payload(-1, ast_format_amr, 0);
-+	add_static_payload(-1, ast_format_amrwb, 0);
-