[asterisk-commits] file: branch group/media_formats-reviewed r411015 - /team/group/media_formats...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Mar 23 06:49:09 CDT 2014


Author: file
Date: Sun Mar 23 06:49:02 2014
New Revision: 411015

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411015
Log:
Merge bridge changes.

Review: https://reviewboard.asterisk.org/r/3318/

Modified:
    team/group/media_formats-reviewed/bridges/bridge_holding.c
    team/group/media_formats-reviewed/bridges/bridge_simple.c
    team/group/media_formats-reviewed/bridges/bridge_softmix.c

Modified: team/group/media_formats-reviewed/bridges/bridge_holding.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/bridges/bridge_holding.c?view=diff&rev=411015&r1=411014&r2=411015
==============================================================================
--- team/group/media_formats-reviewed/bridges/bridge_holding.c (original)
+++ team/group/media_formats-reviewed/bridges/bridge_holding.c Sun Mar 23 06:49:02 2014
@@ -48,6 +48,7 @@
 #include "asterisk/bridge_technology.h"
 #include "asterisk/frame.h"
 #include "asterisk/musiconhold.h"
+#include "asterisk/format_cache.h"
 
 enum holding_roles {
 	HOLDING_ROLE_PARTICIPANT,
@@ -180,7 +181,7 @@
 
 	chan = bridge_channel->chan;
 	participant_entertainment_stop(bridge_channel);
-	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
+	if (ast_set_write_format(chan, ast_format_slin)) {
 		ast_log(LOG_WARNING, "Could not make participant %s compatible.\n", ast_channel_name(chan));
 	}
 }
@@ -233,7 +234,7 @@
 	}
 
 	/* We need to get compatible with the announcer. */
-	if (ast_set_write_format_by_id(us, AST_FORMAT_SLINEAR)) {
+	if (ast_set_write_format(us, ast_format_slin)) {
 		ast_log(LOG_WARNING, "Could not make participant %s compatible.\n", ast_channel_name(us));
 	}
 }
@@ -270,7 +271,7 @@
 		hc->role = HOLDING_ROLE_ANNOUNCER;
 
 		/* The announcer should always be made compatible with signed linear */
