Mon Nov 6 06:42:43 2006

Asterisk developer's documentation


callerid.h File Reference

CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata library. Caller ID names are currently 8 bit characters, propably ISO8859-1, depending on what your channel drivers handle. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define AST_LIN2X(a)   ((codec == AST_FORMAT_ALAW) ? (AST_LIN2A(a)) : (AST_LIN2MU(a)))
#define AST_PRES_ALLOWED   0x00
#define AST_PRES_ALLOWED_NETWORK_NUMBER   AST_PRES_NETWORK_NUMBER + AST_PRES_ALLOWED
#define AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN   AST_PRES_USER_NUMBER_FAILED_SCREEN + AST_PRES_ALLOWED
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED   AST_PRES_USER_NUMBER_UNSCREENED + AST_PRES_ALLOWED
#define AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN   AST_PRES_USER_NUMBER_PASSED_SCREEN + AST_PRES_ALLOWED
#define AST_PRES_NETWORK_NUMBER   0x03
#define AST_PRES_NUMBER_NOT_AVAILABLE   AST_PRES_NETWORK_NUMBER + AST_PRES_UNAVAILABLE
#define AST_PRES_NUMBER_TYPE   0x03
#define AST_PRES_PROHIB_NETWORK_NUMBER   AST_PRES_NETWORK_NUMBER + AST_PRES_RESTRICTED
#define AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN   AST_PRES_USER_NUMBER_FAILED_SCREEN + AST_PRES_RESTRICTED
#define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED   AST_PRES_USER_NUMBER_UNSCREENED + AST_PRES_RESTRICTED
#define AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN   AST_PRES_USER_NUMBER_PASSED_SCREEN + AST_PRES_RESTRICTED
#define AST_PRES_RESERVED   0x60
#define AST_PRES_RESTRICTED   0x20
#define AST_PRES_RESTRICTION   0x60
#define AST_PRES_UNAVAILABLE   0x40
#define AST_PRES_USER_NUMBER_FAILED_SCREEN   0x02
#define AST_PRES_USER_NUMBER_PASSED_SCREEN   0x01
#define AST_PRES_USER_NUMBER_UNSCREENED   0x00
#define AST_XLAW(a)   ((codec == AST_FORMAT_ALAW) ? (AST_ALAW(a)) : (AST_MULAW(a)))
#define CID_PRIVATE_NAME   (1 << 0)
#define CID_PRIVATE_NUMBER   (1 << 1)
#define CID_SIG_BELL   1
#define CID_SIG_DTMF   3
#define CID_SIG_V23   2
#define CID_START_POLARITY   2
#define CID_START_RING   1
#define CID_START_USEHIST   3
#define CID_UNKNOWN_NAME   (1 << 2)
#define CID_UNKNOWN_NUMBER   (1 << 3)
#define MAX_CALLERID_SIZE   32000
#define PUT_AUDIO_SAMPLE(y)
#define PUT_BYTE(a)
#define PUT_CLID(byte)
#define PUT_CLID_BAUD(bit)
#define PUT_CLID_MARKMS

Typedefs

typedef callerid_state CIDSTATE

Functions

int ast_callerid_callwaiting_generate (unsigned char *buf, char *name, char *number, int codec)
 Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm) See ast_callerid_generate() for other details.
int ast_callerid_generate (unsigned char *buf, char *name, char *number, int codec)
 Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format).
char * ast_callerid_merge (char *buf, int bufsiz, const char *name, const char *num, const char *unknown)
int ast_callerid_parse (char *instr, char **name, char **location)
 Destructively parse inbuf into name and location (or number) Parses callerid stream from inbuf and changes into useable form, outputed in name and location.
int ast_callerid_split (const char *src, char *name, int namelen, char *num, int numlen)
const char * ast_describe_caller_presentation (int data)
int ast_gen_cas (unsigned char *outbuf, int sas, int len, int codec)
int ast_isphonenumber (char *n)
 Check if a string consists only of digits.
int ast_parse_caller_presentation (const char *data)
void ast_shrink_phone_number (char *n)
 Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
int callerid_feed (struct callerid_state *cid, unsigned char *ubuf, int samples, int codec)
 Read samples into the state machine.
void callerid_free (struct callerid_state *cid)
 Free a callerID state.
int callerid_generate (unsigned char *buf, char *number, char *name, int flags, int callwaiting, int codec)
 Generates a CallerID FSK stream in ulaw format suitable for transmission.
void callerid_get (struct callerid_state *cid, char **number, char **name, int *flags)
 Extract info out of callerID state machine. Flags are listed above.
void callerid_get_dtmf (char *cidstring, char *number, int *flags)
void callerid_init (void)
 CallerID Initialization.
callerid_state * callerid_new (int cid_signalling)
 Create a callerID state machine.
int vmwi_generate (unsigned char *buf, int active, int mdmf, int codec)
 Generate message waiting indicator (stutter tone).

Variables

float cid_di [4]
float cid_dr [4]
float clidsb


Detailed Description

CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata library. Caller ID names are currently 8 bit characters, propably ISO8859-1, depending on what your channel drivers handle.

Note:
Asterisk does not currently support SIP utf8 caller ID names or caller ID's.
See also

Definition in file callerid.h.


Define Documentation

#define PUT_AUDIO_SAMPLE (  ) 

Value:

do { \
   int index = (short)(rint(8192.0 * (y))); \
   *(buf++) = AST_LIN2X(index); \
   bytes++; \
} while(0)

Definition at line 207 of file callerid.h.

#define PUT_BYTE (  ) 

Value:

do { \
   *(buf++) = (a); \
   bytes++; \
} while(0)

Definition at line 202 of file callerid.h.

#define PUT_CLID_MARKMS

Value:

do { \
   int x; \
   for (x=0;x<8;x++) \
      PUT_AUDIO_SAMPLE(callerid_getcarrier(&cr, &ci, 1)); \
} while(0)

Definition at line 213 of file callerid.h.


Function Documentation

int ast_callerid_generate ( unsigned char *  buf,
char *  name,
char *  number,
int  codec 
)

Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format).

Parameters:
buf buffer for output samples. See callerid_generate() for details regarding buffer.
name Caller-ID Name
number Caller-ID Number
codec Asterisk codec (either AST_FORMAT_ALAW or AST_FORMAT_ULAW)
Acts like callerid_generate except uses an asterisk format callerid string.

int ast_callerid_parse ( char *  instr,
char **  name,
char **  location 
)

Destructively parse inbuf into name and location (or number) Parses callerid stream from inbuf and changes into useable form, outputed in name and location.

Parameters:
instr buffer of callerid stream (in audio form) to be parsed. Warning, data in buffer is changed.
name address of a pointer-to-char for the name value of the stream.
location address of a pointer-to-char for the phone number value of the stream.
Returns:
Returns 0 on success, -1 on failure.

int ast_gen_cas ( unsigned char *  outbuf,
int  sas,
int  len,
int  codec 
)

Parameters:
outbuf Allocated buffer for data. Must be at least 2400 bytes unless no SAS is desired
sas Non-zero if CAS should be preceeded by SAS
len How many samples to generate.
codec Which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
Returns:
Returns -1 on error (if len is less than 2400), 0 on success.

int ast_isphonenumber ( char *  n  ) 

Check if a string consists only of digits.

Parameters:
n number to be checked.
Returns:
Returns 0 if n is a number, 1 if it's not.

void ast_shrink_phone_number ( char *  n  ) 

Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...

Parameters:
n The number to be stripped/shrunk
Returns:
Returns nothing important

int callerid_feed ( struct callerid_state *  cid,
unsigned char *  ubuf,
int  samples,
int  codec 
)

Read samples into the state machine.

Parameters:
cid Which state machine to act upon
ubuf containing your samples
samples number of samples contained within the buffer.
codec which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
Send received audio to the Caller*ID demodulator.
Returns:
Returns -1 on error, 0 for "needs more samples", and 1 if the CallerID spill reception is complete.

void callerid_free ( struct callerid_state *  cid  ) 

Free a callerID state.

Parameters:
cid This is the callerid_state state machine to free This function frees callerid_state cid.

int callerid_generate ( unsigned char *  buf,
char *  number,
char *  name,
int  flags,
int  callwaiting,
int  codec 
)

Generates a CallerID FSK stream in ulaw format suitable for transmission.

Parameters:
buf Buffer to use. If "buf" is supplied, it will use that buffer instead of allocating its own. "buf" must be at least 32000 bytes in size of you want to be sure you don't have an overrun.
number Use NULL for no number or "P" for "private"
name name to be used
flags passed flags
callwaiting callwaiting flag
codec -- either AST_FORMAT_ULAW or AST_FORMAT_ALAW This function creates a stream of callerid (a callerid spill) data in ulaw format.
Returns:
It returns the size (in bytes) of the data (if it returns a size of 0, there is probably an error)

void callerid_get ( struct callerid_state *  cid,
char **  number,
char **  name,
int *  flags 
)

Extract info out of callerID state machine. Flags are listed above.

Parameters:
cid Callerid state machine to act upon
number Pass the address of a pointer-to-char (will contain the phone number)
name Pass the address of a pointer-to-char (will contain the name)
flags Pass the address of an int variable(will contain the various callerid flags)
This function extracts a callerid string out of a callerid_state state machine. If no number is found, *number will be set to NULL. Likewise for the name. Flags can contain any of the following:

Returns:
Returns nothing.

void callerid_get_dtmf ( char *  cidstring,
char *  number,
int *  flags 
)

Parameters:
cidstring The actual transmitted string.
number The cid number is returned here.
flags The cid flags are returned here. This function parses DTMF callerid.

void callerid_init ( void   ) 

CallerID Initialization.

Initializes the callerid system. Mostly stuff for inverse FFT

struct callerid_state* callerid_new ( int  cid_signalling  ) 

Create a callerID state machine.

Parameters:
cid_signalling Type of signalling in use
This function returns a malloc'd instance of the callerid_state data structure.
Returns:
Returns a pointer to a malloc'd callerid_state structure, or NULL on error.


Generated on Mon Nov 6 06:42:43 2006 for Asterisk - the Open Source PBX by  doxygen 1.5.1