[asterisk-commits] file: branch group/media_formats r407986 - in /team/group/media_formats: func...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 12 12:15:46 CST 2014


Author: file
Date: Wed Feb 12 12:15:38 2014
New Revision: 407986

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407986
Log:
Dialplan functions: Woot!

Modified:
    team/group/media_formats/funcs/func_channel.c
    team/group/media_formats/funcs/func_frame_trace.c
    team/group/media_formats/funcs/func_pitchshift.c
    team/group/media_formats/funcs/func_speex.c
    team/group/media_formats/include/asterisk/format_cap.h
    team/group/media_formats/main/format_cap_ng.c
    team/group/media_formats/tests/test_format_cap.c

Modified: team/group/media_formats/funcs/func_channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/funcs/func_channel.c?view=diff&rev=407986&r1=407985&r2=407986
==============================================================================
--- team/group/media_formats/funcs/func_channel.c (original)
+++ team/group/media_formats/funcs/func_channel.c Wed Feb 12 12:15:38 2014
@@ -424,21 +424,25 @@
 	if (!strcasecmp(data, "audionativeformat")) {
 		char tmp[512];
 
-		if ((tmpcap = ast_format_cap_get_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_AUDIO))) {
+		tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+		if (tmpcap) {
+			ast_format_cap_append_by_type(tmpcap, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_AUDIO);
 			ast_copy_string(buf, ast_getformatname_multiple(tmp, sizeof(tmp), tmpcap), len);
-			tmpcap = ast_format_cap_destroy(tmpcap);
+			ao2_ref(tmpcap, -1);
 		}
 	} else if (!strcasecmp(data, "videonativeformat")) {
 		char tmp[512];
 
-		if ((tmpcap = ast_format_cap_get_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO))) {
+		tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+		if (tmpcap) {
+			ast_format_cap_append_by_type(tmpcap, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_VIDEO);
 			ast_copy_string(buf, ast_getformatname_multiple(tmp, sizeof(tmp), tmpcap), len);
-			tmpcap = ast_format_cap_destroy(tmpcap);
+			ao2_ref(tmpcap, -1);
 		}
 	} else if (!strcasecmp(data, "audioreadformat")) {
-		ast_copy_string(buf, ast_getformatname(ast_channel_readformat(chan)), len);
+		ast_copy_string(buf, ast_channel_readformat(chan)->codec->name, len);
 	} else if (!strcasecmp(data, "audiowriteformat")) {
-		ast_copy_string(buf, ast_getformatname(ast_channel_writeformat(chan)), len);
+		ast_copy_string(buf, ast_channel_writeformat(chan)->codec->name, len);
 #ifdef CHANNEL_TRACE
 	} else if (!strcasecmp(data, "trace")) {
 		ast_channel_lock(chan);

Modified: team/group/media_formats/funcs/func_frame_trace.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/funcs/func_frame_trace.c?view=diff&rev=407986&r1=407985&r2=407986
==============================================================================
--- team/group/media_formats/funcs/func_frame_trace.c (original)
+++ team/group/media_formats/funcs/func_frame_trace.c Wed Feb 12 12:15:38 2014
@@ -214,14 +214,14 @@
 		break;
 	case AST_FRAME_VOICE:
 		ast_verbose("FrameType: VOICE\n");
-		ast_verbose("Codec: %s\n", ast_getformatname(&frame->subclass.format));
+		ast_verbose("Codec: %s\n", frame->subclass.format->codec->name);
 		ast_verbose("MS: %ld\n", frame->len);
 		ast_verbose("Samples: %d\n", frame->samples);
 		ast_verbose("Bytes: %d\n", frame->datalen);
 		break;
 	case AST_FRAME_VIDEO:
 		ast_verbose("FrameType: VIDEO\n");
-		ast_verbose("Codec: %s\n", ast_getformatname(&frame->subclass.format));
+		ast_verbose("Codec: %s\n", frame->subclass.format->codec->name);
 		ast_verbose("MS: %ld\n", frame->len);
 		ast_verbose("Samples: %d\n", frame->samples);
 		ast_verbose("Bytes: %d\n", frame->datalen);

Modified: team/group/media_formats/funcs/func_pitchshift.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/funcs/func_pitchshift.c?view=diff&rev=407986&r1=407985&r2=407986
==============================================================================
--- team/group/media_formats/funcs/func_pitchshift.c (original)
+++ team/group/media_formats/funcs/func_pitchshift.c Wed Feb 12 12:15:38 2014
@@ -172,9 +172,7 @@
 	if (!f) {
 		return 0;
 	}
-	if ((audiohook->status == AST_AUDIOHOOK_STATUS_DONE) ||
-		(f->frametype != AST_FRAME_VOICE) ||
-		!(ast_format_is_slinear(&f->subclass.format))) {
+	if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE) {
 		return -1;
 	}
 
@@ -484,7 +482,7 @@
 		return 0;
 	}
 	for (samples = 0; samples < f->samples; samples += 32) {
-		smb_pitch_shift(amount, 32, MAX_FRAME_LENGTH, 32, ast_format_rate(&f->subclass.format), fun+samples, fun+samples, fft);
+		smb_pitch_shift(amount, 32, MAX_FRAME_LENGTH, 32, f->subclass.format->codec->sample_rate, fun+samples, fun+samples, fft);
 	}
 
 	return 0;

