mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
rename FR_SET_BUF to AST_FRAME_SET_BUFFER
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@18639 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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;
|
||||
|
@@ -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)
|
||||
|
@@ -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));
|
||||
|
@@ -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)
|
||||
|
@@ -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));
|
||||
|
@@ -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));
|
||||
|
@@ -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));
|
||||
|
@@ -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;
|
||||
|
@@ -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));
|
||||
|
@@ -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));
|
||||
|
@@ -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));
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
|
@@ -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); \
|
||||
|
Reference in New Issue
Block a user