⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gatepars.c

📁 dialogic voip 测试代码
💻 C
📖 第 1 页 / 共 2 页
字号:
      if(strncmp(p,"ipt_uui",3) == 0) {
         /* get this UUI string */
         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.IPT_UUI,lname);
		 }

         return (0);         
      }


      if(strncmp(p,"nonstdparm",10) == 0) {
         /* get this call string */
         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.NonStdData,lname);			 
		 }

         return (0);         
      }



      /* Parse the UII parameter */

	  if(strncmp(p,"uii",3) == 0) {

         /* get this call string */

         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {

            return(-1);

         }

         for(index = firstSession; index <= lastSession; index++) {

			 strcpy(Session[index].ConfigFileParm.UII.Val,lname);

		 }



         return (0);         

      }



	  

	  /* Parse the Nonstandard Command parameter */

	  if(strncmp(p,"nonstdcmd",9) == 0) {

         /* get this call string */

         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {

            return(-1);

         }

         for(index = firstSession; index <= lastSession; index++) {

			 strcpy(Session[index].ConfigFileParm.NonStdCmd.Val,lname);

		 }



         return (0);         

      }



      /* Parse the ObjectId parameter */

	  if(strncmp(p,"objid",5) == 0) {

         /* get this call string */

         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {

            return(-1);

         }

         for(index = firstSession; index <= lastSession; index++) {

			 strcpy(Session[index].ConfigFileParm.NonStdObjID,lname);

			 strcpy(Session[index].ConfigFileParm.NonStdCmd.ObjId,lname);

			 strcpy(Session[index].ConfigFileParm.Q931Facility.ObjId,lname);

		 }



         return (0);         

      }



       /* Parse the Q931 Facility  parameter */

	   if(strncmp(p,"q931facility",11) == 0) {

         /* get this call string */

         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {

            return(-1);

         }

         for(index = firstSession; index <= lastSession; index++) {

			 strcpy(Session[index].ConfigFileParm.Q931Facility.Data,lname);

		 }



         return (0);         

      }





	          
     /* Get outgoing phone number if any */
      if(strncmp(p,"localphonenumber",5) == 0) {

         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.localPhoneNumber,lname);
		 }

         return (0);        
      }


      /* Get local phone number if any */
      if(strncmp(p,"remotephonenumber",6) == 0) {

         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {
            return(-1);
         }
         for(index = firstSession; index <= lastSession; index++) {
			 strcpy(Session[index].ConfigFileParm.phoneList,lname);
		 }

         return (0);        
      }

	   /* Get pstn Protocol name */
      if(strncmp(p,"pstnprotocol",5) == 0) {

         /* get Protocol string */
         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {
            printf("\tIllegal configuration line %d :\n\t%s\n",line,p);
            return(-1);
         }
         
		 strcpy(pstnProtocol,lname);
		 return (0);
      }

	  
	   /* Get ip Protocol name */
      if(strncmp(p,"ipprotocol",5) == 0) {

         /* get Protocol string */
         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {
            printf("\tIllegal configuration line %d :\n\t%s\n",line,p);
            return(-1);
         }
         
		 strcpy(ipProtocol,lname);
		 if(strcmp(ipProtocol,"h323_ntsc")){
			 strcpy(ipProtocol,"H323_NTSC");
		 }
		 return (0);
      }

      /* check if done with this channel return to stage 0 of check */
      if(*p == '}') {
         stage = 0;
         return(0);
      }

   } /* if on-channel==2 */

   if(stage == 4) {

	   /* Get Capability */
      if(strncmp(p,"type",4) == 0) {
         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {

            printf("\tIllegal configuration line %d:\n\t%s\n",line,p);

            return(-1);
         }

		 if (!(getCoderType(lname,&ii))){
			 printf("%s","\tUnknown coder in .cfg file\n");
			return(-2);
		 }


         /* Save capability */
         for(index = firstSession; index <= lastSession; index++) {
			 maxCoders = (++Session[index].ConfigFileParm.maxTxCoders)-1;
             Session[index].ConfigFileParm.Coder[maxCoders].capability = ii;
			
			 /* Initial the field */
             Session[index].ConfigFileParm.Coder[maxCoders].type = GCCAPTYPE_AUDIO;
			 Session[index].ConfigFileParm.Coder[maxCoders].direction = IP_CAP_DIR_LCLTRANSMIT;
			 Session[index].ConfigFileParm.Coder[maxCoders].payload_type = IP_USE_STANDARD_PAYLOADTYPE;
		 }
         return (0);       
      }

      /* Get Coder Frame Per Packet */
      if(strncmp(p,"framesperpkt",11) == 0) {

         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {

            printf("\tIllegal configuration line %d:\n\t%s\n",line,p);

            return(-1);
         }

		 (unsigned int) *ans = (unsigned int)atoi(lname);
		 

         /* Save frame per packet */
         for(index = firstSession; index <= lastSession; index++) {
			 maxCoders = Session[index].ConfigFileParm.maxTxCoders-1;
			 Session[index].ConfigFileParm.Coder[maxCoders].extra.audio.frames_per_pkt = (unsigned int) *ans;
		 }

         return (0);        
      }

	  
      /* Get VAD enable/disable */
      if(strncmp(p,"vad",3) == 0) {

         if((rc = skip(1,p,(long *)ans,0,(char *)lname)) != 1) {

            printf("\tIllegal configuration line %d:\n\t%s\n",line,p);
            return(-1);
         }

		 (unsigned int) *ans = (unsigned int)atoi(lname);
		 if(((unsigned int) *ans) == 0) {
			 
			 for(index = firstSession; index <= lastSession; index++) {
			    maxCoders = Session[index].ConfigFileParm.maxTxCoders-1;
				Session[index].ConfigFileParm.Coder[maxCoders].extra.audio.VAD = 0;
			 }
		 } 
		 else {
             for(index = firstSession; index <= lastSession; index++) {
				maxCoders = Session[index].ConfigFileParm.maxTxCoders-1;
				Session[index].ConfigFileParm.Coder[maxCoders].extra.audio.VAD = 1; 
			 }
		 }
	 
         return (0);        
      }


      /* check if done with this coder return to stage 2 */
      if(*p == '}') {
         stage = 2;
         return(0);
      }
} /* if stage == 4 */

   
   /* Get self id as string */
   if(strncmp(p,"source",3) == 0) {

      if((rc = skip(1,p,(long *)ans,0,(char *)name)) != 1) {
         return(-1);
      }
        PDLupper(name);
         strcpy(lname,name);
      for(index = firstSession; index <= lastSession; index++) {
		  strcpy(Session[index].ConfigFileParm.srcAddr,lname);
	  }

      return(0);
   }


   /* stage 0 checks for channel -- first 4 letters enough */
   if(strncmp(p,"channel",4) == 0) {
      if((rc = skip(1,p,(long *)ans,2,(char *)lname)) == -1) {
         return(-1);
      }
      switch(rc) {
		  case 1:

			 stage = 1; /* ready to begin */
			 firstSession = ans[0];
			 lastSession = ans[0];
			 return(0);

		  case 2:

			 stage = 1; /* ready to begin */
			 firstSession = ans[0];
			 lastSession = ans[1];

			 return(0);

		  default:
			 printf("Illegal channels (%d) in .cfg FILE\n",*ans);

			 return(-1);
      } /* end of switch(rc) */

   } /* end of if(strncmp(p,"channel",4) == 0) */
   
   return (-1);

} /* function parse_line */

