[asterisk-commits] kharwell: branch group/media_formats-reviewed r411765 - in /team/group/media_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 4 15:28:06 CDT 2014


Author: kharwell
Date: Fri Apr  4 15:27:58 2014
New Revision: 411765

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411765
Log:
media_formats: move app.c and file.c over

This moves app.c and file.c over to the media formats API.

(issue SWP-6726)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/3413/

Modified:
    team/group/media_formats-reviewed/include/asterisk/format.h
    team/group/media_formats-reviewed/main/app.c
    team/group/media_formats-reviewed/main/file.c

Modified: team/group/media_formats-reviewed/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/include/asterisk/format.h?view=diff&rev=411765&r1=411764&r2=411765
==============================================================================
--- team/group/media_formats-reviewed/include/asterisk/format.h (original)
+++ team/group/media_formats-reviewed/include/asterisk/format.h Fri Apr  4 15:27:58 2014
@@ -294,4 +294,22 @@
  */
 unsigned int ast_format_determine_length(const struct ast_format *format, unsigned int samples);
 
+/*!
+ * \since 12
+ * \brief Get the message type used for signaling a format registration
+ *
+ * \retval Stasis message type for format registration
+ * \retval NULL on error
+ */
+struct stasis_message_type *ast_format_register_type(void);
+
+/*!
+ * \since 12
+ * \brief Get the message type used for signaling a format unregistration
+ *
+ * \retval Stasis message type for format unregistration
+ * \retval NULL on error
+ */
+struct stasis_message_type *ast_format_unregister_type(void);
+
 #endif /* _AST_FORMAT_H */

Modified: team/group/media_formats-reviewed/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/app.c?view=diff&rev=411765&r1=411764&r2=411765
==============================================================================
--- team/group/media_formats-reviewed/main/app.c (original)
+++ team/group/media_formats-reviewed/main/app.c Fri Apr  4 15:27:58 2014
@@ -70,6 +70,7 @@
 #include "asterisk/stasis.h"
 #include "asterisk/stasis_channels.h"
 #include "asterisk/json.h"
+#include "asterisk/format_cache.h"
 
 #define MWI_TOPIC_BUCKETS 57
 
@@ -765,16 +766,18 @@
 	int fd;
 	int autoclose;
 	int allowoverride;
-	struct ast_format origwfmt;
+	struct ast_format *origwfmt;
 };
 
 static void linear_release(struct ast_channel *chan, void *params)
 {
 	struct linear_state *ls = params;
 
-	if (ls->origwfmt.id && ast_set_write_format(chan, &ls->origwfmt)) {
-		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", ast_channel_name(chan), ls->origwfmt.id);
-	}
+	if (ls->origwfmt && ast_set_write_format(chan, ls->origwfmt)) {
+		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%s'\n",
+			ast_channel_name(chan), ast_format_get_name(ls->origwfmt));
+	}
+	ao2_cleanup(ls->origwfmt);
 
 	if (ls->autoclose) {
 		close(ls->fd);
@@ -794,7 +797,7 @@
 	};
 	int res;
 
-	ast_format_set(&f.subclass.format, AST_FORMAT_SLINEAR, 0);
+	f.subclass.format = ast_format_slin;
 
 	len = samples * 2;
 	if (len > sizeof(buf) - AST_FRIENDLY_OFFSET) {
@@ -828,10 +831,11 @@
 		ast_clear_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT);
 	}
 
-	ast_format_copy(&ls->origwfmt, ast_channel_writeformat(chan));
-
-	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
+	ls->origwfmt = ast_format_copy(ast_channel_writeformat(chan));
+
+	if (ast_set_write_format(chan, ast_format_slin)) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", ast_channel_name(chan));
+		ao2_cleanup(ls->origwfmt);
 		ast_free(ls);
 		ls = params = NULL;
 	}
@@ -1107,7 +1111,7 @@
 		return NULL;
 	}
 
-	if (orig->subclass.format.id != AST_FORMAT_SLINEAR) {
+	if (ast_format_cmp(orig->subclass.format, ast_format_slin) == AST_FORMAT_CMP_NOT_EQUAL) {
 		ast_log(LOG_WARNING, "Attempting to silence non-slin frame\n");
 		return NULL;
 	}
@@ -1134,7 +1138,7 @@
 	silence->samples = samples;
 	silence->datalen = datalen;
 
-	ast_format_set(&silence->subclass.format, AST_FORMAT_SLINEAR, 0);
+	silence->subclass.format = ast_format_slin;
 
 	return silence;
 }
@@ -1149,13 +1153,13 @@
  * \return 0 on success.
  * \return -1 on error.
  */
-static int set_read_to_slin(struct ast_channel *chan, struct ast_format *orig_format)
+static int set_read_to_slin(struct ast_channel *chan, struct ast_format **orig_format)
 {
 	if (!chan || !orig_format) {
 		return -1;
 	}
-	ast_format_copy(orig_format, ast_channel_readformat(chan));
-	return ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
+	*orig_format = ast_format_copy(ast_channel_readformat(chan));
+	return ast_set_read_format(chan, ast_format_slin);
 }
 
 static int global_silence_threshold = 128;
@@ -1197,7 +1201,7 @@
 	int totalsilence = 0;
 	int dspsilence = 0;
 	int olddspsilence = 0;
-	struct ast_format rfmt;
+	struct ast_format *rfmt = NULL;
 	struct ast_silence_generator *silgen = NULL;
 	char prependfile[PATH_MAX];
 	int ioflags;	/* IO flags for writing output file */
@@ -1216,7 +1220,6 @@
 		break;
 	}
 
-	ast_format_clear(&rfmt);
 	if (silencethreshold < 0) {
 		silencethreshold = global_silence_threshold;
 	}
@@ -1291,6 +1294,7 @@
 		if (res < 0) {
 			ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
 			ast_dsp_free(sildet);
+			ao2_cleanup(rfmt);
 			return -1;
 		}
 	}
@@ -1441,7 +1445,7 @@
 					 * set the mode, if we haven't already
 					 * for sildet
 					 */
-					if (muted && !rfmt.id) {
+					if (muted && !rfmt) {
 						ast_verb(3, "Setting read format to linear mode\n");
 						res = set_read_to_slin(chan, &rfmt);
 						if (res < 0) {
@@ -1561,9 +1565,10 @@
 			ast_filedelete(prependfile, sfmt[x]);
 		}
 	}
-	if (rfmt.id && ast_set_read_format(chan, &rfmt)) {
-		ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(&rfmt), ast_channel_name(chan));
-	}
+	if (rfmt && ast_set_read_format(chan, rfmt)) {
+		ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_format_get_name(rfmt), ast_channel_name(chan));
+	}
+	ao2_cleanup(rfmt);
 	if ((outmsg == 2) && (!skip_confirmation_sound)) {
 		ast_stream_and_wait(chan, "auth-thankyou", "");
 	}

