[asterisk-commits] may: branch may/ooh323_ipv6_direct_rtp r346291 - in /team/may/ooh323_ipv6_dir...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Nov 27 12:36:43 CST 2011


Author: may
Date: Sun Nov 27 12:36:37 2011
New Revision: 346291

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=346291
Log:
Send FastStart proposal with facility msg when media address changed
instead of CloseLC/EmptyTCS if there was no previous H.245 exchange

create rtp instance as fast as we can due to instance is used to get
data for remote bridging

introduce directrtp for remote bridging
introduce earlydirectrtp for early remote bridging (activated by default
if directrtp is on)

Direct rtp support is near of production. Last thing here is to get 
rtp info from the setup packet before LCs are started.


Modified:
    team/may/ooh323_ipv6_direct_rtp/addons/chan_ooh323.c
    team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooh245.c
    team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.c
    team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.h
    team/may/ooh323_ipv6_direct_rtp/channels/sip/reqresp_parser.c
    team/may/ooh323_ipv6_direct_rtp/main/format_cap.c
    team/may/ooh323_ipv6_direct_rtp/main/rtp_engine.c

Modified: team/may/ooh323_ipv6_direct_rtp/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_ipv6_direct_rtp/addons/chan_ooh323.c?view=diff&rev=346291&r1=346290&r2=346291
==============================================================================
--- team/may/ooh323_ipv6_direct_rtp/addons/chan_ooh323.c (original)
+++ team/may/ooh323_ipv6_direct_rtp/addons/chan_ooh323.c Sun Nov 27 12:36:37 2011
@@ -143,6 +143,7 @@
 /* H.323 channel private structure */
 static struct ooh323_pvt {
 	ast_mutex_t lock;		/* Channel private lock */
+	ast_cond_t rtpcond;		/* RTP condition */
 	struct ast_rtp_instance *rtp;
 	struct ast_sockaddr redirip;	/* redir ip */
 	struct ast_rtp_instance *vrtp; /* Placeholder for now */
@@ -197,6 +198,7 @@
 	int progsent;			/* progress is sent */
 	int alertsent;			/* alerting is sent */
 	int directrtp;			/* direct rtp */
+	int earlydirect;		/* early direct rtp */
 	int g729onlyA;			/* G.729 only A */
 	struct ast_dsp *vad;
 	struct OOH323Regex *rtpmask;	/* rtp ip regexp */
@@ -232,6 +234,7 @@
 	int		rtdrcount, rtdrinterval;
 	int		faststart, h245tunneling;
 	int		directrtp;
+	int		earlydirect;
 	int		g729onlyA;
 	struct ooh323_user *next;
 };
@@ -263,6 +266,7 @@
 	int	    rtdrcount,rtdrinterval;
 	int	    faststart, h245tunneling;
 	int	    directrtp;
+	int	    earlydirect;
 	int	    g729onlyA;
 	struct ooh323_peer *next;
 };
@@ -323,6 +327,7 @@
 static int  gBeMaster = 0;
 static int  gMediaWaitForConnect = 0;
 static int  gDirectRTP = 0;
+static int  gEarlyDirect = 0;
 static int  gTOS = 0;
 static int  gRTPTimeout = 60;
 static int  g729onlyA = 0;
@@ -651,6 +656,7 @@
 		p->faststart = peer->faststart;
 		p->h245tunneling = peer->h245tunneling;
 		p->directrtp = peer->directrtp;
+		p->earlydirect = peer->earlydirect;
 		if (peer->rtpmask && peer->rtpmaskstr[0]) {
 			p->rtpmask = peer->rtpmask;
 			ast_copy_string(p->rtpmaskstr, peer->rtpmaskstr, sizeof(p->rtpmaskstr));
@@ -685,6 +691,7 @@
 		p->faststart = gFastStart;
 		p->h245tunneling = gTunneling;
 		p->directrtp = gDirectRTP;
+		p->earlydirect = gEarlyDirect;
 
 		memcpy(&p->prefs, &gPrefs, sizeof(struct ast_codec_pref));
 		p->username = strdup(dest);
@@ -722,7 +729,14 @@
 
       		ast_mutex_unlock(&p->lock);
       		ast_mutex_lock(&ooh323c_cmd_lock);
+		ast_cond_init(&p->rtpcond, NULL);
       		ooMakeCall(data, p->callToken, AST_MAX_EXTENSION, NULL);
+		ast_mutex_lock(&p->lock);
+		if (!p->rtp) {
+			ast_cond_wait(&p->rtpcond, &p->lock);
+		}
+		ast_mutex_unlock(&p->lock);
+		ast_cond_destroy(&p->rtpcond);
       		ast_mutex_unlock(&ooh323c_cmd_lock);
 	}
 
