aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--formats/format_g723.c2
-rw-r--r--formats/format_g726.c2
-rw-r--r--formats/format_g729.c2
-rw-r--r--formats/format_gsm.c2
-rw-r--r--formats/format_h263.c2
-rw-r--r--formats/format_h264.c2
-rw-r--r--formats/format_ilbc.c2
-rw-r--r--formats/format_ogg_vorbis.c2
-rw-r--r--formats/format_pcm.c2
-rw-r--r--formats/format_sln.c2
-rw-r--r--formats/format_vox.c2
-rw-r--r--formats/format_wav.c2
-rw-r--r--formats/format_wav_gsm.c2
-rw-r--r--include/asterisk/frame.h10
14 files changed, 22 insertions, 14 deletions
diff --git a/formats/format_g723.c b/formats/format_g723.c
index 594f3d1c0..4beba0c64 100644
--- a/formats/format_g723.c
+++ b/formats/format_g723.c
@@ -76,7 +76,7 @@ static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_G723_1;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size);
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != size) {
ast_log(LOG_WARNING, "Short read (%d of %d bytes) (%s)!\n", res, size, strerror(errno));
return NULL;
diff --git a/formats/format_g726.c b/formats/format_g726.c
index 135e0a8fe..d72f48991 100644
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -137,7 +137,7 @@ static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_G726;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]);
s->fr.samples = 8 * FRAME_TIME;
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
if (res)
diff --git a/formats/format_g729.c b/formats/format_g729.c
index f2eef83e4..1719e3a5c 100644
--- a/formats/format_g729.c
+++ b/formats/format_g729.c
@@ -62,7 +62,7 @@ static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext)
s->fr.subclass = AST_FORMAT_G729A;
s->fr.mallocd = 0;
s->fr.samples = G729A_SAMPLES;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
if (res && (res != 10)) /* XXX what for ? */
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_gsm.c b/formats/format_gsm.c
index bc91d1f0b..423088c17 100644
--- a/formats/format_gsm.c
+++ b/formats/format_gsm.c
@@ -67,7 +67,7 @@ static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_GSM;
- FR_SET_BUF(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
+ AST_FRAME_SET_BUFFER(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE)
s->fr.mallocd = 0;
if ((res = fread(s->fr.data, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) {
if (res)
diff --git a/formats/format_h263.c b/formats/format_h263.c
index ee455beb3..c64e001fd 100644
--- a/formats/format_h263.c
+++ b/formats/format_h263.c
@@ -88,7 +88,7 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VIDEO;
s->fr.subclass = AST_FORMAT_H263;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_h264.c b/formats/format_h264.c
index 3e358086e..26db782e5 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -84,7 +84,7 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VIDEO;
s->fr.subclass = AST_FORMAT_H264;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
if (res)
ast_log(LOG_WARNING, "Short read (%d of %d) (%s)!\n", res, len, strerror(errno));
diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c
index 2a027cb99..940abf25f 100644
--- a/formats/format_ilbc.c
+++ b/formats/format_ilbc.c
@@ -60,7 +60,7 @@ static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_ILBC;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE);
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c
index 2ca0cce34..ee12e6a8f 100644
--- a/formats/format_ogg_vorbis.c
+++ b/formats/format_ogg_vorbis.c
@@ -436,7 +436,7 @@ static struct ast_frame *ogg_vorbis_read(struct ast_filestream *fs,
fs->fr.frametype = AST_FRAME_VOICE;
fs->fr.subclass = AST_FORMAT_SLINEAR;
fs->fr.mallocd = 0;
- FR_SET_BUF(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+ AST_FRAME_SET_BUFFER(&fs->fr, fs->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
while (samples_out != SAMPLES_MAX) {
float **pcm;
diff --git a/formats/format_pcm.c b/formats/format_pcm.c
index 493d8afe9..889e7afc2 100644
--- a/formats/format_pcm.c
+++ b/formats/format_pcm.c
@@ -95,7 +95,7 @@ static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = s->fmt->format;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_sln.c b/formats/format_sln.c
index 939a121bb..3e4d2e0c9 100644
--- a/formats/format_sln.c
+++ b/formats/format_sln.c
@@ -54,7 +54,7 @@ static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_vox.c b/formats/format_vox.c
index 5afc1e322..b1f7e688a 100644
--- a/formats/format_vox.c
+++ b/formats/format_vox.c
@@ -56,7 +56,7 @@ static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_ADPCM;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE);
if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) {
if (res)
ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
diff --git a/formats/format_wav.c b/formats/format_wav.c
index f56cdae4d..eb3b2d5ad 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -369,7 +369,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes);
if ( (res = fread(s->fr.data, 1, s->fr.datalen, s->f)) <= 0 ) {
if (res)
diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c
index 85b9902c7..d2fa1c0ce 100644
--- a/formats/format_wav_gsm.c
+++ b/formats/format_wav_gsm.c
@@ -379,7 +379,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
s->fr.offset = AST_FRIENDLY_OFFSET;
s->fr.samples = GSM_SAMPLES;
s->fr.mallocd = 0;
- FR_SET_BUF(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE);
+ AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE);
if (fs->secondhalf) {
/* Just return a frame based on the second GSM frame */
s->fr.data = (char *)s->fr.data + GSM_FRAME_SIZE;
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 21b596928..099e20080 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -111,7 +111,15 @@ struct ast_frame {
struct ast_frame *next;
};
-#define FR_SET_BUF(fr, _base, _ofs, _datalen) \
+/*!
+ * Set the various field of a frame to point to a buffer.
+ * Typically you set the base address of the buffer, the offset as
+ * AST_FRIENDLY_OFFSET, and the datalen as the amount of bytes queued.
+ * The remaining things (to be done manually) is set the number of
+ * samples, which cannot be derived from the datalen unless you know
+ * the number of bits per sample.
+ */
+#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen) \
{ \
(fr)->data = (char *)_base + (_ofs); \
(fr)->offset = (_ofs); \