[svn-commits] may: branch may/chan_ooh323_rework r220456 - in /team/may/chan_ooh323_rework/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Sep 24 19:21:12 CDT 2009


Author: may
Date: Thu Sep 24 19:21:08 2009
New Revision: 220456

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=220456
Log:
revert back from semaphore to mutex/cond_timedwait for synchonization gk
thread and call thread (0815)

gk client part corrections

speex support (openh323 compatible variant)

change not used function SendFactility to SendStartH245Facility (not
used now but will used in future)

progress signal is sent if channel is not up as in chan_h323.

implement rtpmask, peer/user keyword rtpmask=aaa.bbb.ccc.ddd or
aaa.bbb.ccc, x for wildcard.
it is usable for taking only predefined rtp channels from peer, if peer
give us  logical channel with another rtp ip then we reject call.

accept more than one remote termcap request from bogus soft-switch. righ
switch send only one.


Modified:
    team/may/chan_ooh323_rework/addons/chan_ooh323.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323ep.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c
    team/may/chan_ooh323_rework/addons/ooh323cDriver.c

Modified: team/may/chan_ooh323_rework/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/chan_ooh323.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/chan_ooh323.c (original)
+++ team/may/chan_ooh323_rework/addons/chan_ooh323.c Thu Sep 24 19:21:08 2009
@@ -171,6 +171,7 @@
 	int amaflags;
 	int progsent;			/* progress is sent */
 	struct ast_dsp *vad;
+	char *rtpmask;			/* rtp ip address mask */
 	struct ooh323_pvt *next;	/* Next entity */
 } *iflist = NULL;
 
@@ -193,6 +194,7 @@
 	int         rtptimeout;
 	int         mUseIP;        /* Use IP address or H323-ID to search user */
 	char        mIP[20];
+	char	    rtpmask[20];
 	struct ooh323_user *next;
 };
 
@@ -216,6 +218,7 @@
 	char        *url;       /* url alias, which asterisk will register with gk to reach this peer*/
 	char        *e164;      /* e164 alias, which asterisk will register with gk to reach this peer*/
 	int         rtptimeout;
+	char	    rtpmask[20];
 	struct ooh323_peer *next;
 };
 