@@ -1373,7 +1387,7 @@
    	ast_mutex_unlock(&p->lock);
 
 	if (gH323Debug)
-		ast_verbose("++++  ooh323_indicate %d on %s\n", condition, callToken);
+		ast_verbose("++++  ooh323_indicate %d on %s is %d\n", condition, callToken, res);
 
    	free(callToken);
 	return res;
@@ -1832,6 +1846,7 @@
 		p->h245tunneling = user->h245tunneling;
 		p->faststart = user->faststart;
 		p->directrtp = user->directrtp;
+		p->earlydirect = user->earlydirect;
 
 		if (p->faststart)
          		OO_SETFLAG(call->flags, OO_M_FASTSTART);
@@ -1859,6 +1874,7 @@
 	 if (!OO_TESTFLAG(p->flags,H323_DISABLEGK)) {
 		p->username = strdup(call->remoteIP);
 		p->directrtp = gDirectRTP;
+		p->earlydirect = gEarlyDirect;
 	} else {
 	  ast_mutex_unlock(&p->lock);
 	  ast_log(LOG_ERROR, "Unacceptable ip %s\n", call->remoteIP);
@@ -1960,7 +1976,7 @@
 			ast_copy_string(call->rtpMaskStr, p->rtpmaskstr, sizeof(call->rtpMaskStr));
 		}
 
-		if (!configure_local_rtp(p, call)) {
+		if (!p->rtp && !configure_local_rtp(p, call)) {
 			ast_mutex_unlock(&p->lock);
 			return OO_FAILED;
 		}
@@ -2054,7 +2070,8 @@
       		ooh323c_set_capability_for_call(call, &p->prefs, p->cap,
                                      p->dtmfmode, p->dtmfcodec, p->t38support, p->g729onlyA);
 
-		/* configure_local_rtp(p, call); */
+		configure_local_rtp(p, call);
+		ast_cond_signal(&p->rtpcond);
 		ast_mutex_unlock(&p->lock);
 	}
 
@@ -2274,6 +2291,7 @@
 		user->faststart = gFastStart;
 		user->h245tunneling = gTunneling;
 		user->directrtp = gDirectRTP;
+		user->earlydirect = gEarlyDirect;
 		user->g729onlyA = g729onlyA;
 		/* set default context */
 		ast_copy_string(user->context, gContext, sizeof(user->context));
