1 <html> 2 3 <head> 4 <title>vorbisfile - chaining_example.c</title> 5 <link rel=stylesheet href="style.css" type="text/css"> 6 </head> 7 8 <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff"> 9 <table border=0 width=100%> 10 <tr> 11 <td><p class=tiny>Vorbisfile documentation</p></td> 12 <td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td> 13 </tr> 14 </table> 15 16 <h1>chaining_example.c</h1> 17 18 <p> 19 The example program source: 20 21 <br><br> 22 <table border=0 width=100% color=black cellspacing=0 cellpadding=7> 23 <tr bgcolor=#cccccc> 24 <td> 25 <pre width="80"><b> 26 27 <font color="#A020F0">#include <vorbis/codec.h></font> 28 <font color="#A020F0">#include <vorbis/vorbisfile.h></font> 29 30 <strong><font color="#4169E1"><a name="main"></a>int main()</font></strong>{ 31 OggVorbis_File ov; 32 int i; 33 34 <font color="#A020F0">#ifdef _WIN32</font> <font color="#B22222">/* We need to set stdin to binary mode on windows. */</font> 35 _setmode( _fileno( stdin ), _O_BINARY ); 36 <font color="#A020F0">#endif</font> 37 38 <font color="#B22222">/* open the file/pipe on stdin */</font> 39 <font color="#4169E1">if</font>(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)<0){ 40 printf(<font color="#666666">"Could not open input as an OggVorbis file.\n\n"</font>); 41 exit(1); 42 } 43 44 <font color="#B22222">/* print details about each logical bitstream in the input */</font> 45 <font color="#4169E1">if</font>(ov_seekable(&ov)){ 46 printf(<font color="#666666">"Input bitstream contained %ld logical bitstream section(s).\n"</font>, 47 ov_streams(&ov)); 48 printf(<font color="#666666">"Total bitstream playing time: %ld seconds\n\n"</font>, 49 (long)ov_time_total(&ov,-1)); 50 51 }<font color="#4169E1">else</font>{ 52 printf(<font color="#666666">"Standard input was not seekable.\n"</font> 53 <font color="#666666">"First logical bitstream information:\n\n"</font>); 54 } 55 56 <font color="#4169E1">for</font>(i=0;i<ov_streams(&ov);i++){ 57 vorbis_info *vi=ov_info(&ov,i); 58 printf(<font color="#666666">"\tlogical bitstream section %d information:\n"</font>,i+1); 59 printf(<font color="#666666">"\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n"</font>, 60 vi->rate,vi->channels,ov_bitrate(&ov,i)/1000, 61 ov_serialnumber(&ov,i)); 62 printf(<font color="#666666">"\t\tcompressed length: %ld bytes "</font>,(long)(ov_raw_total(&ov,i))); 63 printf(<font color="#666666">" play time: %lds\n"</font>,(long)ov_time_total(&ov,i)); 64 } 65 66 ov_clear(&ov); 67 <font color="#4169E1">return</font> 0; 68 } 69 70 </b></pre> 71 </td> 72 </tr> 73 </table> 74 75 76 <br><br> 77 <hr noshade> 78 <table border=0 width=100%> 79 <tr valign=top> 80 <td><p class=tiny>copyright © 2007 Xiph.org</p></td> 81 <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a><br><a href="mailto:team (a] vorbis.org">team (a] vorbis.org</a></p></td> 82 </tr><tr> 83 <td><p class=tiny>Vorbisfile documentation</p></td> 84 <td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td> 85 </tr> 86 </table> 87 88 </body> 89 90 </html> 91