[svn-commits] oej: branch oej/codename-pineapple r47208 - in /team/oej/codename-pineapple/c...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sat Nov 4 15:13:27 MST 2006


Author: oej
Date: Sat Nov  4 16:13:27 2006
New Revision: 47208

URL: http://svn.digium.com/view/asterisk?rev=47208&view=rev
Log:
Updates

Modified:
    team/oej/codename-pineapple/channels/chan_sip3.c
    team/oej/codename-pineapple/channels/sip3/sip3.h
    team/oej/codename-pineapple/channels/sip3/sip3_cliami.c
    team/oej/codename-pineapple/channels/sip3/sip3_dialog.c
    team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
    team/oej/codename-pineapple/channels/sip3/sip3funcs.h

Modified: team/oej/codename-pineapple/channels/chan_sip3.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_sip3.c?rev=47208&r1=47207&r2=47208&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/chan_sip3.c (original)
+++ team/oej/codename-pineapple/channels/chan_sip3.c Sat Nov  4 16:13:27 2006
@@ -152,12 +152,14 @@
 	- manager command renamed - SIPdevices and SIPshowdevice
 	- Added "authuser" configuration option for trunks and services
 	- Added "domain" configuration option for all devices
+	- Fixed handling of too short registration times (sending 423)
 
 	Halfdone
 	- Added separate TOS setting for presence. Need to run setsockopt
 	  in a locked socket for that to work on the SIP interface.
 
 	Todo
+	- check resp 491 to INVITE processing
 	- Make show devices and the completion support domains too
 	- Fix realtime caching and optional loading
 	- Clean up the authuser/username/peername mess!
@@ -360,6 +362,7 @@
 #include "asterisk/udptl.h"
 #include "asterisk/acl.h"
 #include "asterisk/manager.h"
+#include "asterisk/translate.h"
 #include "asterisk/callerid.h"
 #include "asterisk/cli.h"
 #include "asterisk/app.h"
@@ -395,8 +398,6 @@
 	.default_expiry = DEFAULT_DEFAULT_EXPIRY,
 	.expiry = DEFAULT_EXPIRY,		/*!< Is this ever used ??? */
 };
-
-static int usecnt = 0;
 
 /* Default setttings are used as a channel setting and as a default when
    configuring devices */
@@ -980,7 +981,6 @@
 		ast_string_field_set(dialog, fromdomain, device->fromdomain);
 	if (!ast_strlen_zero(device->fromuser))
 		ast_string_field_set(dialog, fromuser, device->fromuser);
-	dialog->maxtime = device->maxms;
 	dialog->callgroup = device->callgroup;
 	dialog->pickupgroup = device->pickupgroup;
 	dialog->allowtransfer = device->allowtransfer;
@@ -1155,16 +1155,17 @@
 	res = update_call_counter(p, INC_CALL_RINGING);
 	if ( res != -1 ) {
 		p->callingpres = ast->cid.cid_pres;
-		p->jointcapability = p->capability;
-		p->t38.jointcapability = p->t38.capability;
-		if (option_debug)
-			ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
-		transmit_invite(p, SIP_INVITE, 1, 2);
-		if (p->maxtime)
-			/* Initialize auto-congest time */
-			p->initid = ast_sched_add(sched, p->maxtime * 4, auto_congest, p);
-		else 
+		p->jointcapability = ast_translate_available_formats(p->capability, p->prefcodec);
+		if (!(p->jointcapability & AST_FORMAT_AUDIO_MASK)) {	
+			ast_log(LOG_WARNING, "No audio formats found to offer. Cancelling call to %s\n", p->username);
+			res = -1;
+		} else {
+			p->t38.jointcapability = p->t38.capability;
+			if (option_debug)
+				ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
+			transmit_invite(p, SIP_INVITE, 1, 2);
 			p->initid = ast_sched_add(sched, SIP_TRANS_TIMEOUT, auto_congest, p);
+		}
 	}
 	return res;
 }
@@ -1328,9 +1329,6 @@
 	p->owner = NULL;
 	ast->tech_pvt = NULL;
 
