diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-05-27 16:42:14 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-05-27 16:42:14 +0200 |
commit | f3d2ad6a19a4303e8e914f4efb1bef36ab2e6b79 (patch) | |
tree | de7ca771b46e11b49e1416241ee939ceb8f93079 /src | |
parent | d192d8c017492a740353780d115bd4fc6cec20e9 (diff) |
add some more comments throughout the code
Diffstat (limited to 'src')
-rw-r--r-- | src/fmt_amr.c | 4 | ||||
-rw-r--r-- | src/fmt_gsm.c | 2 | ||||
-rw-r--r-- | src/pq_codec.c | 7 | ||||
-rw-r--r-- | src/pq_file.c | 12 | ||||
-rw-r--r-- | src/pq_format.c | 4 | ||||
-rw-r--r-- | src/pq_rtp.c | 13 | ||||
-rw-r--r-- | src/procqueue.c | 12 |
7 files changed, 53 insertions, 1 deletions
diff --git a/src/fmt_amr.c b/src/fmt_amr.c index 3017103..2990d7c 100644 --- a/src/fmt_amr.c +++ b/src/fmt_amr.c @@ -1,4 +1,4 @@ -/* Classic .amr file format */ +/* Classic .amr file format. Be warned, actaully contains EFR ;) */ /* * This file is part of gapk (GSM Audio Pocket Knife). @@ -26,6 +26,7 @@ #include <gapk/utils.h> +/* conversion function: .amr file -> canonical format */ static int amr_efr_from_canon(uint8_t *dst, const uint8_t *src) { @@ -43,6 +44,7 @@ amr_efr_from_canon(uint8_t *dst, const uint8_t *src) return 0; } +/* conversion function: canonical format -> .amr file */ static int amr_efr_to_canon(uint8_t *dst, const uint8_t *src) { diff --git a/src/fmt_gsm.c b/src/fmt_gsm.c index 04ca062..8156bee 100644 --- a/src/fmt_gsm.c +++ b/src/fmt_gsm.c @@ -23,6 +23,7 @@ #define GSM_MAGIC 0xd +/* convert canonical -> .gsm */ static int gsm_from_canon(uint8_t *dst, const uint8_t *src) { @@ -35,6 +36,7 @@ gsm_from_canon(uint8_t *dst, const uint8_t *src) return 0; } +/* convert .gsm -> canonical */ static int gsm_to_canon(uint8_t *dst, const uint8_t *src) { diff --git a/src/pq_codec.c b/src/pq_codec.c index 82b79e7..42baf23 100644 --- a/src/pq_codec.c +++ b/src/pq_codec.c @@ -25,6 +25,11 @@ #include <gapk/procqueue.h> +/*! Add a codecl to the processing queue + * \param pq Processing Queue to which the codec is added + * \param[in] codec description + * \param[in] encode (1) or decode (0) + * \returns 0 on success; negative on error */ int pq_queue_codec(struct pq *pq, const struct codec_desc *codec, int enc_dec_n) { @@ -32,10 +37,12 @@ pq_queue_codec(struct pq *pq, const struct codec_desc *codec, int enc_dec_n) const struct format_desc *fmt; struct pq_item *item; + /* allocate a new item to the processing queue */ item = pq_add_item(pq); if (!item) return -ENOMEM; + /* initialize the codec, if there is an init function */ if (codec->codec_init) { item->state = codec->codec_init(); if (!item->state) diff --git a/src/pq_file.c b/src/pq_file.c index 4b16555..7b9e356 100644 --- a/src/pq_file.c +++ b/src/pq_file.c @@ -86,12 +86,24 @@ pq_queue_file_op(struct pq *pq, FILE *fh, unsigned int blk_len, int in_out_n) } +/*! Add file input to given processing queue + * This usually only makes sense as first item in the queue + * \param pq Processing Queue to add the input file to + * \param[in] src caller-fopen()ed input file + * \param[in] blk_len block length to be read from file + * \returns 0 on sucess; negative on error */ int pq_queue_file_input(struct pq *pq, FILE *src, unsigned int blk_len) { return pq_queue_file_op(pq, src, blk_len, 1); } +/*! Add file output to given processing queue + * This usually only makes sense as first item in the queue + * \param pq Processing Queue to add the output file to + * \param[in] dst caller-fopen()ed output file + * \param[in] blk_len block length to be written to file + * \returns 0 on sucess; negative on error */ int pq_queue_file_output(struct pq *pq, FILE *dst, unsigned int blk_len) { diff --git a/src/pq_format.c b/src/pq_format.c index 876ac19..4e9515a 100644 --- a/src/pq_format.c +++ b/src/pq_format.c @@ -32,6 +32,10 @@ pq_cb_fmt_convert(void *_state, uint8_t *out, const uint8_t *in) return f(out, in); } +/*! Add format conversion to processing queue + * \param pq Processing Queue to add conversion to + * \param[in] fmt Format description for conversion + * \param[in] to_from_n convert to (0) or from (1) specified format */ int pq_queue_fmt_convert(struct pq *pq, const struct format_desc *fmt, int to_from_n) { diff --git a/src/pq_rtp.c b/src/pq_rtp.c index 87e0f2e..6860506 100644 --- a/src/pq_rtp.c +++ b/src/pq_rtp.c @@ -187,6 +187,9 @@ pq_queue_rtp_op(struct pq *pq, int udp_fd, unsigned int blk_len, int in_out_n) state->fd = udp_fd; state->blk_len = blk_len; + /* as we're working in GSM, the sample clock is 8000 Hz and we + * operate at 50 Hz (20ms) codec frames; 8000/50 = 160 samples + * per RTP frame */ state->duration = 160; if (in_out_n == 0) { @@ -213,12 +216,22 @@ pq_queue_rtp_op(struct pq *pq, int udp_fd, unsigned int blk_len, int in_out_n) } +/*! Add RTP input to processing queue. + * This typically only makes sense as first item in the queue + * \param pq Processing Queue to add this RTP input to + * \param[in] udp_fd UDP file descriptor for the RTP input + * \param[in] blk_len Block Length to read from RTP */ int pq_queue_rtp_input(struct pq *pq, int udp_fd, unsigned int blk_len) { return pq_queue_rtp_op(pq, udp_fd, blk_len, 1); } +/*! Add RTP output to processing queue. + * This typically only makes sense as last item in the queue + * \param pq Processing Queue to add this RTP output to + * \param[in] udp_fd UDP file descriptor for the RTP output + * \param[in] blk_len Block Length to read from RTP */ int pq_queue_rtp_output(struct pq *pq, int udp_fd, unsigned int blk_len) { diff --git a/src/procqueue.c b/src/procqueue.c index 1b2626e..2451399 100644 --- a/src/procqueue.c +++ b/src/procqueue.c @@ -33,12 +33,15 @@ struct pq { }; +/* crate a new (empty) processing queue */ struct pq * pq_create(void) { return (struct pq *) calloc(1, sizeof(struct pq)); } +/*! destroy a processing queue, calls exit() callback of each item + * \param[in] pq Processing Queue to be destroyed */ void pq_destroy(struct pq *pq) { @@ -61,6 +64,9 @@ pq_destroy(struct pq *pq) free(pq); } +/*! allocate + add an item to a processing queue; return new item + * \param[in] pq Processing Queue to which item is added + * \returns new PQ item; NULL on error */ struct pq_item * pq_add_item(struct pq *pq) { @@ -78,6 +84,9 @@ pq_add_item(struct pq *pq) return item; } +/*! prepare a processing queue; allocates buffers; checks lengths + * \param[in] pq Processing Queue to be prepared + * \returns 0 on succcess; negative on error */ int pq_prepare(struct pq *pq) { @@ -107,6 +116,9 @@ pq_prepare(struct pq *pq) return 0; } +/*! execute a processing queue; iterate over processing elements + * \param[in] pq Processing Queue to be executed + * \returns 0 on success; negative on error (if any item returns negative) */ int pq_execute(struct pq *pq) { |