@@ -310,9 +313,9 @@
                                              const char *host, int capability, const char *linkedid) 
 {
 	struct ast_channel *ch = NULL;
-	int fmt;
-	if (gH323Debug)
-		ast_verbose("---   ooh323_new - %s\n", host);
+	int fmt = 0;
+	if (gH323Debug)
+		ast_verbose("---   ooh323_new - %s, %d\n", host, capability);
 
 
 	/* Don't hold a h323 pvt lock while we allocate a channel */
@@ -330,9 +333,10 @@
 		ast_channel_lock(ch);
 		ch->tech = &ooh323_tech;
 
-		fmt = ast_codec_pref_index(&i->prefs, 0);
+		if (capability)
+			fmt = ast_best_codec(capability);
 		if (!fmt) 
-			fmt = ast_best_codec(capability);
+			fmt = ast_codec_pref_index(&i->prefs, 0);
 
 		ch->nativeformats = ch->rawwriteformat = ch->rawreadformat = fmt;
 
@@ -344,8 +348,6 @@
 			ch->rings = 1;
 
 		ch->adsicpe = AST_ADSI_UNAVAILABLE;
-		if (capability)
-			fmt = ast_best_codec(capability);
 		ast_set_write_format(ch, fmt);
 		ast_set_read_format(ch, fmt);
 		ch->tech_pvt = i;
@@ -510,7 +512,7 @@
 /*
 	Possible data values - peername, exten/peername, exten at ip
  */
-static struct ast_channel *ooh323_request(const char *type, int format, 
+static struct ast_channel *ooh323_request(const char *type, int format,
 		const struct ast_channel *requestor, void *data, int *cause)
 
 {
@@ -595,6 +597,8 @@
 		memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref));
 		p->dtmfmode |= peer->dtmfmode;
 		p->t38support = peer->t38support;
+		if (peer->rtpmask)
+			p->rtpmask = ast_strdup(peer->rtpmask);
 		ast_copy_string(p->accountcode, peer->accountcode, sizeof(p->accountcode));
 		p->amaflags = peer->amaflags;
 	} else {
@@ -1195,23 +1199,26 @@
 		ast_moh_stop(ast);
 		break;
 	case AST_CONTROL_PROGRESS:
-	    if (!p->progsent) {
-             /* ast_mutex_lock(&ooh323c_cmd_lock); */
-	     if (gH323Debug) 
-		ast_log(LOG_DEBUG,"Sending manual progress for %s, res = %d\n", callToken,
-             ooManualProgress(callToken)); else
-	     ooManualProgress(callToken);
-	     p->progsent = 1;
-             /* ast_mutex_unlock(&ooh323c_cmd_lock); */
-	    }
+		if (ast->_state != AST_STATE_UP) {
+	    		if (!p->progsent) {
+	     			if (gH323Debug) 
+					ast_log(LOG_DEBUG,"Sending manual progress for %s, res = %d\n", callToken,
+             				ooManualProgress(callToken));	
+				else
+	     				ooManualProgress(callToken);
+	     			p->progsent = 1;
+	    		}
+		}
 	    break;
       case AST_CONTROL_RINGING:
-            /* ast_mutex_lock(&ooh323c_cmd_lock); */
-	    if (gH323Debug) 
-		ast_log(LOG_DEBUG,"Sending manual ringback for %s, res = %d\n", callToken,
-            ooManualRingback(callToken)); else
-	    ooManualRingback(callToken);
-            /* ast_mutex_unlock(&ooh323c_cmd_lock); */
+	    if (ast->_state == AST_STATE_RING || ast->_state == AST_STATE_RINGING) {
+	    	if (gH323Debug) 
+			ast_log(LOG_DEBUG,"Sending manual ringback for %s, res = %d\n", 
+			callToken,
+            		ooManualRingback(callToken));
+		 else
+	    		ooManualRingback(callToken);
+	    }
 	 break;
       case AST_CONTROL_SRCUPDATE:
 		ast_rtp_instance_new_source(p->rtp);
@@ -1371,8 +1378,8 @@
 	char formats[512];
 
 	if (gH323Debug)
-		ast_verbose("---   ooh323_update_writeformat %s\n", 
-				ast_getformatname_multiple(formats,512, fmt));
+		ast_verbose("---   ooh323_update_writeformat %s/%d\n", 
+				ast_getformatname_multiple(formats,512, fmt), txframes);
 	
 	p = find_call(call);
 	if (!p) {
@@ -1402,6 +1409,8 @@
 			  ast_getformatname_multiple(formats,512, p->owner->nativeformats));
 		if (txframes)
 			ast_codec_pref_setsize(&p->prefs, fmt, txframes);
+		ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
+
 		p->owner->nativeformats = fmt;
 	  	ast_set_write_format(p->owner, p->owner->writeformat);
 	  	ast_set_read_format(p->owner, p->owner->readformat);
@@ -1687,8 +1696,8 @@
 	}
 	
 	if (p->callerid_name) { */
-      user = find_user(p->callerid_name, call->remoteIP);
-      if(user && (user->incominglimit == 0 || user->inUse < user->incominglimit)) {
+      		user = find_user(p->callerid_name, call->remoteIP);
+      		if(user && (user->incominglimit == 0 || user->inUse < user->incominglimit)) {
 			ast_mutex_lock(&user->lock);
 			p->username = strdup(user->name);
 	 		p->neighbor.user = user->mUseIP ? ast_strdup(user->mIP) :
@@ -1700,6 +1709,8 @@
 			memcpy(&p->prefs, &user->prefs, sizeof(struct ast_codec_pref));
 			p->dtmfmode |= user->dtmfmode;
 			p->t38support = user->t38support;
+			if (user->rtpmask)
+				p->rtpmask = ast_strdup(user->rtpmask);
 			/* Since, call is coming from a pbx user, no need to use gk */
 			/* OO_SETFLAG(p->flags, H323_DISABLEGK);
 			OO_SETFLAG(call->flags, OO_M_DISABLEGK); */
@@ -1795,7 +1806,8 @@
 				ooCallAddAliasH323ID(call, p->callerid_num);
 			}
 		}
-  
+		if (p->rtpmask)
+			ast_copy_string(call->rtpMask, p->rtpmask, sizeof(call->rtpMask));
 
 		ast_mutex_unlock(&p->lock);
 	}
