|
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 = AST_BUILDOPT_SUM, .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 ov_callbacks | OV_CALLBACKS_NOCLOSE |
|
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.
299{
301 int current_bitstream = -10;
302 char *out_buf;
303 long bytes_read;
304
308 }
309
310
313
314
315 bytes_read = ov_read(
317 out_buf,
320 2,
321 1,
322 ¤t_bitstream
323 );
324
325
326 if (bytes_read <= 0) {
327
329 }
330
331
336}
#define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen)
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
struct ast_frame fr
frame produced by read, typically
union ast_frame::@226 data
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, ast_frame::ptr, and ast_frame::samples.
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.
149{
151 ogg_packet header_comm;
152 ogg_packet header_code;
154
156 tmp->writing_pcm_pos = 0;
157
158 vorbis_info_init(&
tmp->vi);
159
162 vorbis_info_clear(&
tmp->vi);
163 return -1;
164 }
165
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);
170
171 vorbis_analysis_init(&
tmp->vd, &
tmp->vi);
172 vorbis_block_init(&
tmp->vd, &
tmp->vb);
173
175
176 vorbis_analysis_headerout(&
tmp->vd, &
tmp->vc, &
header, &header_comm,
177 &header_code);
179 ogg_stream_packetin(&
tmp->os, &header_comm);
180 ogg_stream_packetin(&
tmp->os, &header_code);
181
183 if (ogg_stream_flush(&
tmp->os, &
tmp->og) == 0)
184 break;
185 if (fwrite(
tmp->og.header, 1,
tmp->og.header_len, s->
f) !=
tmp->og.header_len) {
187 }
188 if (fwrite(
tmp->og.body, 1,
tmp->og.body_len, s->
f) !=
tmp->og.body_len) {
190 }
191 if (ogg_page_eos(&
tmp->og))
193 }
194
195 return 0;
196}
long int ast_random(void)
References ast_filestream::_private, ast_log, ast_random(), comment, DEFAULT_SAMPLE_RATE, errno, ast_filestream::f, LOG_ERROR, LOG_WARNING, and tmp().
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 235 of file format_ogg_vorbis.c.
236{
237 int i;
238 float **buffer;
239 short *data;
241
244 return -1;
245 }
247 return -1;
248
250
251 buffer = vorbis_analysis_buffer(&s->
vd, f->
samples);
252
253 for (i = 0; i < f->
samples; i++)
254 buffer[0][i] = (double)data[i] / 32768.0;
255
256 vorbis_analysis_wrote(&s->
vd, f->
samples);
257
259
261
262 return 0;
263}
off_t writing_pcm_pos
Stores the current pcm position to support tell() on writing mode.
References ast_filestream::_private, ast_log, ast_frame::data, ast_frame::datalen, ast_filestream::f, if(), LOG_ERROR, ast_frame::ptr, ast_frame::samples, ogg_vorbis_desc::vd, write_stream(), ogg_vorbis_desc::writing, and ogg_vorbis_desc::writing_pcm_pos.
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.
204{
205 while (vorbis_analysis_blockout(&s->
vd, &s->
vb) == 1) {
206 vorbis_analysis(&s->
vb,
NULL);
207 vorbis_bitrate_addblock(&s->
vb);
208
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) {
213 break;
214 }
215 if (fwrite(s->
og.header, 1, s->
og.header_len, f) != s->
og.header_len) {
217 }
218 if (fwrite(s->
og.body, 1, s->
og.body_len, f) != s->
og.body_len) {
220 }
221 if (ogg_page_eos(&s->
og)) {
223 }
224 }
225 }
226 }
227}
int eos
Indicates whether an End of Stream condition has been detected.
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_write_stream(), ogg_vorbis_close(), ogg_vorbis_write(), and tech_write().