/****************************************************************
*        NAME : getCoderType
* DESCRIPTION : Suits the coder type from configuration file to the
*               defined list. 
*       INPUT : coder: poiner to the string that was read from the 
*                      configuration file.
*               ii: pointer to the return coder 
*      OUTPUT : 
*     RETURNS : 1 if succeeded to find a suitable coder from the 
*               coder list.
*    CAUTIONS : 
****************************************************************/
int getCoderType(char *coder, int *coderType)
{
	
	
	if (strcmp(coder,"g711mulaw")==0){
	    *coderType = GCCAP_AUDIO_g711Ulaw64k;
	    return (1);
    	    }
	else if (strcmp(coder,"g711alaw")==0){
		 *coderType = GCCAP_AUDIO_g711Alaw64k;
		 return (1);
        	 }
             else if (strcmp(coder,"g723_5_3k")==0){
	             *coderType = GCCAP_AUDIO_g7231_5_3k;
	   	     return (1);
  	             }
                   else if (strcmp(coder,"g723_6_3k")==0){
                            *coderType = GCCAP_AUDIO_g7231_6_3k;
                            return (1);
                            }
                        else if (strcmp(coder,"gsm")==0){
		                 *coderType = GCCAP_AUDIO_gsmFullRate;
		                 return (1);
	                         }
						else if (strcmp(coder,"g729a")==0){

							*coderType = GCCAP_AUDIO_g729AnnexA;

							return (1);

						}

						else if (strcmp(coder,"g729ab")==0){

							*coderType = GCCAP_AUDIO_g729AnnexAwAnnexB;

							return (1);

						}

	                    else if (strcmp(coder,"gsmefr")==0){
		                     *coderType = GCCAP_AUDIO_gsmEnhancedFullRate;
		                     return (1);
	                    }
    
	return (0);
}








⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -