Index: include/asterisk/callerid.h =================================================================== --- include/asterisk/callerid.h (.../trunk/include/asterisk/callerid.h) (révision 38) +++ include/asterisk/callerid.h (.../branches/newmwi/include/asterisk/callerid.h) (révision 40) @@ -61,6 +61,14 @@ #define CID_START_POLARITY_IN 3 +/* defines dealing with message waiting indication generation */ +/*! MWI SDMF format */ +#define CID_MWI_TYPE_SDMF 0x00 +/*! MWI MDMF format -- generate only MWI field */ +#define CID_MWI_TYPE_MDMF 0x01 +/*! MWI MDMF format -- generate name, callerid, date and MWI fields */ +#define CID_MWI_TYPE_MDMF_FULL 0x02 + #define AST_LIN2X(a) ((codec == AST_FORMAT_ALAW) ? (AST_LIN2A(a)) : (AST_LIN2MU(a))) #define AST_XLAW(a) ((codec == AST_FORMAT_ALAW) ? (AST_ALAW(a)) : (AST_MULAW(a))) @@ -75,7 +83,8 @@ void callerid_init(void); /*! \brief Generates a CallerID FSK stream in ulaw format suitable for transmission. - * \param 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. + * \param buf Buffer to use. "buf" must be at least MAX_CALLERID_SIZE bytes in size if + * you don't want to suffer an overrun. * \param number Use NULL for no number or "P" for "private" * \param name name to be used * \param flags passed flags @@ -84,9 +93,29 @@ * This function creates a stream of callerid (a callerid spill) data in ulaw format. * \return It returns the size * (in bytes) of the data (if it returns a size of 0, there is probably an error) + * \note generated callerid uses MDMF format */ int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, int codec); +/*! \brief Generate message waiting indicator + * \param on The message indicator state + * -- either 0 no messages in mailbox or 1 messages in mailbox + * \param type Format of message (any of CID_MWI_TYPE_*) + * \see callerid_generate() for more info as it use the same encoding +*/ +int vmwi_generate(unsigned char *buf, int on, int type, int codec, const char *name, + const char *number, int flags); + +/*! \brief Is this caller id a message waiting indication? +*/ +int callerid_is_mwi(struct callerid_state *cid); + +/*! \brief Get the message waiting indicator status -- is it on? +* \return 1 if it's on or 0 otherwise (-1 means that something went wrong) +* \note only valid if callerid_is_mwi() returns true +*/ +int callerid_is_mwi_on(struct callerid_state *cid); + /*! \brief Create a callerID state machine * \param cid_signalling Type of signalling in use * @@ -104,6 +133,8 @@ * Send received audio to the Caller*ID demodulator. * \return Returns -1 on error, 0 for "needs more samples", * and 1 if the CallerID spill reception is complete. + * \note should parse correctly MDMF and SDMF format + * including Message Waiting Indication messages */ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, int codec); @@ -158,8 +189,14 @@ */ int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, int codec); -/*! \brief Generate message waiting indicator (stutter tone) */ -int vmwi_generate(unsigned char *buf, int active, int mdmf, int codec); +/*! \brief Generate Message Waiting Indicator spill + * + * This is a simple call to vmwi_generate() using asterisk's callerid string format. + * + * \see vmwi_generate() for more info + */ +int ast_vmwi_generate(unsigned char *buf, int on, int type, const char *name, + const char *number, int codec); /*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm) * See ast_callerid_generate() for other details