|
|
|
@ -48,10 +48,17 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
#include "asterisk/file.h"
|
|
|
|
|
#include "asterisk/logger.h"
|
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* this is the number of samples we deal with. Samples are converted
|
|
|
|
|
* to SLINEAR so each one uses 2 bytes in the buffer.
|
|
|
|
|
*/
|
|
|
|
|
#define SAMPLES_MAX 160
|
|
|
|
|
#define BLOCK_SIZE 4096
|
|
|
|
|
#define BUF_SIZE (2*SAMPLES_MAX)
|
|
|
|
|
|
|
|
|
|
struct vorbis_desc {
|
|
|
|
|
#define BLOCK_SIZE 4096 /* used internally in the vorbis routines */
|
|
|
|
|
|
|
|
|
|
struct vorbis_desc { /* format specific parameters */
|
|
|
|
|
/* structures for handling the Ogg container */
|
|
|
|
|
ogg_sync_state oy;
|
|
|
|
|
ogg_stream_state os;
|
|
|
|
@ -71,14 +78,6 @@ struct vorbis_desc {
|
|
|
|
|
int eos;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AST_MUTEX_DEFINE_STATIC(ogg_vorbis_lock);
|
|
|
|
|
|
|
|
|
|
static int glistcnt = 0;
|
|
|
|
|
|
|
|
|
|
static char *name = "ogg_vorbis";
|
|
|
|
|
static char *desc = "OGG/Vorbis audio";
|
|
|
|
|
static char *exts = "ogg";
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Create a new OGG/Vorbis filestream and set it up for reading.
|
|
|
|
|
* \param f File that points to on disk storage of the OGG/Vorbis data.
|
|
|
|
@ -94,12 +93,11 @@ static int ogg_vorbis_open(struct ast_filestream *s)
|
|
|
|
|
struct vorbis_desc *tmp = (struct vorbis_desc *)s->private;
|
|
|
|
|
|
|
|
|
|
tmp->writing = 0;
|
|
|
|
|
tmp->f = f;
|
|
|
|
|
|
|
|
|
|
ogg_sync_init(&tmp->oy);
|
|
|
|
|
|
|
|
|
|
buffer = ogg_sync_buffer(&tmp->oy, BLOCK_SIZE);
|
|
|
|
|
bytes = fread(buffer, 1, BLOCK_SIZE, f);
|
|
|
|
|
bytes = fread(buffer, 1, BLOCK_SIZE, s->f);
|
|
|
|
|
ogg_sync_wrote(&tmp->oy, bytes);
|
|
|
|
|
|
|
|
|
|
result = ogg_sync_pageout(&tmp->oy, &tmp->og);
|
|
|
|
@ -159,29 +157,25 @@ error:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buffer = ogg_sync_buffer(&tmp->oy, BLOCK_SIZE);
|
|
|
|
|
bytes = fread(buffer, 1, BLOCK_SIZE, f);
|
|
|
|
|
if(bytes == 0 && i < 2) {
|
|
|
|
|
bytes = fread(buffer, 1, BLOCK_SIZE, s->f);
|
|
|
|
|
if (bytes == 0 && i < 2) {
|
|
|
|
|
ast_log(LOG_ERROR, "End of file before finding all Vorbis headers!\n");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
ogg_sync_wrote(&tmp->oy, bytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ptr = tmp->vc.user_comments;
|
|
|
|
|
while(*ptr){
|
|
|
|
|
for (ptr = tmp->vc.user_comments; *ptr; ptr++)
|
|
|
|
|
ast_log(LOG_DEBUG, "OGG/Vorbis comment: %s\n", *ptr);
|
|
|
|
|
++ptr;
|
|
|
|
|
}
|
|
|
|
|
ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate);
|
|
|
|
|
ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor);
|
|
|
|
|
|
|
|
|
|
if(tmp->vi.channels != 1) {
|
|
|
|
|
if (tmp->vi.channels != 1) {
|
|
|
|
|
ast_log(LOG_ERROR, "Only monophonic OGG/Vorbis files are currently supported!\n");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(tmp->vi.rate != DEFAULT_SAMPLE_RATE) {
|
|
|
|
|
if (tmp->vi.rate != DEFAULT_SAMPLE_RATE) {
|
|
|
|
|
ast_log(LOG_ERROR, "Only 8000Hz OGG/Vorbis files are currently supported!\n");
|
|
|
|
|
vorbis_block_clear(&tmp->vb);
|
|
|
|
|
vorbis_dsp_clear(&tmp->vd);
|
|
|
|
@ -191,16 +185,7 @@ error:
|
|
|
|
|
vorbis_synthesis_init(&tmp->vd, &tmp->vi);
|
|
|
|
|
vorbis_block_init(&tmp->vd, &tmp->vb);
|
|
|
|
|
|
|
|
|
|
if(ast_mutex_lock(&ogg_vorbis_lock)) {
|
|
|
|
|
ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
|
|
|
|
|
vorbis_block_clear(&tmp->vb);
|
|
|
|
|
vorbis_dsp_clear(&tmp->vd);
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
glistcnt++;
|
|
|
|
|
ast_mutex_unlock(&ogg_vorbis_lock);
|
|
|
|
|
ast_update_use_count();
|
|
|
|
|
return 0;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@ -209,77 +194,56 @@ return 0;
|
|
|
|
|
* \param comment Comment that should be embedded in the OGG/Vorbis file.
|
|
|
|
|
* \return A new filestream.
|
|
|
|
|
*/
|
|
|
|
|
static struct ast_filestream *ogg_vorbis_rewrite(FILE * f,
|
|
|
|
|
static int ogg_vorbis_rewrite(struct ast_filestream *s,
|
|
|
|
|
const char *comment)
|
|
|
|
|
{
|
|
|
|
|
ogg_packet header;
|
|
|
|
|
ogg_packet header_comm;
|
|
|
|
|
ogg_packet header_code;
|
|
|
|
|
struct vorbis_desc *tmp = (struct vorbis_desc *)s->private;
|
|
|
|
|
|
|
|
|
|
struct ast_filestream *tmp;
|
|
|
|
|
|
|
|
|
|
if ((tmp = malloc(sizeof(struct ast_filestream)))) {
|
|
|
|
|
memset(tmp, 0, sizeof(struct ast_filestream));
|
|
|
|
|
|
|
|
|
|
tmp->writing = 1;
|
|
|
|
|
tmp->f = f;
|
|
|
|
|
|
|
|
|
|
vorbis_info_init(&tmp->vi);
|
|
|
|
|
tmp->writing = 1;
|
|
|
|
|
|
|
|
|
|
if (vorbis_encode_init_vbr(&tmp->vi, 1, DEFAULT_SAMPLE_RATE, 0.4)) {
|
|
|
|
|
ast_log(LOG_ERROR, "Unable to initialize Vorbis encoder!\n");
|
|
|
|
|
free(tmp);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
vorbis_info_init(&tmp->vi);
|
|
|
|
|
|
|
|
|
|
vorbis_comment_init(&tmp->vc);
|
|
|
|
|
vorbis_comment_add_tag(&tmp->vc, "ENCODER", "Asterisk PBX");
|
|
|
|
|
if (comment)
|
|
|
|
|
vorbis_comment_add_tag(&tmp->vc, "COMMENT", (char *) comment);
|
|
|
|
|
if (vorbis_encode_init_vbr(&tmp->vi, 1, DEFAULT_SAMPLE_RATE, 0.4)) {
|
|
|
|
|
ast_log(LOG_ERROR, "Unable to initialize Vorbis encoder!\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vorbis_analysis_init(&tmp->vd, &tmp->vi);
|
|
|
|
|
vorbis_block_init(&tmp->vd, &tmp->vb);
|
|
|
|
|
vorbis_comment_init(&tmp->vc);
|
|
|
|
|
vorbis_comment_add_tag(&tmp->vc, "ENCODER", "Asterisk PBX");
|
|
|
|
|
if (comment)
|
|
|
|
|
vorbis_comment_add_tag(&tmp->vc, "COMMENT", (char *) comment);
|
|
|
|
|
|
|
|
|
|
ogg_stream_init(&tmp->os, rand());
|
|
|
|
|
vorbis_analysis_init(&tmp->vd, &tmp->vi);
|
|
|
|
|
vorbis_block_init(&tmp->vd, &tmp->vb);
|
|
|
|
|
|
|
|
|
|
vorbis_analysis_headerout(&tmp->vd, &tmp->vc, &header, &header_comm,
|
|
|
|
|
&header_code);
|
|
|
|
|
ogg_stream_packetin(&tmp->os, &header);
|
|
|
|
|
ogg_stream_packetin(&tmp->os, &header_comm);
|
|
|
|
|
ogg_stream_packetin(&tmp->os, &header_code);
|
|
|
|
|
ogg_stream_init(&tmp->os, rand());
|
|
|
|
|
|
|
|
|
|
while (!tmp->eos) {
|
|
|
|
|
if (ogg_stream_flush(&tmp->os, &tmp->og) == 0)
|
|
|
|
|
break;
|
|
|
|
|
fwrite(tmp->og.header, 1, tmp->og.header_len, tmp->f);
|
|
|
|
|
fwrite(tmp->og.body, 1, tmp->og.body_len, tmp->f);
|
|
|
|
|
if (ogg_page_eos(&tmp->og))
|
|
|
|
|
tmp->eos = 1;
|
|
|
|
|
}
|
|
|
|
|
vorbis_analysis_headerout(&tmp->vd, &tmp->vc, &header, &header_comm,
|
|
|
|
|
&header_code);
|
|
|
|
|
ogg_stream_packetin(&tmp->os, &header);
|
|
|
|
|
ogg_stream_packetin(&tmp->os, &header_comm);
|
|
|
|
|
ogg_stream_packetin(&tmp->os, &header_code);
|
|
|
|
|
|
|
|
|
|
if (ast_mutex_lock(&ogg_vorbis_lock)) {
|
|
|
|
|
ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
|
|
|
|
|
fclose(f);
|
|
|
|
|
ogg_stream_clear(&tmp->os);
|
|
|
|
|
vorbis_block_clear(&tmp->vb);
|
|
|
|
|
vorbis_dsp_clear(&tmp->vd);
|
|
|
|
|
vorbis_comment_clear(&tmp->vc);
|
|
|
|
|
vorbis_info_clear(&tmp->vi);
|
|
|
|
|
free(tmp);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
glistcnt++;
|
|
|
|
|
ast_mutex_unlock(&ogg_vorbis_lock);
|
|
|
|
|
ast_update_use_count();
|
|
|
|
|
while (!tmp->eos) {
|
|
|
|
|
if (ogg_stream_flush(&tmp->os, &tmp->og) == 0)
|
|
|
|
|
break;
|
|
|
|
|
fwrite(tmp->og.header, 1, tmp->og.header_len, s->f);
|
|
|
|
|
fwrite(tmp->og.body, 1, tmp->og.body_len, s->f);
|
|
|
|
|
if (ogg_page_eos(&tmp->og))
|
|
|
|
|
tmp->eos = 1;
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Write out any pending encoded data.
|
|
|
|
|
* \param s A OGG/Vorbis filestream.
|
|
|
|
|
*/
|
|
|
|
|
static void write_stream(struct ast_filestream *s)
|
|
|
|
|
static void write_stream(struct vorbis_desc *s, FILE *f)
|
|
|
|
|
{
|
|
|
|
|
while (vorbis_analysis_blockout(&s->vd, &s->vb) == 1) {
|
|
|
|
|
vorbis_analysis(&s->vb, NULL);
|
|
|
|
@ -291,8 +255,8 @@ static void write_stream(struct ast_filestream *s)
|
|
|
|
|
if (ogg_stream_pageout(&s->os, &s->og) == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
fwrite(s->og.header, 1, s->og.header_len, s->f);
|
|
|
|
|
fwrite(s->og.body, 1, s->og.body_len, s->f);
|
|
|
|
|
fwrite(s->og.header, 1, s->og.header_len, f);
|
|
|
|
|
fwrite(s->og.body, 1, s->og.body_len, f);
|
|
|
|
|
if (ogg_page_eos(&s->og)) {
|
|
|
|
|
s->eos = 1;
|
|
|
|
|
}
|
|
|
|
@ -307,11 +271,12 @@ static void write_stream(struct ast_filestream *s)
|
|
|
|
|
* \param f An frame containing audio to be written to the filestream.
|
|
|
|
|
* \return -1 ifthere was an error, 0 on success.
|
|
|
|
|
*/
|
|
|
|
|
static int ogg_vorbis_write(struct ast_filestream *s, struct ast_frame *f)
|
|
|
|
|
static int ogg_vorbis_write(struct ast_filestream *fs, struct ast_frame *f)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
float **buffer;
|
|
|
|
|
short *data;
|
|
|
|
|
struct vorbis_desc *s = (struct vorbis_desc *)fs->private;
|
|
|
|
|
|
|
|
|
|
if (!s->writing) {
|
|
|
|
|
ast_log(LOG_ERROR, "This stream is not set up for writing!\n");
|
|
|
|
@ -334,13 +299,12 @@ static int ogg_vorbis_write(struct ast_filestream *s, struct ast_frame *f)
|
|
|
|
|
|
|
|
|
|
buffer = vorbis_analysis_buffer(&s->vd, f->samples);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < f->samples; i++) {
|
|
|
|
|
buffer[0][i] = data[i] / 32768.f;
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < f->samples; i++)
|
|
|
|
|
buffer[0][i] = (double)data[i] / 32768.0;
|
|
|
|
|
|
|
|
|
|
vorbis_analysis_wrote(&s->vd, f->samples);
|
|
|
|
|
|
|
|
|
|
write_stream(s);
|
|
|
|
|
write_stream(s, fs->f);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -349,21 +313,15 @@ static int ogg_vorbis_write(struct ast_filestream *s, struct ast_frame *f)
|
|
|
|
|
* \brief Close a OGG/Vorbis filestream.
|
|
|
|
|
* \param s A OGG/Vorbis filestream.
|
|
|
|
|
*/
|
|
|
|
|
static void ogg_vorbis_close(struct ast_filestream *s)
|
|
|
|
|
static void ogg_vorbis_close(struct ast_filestream *fs)
|
|
|
|
|
{
|
|
|
|
|
if (ast_mutex_lock(&ogg_vorbis_lock)) {
|
|
|
|
|
ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
glistcnt--;
|
|
|
|
|
ast_mutex_unlock(&ogg_vorbis_lock);
|
|
|
|
|
ast_update_use_count();
|
|
|
|
|
struct vorbis_desc *s = (struct vorbis_desc *)fs->private;
|
|
|
|
|
|
|
|
|
|
if (s->writing) {
|
|
|
|
|
/* Tell the Vorbis encoder that the stream is finished
|
|
|
|
|
* and write out the rest of the data */
|
|
|
|
|
vorbis_analysis_wrote(&s->vd, 0);
|
|
|
|
|
write_stream(s);
|
|
|
|
|
write_stream(s, fs->f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ogg_stream_clear(&s->os);
|
|
|
|
@ -383,12 +341,13 @@ static void ogg_vorbis_close(struct ast_filestream *s)
|
|
|
|
|
* \param pcm Pointer to a buffere to store audio data in.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int read_samples(struct ast_filestream *s, float ***pcm)
|
|
|
|
|
static int read_samples(struct ast_filestream *fs, float ***pcm)
|
|
|
|
|
{
|
|
|
|
|
int samples_in;
|
|
|
|
|
int result;
|
|
|
|
|
char *buffer;
|
|
|
|
|
int bytes;
|
|
|
|
|
struct vorbis_desc *s = (struct vorbis_desc *)fs->private;
|
|
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
samples_in = vorbis_synthesis_pcmout(&s->vd, pcm);
|
|
|
|
@ -445,7 +404,7 @@ static int read_samples(struct ast_filestream *s, float ***pcm)
|
|
|
|
|
/* get a buffer from OGG to read the data into */
|
|
|
|
|
buffer = ogg_sync_buffer(&s->oy, BLOCK_SIZE);
|
|
|
|
|
/* read more data from the file descriptor */
|
|
|
|
|
bytes = fread(buffer, 1, BLOCK_SIZE, s->f);
|
|
|
|
|
bytes = fread(buffer, 1, BLOCK_SIZE, fs->f);
|
|
|
|
|
/* Tell OGG how many bytes we actually read into the buffer */
|
|
|
|
|
ogg_sync_wrote(&s->oy, bytes);
|
|
|
|
|
if (bytes == 0) {
|
|
|
|
@ -461,26 +420,30 @@ static int read_samples(struct ast_filestream *s, float ***pcm)
|
|
|
|
|
* \param whennext Number of sample times to schedule the next call.
|
|
|
|
|
* \return A pointer to a frame containing audio data or NULL ifthere is no more audio data.
|
|
|
|
|
*/
|
|
|
|
|
static struct ast_frame *ogg_vorbis_read(struct ast_filestream *s,
|
|
|
|
|
static struct ast_frame *ogg_vorbis_read(struct ast_filestream *fs,
|
|
|
|
|
int *whennext)
|
|
|
|
|
{
|
|
|
|
|
int clipflag = 0;
|
|
|
|
|
int i;
|
|
|
|
|
int j;
|
|
|
|
|
float **pcm;
|
|
|
|
|
float *mono;
|
|
|
|
|
double accumulator[SAMPLES_MAX];
|
|
|
|
|
int val;
|
|
|
|
|
int samples_in;
|
|
|
|
|
int samples_out = 0;
|
|
|
|
|
struct vorbis_desc *s = (struct vorbis_desc *)fs->private;
|
|
|
|
|
short *buf = (short *)(fs->fr.data); /* SLIN data buffer */
|
|
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
/* See ifwe have filled up an audio frame yet */
|
|
|
|
|
if (samples_out == SAMPLES_MAX)
|
|
|
|
|
break;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
while (samples_out != SAMPLES_MAX) {
|
|
|
|
|
float **pcm;
|
|
|
|
|
int len = SAMPLES_MAX - samples_out;
|
|
|
|
|
|
|
|
|
|
/* See ifVorbis decoder has some audio data for us ... */
|
|
|
|
|
samples_in = read_samples(s, &pcm);
|
|
|
|
|
samples_in = read_samples(fs, &pcm);
|
|
|
|
|
if (samples_in <= 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -488,17 +451,15 @@ static struct ast_frame *ogg_vorbis_read(struct ast_filestream *s,
|
|
|
|
|
/* Convert the float audio data to 16-bit signed linear */
|
|
|
|
|
|
|
|
|
|
clipflag = 0;
|
|
|
|
|
|
|
|
|
|
samples_in = samples_in < (SAMPLES_MAX - samples_out) ? samples_in : (SAMPLES_MAX - samples_out);
|
|
|
|
|
|
|
|
|
|
if (samples_in > len)
|
|
|
|
|
samples_in = len;
|
|
|
|
|
for (j = 0; j < samples_in; j++)
|
|
|
|
|
accumulator[j] = 0.0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < s->vi.channels; i++) {
|
|
|
|
|
mono = pcm[i];
|
|
|
|
|
for (j = 0; j < samples_in; j++) {
|
|
|
|
|
float *mono = pcm[i];
|
|
|
|
|
for (j = 0; j < samples_in; j++)
|
|
|
|
|
accumulator[j] += mono[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < samples_in; j++) {
|
|
|
|
@ -506,12 +467,11 @@ static struct ast_frame *ogg_vorbis_read(struct ast_filestream *s,
|
|
|
|
|
if (val > 32767) {
|
|
|
|
|
val = 32767;
|
|
|
|
|
clipflag = 1;
|
|
|
|
|
}
|
|
|
|
|
if (val < -32768) {
|
|
|
|
|
} else if (val < -32768) {
|
|
|
|
|
val = -32768;
|
|
|
|
|
clipflag = 1;
|
|
|
|
|
}
|
|
|
|
|
s->buffer[samples_out + j] = val;
|
|
|
|
|
buf[samples_out + j] = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clipflag)
|
|
|
|
@ -522,17 +482,11 @@ static struct ast_frame *ogg_vorbis_read(struct ast_filestream *s,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (samples_out > 0) {
|
|
|
|
|
s->fr.frametype = AST_FRAME_VOICE;
|
|
|
|
|
s->fr.subclass = AST_FORMAT_SLINEAR;
|
|
|
|
|
s->fr.offset = AST_FRIENDLY_OFFSET;
|
|
|
|
|
s->fr.datalen = samples_out * 2;
|
|
|
|
|
s->fr.data = s->buffer;
|
|
|
|
|
s->fr.src = name;
|
|
|
|
|
s->fr.mallocd = 0;
|
|
|
|
|
s->fr.samples = samples_out;
|
|
|
|
|
fs->fr.datalen = samples_out * 2;
|
|
|
|
|
fs->fr.samples = samples_out;
|
|
|
|
|
*whennext = samples_out;
|
|
|
|
|
|
|
|
|
|
return &s->fr;
|
|
|
|
|
return &fs->fr;
|
|
|
|
|
} else {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
@ -557,8 +511,8 @@ static int ogg_vorbis_trunc(struct ast_filestream *s)
|
|
|
|
|
* \param whence Location to measure
|
|
|
|
|
* \return 0 on success, -1 on failure.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int ogg_vorbis_seek(struct ast_filestream *s, off_t sample_offset, int whence) {
|
|
|
|
|
static int ogg_vorbis_seek(struct ast_filestream *s, off_t sample_offset, int whence)
|
|
|
|
|
{
|
|
|
|
|
ast_log(LOG_WARNING, "Seeking is not supported on OGG/Vorbis streams!\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
@ -578,8 +532,8 @@ static char *ogg_vorbis_getcomment(struct ast_filestream *s)
|
|
|
|
|
static struct ast_format_lock me = { .usecnt = -1 };
|
|
|
|
|
|
|
|
|
|
static const struct ast_format vorbis_f = {
|
|
|
|
|
.name =
|
|
|
|
|
.ext =
|
|
|
|
|
.name = "ogg_vorbis",
|
|
|
|
|
.exts = "ogg",
|
|
|
|
|
.format = AST_FORMAT_SLINEAR,
|
|
|
|
|
.open = ogg_vorbis_open,
|
|
|
|
|
.rewrite = ogg_vorbis_rewrite,
|
|
|
|
@ -589,7 +543,7 @@ static const struct ast_format vorbis_f = {
|
|
|
|
|
.tell = ogg_vorbis_tell,
|
|
|
|
|
.read = ogg_vorbis_read,
|
|
|
|
|
.close = ogg_vorbis_close,
|
|
|
|
|
.buf_sie = BUF_SIZE + AST_FRIENDLY_OFFSET,
|
|
|
|
|
.buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET,
|
|
|
|
|
.desc_size = sizeof(struct vorbis_desc),
|
|
|
|
|
.lockp = &me,
|
|
|
|
|
};
|
|
|
|
@ -601,7 +555,7 @@ int load_module()
|
|
|
|
|
|
|
|
|
|
int unload_module()
|
|
|
|
|
{
|
|
|
|
|
return ast_format_unregister(name);
|
|
|
|
|
return ast_format_unregister(vorbis_f.name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int usecount()
|
|
|
|
@ -611,7 +565,7 @@ int usecount()
|
|
|
|
|
|
|
|
|
|
char *description()
|
|
|
|
|
{
|
|
|
|
|
return desc;
|
|
|
|
|
return "OGG/Vorbis audio";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|