[asterisk-commits] file: branch group/media_formats r411188 - in /team/group/media_formats: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 26 10:10:56 CDT 2014


Author: file
Date: Wed Mar 26 10:10:48 2014
New Revision: 411188

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411188
Log:
Moving on over.

Modified:
    team/group/media_formats/include/asterisk/smoother.h
    team/group/media_formats/main/smoother.c

Modified: team/group/media_formats/include/asterisk/smoother.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/smoother.h?view=diff&rev=411188&r1=411187&r2=411188
==============================================================================
--- team/group/media_formats/include/asterisk/smoother.h (original)
+++ team/group/media_formats/include/asterisk/smoother.h Wed Mar 26 10:10:48 2014
@@ -29,12 +29,7 @@
 extern "C" {
 #endif
 
-#include <sys/time.h>
-
-#include "asterisk/format_pref.h"
-#include "asterisk/format.h"
 #include "asterisk/endian.h"
-#include "asterisk/linkedlists.h"
 
 #define AST_SMOOTHER_FLAG_G729		(1 << 0)
 #define AST_SMOOTHER_FLAG_BE		(1 << 1)
@@ -56,6 +51,8 @@
 - Also see ast_smoother_test_flag(), ast_smoother_set_flags(), ast_smoother_get_flags(), ast_smoother_reset()
 */
 struct ast_smoother;
+
+struct ast_frame;
 
 struct ast_smoother *ast_smoother_new(int bytes);
 void ast_smoother_set_flags(struct ast_smoother *smoother, int flags);

Modified: team/group/media_formats/main/smoother.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/smoother.c?view=diff&rev=411188&r1=411187&r2=411188
==============================================================================
--- team/group/media_formats/main/smoother.c (original)
+++ team/group/media_formats/main/smoother.c Wed Mar 26 10:10:48 2014
@@ -32,24 +32,19 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/_private.h"
-#include "asterisk/lock.h"
 #include "asterisk/frame.h"
-#include "asterisk/channel.h"
-#include "asterisk/cli.h"
-#include "asterisk/term.h"
+#include "asterisk/astobj2.h"
+#include "asterisk/time.h"
 #include "asterisk/utils.h"
-#include "asterisk/threadstorage.h"
-#include "asterisk/linkedlists.h"
-#include "asterisk/translate.h"
-#include "asterisk/dsp.h"
-#include "asterisk/file.h"
+#include "asterisk/format.h"
+#include "asterisk/codec.h"
 #include "asterisk/smoother.h"
 
 #define SMOOTHER_SIZE 8000
 
 struct ast_smoother {
 	int size;
-	struct ast_format format;
+	struct ast_format *format;
 	int flags;
 	float samplesperbyte;
 	unsigned int opt_needs_swap:1;
@@ -85,6 +80,7 @@
 
 void ast_smoother_reset(struct ast_smoother *s, int bytes)
 {
+	ao2_cleanup(s->format);
 	memset(s, 0, sizeof(*s));
 	s->size = bytes;
 }
@@ -116,7 +112,7 @@
 	struct ast_smoother *s;
 	if (size < 1)
 		return NULL;
-	if ((s = ast_malloc(sizeof(*s))))
+	if ((s = ast_calloc(1, sizeof(*s))))
 		ast_smoother_reset(s, size);
 	return s;
 }
@@ -142,12 +138,12 @@
 		ast_log(LOG_WARNING, "Huh?  Can't smooth a non-voice frame!\n");
 		return -1;
 	}
-	if (!s->format.id) {
-		ast_format_copy(&s->format, &f->subclass.format);
+	if (!s->format) {
+		s->format = ast_format_copy(f->subclass.format);
 		s->samplesperbyte = (float)f->samples / (float)f->datalen;
-	} else if (ast_format_cmp(&s->format, &f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
+	} else if (ast_format_cmp(s->format, f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {
 		ast_log(LOG_WARNING, "Smoother was working on %s format frames, now trying to feed %s?\n",
-			ast_getformatname(&s->format), ast_getformatname(&f->subclass.format));
+			s->format->codec->name, f->subclass.format->codec->name);
 		return -1;
 	}
 	if (s->len + f->datalen > SMOOTHER_SIZE) {
@@ -198,7 +194,7 @@
 		len = s->len;
 	/* Make frame */
 	s->f.frametype = AST_FRAME_VOICE;
-	ast_format_copy(&s->f.subclass.format, &s->format);
+	s->f.subclass.format = s->format;
 	s->f.data.ptr = s->framedata + AST_FRIENDLY_OFFSET;
 	s->f.offset = AST_FRIENDLY_OFFSET;
 	s->f.datalen = len;
@@ -215,7 +211,8 @@
 		memmove(s->data, s->data + len, s->len);
 		if (!ast_tvzero(s->delivery)) {
 			/* If we have delivery time, increment it, otherwise, leave it at 0 */
-			s->delivery = ast_tvadd(s->delivery, ast_samp2tv(s->f.samples, ast_format_rate(&s->format)));
+			s->delivery = ast_tvadd(s->delivery, ast_samp2tv(s->f.samples,
+				s->format->codec->sample_rate));
 		}
 	}
 	/* Return frame */
@@ -224,6 +221,7 @@
 
 void ast_smoother_free(struct ast_smoother *s)
 {
+	ao2_cleanup(s->format);
 	ast_free(s);
 }
 




More information about the asterisk-commits mailing list