Bug#786972: asterisk: Please build-depend on libopus-dev to support that codec when mixing

2015-10-15 Thread Jonas Smedegaard
retitle 786972 asterisk: please apply unofficial Opus transcoding patch
thanks

Quoting Jonas Smedegaard (2015-05-27 15:13:50)
> Quoting Tzafrir Cohen (2015-05-27 13:13:05)
>> On Wed, May 27, 2015 at 12:06:13PM +0200, Jonas Smedegaard wrote:
>>> Recent Asterisk supports the Opus audio codec, either as only 
>>> identifier when negotiating a pass-through connection,
>>
>> Right,
>>
>>> or decoding/encoding when mixing audio.
>>
>> Are you sure?
>
> No I am guessing, based on a) my undertanding that pass-through codec 
> negotiation reequire no library linking, and b) noticing that autoconf 
> checks not just library existence but for opus_encoder_create 
> function.

...and I guessed wrong: Simply adding build-dependency makes autotools 
detect it but isn't really used for anything, apparently.

A patch exist to implement Opus transcoding support.  That patch is not 
adopted upstream due to fear of patent trolls.

Please apply it for Debian redistribution, where we evidently do not 
have same concerns¹ (we distribute Opus encoders already).

Patch attached.  Patch also attached from same source (but can be 
applied independently) for read/write support for vp8 codec.

 - Jonas


¹ Please do *not* publicly discuss Debian position regarding patents - 
if needed then ask lea...@debian.org or bring it up somewhere else more 
private.

-- 
 * Jonas Smedegaard - idealist & Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/

 [x] quote me freely  [ ] ask before reusing  [ ] keep private
Description: Add Opus codec module supporting transcoding
Origin: https://github.com/seanbright/asterisk-opus
Author: Lorenzo Miniero 
Forwarded: yes
Bug-Debian: http://bugs.debian.org/786972
Last-Update: 2015-10-12

--- 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)
 
 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc kfreebsd-gnu),)
   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
@@ -159,6 +160,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)
--- a/main/codec_builtin.c
+++ b/main/codec_builtin.c
@@ -38,6 +38,8 @@
 #include "asterisk/format_cache.h"
 #include "asterisk/frame.h"
 
+#include 
+
 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 = {
--- a/res/res_format_attr_opus.c
+++ b/res/res_format_attr_opus.c
@@ -51,6 +51,12 @@
 	unsigned int spropstereo;	/* Default 0 */
 };
 
+static struct opus_attr default_opus_attr = {
+	.fec= 0,
+	.dtx= 0,
+	.stereo = 0,
+};
+
 static void opus_destroy(struct ast_format *format)
 {
 	struct opus_attr *attr = ast_format_get_attribute_data(format);
@@ -120,7 +126,7 @@
 		attr->dtx = val;
 	}
 
-	return 0;
+	return cloned;
 }
 
 static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
@@ -163,6 +169,14 @@
 	struct ast_format *jointformat;
 	struct opus_attr *attr_res;
 
