aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-11-19 21:52:25 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-11-19 21:52:25 +0000
commitfc16142d07fc83655ecb3efe74b1e01b013cea3a (patch)
tree9896e18e82c8abc6a7dbd5e07641f4b200e84e0d
parent69fca6a9c3f1080a4f92a8535c2222e6196d5d01 (diff)
Add sampling rate handling
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4299 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xchannels/iax2-parser.c36
-rwxr-xr-xchannels/iax2-parser.h1
-rwxr-xr-xchannels/iax2.h10
3 files changed, 46 insertions, 1 deletions
diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c
index 5a0e2421e..b66de4124 100755
--- a/channels/iax2-parser.c
+++ b/channels/iax2-parser.c
@@ -111,6 +111,33 @@ static void dump_prov_flags(char *output, int maxlen, void *value, int len)
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 @@ static struct iax2_ie {
{ 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 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
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 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
} 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;
diff --git a/channels/iax2-parser.h b/channels/iax2-parser.h
index 70bbdc781..cb29a088e 100755
--- a/channels/iax2-parser.h
+++ b/channels/iax2-parser.h
@@ -54,6 +54,7 @@ struct iax_ies {
unsigned char *fwdata;
unsigned char fwdatalen;
unsigned int provver;
+ unsigned short samprate;
int provverpres;
};
diff --git a/channels/iax2.h b/channels/iax2.h
index 2b1e4276e..83817442d 100755
--- a/channels/iax2.h
+++ b/channels/iax2.h
@@ -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)