@@ -2298,6 +2316,9 @@
 				user->h245tunneling = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) {
 				user->directrtp = ast_true(v->value);
+				user->earlydirect = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) {
+				user->earlydirect = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "g729onlyA")) {
 				user->g729onlyA = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "rtptimeout")) {
@@ -2418,6 +2439,7 @@
 		peer->faststart = gFastStart;
 		peer->h245tunneling = gTunneling;
 		peer->directrtp = gDirectRTP;
+		peer->earlydirect = gEarlyDirect;
 		peer->g729onlyA = g729onlyA;
 		peer->port = 1720;
 		if (0 == friend_type) {
@@ -2475,6 +2497,9 @@
 				peer->h245tunneling = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) {
 				peer->directrtp = ast_true(v->value);
+				peer->earlydirect = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) {
+				peer->earlydirect = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "g729onlyA")) {
 				peer->g729onlyA = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "rtptimeout")) {
@@ -2737,6 +2762,9 @@
 				ooH323EpDisableH245Tunneling();
 		} else if (!strcasecmp(v->name, "directrtp") || !strcasecmp(v->name, "directmedia")) {
 			gDirectRTP = ast_true(v->value);
+			gEarlyDirect = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "earlydirect") || !strcasecmp(v->name, "directrtpsetup")) {
+			gEarlyDirect = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "g729onlyA")) {
 			g729onlyA = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "roundtrip")) {
@@ -2995,6 +3023,7 @@
 		ast_cli(a->fd, "%s:%s,%s\n", "FastStart/H.245 Tunneling", peer->faststart?"yes":"no",
 					peer->h245tunneling?"yes":"no");
 		ast_cli(a->fd, "%-15s%s\n", "DirectRTP", peer->directrtp?"yes":"no");
+		ast_cli(a->fd, "%-15s%s\n", "EarlyDirectRTP", peer->earlydirect?"yes":"no");
 		ast_cli(a->fd, "%-15.15s%s", "Format Prefs: ", "(");
 		print_codec_to_cli(a->fd, &peer->prefs);
 		ast_cli(a->fd, ")\n");
@@ -3152,6 +3181,7 @@
 		ast_cli(a->fd, "%s:%s,%s\n", "FastStart/H.245 Tunneling", user->faststart?"yes":"no",
 					user->h245tunneling?"yes":"no");
 		ast_cli(a->fd, "%-15s%s\n", "DirectRTP", user->directrtp?"yes":"no");
+		ast_cli(a->fd, "%-15s%s\n", "EarlyDirectRTP", user->earlydirect?"yes":"no");
 		ast_cli(a->fd, "%-15.15s%s", "Format Prefs: ", "(");
 		print_codec_to_cli(a->fd, &user->prefs);
 		ast_cli(a->fd, ")\n");
@@ -3313,7 +3343,8 @@
 	ast_cli(a->fd, "%-20s%s\n", "Tunneling", gTunneling?"yes":"no");
 	ast_cli(a->fd, "%-20s%s\n", "CallerId", gCallerID);
 	ast_cli(a->fd, "%-20s%s\n", "MediaWaitForConnect", gMediaWaitForConnect?"yes":"no");
-   ast_cli(a->fd, "%-20s%s\n", "DirectRTP", gDirectRTP?"yes":"no");
+	ast_cli(a->fd, "%-20s%s\n", "DirectRTP", gDirectRTP?"yes":"no");
+	ast_cli(a->fd, "%-20s%s\n", "EarlyDirectRTP", gEarlyDirect?"yes":"no");
 
 #if (0)
 		extern OOH323EndPoint gH323ep;
@@ -4117,7 +4148,7 @@
 
 	/* there must be checking of directmedia setting */
 
-	if ((chan->_state != AST_STATE_UP && 0) || !p->directrtp) {
+	if ((chan->_state != AST_STATE_UP && !p->earlydirect) || !p->directrtp) {
 		res = AST_RTP_GLUE_RESULT_LOCAL;
 	} else {
 		res = AST_RTP_GLUE_RESULT_REMOTE;
@@ -4223,10 +4254,6 @@
 
 	if (gH323Debug)
 		ast_verbose("---   ooh323_set_peer - %s\n", chan->name);
-
-	if (!rtp) {
-		return 0;
-	}
 
 	mode = ooh323_convertAsteriskCapToH323Cap(&chan->writeformat); 
 	p = (struct ooh323_pvt *) chan->tech_pvt;

Modified: team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooh245.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooh245.c?view=diff&rev=346291&r1=346290&r2=346291
==============================================================================
--- team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooh245.c (original)
+++ team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooh245.c Sun Nov 27 12:36:37 2011
@@ -2279,12 +2279,11 @@
    ooLogicalChannel *temp;
    OOMediaInfo *pMediaInfo = NULL;
    char *lIP = localIP;
+   OOBOOL eTCS = FALSE;
 
    if (!lIP || !lIP[0]) {
       lIP = call->localIP;
    }
-
-   ooSendEmptyTermCapMsg(call);
 
 /* close all log chans */
 
@@ -2295,15 +2294,19 @@
           /* Sending closelogicalchannel only for outgoing channels */
          if(!strcmp(temp->dir, "transmit"))
          {
-            ooSendCloseLogicalChannel(call, temp);
+	    if (call->h245SessionState != OO_H245SESSION_IDLE) {
+              ooSendCloseLogicalChannel(call, temp);
+            } else {
+              ooClearLogicalChannel(call, temp->channelNo);
+            }
          }
-         /* else{
-            ooSendRequestCloseLogicalChannel(call, temp);
-         } */
+         else if (!eTCS && call->h245SessionState != OO_H245SESSION_IDLE) {
+            ooSendEmptyTermCapMsg(call);
+            eTCS = TRUE;
+         }
       }
       temp = temp->next;
    }
-
 
 /* change media address for all caps */
 
@@ -2319,7 +2322,13 @@
       }
    }
 
