[svn-commits] file: branch group/media_formats r408329 - in /team/group/media_formats: addo...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Feb 19 05:32:00 CST 2014


Author: file
Date: Wed Feb 19 05:31:57 2014
New Revision: 408329

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=408329
Log:
Move some addons over.

Modified:
    team/group/media_formats/addons/chan_mobile.c
    team/group/media_formats/addons/format_mp3.c
    team/group/media_formats/channels/chan_phone.c

Modified: team/group/media_formats/addons/chan_mobile.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/addons/chan_mobile.c?view=diff&rev=408329&r1=408328&r2=408329
==============================================================================
--- team/group/media_formats/addons/chan_mobile.c (original)
+++ team/group/media_formats/addons/chan_mobile.c Wed Feb 19 05:31:57 2014
@@ -73,15 +73,15 @@
 #include "asterisk/app.h"
 #include "asterisk/manager.h"
 #include "asterisk/io.h"
+#include "asterisk/smoother.h"
+#include "asterisk/format_cache.h"
 
 #define MBL_CONFIG "chan_mobile.conf"
 #define MBL_CONFIG_OLD "mobile.conf"
 
 #define DEVICE_FRAME_SIZE 48
-#define DEVICE_FRAME_FORMAT AST_FORMAT_SLINEAR
+#define DEVICE_FRAME_FORMAT ast_format_slin
 #define CHANNEL_FRAME_SIZE 320
-
-static struct ast_format prefformat;
 
 static int discovery_interval = 60;			/* The device discovery interval, default 60 seconds. */
 static pthread_t discovery_thread = AST_PTHREADT_NULL;	/* The discovery thread */
@@ -840,7 +840,6 @@
 static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num,
 		const struct ast_channel *requestor)
 {
-
 	struct ast_channel *chn;
 
 	pvt->answered = 0;
@@ -862,11 +861,11 @@
 	}
 
 	ast_channel_tech_set(chn, &mbl_tech);
-	ast_format_cap_add(ast_channel_nativeformats(chn), &prefformat);
-	ast_format_copy(ast_channel_rawreadformat(chn), &prefformat);
-	ast_format_copy(ast_channel_rawwriteformat(chn), &prefformat);
-	ast_format_copy(ast_channel_writeformat(chn), &prefformat);
-	ast_format_copy(ast_channel_readformat(chn), &prefformat);
+	ast_channel_nativeformats_set(chn, mbl_tech.capabilities);
+	ast_channel_set_rawreadformat(chn, DEVICE_FRAME_FORMAT);
+	ast_channel_set_rawwriteformat(chn, DEVICE_FRAME_FORMAT);
+	ast_channel_set_writeformat(chn, DEVICE_FRAME_FORMAT);
+	ast_channel_set_readformat(chn, DEVICE_FRAME_FORMAT);
 	ast_channel_tech_pvt_set(chn, pvt);
 
 	if (state == AST_STATE_RING)
@@ -902,7 +901,7 @@
 		return NULL;
 	}
 
-	if (!(ast_format_cap_iscompatible(cap, &prefformat))) {
+	if (!(ast_format_cap_iscompatible_format(cap, DEVICE_FRAME_FORMAT))) {
 		char tmp[256];
 		ast_log(LOG_WARNING, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap));
 		*cause = AST_CAUSE_FACILITY_NOT_IMPLEMENTED;
@@ -1116,7 +1115,7 @@
 
 	memset(&pvt->fr, 0x00, sizeof(struct ast_frame));
 	pvt->fr.frametype = AST_FRAME_VOICE;
-	ast_format_set(&pvt->fr.subclass.format, DEVICE_FRAME_FORMAT, 0);
+	pvt->fr.subclass.format = ast_format_copy(DEVICE_FRAME_FORMAT);
 	pvt->fr.src = "Mobile";
 	pvt->fr.offset = AST_FRIENDLY_OFFSET;
 	pvt->fr.mallocd = 0;
@@ -1131,6 +1130,7 @@
 			pvt->sco_socket = -1;
 			ast_channel_set_fd(ast, 0, -1);
 		}
+		ao2_ref(pvt->fr.subclass.format, -1);
 		goto e_return;
 	}
 
@@ -4697,7 +4697,8 @@
 	if (sdp_session)
 		sdp_close(sdp_session);
 
-	mbl_tech.capabilities = ast_format_cap_destroy(mbl_tech.capabilities);
+	ao2_ref(mbl_tech.capabilities, -1);
+	mbl_tech.capabilities = NULL;
 	return 0;
 }
 
@@ -4706,11 +4707,11 @@
 
 	int dev_id, s;
 
-	if (!(mbl_tech.capabilities = ast_format_cap_alloc(0))) {
+	if (!(mbl_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	ast_format_set(&prefformat, DEVICE_FRAME_FORMAT, 0);
-	ast_format_cap_add(mbl_tech.capabilities, &prefformat);
+
+	ast_format_cap_add(mbl_tech.capabilities, DEVICE_FRAME_FORMAT, 0);
 	/* Check if we have Bluetooth, no point loading otherwise... */
 	dev_id = hci_get_route(NULL);
 	s = hci_open_dev(dev_id);

Modified: team/group/media_formats/addons/format_mp3.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/addons/format_mp3.c?view=diff&rev=408329&r1=408328&r2=408329
==============================================================================
--- team/group/media_formats/addons/format_mp3.c (original)
+++ team/group/media_formats/addons/format_mp3.c Wed Feb 19 05:31:57 2014
@@ -42,6 +42,7 @@
 #include "asterisk/module.h"
 #include "asterisk/mod_format.h"
 #include "asterisk/logger.h"
+#include "asterisk/format_cache.h"
 
 #define MP3_BUFLEN 320
 #define MP3_SCACHE 16384
@@ -229,10 +230,7 @@
 
 	p->offset += p->buflen;
 	delay = p->buflen / 2;
-	s->fr.frametype = AST_FRAME_VOICE;
-	ast_format_set(&s->fr.subclass.format, AST_FORMAT_SLINEAR, 0);
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, p->buflen);
-	s->fr.mallocd = 0;
 	s->fr.samples = delay;
 	*whennext = delay;
 	return &s->fr;
@@ -318,7 +316,7 @@
 
 static int load_module(void)
 {
-	ast_format_set(&mp3_f.format, AST_FORMAT_SLINEAR, 0);
+	mp3_f.format = ast_format_slin;
 	InitMP3Constants();
 	return ast_format_def_register(&mp3_f);
 }

Modified: team/group/media_formats/channels/chan_phone.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_phone.c?view=diff&rev=408329&r1=408328&r2=408329
==============================================================================
--- team/group/media_formats/channels/chan_phone.c (original)
+++ team/group/media_formats/channels/chan_phone.c Wed Feb 19 05:31:57 2014
@@ -615,7 +615,7 @@
 	p->fr.frametype = p->lastinput->codec->type == AST_MEDIA_TYPE_AUDIO ?
 		AST_FRAME_VOICE : p->lastinput->codec->type == AST_MEDIA_TYPE_IMAGE ?
 		AST_FRAME_IMAGE : AST_FRAME_VIDEO;
-	p->fr.subclass.format = p->lastinput;
+	p->fr.subclass.format = ast_format_copy(p->lastinput);
 	p->fr.offset = AST_FRIENDLY_OFFSET;
 	/* Byteswap from little-endian to native-endian */
 	if (ast_format_cmp(p->fr.subclass.format, ast_format_slin) == AST_FORMAT_CMP_EQUAL)




More information about the svn-commits mailing list