forked from mordak/codec_silk
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcodec_silk.patch
137 lines (131 loc) · 3.7 KB
/
codec_silk.patch
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
--- include/asterisk/format_cache.h (Asterisk 13.10.0)
+++ include/asterisk/format_cache.h (working copy)
@@ -226,2 +226,10 @@
/*!
+ * \brief Built-in cached SILK format.
+ */
+extern struct ast_format *ast_format_silk8;
+extern struct ast_format *ast_format_silk12;
+extern struct ast_format *ast_format_silk16;
+extern struct ast_format *ast_format_silk24;
+
+/*!
* \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,59 @@
+static int silk_samples(struct ast_frame *frame)
+{
+ return ast_format_get_sample_rate(frame->subclass.format) / 50;
+}
+
+static struct ast_codec silk8 = {
+ .name = "silk8",
+ .description = "SILK 8kHz",
+ .type = AST_MEDIA_TYPE_AUDIO,
+ .sample_rate = 8000,
+ .minimum_ms = 20,
+ .maximum_ms = 20,
+ .default_ms = 20,
+ .minimum_bytes = 0,
+ .samples_count = silk_samples,
+ .smooth = 0,
+};
+
+static struct ast_codec silk12 = {
+ .name = "silk12",
+ .description = "SILK 12kHz",
+ .type = AST_MEDIA_TYPE_AUDIO,
+ .sample_rate = 12000,
+ .minimum_ms = 20,
+ .maximum_ms = 20,
+ .default_ms = 20,
+ .minimum_bytes = 0,
+ .samples_count = silk_samples,
+ .smooth = 0,
+};
+
+static struct ast_codec silk16 = {
+ .name = "silk16",
+ .description = "SILK 16kHz",
+ .type = AST_MEDIA_TYPE_AUDIO,
+ .sample_rate = 16000,
+ .minimum_ms = 20,
+ .maximum_ms = 20,
+ .default_ms = 20,
+ .minimum_bytes = 0,
+ .samples_count = silk_samples,
+ .smooth = 0,
+};
+
+static struct ast_codec silk24 = {
+ .name = "silk24",
+ .description = "SILK 24kHz",
+ .type = AST_MEDIA_TYPE_AUDIO,
+ .sample_rate = 24000,
+ .minimum_ms = 20,
+ .maximum_ms = 20,
+ .default_ms = 20,
+ .minimum_bytes = 0,
+ .samples_count = silk_samples,
+ .smooth = 0,
+};
+
#define CODEC_REGISTER_AND_CACHE(codec) \
@@ -806,2 +863,7 @@
+ res |= CODEC_REGISTER_AND_CACHE(silk8);
+ res |= CODEC_REGISTER_AND_CACHE(silk12);
+ res |= CODEC_REGISTER_AND_CACHE(silk16);
+ res |= CODEC_REGISTER_AND_CACHE(silk24);
+
res |= CODEC_REGISTER_AND_CACHE(g723);
--- main/format_cache.c (Asterisk 13.10.0)
+++ main/format_cache.c (working copy)
@@ -220,2 +220,10 @@
/*!
+ * \brief Built-in cached SILK format.
+ */
+struct ast_format *ast_format_silk8;
+struct ast_format *ast_format_silk12;
+struct ast_format *ast_format_silk16;
+struct ast_format *ast_format_silk24;
+
+/*!
* \brief Built-in cached t140 format.
@@ -294,2 +302,7 @@
+ ao2_replace(ast_format_silk8, NULL);
+ ao2_replace(ast_format_silk12, NULL);
+ ao2_replace(ast_format_silk16, NULL);
+ ao2_replace(ast_format_silk24, NULL);
+
ao2_replace(ast_format_g723, NULL);
@@ -426,6 +439,14 @@
ao2_replace(ast_format_t140, format);
} else if (!strcmp(name, "none")) {
ao2_replace(ast_format_none, format);
+ } else if (!strcmp(name, "silk8")) {
+ ao2_replace(ast_format_silk8, format);
+ } else if (!strcmp(name, "silk12")) {
+ ao2_replace(ast_format_silk12, format);
+ } else if (!strcmp(name, "silk16")) {
+ ao2_replace(ast_format_silk16, format);
+ } else if (!strcmp(name, "silk24")) {
+ ao2_replace(ast_format_silk24, format);
}
}
--- main/rtp_engine.c (Asterisk 13.10.0)
+++ main/rtp_engine.c (working copy)
@@ -2201,2 +2201,7 @@
+ set_next_mime_type(ast_format_silk8, 0, "audio", "SILK", 8000);
+ set_next_mime_type(ast_format_silk12, 0, "audio", "SILK", 12000);
+ set_next_mime_type(ast_format_silk16, 0, "audio", "SILK", 16000);
+ set_next_mime_type(ast_format_silk24, 0, "audio", "SILK", 24000);
+
/* Define the static rtp payload mappings */
@@ -2244,2 +2249,7 @@
add_static_payload(107, ast_format_opus, 0);
+
+ add_static_payload(-1, ast_format_silk8, 0);
+ add_static_payload(-1, ast_format_silk12, 0);
+ add_static_payload(-1, ast_format_silk16, 0);
+ add_static_payload(-1, ast_format_silk24, 0);