[asterisk-commits] kharwell: branch kharwell/pimp_sip_video r384455 - in /team/kharwell/pimp_sip...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 1 10:17:57 CDT 2013


Author: kharwell
Date: Mon Apr  1 10:17:54 2013
New Revision: 384455

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384455
Log:
updates from review

Added:
    team/kharwell/pimp_sip_video/res/res_sip_sdp_rtp.c
      - copied, changed from r384429, team/kharwell/pimp_sip_video/res/res_sip_sdp_audio_video.c
Removed:
    team/kharwell/pimp_sip_video/res/res_sip_sdp_audio_video.c
Modified:
    team/kharwell/pimp_sip_video/channels/chan_gulp.c

Modified: team/kharwell/pimp_sip_video/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/channels/chan_gulp.c?view=diff&rev=384455&r1=384454&r2=384455
==============================================================================
--- team/kharwell/pimp_sip_video/channels/chan_gulp.c (original)
+++ team/kharwell/pimp_sip_video/channels/chan_gulp.c Mon Apr  1 10:17:54 2013
@@ -438,7 +438,7 @@
 		ast_format_cap_copy(ast_channel_nativeformats(chan), session->req_caps);
 	}
 
-	ast_codec_choose(&session->endpoint->prefs, session->endpoint->codecs, 1, &fmt);
+	ast_codec_choose(&session->endpoint->prefs, ast_channel_nativeformats(chan), 1, &fmt);
 	ast_format_copy(ast_channel_writeformat(chan), &fmt);
 	ast_format_copy(ast_channel_rawwriteformat(chan), &fmt);
 	ast_format_copy(ast_channel_readformat(chan), &fmt);
@@ -498,6 +498,7 @@
 	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
 	struct ast_frame *f;
 	struct ast_sip_session_media *media = NULL;
+	int rtcp = 0;
 	int fdno = ast_channel_fdno(ast);
 
 	switch (fdno) {
@@ -506,12 +507,14 @@
 		break;
 	case 1:
 		media = pvt->media[SIP_MEDIA_AUDIO];
+		rtcp = 1;
 		break;
 	case 2:
 		media = pvt->media[SIP_MEDIA_VIDEO];
 		break;
 	case 3:
 		media = pvt->media[SIP_MEDIA_VIDEO];
+		rtcp = 1;
 		break;
 	}
 
@@ -519,22 +522,7 @@
 		return &ast_null_frame;
 	}
 
-	switch (fdno) {
-	case 0:
-		f = ast_rtp_instance_read(media->rtp, 0);
-		break;
-	case 1:
-		f = ast_rtp_instance_read(media->rtp, 1);
-		break;
-	case 2:
-		f = ast_rtp_instance_read(media->rtp, 0);
-		break;
-	case 3:
-		f = ast_rtp_instance_read(media->rtp, 1);
-		break;
-	default:
-		f = &ast_null_frame;
-	}
+	f = ast_rtp_instance_read(media->rtp, rtcp);
 
 	if (f && f->frametype == AST_FRAME_VOICE) {
 		if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
@@ -687,7 +675,7 @@
 		"  </vc_primitive>\r\n"
 		" </media_control>\r\n";
 
-	struct ast_sip_body body = {
+	const struct ast_sip_body body = {
 		.type = "application",
 		.subtype = "media_control+xml",
 		.body_text = xml

Copied: team/kharwell/pimp_sip_video/res/res_sip_sdp_rtp.c (from r384429, team/kharwell/pimp_sip_video/res/res_sip_sdp_audio_video.c)
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_video/res/res_sip_sdp_rtp.c?view=diff&rev=384455&p1=team/kharwell/pimp_sip_video/res/res_sip_sdp_audio_video.c&r1=384429&p2=team/kharwell/pimp_sip_video/res/res_sip_sdp_rtp.c&r2=384455
==============================================================================
--- team/kharwell/pimp_sip_video/res/res_sip_sdp_audio_video.c (original)
+++ team/kharwell/pimp_sip_video/res/res_sip_sdp_rtp.c Mon Apr  1 10:17:54 2013
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2013, Digium, Inc.
  *
+ * Joshua Colp <jcolp at digium.com>
  * Kevin Harwell <kharwell at digium.com>
  *
  * See http://www.asterisk.org for more information about
@@ -18,7 +19,7 @@
 
 /*! \file
  *
- * \author Kevin Harwell <kharwell at digium.com>
+ * \author Joshua Colp <jcolp at digium.com>
  *
  * \brief SIP SDP media stream handling
  */
@@ -70,7 +71,7 @@
 {
 	if (!strcasecmp(stream_type, STR_AUDIO)) {
 		return AST_FORMAT_TYPE_AUDIO;
-	} else	if (!strcasecmp(stream_type, STR_VIDEO)) {
+	} else if (!strcasecmp(stream_type, STR_VIDEO)) {
 		return AST_FORMAT_TYPE_VIDEO;
 	}
 
@@ -132,6 +133,7 @@
 	int i, num = 0;
 	char name[256];
 	char media[20];
+	char fmt_param[256];
 
 	ast_rtp_codecs_payloads_initialize(codecs);
 
@@ -161,8 +163,8 @@
 		if ((pjmedia_sdp_attr_get_fmtp(attr, &fmtp)) == PJ_SUCCESS) {
 			sscanf(pj_strbuf(&fmtp.fmt), "%d", &num);
 			if ((format = ast_rtp_codecs_get_payload_format(codecs, num))) {
-				ast_copy_pj_str(name, &fmtp.fmt_param, sizeof(name));
-				ast_format_sdp_parse(format, name);
+				ast_copy_pj_str(fmt_param, &fmtp.fmt_param, sizeof(fmt_param));
+				ast_format_sdp_parse(format, fmt_param);
 			}
 		}
 	}
@@ -428,26 +430,28 @@
 {
 	pjmedia_sdp_attr *attr;
 	/* Apply packetization if available and configured to do so */
-	if (session->endpoint->use_ptime && (attr = pjmedia_sdp_media_find_attr2(remote_stream, "ptime", NULL))) {
-		pj_str_t value = attr->value;
-		unsigned long framing = pj_strtoul(pj_strltrim(&value));
-		int codec;
-		struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(session_media->rtp)->pref;
-
-		for (codec = 0; codec < AST_RTP_MAX_PT; codec++) {
-			struct ast_rtp_payload_type format = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(
-												   session_media->rtp), codec);
-
-			if (!format.asterisk_format) {
-				continue;
-			}
-
-			ast_codec_pref_setsize(pref, &format.format, framing);
-		}
-
-		ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(session_media->rtp),
-						 session_media->rtp, pref);
-	}
+	if (!session->endpoint->use_ptime || !(attr = pjmedia_sdp_media_find_attr2(remote_stream, "ptime", NULL))) {
+		return;
+	}
+
+	pj_str_t value = attr->value;
+	unsigned long framing = pj_strtoul(pj_strltrim(&value));
+	int codec;
+	struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(session_media->rtp)->pref;
+
+	for (codec = 0; codec < AST_RTP_MAX_PT; codec++) {
+		struct ast_rtp_payload_type format = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(
+											   session_media->rtp), codec);
+
+		if (!format.asterisk_format) {
+			continue;
+		}
+
+		ast_codec_pref_setsize(pref, &format.format, framing);
+	}
+
+	ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(session_media->rtp),
+					 session_media->rtp, pref);
 }
 
 /*! \brief Function which negotiates an incoming media stream */
