chaining_example_c.html 3.0 KB

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