-   call->TCSPending = TRUE;
+   if (call->h245SessionState == OO_H245SESSION_IDLE) {
+      if (call->fsSent) {
+         ooSendFSUpdate(call);
+      }
+   } else {
+      call->TCSPending = TRUE;
+   }
 
 /* Restart TCS exchange proc - Paul Cadah do it in chan_h323_exts native bridge code */
 /* We must do it after all log channels are closed */

Modified: team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.c?view=diff&rev=346291&r1=346290&r2=346291
==============================================================================
--- team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.c (original)
+++ team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.c Sun Nov 27 12:36:37 2011
@@ -1647,6 +1647,90 @@
    return ret;
 }
 
+
+int ooSendFSUpdate(OOH323CallData *call)
+{
+   int ret=0;
+   Q931Message *pQ931Msg = NULL;
+   H225Facility_UUIE *facility=NULL;
+   OOCTXT *pctxt = call->msgctxt;
+
+   OOTRACEDBGA3("Building FS update message (%s, %s)\n", call->callType,
+                 call->callToken);
+   ret = ooCreateQ931Message(pctxt, &pQ931Msg, Q931FacilityMsg);
+   if(ret != OO_OK)
+   {
+      OOTRACEERR3
+         ("ERROR: In allocating memory for facility message (%s, %s)\n",
+          call->callType, call->callToken);
+      return OO_FAILED;
+   }
+
+   pQ931Msg->callReference = call->callReference;
+
+   pQ931Msg->userInfo = (H225H323_UserInformation*)memAlloc(pctxt,
+                             sizeof(H225H323_UserInformation));
+   if(!pQ931Msg->userInfo)
+   {
+      OOTRACEERR3("ERROR:Memory - ooSendFSUpdate - userInfo(%s, %s)\n", 
+                   call->callType, call->callToken);
+      return OO_FAILED;
+   }
+   memset (pQ931Msg->userInfo, 0, sizeof(H225H323_UserInformation));
+   pQ931Msg->userInfo->h323_uu_pdu.m.h245TunnelingPresent=1; 
+
+   pQ931Msg->userInfo->h323_uu_pdu.h245Tunneling = 
+      OO_TESTFLAG (call->flags, OO_M_TUNNELING); 
+
+   pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.t = 
+      T_H225H323_UU_PDU_h323_message_body_facility;
+   
+   facility = (H225Facility_UUIE*) 
+      memAllocZ (pctxt, sizeof(H225Facility_UUIE));
+
+   if(!facility)
+   {
+      OOTRACEERR3("ERROR:Memory - ooSendFS Update - facility (%s, %s)"
+                  "\n", call->callType, call->callToken);
+      return OO_FAILED;
+   }
+
+   pQ931Msg->userInfo->h323_uu_pdu.h323_message_body.u.facility = facility;
+
+   /* Populate Facility UUIE */
+   facility->protocolIdentifier = gProtocolID;  
+   facility->m.callIdentifierPresent = 1;
+   facility->callIdentifier.guid.numocts = 
+                                   call->callIdentifier.guid.numocts;
+   memcpy(facility->callIdentifier.guid.data, 
+          call->callIdentifier.guid.data, 
+          call->callIdentifier.guid.numocts);
+   facility->reason.t = T_H225FacilityReason_forwardedElements;
+
+   ret = ooSetFastStartResponse(call, pQ931Msg,
+       &facility->fastStart.n, &facility->fastStart.elem);
+   if(ret != ASN_OK) { return ret; }
+   if(facility->fastStart.n > 0) {
+       facility->m.fastStartPresent = TRUE;
+       call->fsSent = TRUE;
+   } else {
+      facility->m.fastStartPresent = FALSE;
+   }
+
+   OOTRACEDBGA3("Built Facility message to send (%s, %s)\n", call->callType,
+                 call->callToken);
+
+   ret = ooSendH225Msg(call, pQ931Msg);
+   if(ret != OO_OK)
+   {
+      OOTRACEERR3
+         ("Error:Failed to enqueue Facility message to outbound "
+         "queue.(%s, %s)\n", call->callType, call->callToken);
+   }
+   /* memReset (&gH323ep.msgctxt); */
+   memReset (call->msgctxt);
+   return ret;
+}
 
 int ooSendStartH245Facility(OOH323CallData *call)
 {

Modified: team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.h
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.h?view=diff&rev=346291&r1=346290&r2=346291
==============================================================================
--- team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.h (original)
+++ team/may/ooh323_ipv6_direct_rtp/addons/ooh323c/src/ooq931.h Sun Nov 27 12:36:37 2011
@@ -772,6 +772,7 @@
 EXTERN char* ooQ931GetIEName(int number, char* buf);
 EXTERN int ooSendTCSandMSD(struct OOH323CallData *call);
 EXTERN int ooSendStartH245Facility(struct OOH323CallData *call);
+EXTERN int ooSendFSUpdate(struct OOH323CallData *call);
 
 /** 
  * @} 

Modified: team/may/ooh323_ipv6_direct_rtp/channels/sip/reqresp_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_ipv6_direct_rtp/channels/sip/reqresp_parser.c?view=diff&rev=346291&r1=346290&r2=346291
==============================================================================
--- team/may/ooh323_ipv6_direct_rtp/channels/sip/reqresp_parser.c (original)
+++ team/may/ooh323_ipv6_direct_rtp/channels/sip/reqresp_parser.c Sun Nov 27 12:36:37 2011
@@ -71,9 +71,6 @@
 		}
 		if (pass) {
 			*pass = "";
-		}
-		if (domain) {
-			*domain = "";
 		}
 		if (headers) {
 			*headers = "";

Modified: team/may/ooh323_ipv6_direct_rtp/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_ipv6_direct_rtp/main/format_cap.c?view=diff&rev=346291&r1=346290&r2=346291
==============================================================================
--- team/may/ooh323_ipv6_direct_rtp/main/format_cap.c (original)
+++ team/may/ooh323_ipv6_direct_rtp/main/format_cap.c Sun Nov 27 12:36:37 2011
@@ -158,7 +158,9 @@
 
 void ast_format_cap_append(struct ast_format_cap *dst, const struct ast_format_cap *src)
 {
-	ao2_callback(src->formats, OBJ_NODATA | src->nolock, append_cb, dst);
+	if (src) {
+		ao2_callback(src->formats, OBJ_NODATA | src->nolock, append_cb, dst);
+	}
 }
 
 static int copy_cb(void *obj, void *arg, int flag)

Modified: team/may/ooh323_ipv6_direct_rtp/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_ipv6_direct_rtp/main/rtp_engine.c?view=diff&rev=346291&r1=346290&r2=346291
==============================================================================
--- team/may/ooh323_ipv6_direct_rtp/main/rtp_engine.c (original)
+++ team/may/ooh323_ipv6_direct_rtp/main/rtp_engine.c Sun Nov 27 12:36:37 2011
@@ -1501,6 +1501,12 @@
 	}
 
 	res = 0;
+	/* Setup SDP */
+	if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
+		ast_log(LOG_WARNING, "Channel '%s' failed to setup early SDP to '%s'\n", c0->name, c1 ? c1->name : "<unspecified>");
+	} else {
+		ast_debug(1, "SDP for channel '%s' early changed to SDP of '%s'\n", c0->name, c1 ? c1->name : "<unspecified>");
+	}
 
 done:
 	ast_channel_unlock(c0);
@@ -1580,7 +1586,7 @@
 		glue1->get_codec(c1, cap1);
 	}
 
-	/* ast_debug(1,"glues %d, %d, codecs %d, %d\n", audio_glue0_res, audio_glue1_res, (int) codec0, (int) codec1); */
+	ast_debug(1,"glues %d, %d\n", audio_glue0_res, audio_glue1_res);
 
 	/* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
 	if (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE) {
@@ -1591,6 +1597,8 @@
 	if (!ast_format_cap_has_joint(cap0, cap1)) {
 		goto done;
 	}
+
+	ast_debug(1,"Trying to start early bridge on %s with %s\n", c0->name, c1 ? c1->name : "<unspecified>");
 
 	/* Bridge media early */
 	if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {




More information about the asterisk-commits mailing list