-	ast_atomic_fetchadd_int(&usecnt, -1);
-	ast_update_use_count();
-
 	/* Do not destroy this pvt until we have timeout or
 	   get an answer to the BYE or INVITE/CANCEL 
 	   If we get no answer during retransmit period, drop the call anyway.
@@ -1844,8 +1842,6 @@
 	if (!ast_strlen_zero(dialog->language))
 		ast_string_field_set(tmp, language, dialog->language);
 	dialog->owner = tmp;
-	ast_atomic_fetchadd_int(&usecnt, 1);
-	ast_update_use_count();
 	ast_copy_string(tmp->context, dialog->context, sizeof(tmp->context));
 	ast_copy_string(tmp->exten, dialog->exten, sizeof(tmp->exten));
 
@@ -2049,11 +2045,17 @@
 		const struct sip_request *req, enum xmittype reliable)
 {
 	struct sip_request resp;
+	char buf[12];
+
 	respprep(&resp, p, msg, req);
 	append_date(&resp);
 	switch (attach) {
 	case WITH_DATE:
 		add_header_contentLength(&resp, 0);
+		break;
+	case WITH_MINEXPIRY:
+		snprintf(buf, sizeof(buf), "%d", expiry.min_expiry);
+		add_header(&resp, "Min-Expires", buf);
 		break;
 	case WITH_ALLOW:
 		add_header(&resp, "Accept", "application/sdp");
@@ -3226,6 +3228,8 @@
 			localexpiry = expiry.default_expiry;
 		}
 	}
+	if (localexpiry < expiry.min_expiry)
+		return PARSE_REGISTER_FAILED_MINEXPIRY;
 
 	/* Look for brackets */
 	curi = contact;
@@ -3318,8 +3322,8 @@
 		ast_sched_del(sched, peer->expire);
 	if (localexpiry > expiry.max_expiry)
 		localexpiry = expiry.max_expiry;
-	if (localexpiry < expiry.min_expiry)
-		localexpiry = expiry.min_expiry;
+	//if (localexpiry < expiry.min_expiry)
+		//localexpiry = expiry.min_expiry;
 	peer->expire = ast_test_flag(&peer->flags[0], SIP_REALTIME) ? -1 :
 		ast_sched_add(sched, (localexpiry + 10) * 1000, expire_register, peer);
 	pvt->expiry = localexpiry;
@@ -3619,6 +3623,11 @@
 				/* We have a succesful registration attemp with proper authentication,
 				   now, update the peer */
 				switch (parse_register_contact(p, peer, req)) {
+				case PARSE_REGISTER_FAILED_MINEXPIRY:
+					transmit_response_with_attachment(WITH_MINEXPIRY, p, "423 Interval too small", req, XMIT_UNRELIABLE);
+					peer->lastmsgssent = -1;
+					res = 0;
+					break;
 				case PARSE_REGISTER_FAILED:
 					ast_log(LOG_WARNING, "Failed to parse contact info\n");
 					transmit_response_with_attachment(WITH_DATE, p, "400 Bad Request", req, XMIT_UNRELIABLE);
@@ -3649,6 +3658,10 @@
 			ASTOBJ_CONTAINER_LINK(&devicelist, peer);
 			sip_cancel_destroy(p);
 			switch (parse_register_contact(p, peer, req)) {
+			case PARSE_REGISTER_FAILED_MINEXPIRY:
+				transmit_response_with_attachment(WITH_MINEXPIRY, p, "423 Interval too small", req, XMIT_UNRELIABLE);
+				peer->lastmsgssent = -1;
+				res = 0;
 			case PARSE_REGISTER_FAILED:
 				ast_log(LOG_WARNING, "Failed to parse contact info\n");
 				transmit_response_with_attachment(WITH_DATE, p, "400 Bad Request", req, XMIT_UNRELIABLE);
@@ -4992,7 +5005,8 @@
 			ast_log(LOG_DEBUG, "SIP response %d to standard invite\n", resp);
 	}
 
-	if (ast_test_flag(&p->flags[0], SIP_ALREADYGONE)) { /* This call is already gone */
+	//sif (ast_test_flag(&p->flags[0], SIP_ALREADYGONE)) { /* This call is already gone */
+	if (p->state == DIALOG_STATE_TERMINATED) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
 		return;
@@ -5013,6 +5027,10 @@
 	    (resp != 180) &&
 	    (resp != 183))
 		resp = 183;
+
+	if (p->state == DIALOG_STATE_TRYING)
+		dialogstatechange(p, DIALOG_STATE_PROCEEDING);	/* We do have any type of response */
+	/* If we got 1xx reply WITH tag, it has to be DIALOG_STATE_EARLY */
 
 	switch (resp) {
 	case 100:	/* Trying */
@@ -5050,12 +5068,14 @@
 				ast_queue_control(p->owner, AST_CONTROL_PROGRESS);
 			}
 		}
+		dialogstatechange(p, DIALOG_STATE_EARLY);	/* We do have any type of response */
 		ast_set_flag(&p->flags[0], SIP_CAN_BYE);
 		check_pendings(p);
 		break;
 	case 200:	/* 200 OK on invite - someone's answering our call */
 		if (!ast_test_flag(req, SIP_PKT_IGNORE))
 			sip_cancel_destroy(p);
+		dialogstatechange(p, DIALOG_STATE_CONFIRMED);	/* We do have any type of response */
 		p->authtries = 0;
 		if (find_sdp(req)) {
 			if ((res = process_sdp(p, req)) && !ast_test_flag(req, SIP_PKT_IGNORE))
@@ -5180,6 +5200,7 @@
 		ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 		break;
 	case 404: /* Not found */
+		dialogstatechange(p, DIALOG_STATE_TERMINATED);
 		transmit_request(p, SIP_ACK, req->seqno, XMIT_UNRELIABLE, FALSE);
 		if (p->owner && !ast_test_flag(req, SIP_PKT_IGNORE))
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
@@ -5188,6 +5209,7 @@
 	case 481: /* Call leg does not exist */
 		/* Could be REFER or INVITE */
 		ast_log(LOG_WARNING, "Re-invite to non-existing call leg on other UA. SIP dialog '%s'. Giving up.\n", p->callid);
+		dialogstatechange(p, DIALOG_STATE_TERMINATED);
 		transmit_request(p, SIP_ACK, req->seqno, XMIT_UNRELIABLE, FALSE);
 		break;
 	case 491: /* Pending */
@@ -5196,6 +5218,8 @@
 			We should support the retry-after at some point */
 		break;
 	case 501: /* Not implemented */
+		transmit_request(p, SIP_ACK, req->seqno, XMIT_UNRELIABLE, FALSE);
+		dialogstatechange(p, DIALOG_STATE_TERMINATED);
 		if (p->owner)
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
 		break;
@@ -5289,12 +5313,14 @@
 
 	if (peer->pokeexpire > -1)
 		ast_sched_del(sched, peer->pokeexpire);
-	ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 
 	/* Try again eventually */
 	peer->pokeexpire = ast_sched_add(sched,
 		is_reachable ? global.default_qualifycheck_ok: global.default_qualifycheck_notok,
 		sip_poke_peer_s, peer);
+
+	dialogstatechange(p, DIALOG_STATE_TERMINATED);
+	ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 }
 
 /*! \brief Handle SIP response in dialogue */
@@ -6798,14 +6824,20 @@
 
 	if (!ast_test_flag(req, SIP_PKT_IGNORE) && p)
 		p->lastinvite = req->seqno;
+
+	p->expiry = atoi(get_header(req, "Expires"));
+	if (p->expiry < expiry.min_expiry && p->expiry > 0) {
+		transmit_response_with_attachment(WITH_MINEXPIRY, p, "423 Interval too small", req, XMIT_UNRELIABLE);
+		ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
+		return 0;
+	}
+	
+
 	if (p && !ast_test_flag(&p->flags[0], SIP_NEEDDESTROY)) {
-		p->expiry = atoi(get_header(req, "Expires"));
 
 		/* check if the requested expiry-time is within the approved limits from sip.conf */
 		if (p->expiry > expiry.max_expiry)
 			p->expiry = expiry.max_expiry;
-		if (p->expiry < expiry.min_expiry && p->expiry > 0)
-			p->expiry = expiry.min_expiry;
 
 		if (sipdebug || option_debug > 1) {
 			if (p->subscribed == MWI_NOTIFICATION && p->relatedpeer)

Modified: team/oej/codename-pineapple/channels/sip3/sip3.h
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3.h?rev=47208&r1=47207&r2=47208&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3.h (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3.h Sat Nov  4 16:13:27 2006
@@ -172,6 +172,7 @@
 
 /*! \brief Variants for sending responses with transmit_response_with_attachment() */
 enum responseattach {
+	WITH_MINEXPIRY,
 	WITH_DATE,
 	WITH_ALLOW,
 	WITH_SDP,
@@ -215,6 +216,7 @@
 };
 
 enum parse_register_result {
+	PARSE_REGISTER_FAILED_MINEXPIRY,
 	PARSE_REGISTER_FAILED,
 	PARSE_REGISTER_UPDATE,
 	PARSE_REGISTER_QUERY,
@@ -346,6 +348,8 @@
 	DIALOG_STATE_TERMINATED, 	/*!< This call is down - timeout, hangup, replaced 
 					\ref AST_STATE_DOWN
 					*/
+	DIALOG_STATE_TERMINATED_AUTH,	/*!< Asterisk state for dialog that need to restart in
+						TRYING for authentication */
 	
 };
 
@@ -774,8 +778,6 @@
 	struct sip_auth *peerauth;		/*!< Realm authentication */
 	int noncecount;				/*!< Nonce-count */
 
-	int maxtime;				/*!< Max time for first response (needs to go now) */
-
 	/* The grouping below shows that these settings should be allocated in substructures,
 	   depending on the nature of the dialog - the method that opened it. Note that
 	   one dialog can have both INVITE and REFER, but not SUSBCRIBE and REGISTER and INVITE */

Modified: team/oej/codename-pineapple/channels/sip3/sip3_cliami.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_cliami.c?rev=47208&r1=47207&r2=47208&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_cliami.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_cliami.c Sat Nov  4 16:13:27 2006
@@ -819,6 +819,7 @@
 				ast_cli(fd, "  * Subscription (type: %s)\n", subscription_type2str(cur->subscribed));
 			else
 				ast_cli(fd, "  * SIP Call\n");
+			ast_cli(fd, "  State:                  %s\n", dialogstate2str(cur->state));
 			ast_cli(fd, "  Direction:              %s\n", ast_test_flag(&cur->flags[0], SIP_OUTGOING)?"Outgoing":"Incoming");
 			ast_cli(fd, "  Call-ID:                %s\n", cur->callid);
 			ast_cli(fd, "  Owner channel ID:       %s\n", cur->owner ? cur->owner->name : "<none>");

Modified: team/oej/codename-pineapple/channels/sip3/sip3_dialog.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_dialog.c?rev=47208&r1=47207&r2=47208&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_dialog.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_dialog.c Sat Nov  4 16:13:27 2006
@@ -126,6 +126,44 @@
 void dialoglist_unlock(void)
 {
 	ast_mutex_unlock(&dialoglock);
+}
+
+/*! \brief Convert SIP dialog states to string */
+const char *dialogstate2str(const enum dialogstate state)
+{
+	const char *reply = "<unknown>";
+	switch (state) {
+	case DIALOG_STATE_TRYING:
+		reply = "Trying";
+		break;
+	case DIALOG_STATE_PROCEEDING:
+		reply = "Proceeding";
+		break;
+	case DIALOG_STATE_EARLY:
+		reply = "Early";
+		break;
+	case DIALOG_STATE_CONFIRMED:
+		reply = "Confirmed";
+		break;
+	case DIALOG_STATE_CONFIRMED_HOLD:
+		reply = "Confirmed, on hold";
+		break;
+	case DIALOG_STATE_TERMINATED:
+		reply = "Terminated";
+		break;
+	case DIALOG_STATE_TERMINATED_AUTH:
+		reply = "Terminated, auth";
+		break;
+	}
+	return reply;
+}
+
+/*! \brief Change dialog state for a SIP dialog and output to debug */
+void dialogstatechange(struct sip_dialog *dialog, enum dialogstate newstate)
+{
+	dialog->state = newstate;
+	if (sipdebug && option_debug > 1)
+		ast_log(LOG_DEBUG, "-- Dialog %s changed state to %s\n", dialog->callid, dialogstate2str(newstate));
 }
 
 
@@ -639,20 +677,26 @@
 
 	if (p->method != SIP_REGISTER)
 		ast_string_field_set(p, fromdomain, global.default_fromdomain);
+
 	build_via(p);
-	if (!callid)
+	if (!callid)					/* Make sure we have a unique call ID */
 		build_callid_pvt(p);
 	else
 		ast_string_field_set(p, callid, callid);
-	/* Assign default music on hold class */
+
+	dialogstatechange(p, DIALOG_STATE_TRYING);	/* Set dialog state */
+
+							/* Assign default music on hold class */
 	ast_string_field_set(p, mohinterpret, global.default_mohinterpret);
 	ast_string_field_set(p, mohsuggest, global.default_mohsuggest);
-	p->capability = global.capability;
-	p->allowtransfer = global.allowtransfer;
+	
+	p->capability = global.capability;		/* Set default codec settings */
+
 	if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833) ||
 	    (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO))
 		p->noncodeccapability |= AST_RTP_DTMF;
-	if (p->udptl) {
+
+	if (p->udptl) {					/* T.38 fax properties */
 		p->t38.capability = global.t38_capability;
 		if (ast_udptl_get_error_correction_scheme(p->udptl) == UDPTL_ERROR_CORRECTION_REDUNDANCY)
 			p->t38.capability |= T38FAX_UDP_EC_REDUNDANCY;
@@ -664,6 +708,8 @@
 		p->t38.jointcapability = p->t38.capability;
 	}
 	ast_string_field_set(p, context, global.default_context);
+	p->allowtransfer = global.allowtransfer;	/* Default transfer mode */
+
 
 	/* Add to active dialog list */
 	dialoglist_lock();

Modified: team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c?rev=47208&r1=47207&r2=47208&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c Sat Nov  4 16:13:27 2006
@@ -945,7 +945,7 @@
 /*! \brief Add codec offer to SDP offer/answer body in INVITE or 200 OK */
 static void add_codec_to_sdp(const struct sip_dialog *p, int codec, int sample_rate,
 			     char **m_buf, size_t *m_size, char **a_buf, size_t *a_size,
-			     int debug)
+			     int debug, int *min_packet_size)
 {
 	int rtp_code;
 	struct ast_format_list fmt;
@@ -974,8 +974,44 @@
 		ast_build_string(a_buf, a_size, "a=fmtp:%d mode=%d\r\n", rtp_code, fmt.cur_ms);
 	}
 
-	if (codec != AST_FORMAT_ILBC) 
-		ast_build_string(a_buf, a_size, "a=ptime:%d\r\n", fmt.cur_ms);
+	if (fmt.cur_ms && (fmt.cur_ms < *min_packet_size))
+		*min_packet_size = fmt.cur_ms;
+
+	/* Our first codec packetization processed cannot be zero */
+	if ((*min_packet_size)==0 && fmt.cur_ms)
+		*min_packet_size = fmt.cur_ms;
+}
+
+/*! \brief Set all IP media addresses for this call 
+       \note called from add_sdp()
+*/
+static void get_our_media_address(struct sip_dialog *p, int needvideo, struct sockaddr_in *sin, struct sockaddr_in *vsin, struct sockaddr_in *dest, struct sockaddr_in *vdest)
+{
+       /* First, get our address */
+       ast_rtp_get_us(p->rtp, sin);
+       if (p->vrtp)
+               ast_rtp_get_us(p->vrtp, vsin);
+
+       /* Now, try to figure out where we want them to send data */
+       /* Is this a re-invite to move the media out, then use the original offer from caller  */
+       if (p->redirip.sin_addr.s_addr) {       /* If we have a redirection IP, use it */
+               dest->sin_port = p->redirip.sin_port;
+               dest->sin_addr = p->redirip.sin_addr;
+       } else {
+               dest->sin_addr = p->ourip;
+               dest->sin_port = sin->sin_port;
+       }
+       if (needvideo) {
+               /* Determine video destination */
+               if (p->vredirip.sin_addr.s_addr) {
+                       vdest->sin_addr = p->vredirip.sin_addr;
+                       vdest->sin_port = p->vredirip.sin_port;
+               } else {
+                       vdest->sin_addr = p->ourip;
+                       vdest->sin_port = vsin->sin_port;
+               }
+       }
+
 }
 
 /*! \brief Add Session Description Protocol message */
@@ -1014,6 +1050,8 @@
 	int capability;
 	int needvideo = FALSE;
 	int debug = sip_debug_test_pvt(p);
+	int min_audio_packet_size = 0;
+	int min_video_packet_size = 0;
 
 	m_video[0] = '\0';	/* Reset the video media string if it's not needed */
 
@@ -1029,22 +1067,6 @@
 	} else
 		p->sessionversion++;
 
-	/* Get our addresses */
-	ast_rtp_get_us(p->rtp, &sin);
-	if (p->vrtp)
-		ast_rtp_get_us(p->vrtp, &vsin);
-
-	/* Is this a re-invite to move the media out, then use the original offer from caller  */
-	if (p->redirip.sin_addr.s_addr) {
-		dest.sin_port = p->redirip.sin_port;
-		dest.sin_addr = p->redirip.sin_addr;
-		if (p->redircodecs)
-			capability = p->redircodecs;
-	} else {
-		dest.sin_addr = p->ourip;
-		dest.sin_port = sin.sin_port;
-	}
-
 	/* Ok, let's start working with codec selection here */
 	capability = p->jointcapability;
 
@@ -1054,10 +1076,12 @@
 		ast_log(LOG_DEBUG, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec));
 	}
 	
+#ifdef WHEN_WE_HAVE_T38_FOR_OTHER_TRANSPORTS
 	if ((ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_RTP))) {
 		ast_build_string(&m_audio_next, &m_audio_left, " %d", 191);
 		ast_build_string(&a_audio_next, &a_audio_left, "a=rtpmap:%d %s/%d\r\n", 191, "t38", 8000);
 	}
