OGG/Vorbis streams.
Definition in file format_ogg_vorbis.c.
Read a frame full of audio data from the filestream.
- Parameters
-
fs | The filestream. |
whennext | Number of sample times to schedule the next call. |
- Returns
- A pointer to a frame containing audio data or NULL ifthere is no more audio data.
Definition at line 299 of file format_ogg_vorbis.c.
References __BIG_ENDIAN, ast_filestream::_private, AST_FORMAT_SLINEAR, AST_FRAME_SET_BUFFER, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), ast_filestream::buf, BUF_SIZE, ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, desc, ast_filestream::fr, ast_frame::frametype, if(), LOG_WARNING, ast_frame::mallocd, ogg_vorbis_desc::ov_f, ast_frame::ptr, ast_frame::samples, ast_frame::subclass, and ogg_vorbis_desc::writing.
303 int current_bitstream = -10;
320 bytes_read = ov_read(
331 if (bytes_read <= 0) {
union ast_frame_subclass subclass
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
if(yyss+yystacksize-1<=yyssp)
#define AST_FORMAT_SLINEAR
int writing
Indicates whether this filestream is set up for reading or writing.
enum ast_frame_type frametype
union ast_frame::@172 data
static int ogg_vorbis_rewrite |
( |
struct ast_filestream * |
s, |
|
|
const char * |
comment |
|
) |
| |
|
static |
Create a new OGG/Vorbis filestream and set it up for writing.
- Parameters
-
s | File pointer that points to on-disk storage. |
comment | Comment that should be embedded in the OGG/Vorbis file. |
- Returns
- A new filestream.
Definition at line 147 of file format_ogg_vorbis.c.
References ast_filestream::_private, ast_log(), ast_random(), DEFAULT_SAMPLE_RATE, ogg_vorbis_desc::eos, errno, ast_filestream::f, LOG_ERROR, LOG_WARNING, ogg_vorbis_desc::og, ogg_vorbis_desc::os, ogg_vorbis_desc::vb, ogg_vorbis_desc::vc, ogg_vorbis_desc::vd, ogg_vorbis_desc::vi, ogg_vorbis_desc::writing, and ogg_vorbis_desc::writing_pcm_pos.
151 ogg_packet header_comm;
152 ogg_packet header_code;
158 vorbis_info_init(&tmp->
vi);
165 vorbis_comment_init(&tmp->
vc);
166 vorbis_comment_add_tag(&tmp->
vc,
"ENCODER",
"Asterisk PBX");
168 vorbis_comment_add_tag(&tmp->
vc,
"COMMENT", (
char *)
comment);
170 vorbis_analysis_init(&tmp->
vd, &tmp->
vi);
171 vorbis_block_init(&tmp->
vd, &tmp->
vb);
175 vorbis_analysis_headerout(&tmp->
vd, &tmp->
vc, &header, &header_comm,
177 ogg_stream_packetin(&tmp->
os, &header);
178 ogg_stream_packetin(&tmp->
os, &header_comm);
179 ogg_stream_packetin(&tmp->
os, &header_code);
182 if (ogg_stream_flush(&tmp->
os, &tmp->
og) == 0)
184 if (!fwrite(tmp->
og.header, 1, tmp->
og.header_len, s->
f)) {
187 if (!fwrite(tmp->
og.body, 1, tmp->
og.body_len, s->
f)) {
190 if (ogg_page_eos(&tmp->
og))
int eos
Indicates whether an End of Stream condition has been detected.
#define DEFAULT_SAMPLE_RATE
off_t writing_pcm_pos
Stores the current pcm position to support tell() on writing mode.
long int ast_random(void)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
int writing
Indicates whether this filestream is set up for reading or writing.
Write audio data from a frame to an OGG/Vorbis filestream.
- Parameters
-
fs | An OGG/Vorbis filestream. |
f | A frame containing audio to be written to the filestream. |
- Returns
- -1 if there was an error, 0 on success.
Definition at line 234 of file format_ogg_vorbis.c.
References ast_filestream::_private, AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_getformatname(), ast_log(), ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, ast_filestream::f, ast_frame::frametype, if(), LOG_ERROR, LOG_WARNING, ast_frame::ptr, ast_frame::samples, ast_frame::subclass, ogg_vorbis_desc::vd, write_stream(), ogg_vorbis_desc::writing, and ogg_vorbis_desc::writing_pcm_pos.
260 buffer = vorbis_analysis_buffer(&s->
vd, f->
samples);
262 for (i = 0; i < f->
samples; i++)
263 buffer[0][i] = (
double)data[i] / 32768.0;
265 vorbis_analysis_wrote(&s->
vd, f->
samples);
union ast_frame_subclass subclass
off_t writing_pcm_pos
Stores the current pcm position to support tell() on writing mode.
char * ast_getformatname(format_t format)
Get the name of a format.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
if(yyss+yystacksize-1<=yyssp)
#define AST_FORMAT_SLINEAR
int writing
Indicates whether this filestream is set up for reading or writing.
enum ast_frame_type frametype
union ast_frame::@172 data
Write out any pending encoded data.
- Parameters
-
s | An OGG/Vorbis filestream. |
f | The file to write to. |
Definition at line 202 of file format_ogg_vorbis.c.
References ast_log(), ogg_vorbis_desc::eos, errno, LOG_WARNING, ogg_vorbis_desc::og, ogg_vorbis_desc::op, ogg_vorbis_desc::os, ogg_vorbis_desc::vb, and ogg_vorbis_desc::vd.
Referenced by ogg_vorbis_close(), and ogg_vorbis_write().
204 while (vorbis_analysis_blockout(&s->
vd, &s->
vb) == 1) {
205 vorbis_analysis(&s->
vb, NULL);
206 vorbis_bitrate_addblock(&s->
vb);
208 while (vorbis_bitrate_flushpacket(&s->
vd, &s->
op)) {
209 ogg_stream_packetin(&s->
os, &s->
op);
211 if (ogg_stream_pageout(&s->
os, &s->
og) == 0) {
214 if (!fwrite(s->
og.header, 1, s->
og.header_len,
f)) {
217 if (!fwrite(s->
og.body, 1, s->
og.body_len,
f)) {
220 if (ogg_page_eos(&s->
og)) {
int eos
Indicates whether an End of Stream condition has been detected.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...