[asterisk-commits] kharwell: branch kharwell/pimp_sip_media_neg r386663 - /team/kharwell/pimp_si...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 26 16:24:13 CDT 2013


Author: kharwell
Date: Fri Apr 26 16:24:09 2013
New Revision: 386663

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386663
Log:
changed function name to start with GULP.  also refactored media write thread data allocation to on be on stack.

Modified:
    team/kharwell/pimp_sip_media_neg/channels/chan_gulp.c

Modified: team/kharwell/pimp_sip_media_neg/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_media_neg/channels/chan_gulp.c?view=diff&rev=386663&r1=386662&r2=386663
==============================================================================
--- team/kharwell/pimp_sip_media_neg/channels/chan_gulp.c (original)
+++ team/kharwell/pimp_sip_media_neg/channels/chan_gulp.c Fri Apr 26 16:24:09 2013
@@ -77,7 +77,7 @@
 			<para>Returns a properly formatted dial string for dialing all contacts on an AOR.</para>
 		</description>
 	</function>
-	<function name="MEDIA_OFFER" language="en_US">
+	<function name="GULP_MEDIA_OFFER" language="en_US">
 		<synopsis>
 			Media and codec offerings to be set on an outbound SIP channel prior to dialing.
 		</synopsis>
@@ -275,7 +275,7 @@
 		name = ast_getformatname(&fmt);
 
 		if (ast_strlen_zero(name)) {
-			ast_log(LOG_WARNING, "MEDIA_OFFER unrecognized format %s\n", name);
+			ast_log(LOG_WARNING, "GULP_MEDIA_OFFER unrecognized format %s\n", name);
 			continue;
 		}
 
@@ -302,37 +302,12 @@
 struct media_offer_data {
 	struct ast_sip_session *session;
 	enum ast_format_type media_type;
-	char value[0];
+	const char *value;
 };
 
-static void media_offer_data_destroy(void *obj)
+static int media_offer_write_av(void *obj)
 {
 	struct media_offer_data *data = obj;
-	ao2_ref(data->session, -1);
-}
-
-static struct media_offer_data* media_offer_data_create(struct ast_sip_session *session, const char *value,
-							enum ast_format_type media_type)
-{
-	int size = strlen(value) + 1;
-	struct media_offer_data *data = ao2_alloc(sizeof(*data)+size, media_offer_data_destroy);
-
-	if (!data) {
-		return NULL;
-	}
-
-	data->session = session;
-	data->media_type = media_type;
-	ast_copy_string(data->value, value, size);
-
-	ao2_ref(data->session, +1);
-	return data;
-}
-
-static int media_offer_write_av(void *obj)
-{
-	RAII_VAR(struct media_offer_data *, data, obj, ao2_cleanup);
-
 	int i;
 	struct ast_format fmt;
 	/* remove all of the given media type first */
@@ -363,23 +338,23 @@
 static int media_offer_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
 {
 	struct gulp_pvt *pvt = ast_channel_tech_pvt(chan);
-	struct media_offer_data *mdata = NULL;
+
+	struct media_offer_data mdata = {
+		.session = pvt->session,
+		.value = value
+	};
 
 	if (!strcmp(data, "audio")) {
-		mdata = media_offer_data_create(pvt->session, value, AST_FORMAT_TYPE_AUDIO);
+		mdata.media_type = AST_FORMAT_TYPE_AUDIO;
 	} else if (!strcmp(data, "video")) {
-		mdata = media_offer_data_create(pvt->session, value, AST_FORMAT_TYPE_VIDEO);
-	}
-
-	if (mdata && ast_sip_push_task_synchronous(pvt->session->serializer, media_offer_write_av, mdata)) {
-		ao2_ref(mdata, -1);
-		return -1;
-	}
-	return 0;
+		mdata.media_type = AST_FORMAT_TYPE_VIDEO;
+	}
+
+	return ast_sip_push_task_synchronous(pvt->session->serializer, media_offer_write_av, &mdata);
 }
 
 static struct ast_custom_function media_offer_function = {
-	.name = "MEDIA_OFFER",
+	.name = "GULP_MEDIA_OFFER",
 	.read = media_offer_read,
 	.write = media_offer_write
 };
@@ -1538,7 +1513,7 @@
 	}
 
 	if (ast_custom_function_register(&media_offer_function)) {
-		ast_log(LOG_WARNING, "Unable to register MEDIA_OFFER dialplan function\n");
+		ast_log(LOG_WARNING, "Unable to register GULP_MEDIA_OFFER dialplan function\n");
 	}
 
 	if (ast_sip_session_register_supplement(&gulp_supplement)) {




More information about the asterisk-commits mailing list