@@ -2077,6 +2089,7 @@
 
    	user = ast_calloc(1,sizeof(struct ooh323_user));
 	if (user) {
+		memset(user, 0, sizeof(struct ooh323_user));
 		ast_mutex_init(&user->lock);
 		ast_copy_string(user->name, name, sizeof(user->name));
 		user->capability = gCapability;
@@ -2103,6 +2116,8 @@
 				user->rtptimeout = atoi(v->value);
 				if (user->rtptimeout < 0)
 					user->rtptimeout = gRTPTimeout;
+			} else if (!strcasecmp(v->name, "rtpmask")) {
+				ast_copy_string(user->rtpmask, v->value, sizeof(user->rtpmask));
 			} else if (!strcasecmp(v->name, "disallow")) {
 				ast_parse_allow_disallow(&user->prefs, 
 					&user->capability,  v->value, 0);
@@ -2213,18 +2228,20 @@
 				peer->port = atoi(v->value);
 			} else if (!strcasecmp(v->name, "ip")) {
 				ast_copy_string(peer->ip, v->value, sizeof(peer->ip));
-         } else if (!strcasecmp(v->name, "host")) {
-            ast_copy_string(peer->ip, v->value, sizeof(peer->ip));
+         		} else if (!strcasecmp(v->name, "host")) {
+            			ast_copy_string(peer->ip, v->value, sizeof(peer->ip));
 			} else if (!strcasecmp(v->name, "outgoinglimit")) {
-            peer->outgoinglimit = atoi(v->value);
-            if (peer->outgoinglimit < 0)
+            			peer->outgoinglimit = atoi(v->value);
+            			if (peer->outgoinglimit < 0)
 					peer->outgoinglimit = 0;
 			} else if (!strcasecmp(v->name, "accountcode")) {
 				ast_copy_string(peer->accountcode, v->value, sizeof(peer->accountcode));
 			} else if (!strcasecmp(v->name, "rtptimeout")) {
-            peer->rtptimeout = atoi(v->value);
-            if(peer->rtptimeout < 0)
+            			peer->rtptimeout = atoi(v->value);
+            			if(peer->rtptimeout < 0)
 					peer->rtptimeout = gRTPTimeout;
+			} else if (!strcasecmp(v->name, "rtpmask")) {
+				ast_copy_string(peer->rtpmask, v->value, sizeof(peer->rtpmask));
 			} else if (!strcasecmp(v->name, "disallow")) {
 				ast_parse_allow_disallow(&peer->prefs, &peer->capability, 
 												 v->value, 0); 
@@ -2511,7 +2528,7 @@
 			if (gRTPTimeout <= 0)
 				gRTPTimeout = 60;
 		} else if (!strcasecmp(v->name, "tos")) {
-			if (sscanf(v->value, "%i", &format) == 1)
+			if (sscanf(v->value, "%30i", &format) == 1)
 				gTOS = format & 0xff;
 			else if (!strcasecmp(v->value, "lowdelay"))
 				gTOS = IPTOS_LOWDELAY;
@@ -2682,7 +2699,7 @@
 		else
          ast_cli(a->fd, "%s\n", "unknown");
 
-   ast_cli(a->fd,"%-15s", "T.38 Mode: ");
+	ast_cli(a->fd,"%-15s", "T.38 Mode: ");
 	if (peer->t38support == T38_DISABLED)
 		ast_cli(a->fd, "%s\n", "disabled");
 	else if (peer->t38support == T38_TRANSPARENT)
@@ -2690,16 +2707,18 @@
 	else if (peer->t38support == T38_FAXGW)
 		ast_cli(a->fd, "%s\n", "faxgw/chan_sip compatible");
 
-      ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", peer->accountcode);
-      ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", 
+	ast_cli(a->fd, "%-15.15s%s\n", "AccountCode: ", peer->accountcode);
+	ast_cli(a->fd, "%-15.15s%s\n", "AMA flags: ", 
 		ast_cdr_flags2str(peer->amaflags));
-      ast_cli(a->fd, "%-15.15s%s\n", "IP:Port: ", ip_port);
-      ast_cli(a->fd, "%-15.15s%d\n", "OutgoingLimit: ", peer->outgoinglimit);
-      ast_cli(a->fd, "%-15.15s%d\n", "rtptimeout: ", peer->rtptimeout);
+	ast_cli(a->fd, "%-15.15s%s\n", "IP:Port: ", ip_port);
+	ast_cli(a->fd, "%-15.15s%d\n", "OutgoingLimit: ", peer->outgoinglimit);
+	ast_cli(a->fd, "%-15.15s%d\n", "rtptimeout: ", peer->rtptimeout);
+	if (peer->rtpmask[0])
+		ast_cli(a->fd, "%-15.15s%s\n", "rtpmask: ", peer->rtpmask);
 		ast_mutex_unlock(&peer->lock);
 	} else {
-     ast_cli(a->fd, "Peer %s not found\n", a->argv[3]);
-     ast_cli(a->fd, "\n");
+	ast_cli(a->fd, "Peer %s not found\n", a->argv[3]);
+	ast_cli(a->fd, "\n");
 	}
 	ast_mutex_unlock(&peerl.lock);
 
@@ -2834,6 +2853,8 @@
       ast_cli(a->fd, "%-15.15s%d\n", "IncomingLimit: ", user->incominglimit);
       ast_cli(a->fd, "%-15.15s%d\n", "InUse: ", user->inUse);
       ast_cli(a->fd, "%-15.15s%d\n", "rtptimeout: ", user->rtptimeout);
+	if (user->rtpmask[0])
+		ast_cli(a->fd, "%-15.15s%s\n", "rtpmask: ", user->rtpmask);
 		ast_mutex_unlock(&user->lock);
 	} else {
      ast_cli(a->fd, "User %s not found\n", a->argv[3]);
@@ -3348,6 +3369,11 @@
 			cur->callerid_num = 0;
 		}
 
+		if (cur->rtpmask) {
+			free(cur->rtpmask);
+			cur->rtpmask = NULL;
+		}
+
 
 		if (cur->rtp) {
 			ast_rtp_instance_destroy(cur->rtp);
@@ -3642,6 +3668,10 @@
 	case AST_FORMAT_AMRNB:
 		return OO_AMRNB;
 #endif
+#ifdef AST_FORMAT_SPEEX
+	case AST_FORMAT_SPEEX:
+		return OO_SPEEX;
+#endif
 
 	case AST_FORMAT_G729A:
 		return OO_G729A;
@@ -3753,7 +3783,7 @@
 	struct sockaddr_in them;
 
 	if (gH323Debug)
-		ast_verbose("---   setup_rtp_connection\n");
+		ast_verbose("---   setup_rtp_connection %s:%d\n", remoteIp, remotePort);
 
 	/* Find the call or allocate a private structure if call not found */
 	p = find_call(call); 

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c Thu Sep 24 19:21:08 2009
@@ -62,7 +62,7 @@
       return NULL;
    } 
    memset(call, 0, sizeof(OOH323CallData));
-   sem_init(&call->gkWait, 0, 0);
+   ast_cond_init(&call->gkWait, NULL);
    ast_mutex_init(&call->Lock);
    call->pctxt = pctxt;
    call->msgctxt = msgctxt;
@@ -562,6 +562,19 @@
                                 stopTransmitChannel, FALSE);
 }
 