-		if (ast_set_read_format_by_id(us, AST_FORMAT_SLINEAR)) {
+		if (ast_set_read_format(us, ast_format_slin)) {
 			ast_log(LOG_ERROR, "Could not make announcer %s compatible.\n", ast_channel_name(us));
 		}
 
@@ -427,18 +428,19 @@
 
 static int unload_module(void)
 {
-	ast_format_cap_destroy(holding_bridge.format_capabilities);
+	ao2_cleanup(holding_bridge.format_capabilities);
+	holding_bridge.format_capabilities = NULL;
 	return ast_bridge_technology_unregister(&holding_bridge);
 }
 
 static int load_module(void)
 {
-	if (!(holding_bridge.format_capabilities = ast_format_cap_alloc(0))) {
+	if (!(holding_bridge.format_capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_add_all_by_type(holding_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);
-	ast_format_cap_add_all_by_type(holding_bridge.format_capabilities, AST_FORMAT_TYPE_VIDEO);
-	ast_format_cap_add_all_by_type(holding_bridge.format_capabilities, AST_FORMAT_TYPE_TEXT);
+	ast_format_cap_add_all_by_type(holding_bridge.format_capabilities, AST_MEDIA_TYPE_AUDIO);
+	ast_format_cap_add_all_by_type(holding_bridge.format_capabilities, AST_MEDIA_TYPE_VIDEO);
+	ast_format_cap_add_all_by_type(holding_bridge.format_capabilities, AST_MEDIA_TYPE_TEXT);
 
 	return ast_bridge_technology_register(&holding_bridge);
 }

Modified: team/group/media_formats-reviewed/bridges/bridge_simple.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/bridges/bridge_simple.c?view=diff&rev=411015&r1=411014&r2=411015
==============================================================================
--- team/group/media_formats-reviewed/bridges/bridge_simple.c (original)
+++ team/group/media_formats-reviewed/bridges/bridge_simple.c Sun Mar 23 06:49:02 2014
@@ -76,18 +76,19 @@
 
 static int unload_module(void)
 {
-	ast_format_cap_destroy(simple_bridge.format_capabilities);
+	ao2_cleanup(simple_bridge.format_capabilities);
+	simple_bridge.format_capabilities = NULL;
 	return ast_bridge_technology_unregister(&simple_bridge);
 }
 
 static int load_module(void)
 {
-	if (!(simple_bridge.format_capabilities = ast_format_cap_alloc(0))) {
+	if (!(simple_bridge.format_capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);
-	ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_FORMAT_TYPE_VIDEO);
-	ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_FORMAT_TYPE_TEXT);
+	ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_MEDIA_TYPE_AUDIO);
+	ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_MEDIA_TYPE_VIDEO);
+	ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_MEDIA_TYPE_TEXT);
 
 	return ast_bridge_technology_register(&simple_bridge);
 }

Modified: team/group/media_formats-reviewed/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/bridges/bridge_softmix.c?view=diff&rev=411015&r1=411014&r2=411015
==============================================================================
--- team/group/media_formats-reviewed/bridges/bridge_softmix.c (original)
+++ team/group/media_formats-reviewed/bridges/bridge_softmix.c Sun Mar 23 06:49:02 2014
@@ -163,14 +163,14 @@
 struct softmix_translate_helper_entry {
 	int num_times_requested; /*!< Once this entry is no longer requested, free the trans_pvt
 	                              and re-init if it was usable. */
-	struct ast_format dst_format; /*!< The destination format for this helper */
+	struct ast_format *dst_format; /*!< The destination format for this helper */
 	struct ast_trans_pvt *trans_pvt; /*!< the translator for this slot. */
 	struct ast_frame *out_frame; /*!< The output frame from the last translation */
 	AST_LIST_ENTRY(softmix_translate_helper_entry) entry;
 };
 
 struct softmix_translate_helper {
-	struct ast_format slin_src; /*!< the source format expected for all the translators */
+	struct ast_format *slin_src; /*!< the source format expected for all the translators */
 	AST_LIST_HEAD_NOLOCK(, softmix_translate_helper_entry) entries;
 };
 
@@ -180,12 +180,14 @@
 	if (!(entry = ast_calloc(1, sizeof(*entry)))) {
 		return NULL;
 	}
-	ast_format_copy(&entry->dst_format, dst);
+	entry->dst_format = ast_format_copy(dst);
 	return entry;
 }
 
 static void *softmix_translate_helper_free_entry(struct softmix_translate_helper_entry *entry)
 {
+	ao2_cleanup(entry->dst_format);
+
 	if (entry->trans_pvt) {
 		ast_translator_free_path(entry->trans_pvt);
 	}
@@ -199,12 +201,14 @@
 static void softmix_translate_helper_init(struct softmix_translate_helper *trans_helper, unsigned int sample_rate)
 {
 	memset(trans_helper, 0, sizeof(*trans_helper));
-	ast_format_set(&trans_helper->slin_src, ast_format_slin_by_rate(sample_rate), 0);
+	trans_helper->slin_src = ast_format_cache_get_slin_by_rate(sample_rate);
 }
 
 static void softmix_translate_helper_destroy(struct softmix_translate_helper *trans_helper)
 {
 	struct softmix_translate_helper_entry *entry;
+
+	ao2_cleanup(trans_helper->slin_src);
 
 	while ((entry = AST_LIST_REMOVE_HEAD(&trans_helper->entries, entry))) {
 		softmix_translate_helper_free_entry(entry);
@@ -215,11 +219,12 @@
 {
 	struct softmix_translate_helper_entry *entry;
 
-	ast_format_set(&trans_helper->slin_src, ast_format_slin_by_rate(sample_rate), 0);
+	ao2_cleanup(trans_helper->slin_src);
+	trans_helper->slin_src = ast_format_cache_get_slin_by_rate(sample_rate);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&trans_helper->entries, entry, entry) {
 		if (entry->trans_pvt) {
 			ast_translator_free_path(entry->trans_pvt);
-			if (!(entry->trans_pvt = ast_translator_build_path(&entry->dst_format, &trans_helper->slin_src))) {
+			if (!(entry->trans_pvt = ast_translator_build_path(entry->dst_format, trans_helper->slin_src))) {
 				AST_LIST_REMOVE_CURRENT(entry);
 				entry = softmix_translate_helper_free_entry(entry);
 			}
@@ -274,19 +279,20 @@
 	}
 
 	AST_LIST_TRAVERSE(&trans_helper->entries, entry, entry) {
-		if (ast_format_cmp(&entry->dst_format, raw_write_fmt) == AST_FORMAT_CMP_EQUAL) {
+		if (ast_format_cmp(entry->dst_format, raw_write_fmt) == AST_FORMAT_CMP_EQUAL) {
 			entry->num_times_requested++;
 		} else {
 			continue;
 		}
 		if (!entry->trans_pvt && (entry->num_times_requested > 1)) {
-			entry->trans_pvt = ast_translator_build_path(&entry->dst_format, &trans_helper->slin_src);
+			entry->trans_pvt = ast_translator_build_path(entry->dst_format, trans_helper->slin_src);
 		}
 		if (entry->trans_pvt && !entry->out_frame) {
 			entry->out_frame = ast_translate(entry->trans_pvt, &sc->write_frame, 0);
 		}
 		if (entry->out_frame && (entry->out_frame->datalen < MAX_DATALEN)) {
-			ast_format_copy(&sc->write_frame.subclass.format, &entry->out_frame->subclass.format);
+			ao2_cleanup(sc->write_frame.subclass.format);
+			sc->write_frame.subclass.format = ast_format_copy(entry->out_frame->subclass.format);
 			memcpy(sc->final_buf, entry->out_frame->data.ptr, entry->out_frame->datalen);
 			sc->write_frame.datalen = entry->out_frame->datalen;
 			sc->write_frame.samples = entry->out_frame->samples;
@@ -316,7 +322,7 @@
 static void set_softmix_bridge_data(int rate, int interval, struct ast_bridge_channel *bridge_channel, int reset)
 {
 	struct softmix_channel *sc = bridge_channel->tech_pvt;
-	unsigned int channel_read_rate = ast_format_rate(ast_channel_rawreadformat(bridge_channel->chan));
+	unsigned int channel_read_rate = ast_format_get_sample_rate(ast_channel_rawreadformat(bridge_channel->chan));
 
 	ast_mutex_lock(&sc->lock);
 	if (reset) {
@@ -325,23 +331,25 @@
 	}
 	/* Setup read/write frame parameters */
 	sc->write_frame.frametype = AST_FRAME_VOICE;
-	ast_format_set(&sc->write_frame.subclass.format, ast_format_slin_by_rate(rate), 0);
+	ao2_cleanup(sc->write_frame.subclass.format);
+	sc->write_frame.subclass.format = ast_format_cache_get_slin_by_rate(rate);
 	sc->write_frame.data.ptr = sc->final_buf;
 	sc->write_frame.datalen = SOFTMIX_DATALEN(rate, interval);
 	sc->write_frame.samples = SOFTMIX_SAMPLES(rate, interval);
 
 	sc->read_frame.frametype = AST_FRAME_VOICE;
-	ast_format_set(&sc->read_frame.subclass.format, ast_format_slin_by_rate(channel_read_rate), 0);
+	ao2_cleanup(sc->read_frame.subclass.format);
+	sc->read_frame.subclass.format = ast_format_cache_get_slin_by_rate(channel_read_rate);
 	sc->read_frame.data.ptr = sc->our_buf;
 	sc->read_frame.datalen = SOFTMIX_DATALEN(channel_read_rate, interval);
 	sc->read_frame.samples = SOFTMIX_SAMPLES(channel_read_rate, interval);
 
 	/* Setup smoother */
-	ast_slinfactory_init_with_format(&sc->factory, &sc->write_frame.subclass.format);
+	ast_slinfactory_init_with_format(&sc->factory, sc->write_frame.subclass.format);
 
 	/* set new read and write formats on channel. */
-	ast_set_read_format(bridge_channel->chan, &sc->read_frame.subclass.format);
-	ast_set_write_format(bridge_channel->chan, &sc->write_frame.subclass.format);
+	ast_set_read_format(bridge_channel->chan, sc->read_frame.subclass.format);
+	ast_set_write_format(bridge_channel->chan, sc->write_frame.subclass.format);
 
 	/* set up new DSP.  This is on the read side only right before the read frame enters the smoother.  */
 	sc->dsp = ast_dsp_new_with_rate(channel_read_rate);
@@ -445,6 +453,10 @@
 
 	/* Drop the factory */
 	ast_slinfactory_destroy(&sc->factory);
+
+	/* Drop any formats on the frames */
+	ao2_cleanup(sc->write_frame.subclass.format);
+	ao2_cleanup(sc->read_frame.subclass.format);
 
 	/* Drop the DSP */
 	ast_dsp_free(sc->dsp);
@@ -500,7 +512,7 @@
 		ast_mutex_lock(&sc->lock);
 		ast_bridge_update_talker_src_video_mode(bridge, bridge_channel->chan,
 			sc->video_talker.energy_average,
-			ast_format_get_video_mark(&frame->subclass.format));
+			frame->subclass.video.frame_ending);
 		ast_mutex_unlock(&sc->lock);
 		video_src_priority = ast_bridge_is_video_src(bridge, bridge_channel->chan);
 		if (video_src_priority == 1) {
@@ -575,8 +587,7 @@
 
 	/* If a frame was provided add it to the smoother, unless drop silence is enabled and this frame
 	 * is not determined to be talking. */
-	if (!(bridge_channel->tech_args.drop_silence && !sc->talking) &&
-		(frame->frametype == AST_FRAME_VOICE && ast_format_is_slinear(&frame->subclass.format))) {
+	if (!(bridge_channel->tech_args.drop_silence && !sc->talking)) {
 		ast_slinfactory_feed(&sc->factory, frame);
 	}
 
@@ -677,8 +688,8 @@
 	int channel_native_rate;
 	int i;
 	/* Gather stats about channel sample rates. */
-	channel_native_rate = MAX(ast_format_rate(ast_channel_rawwriteformat(bridge_channel->chan)),
-		ast_format_rate(ast_channel_rawreadformat(bridge_channel->chan)));
+	channel_native_rate = MAX(ast_format_get_sample_rate(ast_channel_rawwriteformat(bridge_channel->chan)),
+		ast_format_get_sample_rate(ast_channel_rawreadformat(bridge_channel->chan)));
 
 	if (channel_native_rate > stats->highest_supported_rate) {
 		stats->highest_supported_rate = channel_native_rate;
@@ -842,7 +853,7 @@
 	while (!softmix_data->stop && bridge->num_active) {
 		struct ast_bridge_channel *bridge_channel;
 		int timeout = -1;
-		enum ast_format_id cur_slin_id = ast_format_slin_by_rate(softmix_data->internal_rate);
+		struct ast_format *cur_slin = ast_format_cache_get_slin_by_rate(softmix_data->internal_rate);
 		unsigned int softmix_samples = SOFTMIX_SAMPLES(softmix_data->internal_rate, softmix_data->internal_mixing_interval);
 		unsigned int softmix_datalen = SOFTMIX_DATALEN(softmix_data->internal_rate, softmix_data->internal_mixing_interval);
 
@@ -854,12 +865,14 @@
 			ast_log(LOG_WARNING,
 				"Bridge %s: Conference mixing error, requested mixing length greater than mixing buffer.\n",
 				bridge->uniqueid);
+			ao2_ref(cur_slin, -1);
 			goto softmix_cleanup;
 		}
 
 		/* Grow the mixing array buffer as participants are added. */
 		if (mixing_array.max_num_entries < bridge->num_channels
 			&& softmix_mixing_array_grow(&mixing_array, bridge->num_channels + 5)) {
+			ao2_ref(cur_slin, -1);
 			goto softmix_cleanup;
 		}
 
@@ -924,8 +937,9 @@
 			ast_mutex_lock(&sc->lock);
 
 			/* Make SLINEAR write frame from local buffer */
-			if (sc->write_frame.subclass.format.id != cur_slin_id) {
-				ast_format_set(&sc->write_frame.subclass.format, cur_slin_id, 0);
+			if (sc->write_frame.subclass.format != cur_slin) {
+				ao2_cleanup(sc->write_frame.subclass.format);
+				sc->write_frame.subclass.format = ast_format_copy(cur_slin);
 			}
 			sc->write_frame.datalen = softmix_datalen;
 			sc->write_frame.samples = softmix_samples;
@@ -939,6 +953,8 @@
 			/* A frame is now ready for the channel. */
 			ast_bridge_channel_queue_frame(bridge_channel, &sc->write_frame);
 		}
+
+		ao2_ref(cur_slin, -1);
 
 		update_all_rates = 0;
 		if (!stat_iteration_counter) {
@@ -1141,17 +1157,17 @@
 
 static int unload_module(void)
 {
-	ast_format_cap_destroy(softmix_bridge.format_capabilities);
+	ao2_cleanup(softmix_bridge.format_capabilities);
+	softmix_bridge.format_capabilities = NULL;
 	return ast_bridge_technology_unregister(&softmix_bridge);
 }
 
 static int load_module(void)
 {
-	struct ast_format tmp;
-	if (!(softmix_bridge.format_capabilities = ast_format_cap_alloc(0))) {
+	if (!(softmix_bridge.format_capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_cap_add(softmix_bridge.format_capabilities, ast_format_set(&tmp, AST_FORMAT_SLINEAR, 0));
+	ast_format_cap_add(softmix_bridge.format_capabilities, ast_format_slin, 0);
 	return ast_bridge_technology_register(&softmix_bridge);
 }
 




More information about the asterisk-commits mailing list