forked from seanbright/asterisk-opus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasterisk.patch
51 lines (46 loc) · 1.29 KB
/
asterisk.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
diff -urN a/main/Makefile b/main/Makefile
--- a/main/Makefile
+++ b/main/Makefile
@@ -40,6 +40,7 @@
AST_LIBS+=$(URIPARSER_LIB)
AST_LIBS+=$(UUID_LIB)
AST_LIBS+=$(CRYPT_LIB)
+AST_LIBS+=$(OPUS_LIB)
AST_LIBS+=$(AST_CLANG_BLOCKS_LIBS)
ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc kfreebsd-gnu),)
@@ -160,6 +161,7 @@
bucket.o: _ASTCFLAGS+=$(URIPARSER_INCLUDE)
crypt.o: _ASTCFLAGS+=$(CRYPT_INCLUDE)
uuid.o: _ASTCFLAGS+=$(UUID_INCLUDE)
+codec_builtin.o: _ASTCFLAGS+=$(OPUS_INCLUDE)
ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
http.o: _ASTCFLAGS+=$(GMIME_INCLUDE)
diff -urN a/main/codec_builtin.c b/main/codec_builtin.c
--- a/main/codec_builtin.c
+++ b/main/codec_builtin.c
@@ -38,6 +38,8 @@
#include "asterisk/format_cache.h"
#include "asterisk/frame.h"
+#include <opus/opus.h>
+
enum frame_type {
TYPE_HIGH, /* 0x0 */
TYPE_LOW, /* 0x1 */
@@ -698,6 +700,11 @@
.get_length = g719_length,
};
+static int opus_samples(struct ast_frame *frame)
+{
+ return opus_packet_get_nb_samples(frame->data.ptr, frame->datalen, 48000);
+}
+
static struct ast_codec opus = {
.name = "opus",
.description = "Opus Codec",
@@ -707,6 +714,7 @@
.maximum_ms = 60,
.default_ms = 20,
.minimum_bytes = 10,
+ .samples_count = opus_samples,
};
static struct ast_codec jpeg = {