[Pkg-voip-commits] [asterisk] 05/07: Drop changes to res/res_format_attr_opus.c from opus.patch

Bernhard Schmidt berni at moszumanska.debian.org
Tue Dec 20 21:03:07 UTC 2016


This is an automated email from the git hooks/post-receive script.

berni pushed a commit to branch master
in repository asterisk.

commit 09af33bd0b27240006d9a9c546f350e7dab7afd3
Author: Bernhard Schmidt <berni at debian.org>
Date:   Sun Dec 18 14:52:43 2016 +0100

    Drop changes to res/res_format_attr_opus.c from opus.patch
---
 debian/patches/opus.patch | 508 ----------------------------------------------
 1 file changed, 508 deletions(-)

diff --git a/debian/patches/opus.patch b/debian/patches/opus.patch
index 2397bab..ab3474d 100644
--- a/debian/patches/opus.patch
+++ b/debian/patches/opus.patch
@@ -916,514 +916,6 @@ Last-Update: 2016-11-02
  #define CODEC_OPUS_DEFAULT_DTX 0
  #define CODEC_OPUS_DEFAULT_STEREO 0
  
---- a/res/res_format_attr_opus.c
-+++ b/res/res_format_attr_opus.c
-@@ -29,14 +29,18 @@
- 
- #include "asterisk.h"
- 
--ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-+#if defined(ASTERISK_REGISTER_FILE)
-+ASTERISK_REGISTER_FILE()
-+#elif defined(ASTERISK_FILE_VERSION)
-+ASTERISK_FILE_VERSION(__FILE__, "$Revision: $")
-+#endif
- 
- #include "asterisk/module.h"
- #include "asterisk/format.h"
--#include "asterisk/logger.h"
--#include "asterisk/strings.h"
--#include "asterisk/utils.h"
--#include "asterisk/opus.h"
-+#include "asterisk/logger.h"            /* for ast_log, LOG_WARNING */
-+#include "asterisk/opus.h"              /* for CODEC_OPUS_DEFAULT_* */
-+#include "asterisk/strings.h"           /* for ast_str_append */
-+#include "asterisk/utils.h"             /* for MIN, ast_malloc, ast_free */
- 
- /*!
-  * \brief Opus attribute structure.
-@@ -44,42 +48,32 @@
-  * \note http://tools.ietf.org/html/rfc7587#section-6
-  */
- struct opus_attr {
--	int maxbitrate;
--	int maxplayrate;
--	int ptime;
--	int stereo;
--	int cbr;
--	int fec;
--	int dtx;
--	int spropmaxcapturerate;
--	int spropstereo;
--	int maxptime;
--	/* Note data is expected to be an ao2_object type */
--	void *data;
-+	unsigned int maxbitrate;
-+	unsigned int maxplayrate;
-+	unsigned int unused; /* was minptime, kept for binary compatibility */
-+	unsigned int stereo;
-+	unsigned int cbr;
-+	unsigned int fec;
-+	unsigned int dtx;
-+	unsigned int spropmaxcapturerate;
-+	unsigned int spropstereo;
- };
- 
- static struct opus_attr default_opus_attr = {
--	.maxbitrate = CODEC_OPUS_DEFAULT_BITRATE,
--	.maxplayrate = CODEC_OPUS_DEFAULT_SAMPLE_RATE,
--	.ptime = CODEC_OPUS_DEFAULT_PTIME,
--	.stereo = CODEC_OPUS_DEFAULT_STEREO,
--	.cbr = CODEC_OPUS_DEFAULT_CBR,
--	.fec = CODEC_OPUS_DEFAULT_FEC,
--	.dtx = CODEC_OPUS_DEFAULT_DTX,
--	.spropmaxcapturerate = CODEC_OPUS_DEFAULT_SAMPLE_RATE,
--	.spropstereo = CODEC_OPUS_DEFAULT_STEREO,
--	.maxptime = CODEC_OPUS_DEFAULT_MAX_PTIME
-+	.maxplayrate         = CODEC_OPUS_DEFAULT_MAX_PLAYBACK_RATE,
-+	.spropmaxcapturerate = CODEC_OPUS_DEFAULT_MAX_PLAYBACK_RATE,
-+	.maxbitrate          = CODEC_OPUS_DEFAULT_BITRATE,
-+	.stereo              = CODEC_OPUS_DEFAULT_STEREO,
-+	.spropstereo         = CODEC_OPUS_DEFAULT_STEREO,
-+	.cbr                 = CODEC_OPUS_DEFAULT_CBR,
-+	.fec                 = CODEC_OPUS_DEFAULT_FEC,
-+	.dtx                 = CODEC_OPUS_DEFAULT_DTX,
- };
- 
- static void opus_destroy(struct ast_format *format)
- {
- 	struct opus_attr *attr = ast_format_get_attribute_data(format);
- 
--	if (!attr) {
--		return;
--	}
--
--	ao2_cleanup(attr->data);
- 	ast_free(attr);
- }
- 
-@@ -92,129 +86,172 @@
- 		return -1;
- 	}
- 
--	*attr = original ? *original : default_opus_attr;
--	ao2_bump(attr->data);
-+	if (original) {
-+		*attr = *original;
-+	} else {
-+		*attr = default_opus_attr;
-+	}
- 
- 	ast_format_set_attribute_data(dst, attr);
- 
- 	return 0;
- }
- 
--static void sdp_fmtp_get(const char *attributes, const char *name, int *attr)
--{
--	const char *kvp = "";
--	int val;
--
--	if (attributes && !(kvp = strstr(attributes, name))) {
--		return;
--	}
--
--	/*
--	 * If the named attribute is not at the start of the given attributes, and
--	 * the preceding character is not a space or semicolon then it's not the
--	 * attribute we are looking for. It's an attribute with the name embedded
--	 * within it (e.g. ptime in maxptime, stereo in sprop-stereo).
--	 */
--	if (kvp != attributes && *(kvp - 1) != ' ' && *(kvp - 1) != ';') {
--		/* Keep searching as it might still be in the attributes string */
--		sdp_fmtp_get(strchr(kvp, ';'), name, attr);
--	/*
--	 * Otherwise it's a match, so retrieve the value and set the attribute.
--	 */
--	} else if (sscanf(kvp, "%*[^=]=%30d", &val) == 1) {
--		*attr = val;
--	}
--}
--
- static struct ast_format *opus_parse_sdp_fmtp(const struct ast_format *format, const char *attributes)
- {
- 	struct ast_format *cloned;
- 	struct opus_attr *attr;
-+	const char *kvp;
-+	unsigned int val;
- 
- 	cloned = ast_format_clone(format);
- 	if (!cloned) {
- 		return NULL;
- 	}
--
- 	attr = ast_format_get_attribute_data(cloned);
- 
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, &attr->maxplayrate);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH,
--		&attr->maxplayrate);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE,
--		&attr->spropmaxcapturerate);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_PTIME, &attr->maxptime);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_PTIME, &attr->ptime);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, &attr->maxbitrate);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_STEREO, &attr->stereo);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_SPROP_STEREO, &attr->spropstereo);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_CBR, &attr->cbr);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_FEC, &attr->fec);
--	sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_DTX, &attr->dtx);
--
--	return cloned;
--}
--
--static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
--{
--	struct opus_attr *attr = ast_format_get_attribute_data(format);
--	int size;
--
--	if (!attr) {
--		/*
--		 * (Only) cached formats do not have attribute data assigned because
--		 * they were created before this attribute module was registered.
--		 * Therefore, we assume the default attribute values here.
--		 */
--		attr = &default_opus_attr;
-+	if ((kvp = strstr(attributes, "maxplaybackrate")) && sscanf(kvp, "maxplaybackrate=%30u", &val) == 1) {
-+		attr->maxplayrate = val;
-+	} else {
-+		attr->maxplayrate = 48000;
- 	}
- 
--	size = ast_str_append(str, 0, "a=fmtp:%u ", payload);
-+	if ((kvp = strstr(attributes, "sprop-maxcapturerate")) && sscanf(kvp, "sprop-maxcapturerate=%30u", &val) == 1) {
-+		attr->spropmaxcapturerate = val;
-+	} else {
-+		attr->spropmaxcapturerate = 48000;
-+	}
- 
--	if (CODEC_OPUS_DEFAULT_SAMPLE_RATE != attr->maxplayrate) {
--		ast_str_append(str, 0, "%s=%d;",
--			CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, attr->maxplayrate);
-+	if ((kvp = strstr(attributes, "maxaveragebitrate")) && sscanf(kvp, "maxaveragebitrate=%30u", &val) == 1) {
-+		attr->maxbitrate = val;
-+	} else {
-+		attr->maxbitrate = 510000;
- 	}
- 
--	if (CODEC_OPUS_DEFAULT_SAMPLE_RATE != attr->spropmaxcapturerate) {
--		ast_str_append(str, 0, "%s=%d;",
--			CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE, attr->spropmaxcapturerate);
-+	if (!strncmp(attributes, "stereo=1", 8)) {
-+		attr->stereo = 1;
-+	} else if (strstr(attributes, " stereo=1")) {
-+		attr->stereo = 1;
-+	} else if (strstr(attributes, ";stereo=1")) {
-+		attr->stereo = 1;
-+	} else {
-+		attr->stereo = 0;
- 	}
- 
--	if (CODEC_OPUS_DEFAULT_BITRATE != attr->maxbitrate || attr->maxbitrate > 0) {
--		ast_str_append(str, 0, "%s=%d;",
--			CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, attr->maxbitrate);
-+	if (strstr(attributes, "sprop-stereo=1")) {
-+		attr->spropstereo = 1;
-+	} else {
-+		attr->spropstereo = 0;
- 	}
- 
--	if (CODEC_OPUS_DEFAULT_STEREO != attr->stereo) {
--		ast_str_append(str, 0, "%s=%d;",
--			CODEC_OPUS_ATTR_STEREO, attr->stereo);
-+	if (strstr(attributes, "cbr=1")) {
-+		attr->cbr = 1;
-+	} else {
-+		attr->cbr = 0;
- 	}
- 
--	if (CODEC_OPUS_DEFAULT_STEREO != attr->spropstereo) {
--		ast_str_append(str, 0, "%s=%d;",
--			CODEC_OPUS_ATTR_SPROP_STEREO, attr->spropstereo);
-+	if (strstr(attributes, "useinbandfec=1")) {
-+		attr->fec = 1;
-+	} else {
-+		attr->fec = 0;
- 	}
- 
--	if (CODEC_OPUS_DEFAULT_CBR != attr->cbr) {
--		ast_str_append(str, 0, "%s=%d;",
--			CODEC_OPUS_ATTR_CBR, attr->cbr);
-+	if (strstr(attributes, "usedtx=1")) {
-+		attr->dtx = 1;
-+	} else {
-+		attr->dtx = 0;
- 	}
- 
--	if (CODEC_OPUS_DEFAULT_FEC!= attr->fec) {
--		ast_str_append(str, 0, "%s=%d;",
--		       CODEC_OPUS_ATTR_FEC, attr->fec);
-+	return cloned;
-+}
-+
-+static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
-+{
-+	struct opus_attr *attr = ast_format_get_attribute_data(format);
-+	int added = 0;
-+
-+	if (!attr) {
-+		/*
-+		 * (Only) cached formats do not have attribute data assigned because
-+		 * they were created before this attribute module was registered.
-+		 * Therefore, we assume the default attribute values here.
-+		 */
-+		attr = &default_opus_attr;
- 	}
- 
--	if (CODEC_OPUS_DEFAULT_DTX != attr->dtx) {
--		ast_str_append(str, 0, "%s=%d;",
--			CODEC_OPUS_ATTR_DTX, attr->dtx);
-+	if (48000 != attr->maxplayrate) {
-+		if (added) {
-+			ast_str_append(str, 0, ";");
-+		} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
-+			added = 1;
-+		}
-+		ast_str_append(str, 0, "maxplaybackrate=%u", attr->maxplayrate);
-+	}
-+
-+	if (48000 != attr->spropmaxcapturerate) {
-+		if (added) {
-+			ast_str_append(str, 0, ";");
-+		} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
-+			added = 1;
-+		}
-+		ast_str_append(str, 0, "sprop-maxcapturerate=%u", attr->spropmaxcapturerate);
-+	}
-+
-+	if (510000 != attr->maxbitrate) {
-+		if (added) {
-+			ast_str_append(str, 0, ";");
-+		} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
-+			added = 1;
-+		}
-+		ast_str_append(str, 0, "maxaveragebitrate=%u", attr->maxbitrate);
-+	}
-+
-+	if (0 != attr->stereo) {
-+		if (added) {
-+			ast_str_append(str, 0, ";");
-+		} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
-+			added = 1;
-+		}
-+		ast_str_append(str, 0, "stereo=%u", attr->stereo);
-+	}
-+
-+	if (0 != attr->spropstereo) {
-+		if (added) {
-+			ast_str_append(str, 0, ";");
-+		} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
-+			added = 1;
-+		}
-+		ast_str_append(str, 0, "sprop-stereo=%u", attr->spropstereo);
-+	}
-+
-+	if (0 != attr->cbr) {
-+		if (added) {
-+			ast_str_append(str, 0, ";");
-+		} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
-+			added = 1;
-+		}
-+		ast_str_append(str, 0, "cbr=%u", attr->cbr);
-+	}
-+
-+	if (0 != attr->fec) {
-+		if (added) {
-+			ast_str_append(str, 0, ";");
-+		} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
-+			added = 1;
-+		}
-+		ast_str_append(str, 0, "useinbandfec=%u", attr->fec);
-+	}
-+
-+	if (0 != attr->dtx) {
-+		if (added) {
-+			ast_str_append(str, 0, ";");
-+		} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
-+			added = 1;
-+		}
-+		ast_str_append(str, 0, "usedtx=%u", attr->dtx);
- 	}
- 
--	if (size == ast_str_strlen(*str)) {
--		ast_str_reset(*str);
--	} else {
--		ast_str_truncate(*str, -1);
-+	if (added) {
- 		ast_str_append(str, 0, "\r\n");
- 	}
- }
-@@ -253,68 +290,49 @@
- 	 * to receive stereo signals, it may be a waste of bandwidth. */
- 	attr_res->stereo = attr1->stereo && attr2->stereo ? 1 : 0;
- 
--	if (attr1->maxbitrate < 0) {
--		attr_res->maxbitrate = attr2->maxbitrate;
--	} else if (attr2->maxbitrate < 0) {
--		attr_res->maxbitrate = attr1->maxbitrate;
--	} else {
--		attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate);
--	}
--
-+	attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate);
- 	attr_res->spropmaxcapturerate = MIN(attr1->spropmaxcapturerate, attr2->spropmaxcapturerate);
- 	attr_res->maxplayrate = MIN(attr1->maxplayrate, attr2->maxplayrate);
- 
- 	return jointformat;
- }
- 
--static struct ast_format *opus_set(const struct ast_format *format,
--	const char *name, const char *value)
-+static struct ast_format *opus_set(const struct ast_format *format, const char *name, const char *value)
- {
- 	struct ast_format *cloned;
- 	struct opus_attr *attr;
--	int val;
-+	unsigned int val;
- 
--	if (!(cloned = ast_format_clone(format))) {
-+	if (sscanf(value, "%30u", &val) != 1) {
-+		ast_log(LOG_WARNING, "Unknown value '%s' for attribute type '%s'\n",
-+			value, name);
- 		return NULL;
- 	}
- 
--	attr = ast_format_get_attribute_data(cloned);
--
--	if (!strcmp(name, CODEC_OPUS_ATTR_DATA)) {
--		ao2_cleanup(attr->data);
--		attr->data = ao2_bump((void*)value);
--		return cloned;
--	}
--
--	if (sscanf(value, "%30d", &val) != 1) {
--		ast_log(LOG_WARNING, "Unknown value '%s' for attribute type '%s'\n",
--			value, name);
--		ao2_ref(cloned, -1);
-+	cloned = ast_format_clone(format);
-+	if (!cloned) {
- 		return NULL;
- 	}
-+	attr = ast_format_get_attribute_data(cloned);
- 
--	if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE)) {
--		attr->maxplayrate = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH)) {
--		attr->maxplayrate = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE)) {
--		attr->spropmaxcapturerate = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PTIME)) {
--		attr->maxptime = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_PTIME)) {
--		attr->ptime = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE)) {
-+	if (!strcasecmp(name, "max_bitrate")) {
- 		attr->maxbitrate = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_STEREO)) {
-+	} else if (!strcasecmp(name, "max_playrate")) {
-+		attr->maxplayrate = val;
-+	} else if (!strcasecmp(name, "minptime")) {
-+		attr->unused = val;
-+	} else if (!strcasecmp(name, "stereo")) {
- 		attr->stereo = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_STEREO)) {
--		attr->spropstereo = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_CBR)) {
-+	} else if (!strcasecmp(name, "cbr")) {
- 		attr->cbr = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_FEC)) {
-+	} else if (!strcasecmp(name, "fec")) {
- 		attr->fec = val;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_DTX)) {
-+	} else if (!strcasecmp(name, "dtx")) {
- 		attr->dtx = val;
-+	} else if (!strcasecmp(name, "sprop_capture_rate")) {
-+		attr->spropmaxcapturerate = val;
-+	} else if (!strcasecmp(name, "sprop_stereo")) {
-+		attr->spropstereo = val;
- 	} else {
- 		ast_log(LOG_WARNING, "unknown attribute type %s\n", name);
- 	}
-@@ -322,44 +340,6 @@
- 	return cloned;
- }
- 
--static const void *opus_get(const struct ast_format *format, const char *name)
--{
--	struct opus_attr *attr = ast_format_get_attribute_data(format);
--	int *val = NULL;
--
--	if (!attr) {
--		return NULL;
--	}
--
--	if (!strcasecmp(name, CODEC_OPUS_ATTR_DATA)) {
--		return ao2_bump(attr->data);
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE)) {
--		val = &attr->maxplayrate;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE)) {
--		val = &attr->spropmaxcapturerate;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PTIME)) {
--		val = &attr->maxptime;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_PTIME)) {
--		val = &attr->ptime;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE)) {
--		val = &attr->maxbitrate;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_STEREO)) {
--		val = &attr->stereo;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_STEREO)) {
--		val = &attr->spropstereo;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_CBR)) {
--		val = &attr->cbr;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_FEC)) {
--		val = &attr->fec;
--	} else if (!strcasecmp(name, CODEC_OPUS_ATTR_DTX)) {
--		val = &attr->dtx;
--	} else {
--		ast_log(LOG_WARNING, "unknown attribute type %s\n", name);
--	}
--
--	return val;
--}
--
- static struct ast_format_interface opus_interface = {
- 	.format_destroy = opus_destroy,
- 	.format_clone = opus_clone,
-@@ -367,12 +347,11 @@
- 	.format_attribute_set = opus_set,
- 	.format_parse_sdp_fmtp = opus_parse_sdp_fmtp,
- 	.format_generate_sdp_fmtp = opus_generate_sdp_fmtp,
--	.format_attribute_get = opus_get
- };
- 
- static int load_module(void)
- {
--	if (__ast_format_interface_register("opus", &opus_interface, ast_module_info->self)) {
-+	if (ast_format_interface_register("opus", &opus_interface)) {
- 		return AST_MODULE_LOAD_DECLINE;
- 	}
- 
-@@ -384,9 +363,9 @@
- 	return 0;
- }
- 
--AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Opus Format Attribute Module",
-+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Opus Format Attribute Module",
- 	.support_level = AST_MODULE_SUPPORT_CORE,
- 	.load = load_module,
- 	.unload = unload_module,
--	.load_pri = AST_MODPRI_REALTIME_DRIVER /* Needs to load before codec_opus */
-+	.load_pri = AST_MODPRI_CHANNEL_DEPEND,
- );
 --- a/build_tools/menuselect-deps.in
 +++ b/build_tools/menuselect-deps.in
 @@ -44,6 +44,7 @@

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/asterisk.git



More information about the Pkg-voip-commits mailing list