Modified: team/group/media_formats/funcs/func_speex.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/funcs/func_speex.c?view=diff&rev=407986&r1=407985&r2=407986
==============================================================================
--- team/group/media_formats/funcs/func_speex.c (original)
+++ team/group/media_formats/funcs/func_speex.c Wed Feb 12 12:15:38 2014
@@ -165,8 +165,8 @@
 		return -1;
 	}
 
-	if ((sdi->samples != frame->samples) || (ast_format_rate(&frame->subclass.format) != si->lastrate)) {
-		si->lastrate = ast_format_rate(&frame->subclass.format);
+	if ((sdi->samples != frame->samples) || (frame->subclass.format->codec->sample_rate != si->lastrate)) {
+		si->lastrate = frame->subclass.format->codec->sample_rate;
 		if (sdi->state) {
 			speex_preprocess_state_destroy(sdi->state);
 		}

Modified: team/group/media_formats/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_cap.h?view=diff&rev=407986&r1=407985&r2=407986
==============================================================================
--- team/group/media_formats/include/asterisk/format_cap.h (original)
+++ team/group/media_formats/include/asterisk/format_cap.h Wed Feb 12 12:15:38 2014
@@ -89,15 +89,18 @@
 int ast_format_cap_add_all_by_type(struct ast_format_cap *cap, enum ast_media_type type);
 
 /*!
- * \brief Append the formats in src to dst
+ * \brief Append the formats of provided type in src to dst
  *
  * \param dst The destination capabilities structure
  * \param src The source capabilities structure
- *
- * \retval 0 success
- * \retval -1 failure
- */
-int ast_format_cap_append(struct ast_format_cap *dst, const struct ast_format_cap *src);
+ * \param type The type of formats to append.
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ *
+ * \note If AST_MEDIA_TYPE_UNKNOWN is passed as the type all known codecs will be added.
+ */
+int ast_format_cap_append_by_type(struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type);
 
 /*!
  * \brief Get the number of formats present within the capabilities structure

Modified: team/group/media_formats/main/format_cap_ng.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/format_cap_ng.c?view=diff&rev=407986&r1=407985&r2=407986
==============================================================================
--- team/group/media_formats/main/format_cap_ng.c (original)
+++ team/group/media_formats/main/format_cap_ng.c Wed Feb 12 12:15:38 2014
@@ -189,14 +189,17 @@
 	return 0;
 }
 
-int ast_format_cap_ng_append(struct ast_format_cap *dst, const struct ast_format_cap *src)
+int ast_format_cap_ng_append_by_type(struct ast_format_cap *dst, const struct ast_format_cap *src,
+	enum ast_media_type type)
 {
 	int idx, res = 0;
 
 	for (idx = 0; (idx < AST_VECTOR_SIZE(&src->preference_order)) && !res; ++idx) {
 		struct format_cap_framed *framed = AST_VECTOR_GET(&src->preference_order, idx);
 
-		res = ast_format_cap_ng_add(dst, framed->format, framed->framing);
+		if (type == AST_MEDIA_TYPE_UNKNOWN || framed->format->codec->type == type) {
+			res = ast_format_cap_ng_add(dst, framed->format, framed->framing);
+		}
 	}
 
 	return res;

Modified: team/group/media_formats/tests/test_format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/tests/test_format_cap.c?view=diff&rev=407986&r1=407985&r2=407986
==============================================================================
--- team/group/media_formats/tests/test_format_cap.c (original)
+++ team/group/media_formats/tests/test_format_cap.c Wed Feb 12 12:15:38 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)) {




More information about the asterisk-commits mailing list