Modified: team/group/media_formats-reviewed/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed/main/file.c?view=diff&rev=411765&r1=411764&r2=411765
==============================================================================
--- team/group/media_formats-reviewed/main/file.c (original)
+++ team/group/media_formats-reviewed/main/file.c Fri Apr  4 15:27:58 2014
@@ -189,8 +189,8 @@
 	if (ast_channel_stream(tmp)) {
 		ast_closestream(ast_channel_stream(tmp));
 		ast_channel_stream_set(tmp, NULL);
-		if (ast_channel_oldwriteformat(tmp)->id && ast_set_write_format(tmp, ast_channel_oldwriteformat(tmp)))
-			ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(ast_channel_oldwriteformat(tmp)));
+		if (ast_channel_oldwriteformat(tmp) && ast_set_write_format(tmp, ast_channel_oldwriteformat(tmp)))
+			ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_format_get_name(ast_channel_oldwriteformat(tmp)));
 	}
 	/* Stop the video stream too */
 	if (ast_channel_vstream(tmp) != NULL) {
@@ -207,10 +207,10 @@
 {
 	int res = -1;
 	if (f->frametype == AST_FRAME_VIDEO) {
-		if (AST_FORMAT_GET_TYPE(fs->fmt->format.id) == AST_FORMAT_TYPE_AUDIO) {
+		if (ast_format_get_type(fs->fmt->format) == AST_MEDIA_TYPE_AUDIO) {
 			/* This is the audio portion.  Call the video one... */
 			if (!fs->vfs && fs->filename) {
-				const char *type = ast_getformatname(&f->subclass.format);
+				const char *type = ast_format_get_name(f->subclass.format);
 				fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode);
 				ast_debug(1, "Opened video output file\n");
 			}
@@ -223,7 +223,7 @@
 		ast_log(LOG_WARNING, "Tried to write non-voice frame\n");
 		return -1;
 	}
-	if (ast_format_cmp(&f->subclass.format, &fs->fmt->format) != AST_FORMAT_CMP_NOT_EQUAL) {
+	if (ast_format_cmp(f->subclass.format, fs->fmt->format) != AST_FORMAT_CMP_NOT_EQUAL) {
 		res =  fs->fmt->write(fs, f);
 		if (res < 0)
 			ast_log(LOG_WARNING, "Natural write failed\n");
@@ -232,18 +232,20 @@
 	} else {
 		/* XXX If they try to send us a type of frame that isn't the normal frame, and isn't
 		       the one we've setup a translator for, we do the "wrong thing" XXX */
-		if (fs->trans && (ast_format_cmp(&f->subclass.format, &fs->lastwriteformat) != AST_FORMAT_CMP_EQUAL)) {
+		if (fs->trans && (ast_format_cmp(f->subclass.format, fs->lastwriteformat) != AST_FORMAT_CMP_EQUAL)) {
 			ast_translator_free_path(fs->trans);
 			fs->trans = NULL;
 		}
-		if (!fs->trans)
-			fs->trans = ast_translator_build_path(&fs->fmt->format, &f->subclass.format);
-		if (!fs->trans)
+		if (!fs->trans) {
+			fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass.format);
+		}
+		if (!fs->trans) {
 			ast_log(LOG_WARNING, "Unable to translate to format %s, source format %s\n",
-				fs->fmt->name, ast_getformatname(&f->subclass.format));
-		else {
+				fs->fmt->name, ast_format_get_name(f->subclass.format));
+		} else {
 			struct ast_frame *trf;
-			ast_format_copy(&fs->lastwriteformat, &f->subclass.format);
+			ao2_cleanup(fs->lastwriteformat);
+			fs->lastwriteformat = ast_format_copy(f->subclass.format);
 			/* Get the translated frame but don't consume the original in case they're using it on another stream */
 			if ((trf = ast_translate(fs->trans, f, 0))) {
 				struct ast_frame *cur;
@@ -349,7 +351,7 @@
  */
 static void filestream_close(struct ast_filestream *f)
 {
-	enum ast_format_type format_type = AST_FORMAT_GET_TYPE(f->fmt->format.id);
+	enum ast_media_type format_type = ast_format_get_type(f->fmt->format);
 
 	if (!f->owner) {
 		return;
@@ -358,12 +360,12 @@
 	/* Stop a running stream if there is one */
 	switch (format_type)
 	{
-	case AST_FORMAT_TYPE_AUDIO:
+	case AST_MEDIA_TYPE_AUDIO:
 		ast_channel_stream_set(f->owner, NULL);
 		AST_SCHED_DEL_ACCESSOR(ast_channel_sched(f->owner), f->owner, ast_channel_streamid, ast_channel_streamid_set);
 		ast_settimeout(f->owner, 0, NULL, NULL);
 		break;
-	case AST_FORMAT_TYPE_VIDEO:
+	case AST_MEDIA_TYPE_VIDEO:
 		ast_channel_vstream_set(f->owner, NULL);
 		AST_SCHED_DEL_ACCESSOR(ast_channel_sched(f->owner), f->owner, ast_channel_vstreamid, ast_channel_vstreamid_set);
 		break;
@@ -418,6 +420,8 @@
 	}
 	if (f->orig_chan_name)
 		free((void *) f->orig_chan_name);
+	ao2_cleanup(f->lastwriteformat);
+	ao2_cleanup(f->fr.subclass.format);
 	ast_module_unref(f->fmt->module);
 }
 
@@ -436,6 +440,15 @@
 	if (fmt->buf_size)
 		s->buf = (char *)(s + 1);
 	s->fr.src = fmt->name;
+
+	if (ast_format_get_type(fmt->format) == AST_MEDIA_TYPE_AUDIO) {
+		s->fr.frametype = AST_FRAME_VOICE;
+	} else if (ast_format_get_type(fmt->format) == AST_MEDIA_TYPE_VIDEO) {
+		s->fr.frametype = AST_FRAME_VIDEO;
+	}
+	s->fr.mallocd = 0;
+	s->fr.subclass.format = ast_format_copy(fmt->format);
+
 	return s;
 }
 
@@ -529,9 +542,9 @@
 				FILE *bfile;
 				struct ast_filestream *s;
 
-				if ((ast_format_cmp(ast_channel_writeformat(chan), &f->format) == AST_FORMAT_CMP_NOT_EQUAL) &&
-				     !(((AST_FORMAT_GET_TYPE(f->format.id) == AST_FORMAT_TYPE_AUDIO) && fmt) ||
-					  ((AST_FORMAT_GET_TYPE(f->format.id) == AST_FORMAT_TYPE_VIDEO) && fmt))) {
+				if ((ast_format_cmp(ast_channel_writeformat(chan), f->format) == AST_FORMAT_CMP_NOT_EQUAL) &&
+				     !(((ast_format_get_type(f->format) == AST_MEDIA_TYPE_AUDIO) && fmt) ||
+					  ((ast_format_get_type(f->format) == AST_MEDIA_TYPE_VIDEO) && fmt))) {
 					ast_free(fn);
 					continue;	/* not a supported format */
 				}
@@ -559,7 +572,7 @@
 				s->fmt = f;
 				s->trans = NULL;
 				s->filename = NULL;
-				if (AST_FORMAT_GET_TYPE(s->fmt->format.id) == AST_FORMAT_TYPE_AUDIO) {
+				if (ast_format_get_type(s->fmt->format) == AST_MEDIA_TYPE_AUDIO) {
 					if (ast_channel_stream(chan))
 						ast_closestream(ast_channel_stream(chan));
 					ast_channel_stream_set(chan, s);
@@ -579,7 +592,7 @@
 				/* if arg2 is present, it is a format capabilities structure.
 				 * Add this format to the set of formats this file can be played in */
 				if (arg2) {
-					ast_format_cap_add((struct ast_format_cap *) arg2, &f->format);
+					ast_format_cap_add((struct ast_format_cap *) arg2, f->format, 0);
 				}
 				res = 1; /* file does exist and format it exists in is returned in arg2 */
 				break;
@@ -749,23 +762,23 @@
 	buflen = strlen(preflang) + strlen(filename) + 4;
 	buf = ast_alloca(buflen);
 
-	if (!(file_fmt_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
+	if (!(file_fmt_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return NULL;
 	}
 	if (!fileexists_core(filename, NULL, preflang, buf, buflen, file_fmt_cap) ||
-		!ast_format_cap_has_type(file_fmt_cap, AST_FORMAT_TYPE_AUDIO)) {
+		!ast_format_cap_has_type(file_fmt_cap, AST_MEDIA_TYPE_AUDIO)) {
 
 		ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename);
-		file_fmt_cap = ast_format_cap_destroy(file_fmt_cap);
+		ao2_ref(file_fmt_cap, -1);
 		return NULL;
 	}
 
 	/* Set the channel to a format we can work with and save off the previous format. */
-	ast_format_copy(ast_channel_oldwriteformat(chan), ast_channel_writeformat(chan));
+	ast_channel_set_oldwriteformat(chan, ast_channel_writeformat(chan));
 	/* Set the channel to the best format that exists for the file. */
 	res = ast_set_write_format_from_cap(chan, file_fmt_cap);
 	/* don't need this anymore now that the channel's write format is set. */
-	file_fmt_cap = ast_format_cap_destroy(file_fmt_cap);
+	ao2_ref(file_fmt_cap, -1);
 
 	if (res == -1) {	/* No format available that works with this channel */
 		return NULL;
@@ -781,50 +794,50 @@
 	/* As above, but for video. But here we don't have translators
 	 * so we must enforce a format.
 	 */
-	struct ast_format tmp_fmt;
 	struct ast_format_cap *tmp_cap;
 	char *buf;
 	int buflen;
-	const char *fmt;
-	int fd;
-
-	if (preflang == NULL)
+	int i, fd;
+
+	if (preflang == NULL) {
 		preflang = "";
+	}
 	buflen = strlen(preflang) + strlen(filename) + 4;
 	buf = ast_alloca(buflen);
 
 	/* is the channel capable of video without translation ?*/
-	if (!ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_VIDEO)) {
+	if (!ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_MEDIA_TYPE_VIDEO)) {
 		return NULL;
 	}
-	if (!(tmp_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
+	if (!(tmp_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return NULL;
 	}
 	/* Video is supported, so see what video formats exist for this file */
 	if (!fileexists_core(filename, NULL, preflang, buf, buflen, tmp_cap)) {
-		tmp_cap = ast_format_cap_destroy(tmp_cap);
+		ao2_ref(tmp_cap, -1);
 		return NULL;
 	}
 
 	/* iterate over file formats and pick the first one compatible with the channel's native formats */
-	ast_format_cap_iter_start(tmp_cap);
-	while (!ast_format_cap_iter_next(tmp_cap, &tmp_fmt)) {
-		fmt = ast_getformatname(&tmp_fmt);
-		if ((AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_VIDEO) ||
-			!ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &tmp_fmt)) {
+	for (i = 0; i < ast_format_cap_count(tmp_cap); ++i) {
+		struct ast_format *format = ast_format_cap_get_format(tmp_cap, i);
+
+		if ((ast_format_get_type(format) != AST_MEDIA_TYPE_VIDEO) ||
+			!ast_format_cap_iscompatible(ast_channel_nativeformats(chan), tmp_cap)) {
+			ao2_ref(format, -1);
 			continue;
 		}
 
-		fd = filehelper(buf, chan, fmt, ACTION_OPEN);
+		fd = filehelper(buf, chan, ast_format_get_name(format), ACTION_OPEN);
 		if (fd >= 0) {
-			ast_format_cap_iter_end(tmp_cap);
-			tmp_cap = ast_format_cap_destroy(tmp_cap);
+			ao2_ref(format, -1);
+			ao2_ref(tmp_cap, -1);
 			return ast_channel_vstream(chan);
 		}
 		ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename);
-	}
-	ast_format_cap_iter_end(tmp_cap);
-	tmp_cap = ast_format_cap_destroy(tmp_cap);
+		ao2_ref(format, -1);
+	}
+	ao2_ref(tmp_cap, -1);
 
 	return NULL;
 }
@@ -897,14 +910,14 @@
 
 	if (whennext != s->lasttimeout) {
 		if (ast_channel_timingfd(s->owner) > -1) {
-			float samp_rate = (float) ast_format_rate(&s->fmt->format);
+			float samp_rate = (float) ast_format_get_sample_rate(s->fmt->format);
 			unsigned int rate;
 
 			rate = (unsigned int) roundf(samp_rate / ((float) whennext));
 
 			ast_settimeout_full(s->owner, rate, ast_fsread_audio, s, 1);
 		} else {
-			ast_channel_streamid_set(s->owner, ast_sched_add(ast_channel_sched(s->owner), whennext / (ast_format_rate(&s->fmt->format) / 1000), ast_fsread_audio, s));
+			ast_channel_streamid_set(s->owner, ast_sched_add(ast_channel_sched(s->owner), whennext / (ast_format_get_sample_rate(s->fmt->format) / 1000), ast_fsread_audio, s));
 		}
 		s->lasttimeout = whennext;
 		return FSREAD_SUCCESS_NOSCHED;
@@ -954,7 +967,7 @@
 	}
 
 	if (whennext != s->lasttimeout) {
-		ast_channel_vstreamid_set(s->owner, ast_sched_add(ast_channel_sched(s->owner), whennext / (ast_format_rate(&s->fmt->format) / 1000), ast_fsread_video, s));
+		ast_channel_vstreamid_set(s->owner, ast_sched_add(ast_channel_sched(s->owner), whennext / (ast_format_get_sample_rate(s->fmt->format) / 1000), ast_fsread_video, s));
 		s->lasttimeout = whennext;
 		return FSREAD_SUCCESS_NOSCHED;
 	}
@@ -985,7 +998,7 @@
 {
 	enum fsread_res res;
 
-	if (AST_FORMAT_GET_TYPE(s->fmt->format.id) == AST_FORMAT_TYPE_AUDIO)
+	if (ast_format_get_type(s->fmt->format) == AST_MEDIA_TYPE_AUDIO)
 		res = ast_readaudio_callback(s);
 	else
 		res = ast_readvideo_callback(s);
@@ -1096,7 +1109,7 @@
 
 	vfs = ast_openvstream(chan, filename, preflang);
 	if (vfs) {
-		ast_debug(1, "Ooh, found a video stream, too, format %s\n", ast_getformatname(&vfs->fmt->format));
+		ast_debug(1, "Ooh, found a video stream, too, format %s\n", ast_format_get_name(vfs->fmt->format));
 	}
 
 	if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_MASQ_NOSTREAM))
@@ -1108,7 +1121,7 @@
 	res = ast_playstream(fs);
 	if (!res && vfs)
 		res = ast_playstream(vfs);
-	ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", ast_channel_name(chan), filename, ast_getformatname(ast_channel_writeformat(chan)), preflang ? preflang : "default");
+	ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", ast_channel_name(chan), filename, ast_format_get_name(ast_channel_writeformat(chan)), preflang ? preflang : "default");
 
 	return res;
 }
@@ -1330,7 +1343,7 @@
 	}
 
 	if (cb) {
-		long ms_len = ast_tellstream(ast_channel_stream(c)) / (ast_format_rate(&ast_channel_stream(c)->fmt->format) / 1000);
+		long ms_len = ast_tellstream(ast_channel_stream(c)) / (ast_format_get_sample_rate(ast_channel_stream(c)->fmt->format) / 1000);
 		cb(c, ms_len, type);
 	}
 
@@ -1373,7 +1386,7 @@
 		orig_chan_name = ast_strdupa(ast_channel_name(c));
 
 	if (ast_channel_stream(c) && cb) {
-		long ms_len = ast_tellstream(ast_channel_stream(c)) / (ast_format_rate(&ast_channel_stream(c)->fmt->format) / 1000);
+		long ms_len = ast_tellstream(ast_channel_stream(c)) / (ast_format_get_sample_rate(ast_channel_stream(c)->fmt->format) / 1000);
 		cb(c, ms_len, AST_WAITSTREAM_CB_START);
 	}
 
@@ -1722,7 +1735,7 @@
 
 	AST_RWLIST_RDLOCK(&formats);
 	AST_RWLIST_TRAVERSE(&formats, f, list) {
-		ast_cli(a->fd, FORMAT2, ast_getformatname(&f->format), f->name, f->exts);
+		ast_cli(a->fd, FORMAT2, ast_format_get_name(f->format), f->name, f->exts);
 		count_fmt++;
 	}
 	AST_RWLIST_UNLOCK(&formats);
@@ -1738,7 +1751,7 @@
 	SCOPED_RDLOCK(lock, &formats.lock);
 	AST_RWLIST_TRAVERSE(&formats, f, list) {
 		if (exts_compare(f->exts, file_ext)) {
-			return &f->format;
+			return f->format;
 		}
 	}
 




More information about the asterisk-commits mailing list