+#endif
 
 	/* Check if we need video in this call */
 	if((capability & AST_FORMAT_VIDEO_MASK) && !ast_test_flag(&p->flags[0], SIP_NOVIDEO)) {
@@ -1068,20 +1092,13 @@
 		} else if (option_debug > 1)
 			ast_log(LOG_DEBUG, "This call needs video offers, but there's no video support enabled ! \n");
 	}
-		
+
+	/* Get our media IP addresses for RTP */
+	get_our_media_address(p, needvideo, &sin, &vsin, &dest, &vdest);
 
 	/* Ok, we need video. Let's add what we need for video and set codecs.
 	   Video is handled differently than audio since we can not transcode. */
 	if (needvideo) {
-
-		/* Determine video destination */
-		if (p->vredirip.sin_addr.s_addr) {
-			vdest.sin_addr = p->vredirip.sin_addr;
-			vdest.sin_port = p->vredirip.sin_port;
-		} else {
-			vdest.sin_addr = p->ourip;
-			vdest.sin_port = vsin.sin_port;
-		}
 		ast_build_string(&m_video_next, &m_video_left, "m=video %d RTP/AVP", ntohs(vdest.sin_port));
 
 		/* Build max bitrate string */
@@ -1090,29 +1107,7 @@
 		if (debug) 
 			ast_verbose("Video is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(vsin.sin_port));	
 
-		/* For video, we can't negotiate video offers. Let's compare the incoming call with what we got. */
-		if (p->prefcodec) {
-			int videocapability = (capability & p->prefcodec) & AST_FORMAT_VIDEO_MASK; /* Outbound call */
-		
-			/*! \todo XXX We need to select one codec, not many, since there's no transcoding */
-
-			/* Now, merge this video capability into capability while removing unsupported codecs */
-			if (!videocapability) {
-				needvideo = FALSE;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "** No compatible video codecs... Disabling video.\n");
-			} 
-
-			/* Replace video capabilities with the new videocapability */
-			capability = (capability & AST_FORMAT_AUDIO_MASK) | videocapability;
-
-			if (option_debug > 4) {
-				char codecbuf[BUFSIZ];
-				if (videocapability)
-					ast_log(LOG_DEBUG, "** Our video codec selection is: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), videocapability));
-				ast_log(LOG_DEBUG, "** Capability now set to : %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability));
-			}
-		}
+		/*! \todo XXX We need to select one codec, not many, since there's no transcoding */
 	}
 	if (debug) 
 		ast_verbose("Audio is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(sin.sin_port));	
@@ -1146,7 +1141,7 @@
 		add_codec_to_sdp(p, p->prefcodec & AST_FORMAT_AUDIO_MASK, 8000,
 				 &m_audio_next, &m_audio_left,
 				 &a_audio_next, &a_audio_left,
-				 debug);
+				 debug, &min_audio_packet_size);
 		alreadysent |= p->prefcodec & AST_FORMAT_AUDIO_MASK;
 	}
 
@@ -1167,7 +1162,7 @@
 		add_codec_to_sdp(p, pref_codec, 8000,
 				 &m_audio_next, &m_audio_left,
 				 &a_audio_next, &a_audio_left,
-				 debug);
+				 debug, &min_audio_packet_size);
 		alreadysent |= pref_codec;
 	}
 
