Additional TDD changes (preparing for SIP changes - adding TDD support to SIP)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89048 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Olle Johansson
2007-11-06 19:10:26 +00:00
parent 23a02e04c5
commit 6519abeffc
2 changed files with 27 additions and 16 deletions

View File

@@ -34,35 +34,29 @@ typedef struct tdd_state TDDSTATE;
*/ */
void tdd_init(void); void tdd_init(void);
/*! /*! Generates a CallerID FSK stream in ulaw format suitable for transmission.
* \brief Generates a CallerID FSK stream in ulaw format suitable for transmission.
* \param tdd tdd structure * \param tdd tdd structure
* \param buf Buffer to use. This needs to be large enough to accomodate all the generated samples. * \param buf Buffer to use. This needs to be large enough to accomodate all the generated samples.
* \param string This is the string to send. * \param string This is the string to send.
* This function creates a stream of TDD data in ulaw format. * This function creates a stream of TDD data in ulaw format. It returns the size
* \return The size (in bytes) of the data (if it returns a size of 0, there is probably an error) * (in bytes) of the data (if it returns a size of 0, there is probably an error)
*/ */
int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *string); int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *string);
/*! /*! Create a TDD state machine
* \brief Create a TDD state machine.
* This function returns a malloc'd instance of the tdd_state data structure. * This function returns a malloc'd instance of the tdd_state data structure.
* \retval a pointer to a malloc'd tdd_state structure * Returns a pointer to a malloc'd tdd_state structure, or NULL on error.
* \retval NULL on error.
*/ */
struct tdd_state *tdd_new(void); struct tdd_state *tdd_new(void);
/*! /*! Read samples into the state machine, and return character (if any).
* \brief Read samples into the state machine, and return character (if any).
* \param tdd Which state machine to act upon * \param tdd Which state machine to act upon
* \param ubuf containing your samples * \param ubuf containing your samples
* \param samples number of samples contained within the buffer. * \param samples number of samples contained within the buffer.
* *
* Send received audio to the TDD demodulator. * Send received audio to the TDD demodulator.
* * Returns -1 on error, 0 for "needs more samples",
* \retval -1 on error * and > 0 (the character) if reception of a character is complete.
* \retval 0 for "needs more samples"
* \retval > 0 (the character) if reception of a character is complete.
*/ */
int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples); int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples);
@@ -75,9 +69,14 @@ void tdd_free(struct tdd_state *tdd);
/*! Generate Echo Canceller disable tone (2100HZ) /*! Generate Echo Canceller disable tone (2100HZ)
* \param outbuf This is the buffer to receive the tone data * \param outbuf This is the buffer to receive the tone data
* \param len This is the length (in samples) of the tone data to generate * \param len This is the length (in samples) of the tone data to generate
* \retval 0 if no error * Returns 0 if no error, and -1 if error.
* \retval -1 if error.
*/ */
int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len); int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len);
/*! Generate hold tone
* \param outbuf This is the buffer to receive the tone data
*/
int tdd_gen_holdtone(unsigned char* outbuf);
#endif /* _ASTERISK_TDD_H */ #endif /* _ASTERISK_TDD_H */

View File

@@ -261,6 +261,18 @@ static inline float tdd_getcarrier(float *cr, float *ci, int bit)
PUT_TDD_STOP; /* Stop bit */ \ PUT_TDD_STOP; /* Stop bit */ \
} while(0); } while(0);
/*! Generate TDD hold tone */
int tdd_gen_holdtone(unsigned char *buf)
{
int bytes=0;
float scont=0.0,cr=1.0,ci=0.0;
while(scont < tddsb*10.0) {
PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, 1));
scont += 1.0;
}
return bytes;
}
int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *str) int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *str)
{ {
int bytes=0; int bytes=0;