[asterisk-commits] coreyfarrell: branch group/media_formats-reviewed-trunk r417190 - in /team/gr...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 24 12:37:08 CDT 2014


Author: coreyfarrell
Date: Tue Jun 24 12:37:01 2014
New Revision: 417190

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417190
Log:
Media Formats fixes to enable compiling again since rebase to trunk

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

Modified:
    team/group/media_formats-reviewed-trunk/funcs/func_talkdetect.c
    team/group/media_formats-reviewed-trunk/main/channel.c
    team/group/media_formats-reviewed-trunk/main/cli.c
    team/group/media_formats-reviewed-trunk/main/codec_builtin.c
    team/group/media_formats-reviewed-trunk/main/manager.c
    team/group/media_formats-reviewed-trunk/res/res_fax_spandsp.c
    team/group/media_formats-reviewed-trunk/res/res_musiconhold.c
    team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c
    team/group/media_formats-reviewed-trunk/res/res_rtp_multicast.c
    team/group/media_formats-reviewed-trunk/tests/test_abstract_jb.c
    team/group/media_formats-reviewed-trunk/tests/test_format_cap.c
    team/group/media_formats-reviewed-trunk/tests/test_voicemail_api.c

Modified: team/group/media_formats-reviewed-trunk/funcs/func_talkdetect.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/funcs/func_talkdetect.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/funcs/func_talkdetect.c (original)
+++ team/group/media_formats-reviewed-trunk/funcs/func_talkdetect.c Tue Jun 24 12:37:01 2014
@@ -284,7 +284,7 @@
 		td_params->audiohook.manipulate_callback = talk_detect_audiohook_cb;
 		ast_set_flag(&td_params->audiohook, AST_AUDIOHOOK_TRIGGER_READ);
 
-		td_params->dsp = ast_dsp_new_with_rate(ast_format_rate(ast_channel_rawreadformat(chan)));
+		td_params->dsp = ast_dsp_new_with_rate(ast_format_get_sample_rate(ast_channel_rawreadformat(chan)));
 		if (!td_params->dsp) {
 			ast_datastore_free(datastore);
 			ast_free(td_params);

Modified: team/group/media_formats-reviewed-trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/channel.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/channel.c (original)
+++ team/group/media_formats-reviewed-trunk/main/channel.c Tue Jun 24 12:37:01 2014
@@ -2301,7 +2301,7 @@
 		ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE) ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), device_name);
 	}
 
-	ast_channel_nativeformats_set(chan, ast_format_cap_destroy(ast_channel_nativeformats(chan)));
+	ast_channel_nativeformats_set(chan, NULL);
 	if (callid) {
 		ast_callid_unref(callid);
 	}
@@ -3606,9 +3606,9 @@
 	 * We must generate frames in phase locked mode since
 	 * we have no internal timer available.
 	 */
-	if (ast_format_cmp(&f->subclass.format, ast_channel_writeformat(chan)) == AST_FORMAT_CMP_NOT_EQUAL) {
+	if (ast_format_cmp(f->subclass.format, ast_channel_writeformat(chan)) == AST_FORMAT_CMP_NOT_EQUAL) {
 		float factor;
-		factor = ((float) ast_format_get_sample_rate(ast_channel_writeformat(chan))) / ((float) ast_format_get_sample_rate(&f->subclass.format));
+		factor = ((float) ast_format_get_sample_rate(ast_channel_writeformat(chan))) / ((float) ast_format_get_sample_rate(f->subclass.format));
 		samples = (int) (((float) f->samples) * factor);
 	} else {
 		samples = f->samples;
@@ -5369,28 +5369,6 @@
 	return res;
 }
 
-int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
-{
-	struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
-	struct ast_format tmp_format;
-	int res;
-
-	if (!cap) {
-		return -1;
-	}
-	ast_format_cap_add(cap, ast_format_set(&tmp_format, id, 0));
-
-	res = set_format(chan,
-		cap,
-		ast_channel_rawreadformat(chan),
-		ast_channel_readformat(chan),
-		&set_format_readtrans,
-		0);
-
-	ast_format_cap_destroy(cap);
-	return res;
-}
-
 int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *cap)
 {
 	return set_format(chan,
@@ -5419,28 +5397,6 @@
 		1);
 
 	ao2_cleanup(cap);
-	return res;
-}
-
-int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
-{
-	struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK);
-	struct ast_format tmp_format;
-	int res;
-
-	if (!cap) {
-		return -1;
-	}
-	ast_format_cap_add(cap, ast_format_set(&tmp_format, id, 0));
-
-	res = set_format(chan,
-		cap,
-		ast_channel_rawwriteformat(chan),
-		ast_channel_writeformat(chan),
-		&set_format_writetrans,
-		1);
-
-	ast_format_cap_destroy(cap);
 	return res;
 }
 

Modified: team/group/media_formats-reviewed-trunk/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/cli.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/cli.c (original)
+++ team/group/media_formats-reviewed-trunk/main/cli.c Tue Jun 24 12:37:01 2014
@@ -1635,8 +1635,8 @@
 		ast_state2str(ast_channel_state(chan)),
 		ast_channel_state(chan),
 		ast_getformatname_multiple(nativeformats, sizeof(nativeformats), ast_channel_nativeformats(chan)),
-		ast_getformatname(ast_channel_writeformat(chan)),
-		ast_getformatname(ast_channel_readformat(chan)),
+		ast_format_get_name(ast_channel_writeformat(chan)),
+		ast_format_get_name(ast_channel_readformat(chan)),
 		ast_str_strlen(write_transpath) ? "Yes" : "No",
 		ast_str_buffer(write_transpath),
 		ast_str_strlen(read_transpath) ? "Yes" : "No",

Modified: team/group/media_formats-reviewed-trunk/main/codec_builtin.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/codec_builtin.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/codec_builtin.c (original)
+++ team/group/media_formats-reviewed-trunk/main/codec_builtin.c Tue Jun 24 12:37:01 2014
@@ -32,6 +32,7 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/logger.h"
+#include "asterisk/astobj2.h"
 #include "asterisk/codec.h"
 #include "asterisk/format.h"
 #include "asterisk/format_cache.h"
@@ -701,16 +702,28 @@
 #define CODEC_REGISTER_AND_CACHE(codec) \
 	({ \
 		int __res_ ## __LINE__ = 0; \
+		struct ast_format *__fmt_ ## __LINE__; \
+		struct ast_codec *__codec_ ## __LINE__; \
 		res |= __ast_codec_register(&(codec), NULL); \
-		res |= ast_format_cache_set((codec).name, ast_format_create(ast_codec_get((codec).name, (codec).type, (codec).sample_rate))); \
+		__codec_ ## __LINE__ = ast_codec_get((codec).name, (codec).type, (codec).sample_rate); \
+		__fmt_ ## __LINE__ = ast_format_create(__codec_ ## __LINE__); \
+		res |= ast_format_cache_set((codec).name, __fmt_ ## __LINE__); \
+		ao2_ref(__fmt_ ## __LINE__, -1); \
+		ao2_ref(__codec_ ## __LINE__, -1); \
 		__res_ ## __LINE__; \
 	})
 
 #define CODEC_REGISTER_AND_CACHE_NAMED(format_name, codec) \
 	({ \
 		int __res_ ## __LINE__ = 0; \
+		struct ast_format *__fmt_ ## __LINE__; \
+		struct ast_codec *__codec_ ## __LINE__; \
 		res |= __ast_codec_register(&(codec), NULL); \
-		res |= ast_format_cache_set((format_name), ast_format_create_named((format_name), ast_codec_get((codec).name, (codec).type, (codec).sample_rate))); \
+		__codec_ ## __LINE__ = ast_codec_get((codec).name, (codec).type, (codec).sample_rate); \
+		__fmt_ ## __LINE__ = ast_format_create_named((format_name), __codec_ ## __LINE__); \
+		res |= ast_format_cache_set((format_name), __fmt_ ## __LINE__); \
+		ao2_ref(__fmt_ ## __LINE__, -1); \
+		ao2_ref(__codec_ ## __LINE__, -1); \
 		__res_ ## __LINE__; \
 	})
 
@@ -758,4 +771,4 @@
 	res |= CODEC_REGISTER_AND_CACHE(t140);
 
 	return res;
-}
+}

Modified: team/group/media_formats-reviewed-trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/manager.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/manager.c (original)
+++ team/group/media_formats-reviewed-trunk/main/manager.c Tue Jun 24 12:37:01 2014
@@ -4005,9 +4005,9 @@
 			ast_channel_appl(chan),
 			ast_channel_data(chan),
 			ast_getformatname_multiple(nativeformats, sizeof(nativeformats), ast_channel_nativeformats(chan)),
-			ast_getformatname(ast_channel_readformat(chan)),
+			ast_format_get_name(ast_channel_readformat(chan)),
 			ast_translate_path_to_str(ast_channel_readtrans(chan), &read_transpath),
-			ast_getformatname(ast_channel_writeformat(chan)),
+			ast_format_get_name(ast_channel_writeformat(chan)),
 			ast_translate_path_to_str(ast_channel_writetrans(chan), &write_transpath),
 			ast_channel_callgroup(chan),
 			ast_channel_pickupgroup(chan),

Modified: team/group/media_formats-reviewed-trunk/res/res_fax_spandsp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/res/res_fax_spandsp.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/res/res_fax_spandsp.c (original)
+++ team/group/media_formats-reviewed-trunk/res/res_fax_spandsp.c Tue Jun 24 12:37:01 2014
@@ -662,20 +662,21 @@
 		return -1;
 	}
 
-	ast_debug(5, "frame={ datalen=%d, samples=%d, mallocd=%d, src=%s, flags=%u, ts=%ld, len=%ld, seqno=%d, data.ptr=%p, subclass.format.id=%u  }\n", f->datalen, f->samples, f->mallocd, f->src, f->flags, f->ts, f->len, f->seqno, f->data.ptr, f->subclass.format.id);
+	ast_debug(5, "frame={ datalen=%d, samples=%d, mallocd=%d, src=%s, flags=%u, ts=%ld, len=%ld, seqno=%d, data.ptr=%p, subclass.format=%s  }\n", f->datalen, f->samples, f->mallocd, f->src, f->flags, f->ts, f->len, f->seqno, f->data.ptr, ast_format_get_name(f->subclass.format));
 
 	/* slinear frame can be passed to spandsp */
-	if (f->subclass.format.id == AST_FORMAT_SLINEAR) {
+	if (ast_format_cmp(f->subclass.format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
 		modem_connect_tones_rx(p->tone_state, f->data.ptr, f->samples);
 
 	/* alaw/ulaw frame must be converted to slinear before passing to spandsp */
-	} else if (f->subclass.format.id == AST_FORMAT_ALAW || f->subclass.format.id == AST_FORMAT_ULAW) {
+	} else if (ast_format_cmp(f->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL ||
+	           ast_format_cmp(f->subclass.format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
 		if (!(slndata = ast_malloc(sizeof(*slndata) * f->samples))) {
 			return -1;
 		}
-		decoder = g711_init(NULL, (f->subclass.format.id == AST_FORMAT_ALAW ? G711_ALAW : G711_ULAW));
+		decoder = g711_init(NULL, (ast_format_cmp(f->subclass.format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL ? G711_ALAW : G711_ULAW));
 		g711_decode(decoder, slndata, f->data.ptr, f->samples);
-		ast_debug(5, "spandsp transcoding frame from %s to slinear for v21 detection\n", (f->subclass.format.id == AST_FORMAT_ALAW ? "G711_ALAW" : "G711_ULAW"));
+		ast_debug(5, "spandsp transcoding frame from %s to slinear for v21 detection\n", ast_format_get_name(f->subclass.format));
 		modem_connect_tones_rx(p->tone_state, slndata, f->samples);
 		g711_release(decoder);
 #if SPANDSP_RELEASE_DATE >= 20090220
@@ -685,7 +686,7 @@
 
 	/* frame in other formats cannot be passed to spandsp, it could cause segfault */
 	} else {
-		ast_log(LOG_WARNING, "Unknown frame format %u, v.21 detection skipped\n", f->subclass.format.id);
+		ast_log(LOG_WARNING, "Frame format %s not supported, v.21 detection skipped\n", ast_format_get_name(f->subclass.format));
 		return -1;
 	}
 

Modified: team/group/media_formats-reviewed-trunk/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/res/res_musiconhold.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/res/res_musiconhold.c (original)
+++ team/group/media_formats-reviewed-trunk/res/res_musiconhold.c Tue Jun 24 12:37:01 2014
@@ -769,7 +769,7 @@
 			res = 8 * MOH_MS_INTERVAL; /* 800/100 = 8 samples/ms */
 		}
 		/* For non-8000Hz formats, we need to alter the resolution */
-		res = res * ast_format_rate(&class->format) / 8000;
+		res = res * ast_format_get_sample_rate(class->format) / 8000;
 
 		if ((strncasecmp(class->dir, "http://", 7) && strcasecmp(class->dir, "nodir")) && AST_LIST_EMPTY(&class->members))
 			continue;

Modified: team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c (original)
+++ team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c Tue Jun 24 12:37:01 2014
@@ -738,7 +738,7 @@
 		return -1;
 	}
 
-	if (media_type == AST_FORMAT_TYPE_AUDIO) {
+	if (media_type == AST_MEDIA_TYPE_AUDIO) {
 		apply_packetization(session, session_media, stream);
 	}
 

Modified: team/group/media_formats-reviewed-trunk/res/res_rtp_multicast.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/res/res_rtp_multicast.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/res/res_rtp_multicast.c (original)
+++ team/group/media_formats-reviewed-trunk/res/res_rtp_multicast.c Tue Jun 24 12:37:01 2014
@@ -53,6 +53,7 @@
 #include "asterisk/unaligned.h"
 #include "asterisk/module.h"
 #include "asterisk/rtp_engine.h"
+#include "asterisk/format_cache.h"
 
 /*! Command value used for Linksys paging to indicate we are starting */
 #define LINKSYS_MCAST_STARTCMD 6
@@ -144,7 +145,8 @@
 
 static int rtp_get_rate(struct ast_format *format)
 {
-        return (format->id == AST_FORMAT_G722) ? 8000 : ast_format_rate(format);
+	return ast_format_cmp(format, ast_format_g722) == AST_FORMAT_CMP_EQUAL ?
+		8000 : ast_format_get_sample_rate(format);
 }
 
 static unsigned int calc_txstamp(struct multicast_rtp *rtp, struct timeval *delivery)
@@ -237,7 +239,7 @@
 	int hdrlen = 12, res = 0, codec;
 	unsigned char *rtpheader;
 	unsigned int ms = calc_txstamp(multicast, &frame->delivery);
-	int rate = rtp_get_rate(&frame->subclass.format) / 1000;
+	int rate = rtp_get_rate(frame->subclass.format) / 1000;
 
 	/* We only accept audio, nothing else */
 	if (frame->frametype != AST_FRAME_VOICE) {
@@ -245,7 +247,7 @@
 	}
 
 	/* Grab the actual payload number for when we create the RTP packet */
-	if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, &frame->subclass.format, 0)) < 0) {
+	if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, frame->subclass.format, 0)) < 0) {
 		return -1;
 	}
 

Modified: team/group/media_formats-reviewed-trunk/tests/test_abstract_jb.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/tests/test_abstract_jb.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/tests/test_abstract_jb.c (original)
+++ team/group/media_formats-reviewed-trunk/tests/test_abstract_jb.c Tue Jun 24 12:37:01 2014
@@ -43,6 +43,7 @@
 #include "asterisk/test.h"
 #include "asterisk/abstract_jb.h"
 #include "asterisk/frame.h"
+#include "asterisk/format_cache.h"
 
 #define DEFAULT_FRAME_MS 160
 #define DEFAULT_CONFIG_FLAGS 0
@@ -85,7 +86,7 @@
 {
 	struct ast_frame f = {0};
 
-	f.subclass.format.id = AST_FORMAT_SLINEAR;
+	f.subclass.format = ast_format_slin;
 	f.frametype = AST_FRAME_VOICE;
 	f.src = "TEST";
 	f.ts = timestamp;

Modified: team/group/media_formats-reviewed-trunk/tests/test_format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/tests/test_format_cap.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/tests/test_format_cap.c (original)
+++ team/group/media_formats-reviewed-trunk/tests/test_format_cap.c Tue Jun 24 12:37:01 2014
@@ -327,7 +327,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (ast_format_cap_append(dst_caps, src_caps)) {
+	if (ast_format_cap_append_by_type(dst_caps, src_caps, AST_MEDIA_TYPE_UNKNOWN)) {
 		ast_test_status_update(test, "Failed to append formats to capabilities structure\n");
 		return AST_TEST_FAIL;
 	} else if (!ast_format_cap_has_type(dst_caps, AST_MEDIA_TYPE_AUDIO)) {

Modified: team/group/media_formats-reviewed-trunk/tests/test_voicemail_api.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/tests/test_voicemail_api.c?view=diff&rev=417190&r1=417189&r2=417190
==============================================================================
--- team/group/media_formats-reviewed-trunk/tests/test_voicemail_api.c (original)
+++ team/group/media_formats-reviewed-trunk/tests/test_voicemail_api.c Tue Jun 24 12:37:01 2014
@@ -43,6 +43,7 @@
 #include "asterisk/paths.h"
 #include "asterisk/channel.h"
 #include "asterisk/app.h"
+#include "asterisk/format_cache.h"
 
 /*!
  * \internal
@@ -825,12 +826,12 @@
 		return NULL;
 	}
 
-	ast_format_set(ast_channel_writeformat(mock_channel), AST_FORMAT_GSM, 0);
+	ast_channel_set_writeformat(mock_channel, ast_format_gsm);
 	native_formats = ast_channel_nativeformats(mock_channel);
-	ast_format_cap_add(native_formats, ast_channel_writeformat(mock_channel));
-	ast_format_set(ast_channel_rawwriteformat(mock_channel), AST_FORMAT_GSM, 0);
-	ast_format_set(ast_channel_readformat(mock_channel), AST_FORMAT_GSM, 0);
-	ast_format_set(ast_channel_rawreadformat(mock_channel), AST_FORMAT_GSM, 0);
+	ast_format_cap_add(native_formats, ast_channel_writeformat(mock_channel), 0);
+	ast_channel_set_rawwriteformat(mock_channel, ast_format_gsm);
+	ast_channel_set_readformat(mock_channel, ast_format_gsm);
+	ast_channel_set_rawreadformat(mock_channel, ast_format_gsm);
 	ast_channel_tech_set(mock_channel, &mock_channel_tech);
 
 	ast_channel_unlock(mock_channel);




More information about the asterisk-commits mailing list