@@ -1183,12 +1178,12 @@
 			add_codec_to_sdp(p, x, 8000,
 					 &m_audio_next, &m_audio_left,
 					 &a_audio_next, &a_audio_left,
-					 debug);
+					 debug, &min_audio_packet_size);
 		else 
 			add_codec_to_sdp(p, x, 90000,
 					 &m_video_next, &m_video_left,
 					 &a_video_next, &a_video_left,
-					 debug);
+					 debug, &min_video_packet_size);
 	}
 
 	/* Now add DTMF RFC2833 telephony-event as a codec */
@@ -1207,6 +1202,12 @@
 
 	if(!p->owner || !ast_internal_timing_enabled(p->owner))
 		ast_build_string(&a_audio_next, &a_audio_left, "a=silenceSupp:off - - - -\r\n");
+	if (min_audio_packet_size)
+		ast_build_string(&a_audio_next, &a_audio_left, "a=ptime:%d\r\n", min_audio_packet_size);
+
+	if (min_video_packet_size)
+		ast_build_string(&a_video_next, &a_video_left, "a=ptime:%d\r\n", min_video_packet_size);
+
 
 	if ((m_audio_left < 2) || (m_video_left < 2) || (a_audio_left == 0) || (a_video_left == 0))
 		ast_log(LOG_WARNING, "SIP SDP may be truncated due to undersized buffer!!\n");

Modified: team/oej/codename-pineapple/channels/sip3/sip3funcs.h
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3funcs.h?rev=47208&r1=47207&r2=47208&view=diff
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3funcs.h (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3funcs.h Sat Nov  4 16:13:27 2006
@@ -203,6 +203,8 @@
 /* sip3_dialog.c */
 GNURK void dialoglist_lock(void);
 GNURK void dialoglist_unlock(void);
+GNURK const char *dialogstate2str(const enum dialogstate state);
+GNURK void dialogstatechange(struct sip_dialog *dialog, enum dialogstate newstate);
 GNURK void sip_scheddestroy(struct sip_dialog *p, int ms);
 GNURK void sip_cancel_destroy(struct sip_dialog *p);
 GNURK int hangup_sip2cause(int cause);
@@ -215,6 +217,7 @@
 GNURK void __sip_ack(struct sip_dialog *dialog, int seqno, int resp, int sipmethod, int reset);
 GNURK int __sip_semi_ack(struct sip_dialog *p, int seqno, int resp, int sipmethod);
 
+
 /* sip3_services.c - outbound registration for services from other servers/providers  */
 
 GNURK void sip_send_all_registers(void);



More information about the svn-commits mailing list