[Asterisk-cvs] asterisk/channels iax2-parser.c, 1.29, 1.30 iax2-parser.h, 1.10, 1.11 iax2.h, 1.16, 1.17

markster at lists.digium.com markster at lists.digium.com
Fri Nov 19 16:52:12 CST 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv5616/channels

Modified Files:
	iax2-parser.c iax2-parser.h iax2.h 
Log Message:
Add sampling rate handling


Index: iax2-parser.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/iax2-parser.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- iax2-parser.c	24 Oct 2004 06:44:36 -0000	1.29
+++ iax2-parser.c	19 Nov 2004 21:52:25 -0000	1.30
@@ -111,6 +111,33 @@
 		snprintf(output, maxlen, "Invalid INT");
 }
 
+static void dump_samprate(char *output, int maxlen, void *value, int len)
+{
+	char tmp[256]="";
+	int sr;
+	if (len == (int)sizeof(unsigned short)) {
+		sr = ntohs(*((unsigned short *)value));
+		if (sr & IAX_RATE_8KHZ)
+			strcat(tmp, ",8khz");
+		if (sr & IAX_RATE_11KHZ)
+			strcat(tmp, ",11.025khz");
+		if (sr & IAX_RATE_16KHZ)
+			strcat(tmp, ",16khz");
+		if (sr & IAX_RATE_22KHZ)
+			strcat(tmp, ",22.05khz");
+		if (sr & IAX_RATE_44KHZ)
+			strcat(tmp, ",44.1khz");
+		if (sr & IAX_RATE_48KHZ)
+			strcat(tmp, ",48khz");
+		if (strlen(tmp))
+			strncpy(output, &tmp[1], maxlen - 1);
+		else
+			strncpy(output, "None specified!\n", maxlen - 1);
+	} else
+		snprintf(output, maxlen, "Invalid SHORT");
+
+}
+
 static void dump_prov_ies(char *output, int maxlen, unsigned char *iedata, int len);
 static void dump_prov(char *output, int maxlen, void *value, int len)
 {
@@ -161,6 +188,7 @@
 	{ IAX_IE_CALLINGPRES, "CALLING PRESNTN", dump_byte },
 	{ IAX_IE_CALLINGTON, "CALLING TYPEOFNUM", dump_byte },
 	{ IAX_IE_CALLINGTNS, "CALLING TRANSITNET", dump_short },
+	{ IAX_IE_SAMPLINGRATE, "SAMPLINGRATE", dump_samprate },
 };
 
 static struct iax2_ie prov_ies[] = {
@@ -487,6 +515,7 @@
 	ies->calling_ton = -1;
 	ies->calling_tns = -1;
 	ies->calling_pres = -1;
+	ies->samprate = IAX_RATE_8KHZ;
 	while(datalen >= 2) {
 		ie = data[0];
 		len = data[1];
@@ -547,6 +576,13 @@
 			} else
 				ies->adsicpe = ntohs(*((unsigned short *)(data + 2)));
 			break;
+		case IAX_IE_SAMPLINGRATE:
+			if (len != (int)sizeof(unsigned short)) {
+				snprintf(tmp, (int)sizeof(tmp), "Expecting samplingrate to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
+				errorf(tmp);
+			} else
+				ies->samprate = ntohs(*((unsigned short *)(data + 2)));
+			break;
 		case IAX_IE_DNID:
 			ies->dnid = data + 2;
 			break;

Index: iax2-parser.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/iax2-parser.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- iax2-parser.h	2 Oct 2004 01:56:08 -0000	1.10
+++ iax2-parser.h	19 Nov 2004 21:52:25 -0000	1.11
@@ -54,6 +54,7 @@
 	unsigned char *fwdata;
 	unsigned char fwdatalen;
 	unsigned int provver;
+	unsigned short samprate;
 	int provverpres;
 };
 

Index: iax2.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/iax2.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- iax2.h	2 Oct 2004 01:56:08 -0000	1.16
+++ iax2.h	19 Nov 2004 21:52:25 -0000	1.17
@@ -104,7 +104,7 @@
 #define IAX_IE_TRANSFERID			27		/* Transfer Request Identifier -- int */
 #define IAX_IE_RDNIS				28		/* Referring DNIS -- string */
 #define IAX_IE_PROVISIONING			29		/* Provisioning info */
-#define IAX_IE_AESPROVISIONING			30		/* AES Provisioning info */
+#define IAX_IE_AESPROVISIONING		30		/* AES Provisioning info */
 #define IAX_IE_DATETIME				31		/* Date/Time */
 #define IAX_IE_DEVICETYPE			32		/* Device Type -- string */
 #define IAX_IE_SERVICEIDENT			33		/* Service Identifier -- string */
@@ -115,6 +115,7 @@
 #define IAX_IE_CALLINGPRES			38		/* Calling presentation (u8) */
 #define IAX_IE_CALLINGTON			39		/* Calling type of number (u8) */
 #define IAX_IE_CALLINGTNS			40		/* Calling transit network select (u16) */
+#define IAX_IE_SAMPLINGRATE			41		/* Supported sampling rates (u16) */
 
 #define IAX_AUTH_PLAINTEXT			(1 << 0)
 #define IAX_AUTH_MD5				(1 << 1)
@@ -123,6 +124,13 @@
 #define IAX_META_TRUNK				1		/* Trunk meta-message */
 #define IAX_META_VIDEO				2		/* Video frame */
 
+#define IAX_RATE_8KHZ				(1 << 0) /* 8khz sampling (default if absent) */
+#define IAX_RATE_11KHZ				(1 << 1) /* 11.025khz sampling */
+#define IAX_RATE_16KHZ				(1 << 2) /* 16khz sampling */
+#define IAX_RATE_22KHZ				(1 << 3) /* 22.05khz sampling */
+#define IAX_RATE_44KHZ				(1 << 4) /* 44.1khz sampling */
+#define IAX_RATE_48KHZ				(1 << 5) /* 48khz sampling */
+
 #define IAX_DPSTATUS_EXISTS			(1 << 0)
 #define IAX_DPSTATUS_CANEXIST		(1 << 1)
 #define IAX_DPSTATUS_NONEXISTANT	(1 << 2)




More information about the svn-commits mailing list