+int ooCallAddSpeexCapability(OOH323CallData *call, int cap, int txframes, 
+                            int rxframes, OOBOOL silenceSuppression, int dir,
+                            cb_StartReceiveChannel startReceiveChannel,
+                            cb_StartTransmitChannel startTransmitChannel,
+                            cb_StopReceiveChannel stopReceiveChannel,
+                            cb_StopTransmitChannel stopTransmitChannel)
+{
+   return ooCapabilityAddSimpleCapability(call, cap, txframes, rxframes, 
+                                silenceSuppression, dir, startReceiveChannel, 
+                                startTransmitChannel, stopReceiveChannel, 
+                                stopTransmitChannel, FALSE);
+}
+
 int ooCallAddG7231Capability(OOH323CallData *call, int cap, int txframes, 
                             int rxframes, OOBOOL silenceSuppression, int dir,
                             cb_StartReceiveChannel startReceiveChannel,

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h Thu Sep 24 19:21:08 2009
@@ -143,7 +143,7 @@
    OOCTXT               *pctxt;
    OOCTXT               *msgctxt;
    pthread_t		callThread;
-   sem_t		gkWait;
+   ast_cond_t		gkWait;
    ast_mutex_t		Lock;
    OOBOOL 		Monitor;
    OOBOOL		fsSent;
@@ -207,6 +207,7 @@
    ASN1UINT		t38sides;
    H235TimeStamp	alertingTime, connectTime, endTime; /* time data for gatekeeper */
    FastStartResponse    *pFastStartRes; /* fast start response */
+   char			rtpMask[20];
    void                 *usrData; /*!<User can set this to user specific data*/
    struct OOH323CallData* next;
    struct OOH323CallData* prev;

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.c Thu Sep 24 19:21:08 2009
@@ -728,6 +728,7 @@
    case OO_G726:
    case OO_G726AAL2:
    case OO_AMRNB:
+   case OO_SPEEX:
      return ooCapabilityCreateNonStandardCapability(epCap, pctxt, dir);
    case OO_GSMHALFRATE:
    case OO_GSMENHANCEDFULLRATE:
@@ -1016,7 +1017,7 @@
    }
    return NULL;
 }
-/* This is used for g726, AMRNB */
+/* This is used for g726, AMRNB, Speex */
 struct H245AudioCapability* ooCapabilityCreateNonStandardCapability
    (ooH323EpCapability *epCap, OOCTXT* pctxt, int dir)
 {
@@ -1043,6 +1044,7 @@
    case OO_AMRNB:
    case OO_G726:
    case OO_G726AAL2:
+   case OO_SPEEX:
       pAudio->t = T_H245AudioCapability_nonStandard;
       pAudio->u.nonStandard = (H245NonStandardParameter*)memAlloc(pctxt, 
                                            sizeof(H245NonStandardParameter));
@@ -1087,6 +1089,17 @@
       case OO_AMRNB:
        pAudio->u.nonStandard->data.data = "AMRNB";
        pAudio->u.nonStandard->data.numocts = sizeof("AMRNB")-1;
+       break;
+
+      case OO_SPEEX:
+       pAudio->u.nonStandard->data.data = "Speex";
+       pAudio->u.nonStandard->data.numocts = sizeof("Speex")-1;
+       /* Equivalence OpenH323 SpeexNB */
+       pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35CountryCode = 9;
+       pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->t35Extension = 0;
+       pAudio->u.nonStandard->nonStandardIdentifier.u.h221NonStandard->manufacturerCode = 61;
+
+       break;
       }
       return pAudio;
 
@@ -1289,10 +1302,13 @@
 	 else
 	  return FALSE;
 	 break;
-	case sizeof("AMRNB")-1:
+	case sizeof("AMRNB")-1: /* case sizeof("Speex")-1 */
 	 if (!strncmp(audioCap->u.nonStandard->data.data, "AMRNB", 
 		audioCap->u.nonStandard->data.numocts))
 	  cap = OO_AMRNB;
+	 else if (!strncmp(audioCap->u.nonStandard->data.data, "Speex", 
+		audioCap->u.nonStandard->data.numocts))
+	  cap = OO_SPEEX;
 	 else
 	  return FALSE;
 	 break;
@@ -1993,10 +2009,13 @@
 	 else
 	  return NULL;
 	 break;
-	case sizeof("AMRNB")-1:
+	case sizeof("AMRNB")-1: /* sizeof("Speex") */
 	 if (!strncmp(audioCap->u.nonStandard->data.data, "AMRNB",
 		audioCap->u.nonStandard->data.numocts))
 	  cap = OO_AMRNB;
+	 else if (!strncmp(audioCap->u.nonStandard->data.data, "Speex",
+		audioCap->u.nonStandard->data.numocts))
+	  cap = OO_SPEEX;
 	 else
 	  return NULL;
 	 break;
@@ -2700,6 +2719,15 @@
                    audioCap->u.nonStandard->data.numocts))
       return ooCapabilityAddSimpleCapability(call, OO_AMRNB, 4, 
                            4, FALSE, dir, NULL, NULL, NULL, NULL, TRUE);
+
+      if (audioCap->u.nonStandard && 
+          audioCap->u.nonStandard->nonStandardIdentifier.t == 
+           T_H245NonStandardIdentifier_h221NonStandard &&
+          audioCap->u.nonStandard->data.numocts == sizeof("Speex")-1 &&
+          !strncmp(audioCap->u.nonStandard->data.data, "Speex", 
+                   audioCap->u.nonStandard->data.numocts))
+      return ooCapabilityAddSimpleCapability(call, OO_SPEEX, 4, 
+                           4, FALSE, dir, NULL, NULL, NULL, NULL, TRUE);
       break;
 
    case T_H245AudioCapability_g728:
@@ -3024,7 +3052,7 @@
       "OO_GSMENHANCEDFULLRATE",
       "OO_GENERICAUDIO",
       "OO_G729EXTENSIONS",
-      "OO_VBD",
+      "OO_SPEEX",
       "OO_AUDIOTELEPHONYEVENT",
       "OO_AUDIOTONE",
       "OO_EXTELEM1",

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCapability.h Thu Sep 24 19:21:08 2009
@@ -60,7 +60,11 @@
    OO_GSMENHANCEDFULLRATE = 20,
    OO_GENERICAUDIO        = 21,
    OO_G729EXT             = 22,
+#if 0
    OO_AUDIO_VBD           = 23,
+#else
+   OO_SPEEX		  = 23,
+#endif
    OO_AUDIOTELEPHONYEVENT = 24,
    OO_AUDIO_TONE          = 25,
    OO_EXTELEM1            = 26,

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c Thu Sep 24 19:21:08 2009
@@ -1950,7 +1950,7 @@
                        pCallAdmInfo->call->callToken);
 
 	 pCallAdmInfo->call->callState = OO_CALL_CONNECTING;
-	 sem_post(&pCallAdmInfo->call->gkWait);
+	 ast_cond_signal(&pCallAdmInfo->call->gkWait);
          /* ooH323CallAdmitted( pCallAdmInfo->call); */
 
          dListRemove(&pGkClient->callsPendingList, pNode);
@@ -1975,9 +1975,10 @@
    (ooGkClient *pGkClient, H225AdmissionReject *pAdmissionReject)
 {
    RasCallAdmissionInfo* pCallAdmInfo=NULL;
-   unsigned int x;
-   DListNode *pNode=NULL;
+   unsigned int x, y;
+   DListNode *pNode=NULL, *pNode1=NULL;
    OOH323CallData *call=NULL;
+   OOTimer *pTimer = NULL;
 
    /* Search call in pending calls list */
    for(x=0 ; x<pGkClient->callsPendingList.count; x++)
@@ -2004,6 +2005,24 @@
       memFreePtr(&pGkClient->ctxt, pNode);
    }
 
+   /* Delete ARQ timer */
+   for(y=0; y<pGkClient->timerList.count; y++)
+   {
+     pNode1 =  dListFindByIndex(&pGkClient->timerList, y);
+     pTimer = (OOTimer*)pNode1->data;
+     if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_ARQ_TIMER)
+     {
+               if(((ooGkClientTimerCb*)pTimer->cbData)->pAdmInfo == 
+                                                                 pCallAdmInfo)
+               {
+                  memFreePtr(&pGkClient->ctxt, pTimer->cbData);
+                  ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, 
+                                                                       pTimer);
+                  OOTRACEDBGA1("Deleted ARQ Timer.\n");
+                  break;
+               }
+     }
+   }       
    OOTRACEINFO4("Admission Reject message received with reason code %d for "
                 "(%s, %s)\n", pAdmissionReject->rejectReason.t, call->callType,
                  call->callToken);
@@ -2049,7 +2068,7 @@
          break;
    }
 
-   sem_post(&pCallAdmInfo->call->gkWait);
+   ast_cond_signal(&pCallAdmInfo->call->gkWait);
    return OO_OK;   
 }
 
@@ -2563,6 +2582,9 @@
 
    OOTRACEDBGA1("Gatekeeper client ARQ timer expired.\n");
    memFreePtr(&pGkClient->ctxt, cbData);   
+
+   if(!pAdmInfo)
+    return OO_OK;
 
    if(pAdmInfo->retries < OO_MAX_ARQ_RETRIES)
    {

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c Thu Sep 24 19:21:08 2009
@@ -959,7 +959,7 @@
    ast_mutex_lock(&call->Lock);
    ast_mutex_unlock(&call->Lock);
    ast_mutex_destroy(&call->Lock);
-   sem_destroy(&call->gkWait);
+   ast_cond_destroy(&call->gkWait);
    pctxt = call->pctxt;
    freeContext(pctxt);
    free(pctxt);

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooh245.c Thu Sep 24 19:21:08 2009
@@ -922,7 +922,7 @@
             if(gH323ep.h323Callbacks.openLogicalChannels)
                gH323ep.h323Callbacks.openLogicalChannels(call);
             else{
-               if(!call->logicalChans)
+               if(!ooGetTransmitLogicalChannel(call))
                   ooOpenLogicalChannels(call);
             }
 #if 0
@@ -1733,7 +1733,8 @@
 int ooOnReceivedOpenLogicalChannelAck(OOH323CallData *call,
                                       H245OpenLogicalChannelAck *olcAck)
 {
-   char remoteip[20];
+   char remoteip[20], remoteip3[20];
+   int i;
    ooLogicalChannel *pLogicalChannel;
    H245H2250LogicalChannelAckParameters *h2250lcap;
    H245UnicastAddress *unicastAddr;
@@ -1779,6 +1780,11 @@
    iPAddress = unicastAddr->u.iPAddress;
    
    sprintf(remoteip,"%d.%d.%d.%d", iPAddress->network.data[0],
+                                  iPAddress->network.data[1], 
+                                  iPAddress->network.data[2], 
+                                  iPAddress->network.data[3]);
+   
+   sprintf(remoteip3,"%03d.%03d.%03d.%03d", iPAddress->network.data[0],
                                   iPAddress->network.data[1], 
                                   iPAddress->network.data[2], 
                                   iPAddress->network.data[3]);
@@ -1827,6 +1833,17 @@
       pLogicalChannel->sessionID = h2250lcap->sessionID;   
 
    /* Populate ports &ip  for channel */
+
+   if (call->rtpMask[0]) {
+     for (i=0;i<strlen(call->rtpMask) && i<strlen(remoteip3);i++)
+	if (call->rtpMask[i] != 'x' && call->rtpMask[i] != remoteip3[i]) {
+	 OOTRACEERR5("ERROR:H245 Address is not matched with filter %s/%s"
+			"(%s, %s)\n", remoteip3, call->rtpMask, call->callType, call->callToken);
+	 return OO_FAILED;
+	}
+	 
+   }
+
    strcpy(pLogicalChannel->remoteIP, remoteip);   
    pLogicalChannel->remoteMediaPort = iPAddress->tsapIdentifier;
    if (iPAddress1)
@@ -2071,7 +2088,7 @@
       if(gH323ep.h323Callbacks.openLogicalChannels)
          gH323ep.h323Callbacks.openLogicalChannels(call);
       else{
-         if(!call->logicalChans)
+         if(!ooGetTransmitLogicalChannel(call))
             ooOpenLogicalChannels(call);
       }
 #if 0
@@ -2529,8 +2546,6 @@
                   call->h245SessionState = OO_H245SESSION_ACTIVE; 
 
                ooOnReceivedTerminalCapabilitySet(call, pH245);
-               if(call->localTermCapState == OO_LocalTermCapExchange_Idle)
-                  ooSendTermCapMsg(call);
                break;
             case T_H245RequestMessage_masterSlaveDetermination:
                ooHandleMasterSlave(call, 
@@ -2850,7 +2865,7 @@
    H245CapabilityTableEntry *capEntry = NULL;
 
    tcs =  pmsg->h245Msg.u.request->u.terminalCapabilitySet;
-   if(call->remoteTermCapSeqNo >= tcs->sequenceNumber)
+   if(call->remoteTermCapSeqNo > tcs->sequenceNumber)
    {
       OOTRACEINFO4("Rejecting TermCapSet message with SeqNo %d, as already "
                    "acknowledged message with this SeqNo (%s, %s)\n", 
@@ -2858,6 +2873,14 @@
       ooSendTerminalCapabilitySetReject(call, tcs->sequenceNumber, 
                          T_H245TerminalCapabilitySetReject_cause_unspecified);
       return OO_OK;
+   } else {
+/* 20090924 */
+/* bogus soft-switch can send more than one request with  cap set
+   if it goto to next choice. Right swith don't send but not all are right ;(
+   we can accept new capability set only. We must remember also that new join caps
+   will be previously joined caps with new cap set.
+ */
+    call->localTermCapState = OO_LocalTermCapExchange_Idle;
    }
   
    if(!tcs->m.capabilityTablePresent)
@@ -2934,7 +2957,7 @@
    if(gH323ep.h323Callbacks.openLogicalChannels)
       gH323ep.h323Callbacks.openLogicalChannels(call);
    else{
-      if(!call->logicalChans)
+      if(!ooGetTransmitLogicalChannel(call))
          ooOpenLogicalChannels(call);
    }
 #if 0
@@ -3331,7 +3354,7 @@
       }
 
    }
-   else if(call->masterSlaveState == OO_MasterSlave_Slave)
+   else
    {
       epCap = call->jointCaps;
 
@@ -3359,6 +3382,7 @@
    case OO_G726:
    case OO_G726AAL2:
    case OO_AMRNB:
+   case OO_SPEEX:
    case OO_G728:
    case OO_G729:
    case OO_G729A:
@@ -3969,6 +3993,8 @@
 {
    H245UnicastAddress *unicastAddress = NULL;
    H245UnicastAddress_iPAddress *ipAddress = NULL;
+   int i;
+   char ip3[20];
 
    if(h245Address->t != T_H245TransportAddress_unicastAddress)
    {
@@ -3992,6 +4018,19 @@
                               ipAddress->network.data[1],
                               ipAddress->network.data[2],
                               ipAddress->network.data[3]);
+   sprintf(ip3, "%03d.%03d.%03d.%03d", ipAddress->network.data[0], 
+                              ipAddress->network.data[1],
+                              ipAddress->network.data[2],
+                              ipAddress->network.data[3]);
+   if (call->rtpMask[0]) {
+     for (i=0;i<strlen(call->rtpMask) && i<strlen(ip3);i++)
+	if (call->rtpMask[i] != 'x' && call->rtpMask[i] != ip3[i]) {
+	 OOTRACEERR5("ERROR:H245 Address is not matched with filter %s/%s"
+			"(%s, %s)\n", ip3, call->rtpMask, call->callType, call->callToken);
+	 return OO_FAILED;
+	}
+	 
+   }
    return OO_OK;
 }
 

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c Thu Sep 24 19:21:08 2009
@@ -526,6 +526,11 @@
                
                if(ret != OO_OK)
                {
+               	if(call->callState < OO_CALL_CLEAR)
+               	{
+                  call->callEndReason = OO_REASON_INVALIDMESSAGE;
+                  call->callState = OO_CALL_CLEAR;
+               	}
                   OOTRACEERR3("ERROR:Unsupported media channel address type "
                               "(%s, %s)\n", call->callType, call->callToken);
                   return OO_FAILED;
@@ -584,6 +589,22 @@
             call->callState = OO_CALL_CLEAR;
          }
          return OO_FAILED;
+      }
+      if(call->remoteH245Port != 0 && !call->pH245Channel) {
+      /* Create an H.245 connection. 
+      */
+       if(ooCreateH245Connection(call)== OO_FAILED)
+       {
+         OOTRACEERR3("Error: H.245 channel creation failed (%s, %s)\n", 
+                     call->callType, call->callToken);
+
+         if(call->callState < OO_CALL_CLEAR)
+         {
+            call->callEndReason = OO_REASON_TRANSPORTFAILURE;
+            call->callState = OO_CALL_CLEAR;
+         }
+         return OO_FAILED;
+       }
       }
    }
    return OO_OK;
@@ -743,6 +764,11 @@
                
                if(ret != OO_OK)
                {
+               	if(call->callState < OO_CALL_CLEAR)
+               	{
+                  call->callEndReason = OO_REASON_INVALIDMESSAGE;
+                  call->callState = OO_CALL_CLEAR;
+               	}
                   OOTRACEERR3("ERROR:Unsupported media channel address type "
                               "(%s, %s)\n", call->callType, call->callToken);
                   return OO_FAILED;
@@ -765,8 +791,8 @@
          finishPrint();
          removeEventHandler(call->pctxt);
          OO_SETFLAG(call->flags, OO_M_FASTSTARTANSWERED);
-      }
-      
+      } 
+
    }
 
    /* Retrieve the H.245 control channel address from the connect msg */
@@ -801,6 +827,22 @@
             call->callState = OO_CALL_CLEAR;
          }
          return OO_FAILED;
+      }
+      if(call->remoteH245Port != 0 && !call->pH245Channel) {
+      /* Create an H.245 connection. 
+      */
+       if(ooCreateH245Connection(call)== OO_FAILED)
+       {
+         OOTRACEERR3("Error: H.245 channel creation failed (%s, %s)\n", 
+                     call->callType, call->callToken);
+
+         if(call->callState < OO_CALL_CLEAR)
+         {
+            call->callEndReason = OO_REASON_TRANSPORTFAILURE;
+            call->callState = OO_CALL_CLEAR;
+         }
+         return OO_FAILED;
+       }
       }
    }
 
@@ -961,6 +1003,11 @@
                
                if(ret != OO_OK)
                {
+               	if(call->callState < OO_CALL_CLEAR)
+               	{
+                  call->callEndReason = OO_REASON_INVALIDMESSAGE;
+                  call->callState = OO_CALL_CLEAR;
+               	}
                   OOTRACEERR3("ERROR:Unsupported media channel address type "
                               "(%s, %s)\n", call->callType, call->callToken);
                   return OO_FAILED;
@@ -1020,6 +1067,22 @@
          }
          return OO_FAILED;
       }
+      if(call->remoteH245Port != 0 && !call->pH245Channel) {
+       /* Create an H.245 connection. 
+      */
+       if(ooCreateH245Connection(call)== OO_FAILED)
+       {
+         OOTRACEERR3("Error: H.245 channel creation failed (%s, %s)\n", 
+                     call->callType, call->callToken);
+
+         if(call->callState < OO_CALL_CLEAR)
+         {
+            call->callEndReason = OO_REASON_TRANSPORTFAILURE;
+            call->callState = OO_CALL_CLEAR;
+         }
+         return OO_FAILED;
+       }
+      }
    }
 
    return OO_OK;
@@ -1184,6 +1247,11 @@
                                    &pChannel->remoteMediaPort);
             if(ret != OO_OK)
             {
+               	if(call->callState < OO_CALL_CLEAR)
+               	{
+                  call->callEndReason = OO_REASON_INVALIDMESSAGE;
+                  call->callState = OO_CALL_CLEAR;
+               	}
                OOTRACEERR3("ERROR:Unsupported media channel address type "
                            "(%s, %s)\n", call->callType, call->callToken);
                finishPrint();
@@ -1243,7 +1311,7 @@
       }
    }
 
-   if(call->remoteH245Port != 0)
+   if(call->remoteH245Port != 0 && !call->pH245Channel)
    {
        /* Create an H.245 connection. 
       */
@@ -1349,15 +1417,15 @@
             if(gH323ep.gkClient->state == GkClientRegistered)
             {
                call->callState = OO_CALL_WAITING_ADMISSION;
-	       // ast_mutex_lock(&call->Lock);
+	       ast_mutex_lock(&call->Lock);
                ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, 
                                                     FALSE);
                 clock_gettime(CLOCK_REALTIME, &ts);
                 ts.tv_sec += 24;
-                sem_timedwait(&call->gkWait, &ts);
+                ast_cond_timedwait(&call->gkWait, &call->Lock, &ts);
                 if (call->callState == OO_CALL_WAITING_ADMISSION)
 			call->callState = OO_CALL_CLEAR;
-               // ast_mutex_unlock(&call->Lock);
+                ast_mutex_unlock(&call->Lock);
 
             }
             else {

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323ep.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323ep.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323ep.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323ep.c Thu Sep 24 19:21:08 2009
@@ -683,6 +683,18 @@
                              startTransmitChannel, stopReceiveChannel, 
                              stopTransmitChannel, FALSE);
 }