+	if (!attr1) {
+		attr1 = _opus_attr;
+	}
+
+	if (!attr2) {
+		attr2 = _opus_attr;
+	}
+
 	jointformat = ast_format_clone(format1);
 	if (!jointformat) {
 		return NULL;
--- /dev/null
+++ b/codecs/ex_opus.h
@@ -0,0 +1,35 @@
+/*! \file
+ * \brief 8-bit data
+ *
+ * Copyright (C) 2014, Lorenzo Miniero
+ *
+ * Distributed under the terms of the GNU General Public License
+ *
+ */
+
+/* Opus, a 20ms sample */
+static uint8_t ex_opus[] = {
+	0x4b, 0x41, 0x25, 0x0b, 0xe4, 0x55, 0xc6, 0x74,
+	0xda, 0xbb, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static struct ast_frame *opus_sample(void)
+{
+	static struct ast_frame f = {
+		.frametype = AST_FRAME_VOICE,
+		.datalen = sizeof(ex_opus),
+		.samples = 960,	// ARRAY_LEN(ex_opus),
+		.mallocd = 0,
+		.offset = 0,
+		.src = __PRETTY_FUNCTION__,
+		.data.ptr = ex_opus,
+	};
+
+	f.subclass.format = ast_format_opus;
+
+	return 
+}
--- /dev/null
+++ b/codecs/codec_opus.c
@@ -0,0 +1,587 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2014, Lorenzo Miniero
+ *
+ * Lorenzo Miniero 
+ *
+ * See http://www.asterisk.org for more information about
+ * 

Bug#786972: asterisk: Please build-depend on libopus-dev to support that codec when mixing

2015-05-27 Thread Tzafrir Cohen
On Wed, May 27, 2015 at 12:06:13PM +0200, Jonas Smedegaard wrote:
 Package: asterisk
 Severity: normal
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Recent Asterisk supports the Opus audio codec, either as only identifier
 when negotiating a pass-through connection, 

Right,

 or decoding/encoding when
 mixing audio.

Are you sure?


Regardless, libopus should be added as a build dependency. Thanks for
the report.

-- 
   Tzafrir Cohen
icq#16849755  jabber:tzafrir.co...@xorcom.com
+972-50-7952406   mailto:tzafrir.co...@xorcom.com
http://www.xorcom.com


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#786972: asterisk: Please build-depend on libopus-dev to support that codec when mixing

2015-05-27 Thread Jonas Smedegaard
Package: asterisk
Severity: normal

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Recent Asterisk supports the Opus audio codec, either as only identifier
when negotiating a pass-through connection, or decoding/encoding when
mixing audio.

Please build-depend on libopus-dev for the latter half of that support.

 - Jonas

-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQIcBAEBAgAGBQJVZZcRAAoJECx8MUbBoAEhk7MQAKv1T60+fV9GwcN3DI2qi0w0
FKClo2cHtOqSIfOk+Q8OzwzvfJcBsXwLkM8Yvcv8ahBFNJlJb86jkdnTyDnLEBEb
XdruDFafJSU2hjSfP6Y6EbxKki0TnYqPUzGjlDPn2+S0uVc+o3W1AXTC03BnHrLf
vqRkxQIeGszeI+KQZe+9HTSKhPZ2OIhkfNrVZCInnnvk0CxCVRcTO9R8oSV7r0ru
ISeO6/acDBUlfzh20q+ol6TPTnpjqF04+t2CxMOk5kOeqZxVYYfT8PeD2/utTnca
zfBxM59oqfDISt1CsY580LWrxc7u2Z/UIzz2jFefU6Jq4Nr/aC9yJfZ1AAzbsfzx
kpwjsOrujaqhg5mMIslak9PmuD0ghWOadmBK1GeaveSMF+QtreP0WSR+WLs2+6gG
1fgCksiQ0R0lEqDiU302qqGRVe/0YscWUFUWOdtL8r8XXqwgDYWFwdTRrWuZ+A/o
KH6vW7eMJlNBQ3MFqXWdPCzfVxr1lTfY9zzbVd3eyIovDWWuOeGV499xJMchhyqy
mdWJGaknUTaoNqugdvweH3HeUmqd22Ya8f6u+4D2WkFmsyWbF4MHs7BYHTzH9t5X
TTaVzGlFFRY6qGbsBdKMIg3ovdaDoQHyXGbgXW6SKqJyzMWBWXHMWuTflT8R6IEY
H4t/wiFc8rI+Ej0l/t8b
=zMxV
-END PGP SIGNATURE-


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#786972: asterisk: Please build-depend on libopus-dev to support that codec when mixing

2015-05-27 Thread Jonas Smedegaard
Hi Tzafrir,

Quoting Tzafrir Cohen (2015-05-27 13:13:05)
 On Wed, May 27, 2015 at 12:06:13PM +0200, Jonas Smedegaard wrote:
 Recent Asterisk supports the Opus audio codec, either as only 
 identifier when negotiating a pass-through connection,

 Right,

 or decoding/encoding when
 mixing audio.

 Are you sure?

No I am guessing, based on a) my undertanding that pass-through codec 
negotiation reequire no library linking, and b) noticing that autoconf 
checks not just library existence but for opus_encoder_create function.


 - Jonas

-- 
 * Jonas Smedegaard - idealist  Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/

 [x] quote me freely  [ ] ask before reusing  [ ] keep private


signature.asc
Description: signature