|
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "OGG/Vorbis audio" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND } |
|
static const struct ast_module_info * | ast_module_info = &__mod_info |
|
static struct ast_format_def | vorbis_f |
|
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 297 of file format_ogg_vorbis.c.
References __BIG_ENDIAN, __BYTE_ORDER, ast_filestream::_private, AST_FRAME_SET_BUFFER, AST_FRIENDLY_OFFSET, ast_log, ast_filestream::buf, BUF_SIZE, ast_frame::data, ast_frame::datalen, desc, ast_filestream::fr, if(), LOG_WARNING, NULL, ogg_vorbis_desc::ov_f, ast_frame::ptr, ast_frame::samples, and ogg_vorbis_desc::writing.
301 int current_bitstream = -10;
315 bytes_read = ov_read(
326 if (bytes_read <= 0) {
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
struct ast_frame fr
frame produced by read, typically
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
int writing
Indicates whether this filestream is set up for reading or writing.
union ast_frame::@263 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, tmp(), 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);
162 vorbis_info_clear(&tmp->
vi);
166 vorbis_comment_init(&tmp->
vc);
167 vorbis_comment_add_tag(&tmp->
vc,
"ENCODER",
"Asterisk PBX");
169 vorbis_comment_add_tag(&tmp->
vc,
"COMMENT", (
char *)
comment);
171 vorbis_analysis_init(&tmp->
vd, &tmp->
vi);
172 vorbis_block_init(&tmp->
vd, &tmp->
vb);
176 vorbis_analysis_headerout(&tmp->
vd, &tmp->
vc, &header, &header_comm,
178 ogg_stream_packetin(&tmp->
os, &header);
179 ogg_stream_packetin(&tmp->
os, &header_comm);
180 ogg_stream_packetin(&tmp->
os, &header_code);
183 if (ogg_stream_flush(&tmp->
os, &tmp->
og) == 0)
185 if (fwrite(tmp->
og.header, 1, tmp->
og.header_len, s->
f) != tmp->
og.header_len) {
188 if (fwrite(tmp->
og.body, 1, tmp->
og.body_len, s->
f) != tmp->
og.body_len) {
191 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)
int writing
Indicates whether this filestream is set up for reading or writing.
Write out any pending encoded data.
- Parameters
-
s | An OGG/Vorbis filestream. |
f | The file to write to. |
Definition at line 203 of file format_ogg_vorbis.c.
References ast_log, ogg_vorbis_desc::eos, errno, LOG_WARNING, NULL, ogg_vorbis_desc::og, ogg_vorbis_desc::op, ogg_vorbis_desc::os, ogg_vorbis_desc::vb, and ogg_vorbis_desc::vd.
Referenced by ast_monitor_stop(), ast_write_stream(), ogg_vorbis_close(), ogg_vorbis_write(), and tech_write().
205 while (vorbis_analysis_blockout(&s->
vd, &s->
vb) == 1) {
206 vorbis_analysis(&s->
vb,
NULL);
207 vorbis_bitrate_addblock(&s->
vb);
209 while (vorbis_bitrate_flushpacket(&s->
vd, &s->
op)) {
210 ogg_stream_packetin(&s->
os, &s->
op);
212 if (ogg_stream_pageout(&s->
os, &s->
og) == 0) {
215 if (fwrite(s->
og.header, 1, s->
og.header_len, f) != s->
og.header_len) {
218 if (fwrite(s->
og.body, 1, s->
og.body_len, f) != s->
og.body_len) {
221 if (ogg_page_eos(&s->
og)) {
int eos
Indicates whether an End of Stream condition has been detected.