+int ooH323EpAddSpeexCapability(int cap, int txframes, int rxframes, 
+                              OOBOOL silenceSuppression, int dir,
+                              cb_StartReceiveChannel startReceiveChannel,
+                              cb_StartTransmitChannel startTransmitChannel,
+                              cb_StopReceiveChannel stopReceiveChannel,
+                              cb_StopTransmitChannel stopTransmitChannel)
+{
+   return ooCapabilityAddSimpleCapability(NULL, cap, txframes, rxframes, 
+                             silenceSuppression, dir, startReceiveChannel, 
+                             startTransmitChannel, stopReceiveChannel, 
+                             stopTransmitChannel, FALSE);
+}
 
 int ooH323EpAddGSMCapability(int cap, ASN1USINT framesPerPkt, 
                              OOBOOL comfortNoise, OOBOOL scrambled, int dir,

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c Thu Sep 24 19:21:08 2009
@@ -1542,13 +1542,14 @@
 }
 
 
-int ooSendFacility(OOH323CallData *call)
+int ooSendStartH245Facility(OOH323CallData *call)
 {
    int ret=0;
    Q931Message *pQ931Msg = NULL;
    H225Facility_UUIE *facility=NULL;
    /* OOCTXT *pctxt = &gH323ep.msgctxt; */
    OOCTXT *pctxt = call->msgctxt;
+   H225TransportAddress_ipAddress *h245IpAddr;
 
    OOTRACEDBGA3("Building Facility message (%s, %s)\n", call->callType,
                  call->callToken);
@@ -1600,7 +1601,29 @@
    memcpy(facility->callIdentifier.guid.data, 
           call->callIdentifier.guid.data, 
           call->callIdentifier.guid.numocts);
-   facility->reason.t = T_H225FacilityReason_transportedInformation;
+   facility->reason.t = T_H225FacilityReason_startH245;
+
+   if (!call->h245listener && ooCreateH245Listener(call) != OO_OK) {
+	OOTRACEERR ("Error:No H245Listener, can't send startH245 facility (%s, %s)\n",
+		    call->callType, call->callToken);
+	return OO_FAILED;
+   }
+
+   facility->m.h245AddressPresent = TRUE;
+   facility->h245Address.t = T_H225TransportAddress_ipAddress;
+
+   h245IpAddr = (H225TransportAddress_ipAddress*)
+   	memAllocZ (pctxt, sizeof(H225TransportAddress_ipAddress));
+   if(!h245IpAddr) {
+         OOTRACEERR3("Error:Memory - ooSendFacility - h245IpAddr"
+                     "(%s, %s)\n", call->callType, call->callToken);
+         return OO_FAILED;
+   }
+   ooSocketConvertIpToNwAddr(call->localIP, h245IpAddr->ip.data);
+   h245IpAddr->ip.numocts=4;
+   h245IpAddr->port = *(call->h245listenport);
+   facility->h245Address.u.ipAddress = h245IpAddr;
+
    OOTRACEDBGA3("Built Facility message to send (%s, %s)\n", call->callType,
                  call->callToken);
 
@@ -2009,7 +2032,7 @@
       ast_mutex_lock(&fwdedCall->Lock);
       clock_gettime(CLOCK_REALTIME, &ts);
       ts.tv_sec += 24;
-      sem_timedwait(&fwdedCall->gkWait, &ts);
+      ast_cond_timedwait(&fwdedCall->gkWait, &fwdedCall->Lock, &ts);
       if (fwdedCall->callState == OO_CALL_WAITING_ADMISSION) /* GK is not responding */
           fwdedCall->callState = OO_CALL_CLEAR;
       ast_mutex_unlock(&fwdedCall->Lock);
@@ -2128,14 +2151,14 @@
         MakeCall command */
 
      call->callState = OO_CALL_WAITING_ADMISSION;
-     // ast_mutex_lock(&call->Lock);
+     ast_mutex_lock(&call->Lock);
      ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, FALSE);
      clock_gettime(CLOCK_REALTIME, &ts);
      ts.tv_sec += 24;
-     sem_timedwait(&call->gkWait, &ts);
+     ast_cond_timedwait(&call->gkWait, &call->Lock, &ts);
      if (call->callState == OO_CALL_WAITING_ADMISSION)
 		call->callState = OO_CALL_CLEAR;
-     // ast_mutex_unlock(&call->Lock);
+     ast_mutex_unlock(&call->Lock);
 
    }
 

Modified: team/may/chan_ooh323_rework/addons/ooh323cDriver.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_rework/addons/ooh323cDriver.c?view=diff&rev=220456&r1=220455&r2=220456
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323cDriver.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323cDriver.c Thu Sep 24 19:21:08 2009
@@ -302,7 +302,7 @@
                                               call->callType, call->callToken);
 	 txframes = prefs->framing[x];
          ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes, 
-                                      grxframes, OORXANDTX, 
+                                      txframes, OORXANDTX, 

[... 40 lines stripped ...]



More information about the svn-commits mailing list