2013-01-24 15:44:19 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>vorbisfile - vorbisfile_example.c</title>
|
|
|
|
<link rel=stylesheet href="style.css" type="text/css">
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
|
|
|
|
<table border=0 width=100%>
|
|
|
|
<tr>
|
|
|
|
<td><p class=tiny>Vorbisfile documentation</p></td>
|
|
|
|
<td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<h1>vorbisfile_example.c</h1>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
The example program source:
|
|
|
|
|
|
|
|
<br><br>
|
|
|
|
<table border=0 width=100% color=black cellspacing=0 cellpadding=7>
|
|
|
|
<tr bgcolor=#cccccc>
|
|
|
|
<td>
|
|
|
|
<pre><b>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include "vorbis/codec.h"
|
|
|
|
#include "vorbis/vorbisfile.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <io.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
char pcmout[4096];
|
|
|
|
|
|
|
|
int main(int argc, char **argv){
|
|
|
|
OggVorbis_File vf;
|
|
|
|
int eof=0;
|
|
|
|
int current_section;
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
_setmode( _fileno( stdin ), _O_BINARY );
|
|
|
|
_setmode( _fileno( stdout ), _O_BINARY );
|
|
|
|
#endif
|
|
|
|
|
2015-01-24 18:58:23 +00:00
|
|
|
if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) {
|
2013-01-24 15:44:19 +00:00
|
|
|
fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2015-01-24 18:58:23 +00:00
|
|
|
char **ptr=ov_comment(&vf,-1)->user_comments;
|
|
|
|
vorbis_info *vi=ov_info(&vf,-1);
|
2013-01-24 15:44:19 +00:00
|
|
|
while(*ptr){
|
|
|
|
fprintf(stderr,"%s\n",*ptr);
|
|
|
|
++ptr;
|
|
|
|
}
|
2015-01-24 18:58:23 +00:00
|
|
|
fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
|
|
|
|
fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
|
2013-01-24 15:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while(!eof){
|
2015-01-24 18:58:23 +00:00
|
|
|
long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section);
|
2013-01-24 15:44:19 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
/* EOF */
|
|
|
|
eof=1;
|
2015-01-24 18:58:23 +00:00
|
|
|
} else if (ret < 0) {
|
2013-01-24 15:44:19 +00:00
|
|
|
/* error in the stream. Not a problem, just reporting it in
|
|
|
|
case we (the app) cares. In this case, we don't. */
|
|
|
|
} else {
|
|
|
|
/* we don't bother dealing with sample rate changes, etc, but
|
|
|
|
you'll have to */
|
|
|
|
fwrite(pcmout,1,ret,stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-24 18:58:23 +00:00
|
|
|
ov_clear(&vf);
|
2013-01-24 15:44:19 +00:00
|
|
|
|
|
|
|
fprintf(stderr,"Done.\n");
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
</b></pre>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
<br><br>
|
|
|
|
<hr noshade>
|
|
|
|
<table border=0 width=100%>
|
|
|
|
<tr valign=top>
|
|
|
|
<td><p class=tiny>copyright © 2000-2010 Xiph.Org</p></td>
|
|
|
|
<td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a></p></td>
|
|
|
|
</tr><tr>
|
|
|
|
<td><p class=tiny>Vorbisfile documentation</p></td>
|
|
|
|
<td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|