@@ -550,12 +554,10 @@
 		return -1;
 	}
 
-	if (ast_format_cap_is_empty(session->req_caps)) {
-		if (direct_media_enabled) {
-			ast_format_cap_joint_copy(session->endpoint->codecs, session->direct_media_cap, caps);
-		} else {
-			ast_format_cap_copy(caps, session->endpoint->codecs);
-		}
+	if (direct_media_enabled) {
+		ast_format_cap_joint_copy(session->endpoint->codecs, session->direct_media_cap, caps);
+	} else if (ast_format_cap_is_empty(session->req_caps)) {
+		ast_format_cap_copy(caps, session->endpoint->codecs);
 	} else {
 		ast_format_cap_joint_copy(session->endpoint->codecs, session->req_caps, caps);
 	}
@@ -680,6 +682,7 @@
 	/* If ICE support is enabled find all the needed attributes */
 	process_ice_attributes(session, session_media, remote, remote_stream);
 
+	/* audio stream handles music on hold */
 	if (media_type != AST_FORMAT_TYPE_AUDIO) {
 		return 1;
 	}
@@ -760,11 +763,15 @@
 	struct pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
 	pjsip_tx_data *tdata;
 
-	if (!pj_strcmp2(&rdata->msg_info.msg->body->content_type.type, "application") &&
-	    !pj_strcmp2(&rdata->msg_info.msg->body->content_type.subtype, "media_control+xml")) {
-		ast_queue_control(session->channel, AST_CONTROL_VIDUPDATE);
-
-		pjsip_dlg_create_response(session->inv_session->dlg, rdata, 200, NULL, &tdata);
+	if (pj_strcmp2(&rdata->msg_info.msg->body->content_type.type, "application") ||
+	    pj_strcmp2(&rdata->msg_info.msg->body->content_type.subtype, "media_control+xml")) {
+
+		return 0;
+	}
+
+	ast_queue_control(session->channel, AST_CONTROL_VIDUPDATE);
+
+	if (pjsip_dlg_create_response(session->inv_session->dlg, rdata, 200, NULL, &tdata) == PJ_SUCCESS) {
 		pjsip_dlg_send_response(session->inv_session->dlg, tsx, tdata);
 	}
 
@@ -775,6 +782,20 @@
 	.method = "INFO",
 	.incoming_request = video_info_incoming_request,
 };
+
+/*! \brief Unloads the sdp RTP/AVP module from Asterisk */
+static int unload_module(void)
+{
+	ast_sip_session_unregister_supplement(&video_info_supplement);
+	ast_sip_session_unregister_sdp_handler(&video_sdp_handler, STR_VIDEO);
+	ast_sip_session_unregister_sdp_handler(&audio_sdp_handler, STR_AUDIO);
+
+	if (sched) {
+		ast_sched_context_destroy(sched);
+	}
+
+	return 0;
+}
 
 /*!
  * \brief Load the module
@@ -815,24 +836,12 @@
 
 	return AST_MODULE_LOAD_SUCCESS;
 end:
-	if (sched) {
-		ast_sched_context_destroy(sched);
-	}
+	unload_module();
 
 	return AST_MODULE_LOAD_FAILURE;
 }
 
-/*! \brief Unload the Gulp channel from Asterisk */
-static int unload_module(void)
-{
-	ast_sip_session_unregister_supplement(&video_info_supplement);
-	ast_sip_session_unregister_sdp_handler(&video_sdp_handler, STR_VIDEO);
-	ast_sip_session_unregister_sdp_handler(&audio_sdp_handler, STR_AUDIO);
-	ast_sched_context_destroy(sched);
-	return 0;
-}
-
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SIP SDP Media Stream Handler",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SIP SDP RTP/AVP stream handler",
 		.load = load_module,
 		.unload = unload_module,
 		.load_pri = AST_MODPRI_CHANNEL_DRIVER,




More information about the asterisk-commits mailing list