diff options
author | Aki <please@ignore.pl> | 2021-09-29 22:52:49 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-09-29 22:52:49 +0200 |
commit | 760f65d35df281b04d99843958623d99ab35dcaf (patch) | |
tree | 76f6f05695822256bbf8097fa0aa6b5d2a34369b /vorbis/doc/vorbisfile/seekexample.html | |
parent | bdb934044a10bcccdea4ae5e9b067a2e764e0e7f (diff) | |
parent | 74f4b1bc3b627ba4c7e03498234d88cacdfbe97b (diff) | |
download | starshatter-760f65d35df281b04d99843958623d99ab35dcaf.zip starshatter-760f65d35df281b04d99843958623d99ab35dcaf.tar.gz starshatter-760f65d35df281b04d99843958623d99ab35dcaf.tar.bz2 |
Merge commit '74f4b1bc3b627ba4c7e03498234d88cacdfbe97b' as 'vorbis'
Diffstat (limited to 'vorbis/doc/vorbisfile/seekexample.html')
-rw-r--r-- | vorbis/doc/vorbisfile/seekexample.html | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/vorbis/doc/vorbisfile/seekexample.html b/vorbis/doc/vorbisfile/seekexample.html new file mode 100644 index 0000000..897403d --- /dev/null +++ b/vorbis/doc/vorbisfile/seekexample.html @@ -0,0 +1,152 @@ +<html> + +<head> +<title>vorbisfile - Example Code</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>Example Code: seeking</h1> + +<p> +The following is a run-through of the seeking example program supplied +with vorbisfile - <a href="seeking_test_c.html">seeking_test.c</a>. +This program tests the vorbisfile <a href="ov_time_seek.html">ov_time_seek</a> function by seeking to random points within the file. + +<p> +First, relevant headers, including vorbis-specific "codec.h" and "vorbisfile.h" have to be included. + +<br><br> +<table border=0 width=100% color=black cellspacing=0 cellpadding=7> +<tr bgcolor=#cccccc> + <td> +<pre><b> +#include <stdlib.h> +#include <stdio.h> +#include "vorbis/codec.h" +#include "vorbis/vorbisfile.h" +</b></pre> + </td> +</tr> +</table> + +<p>Inside main(), we declare our primary OggVorbis_File structure. We also declare other helpful variables to track our progress within the file. +<br><br> +<table border=0 width=100% color=black cellspacing=0 cellpadding=7> +<tr bgcolor=#cccccc> + <td> +<pre><b> +int main(){ + OggVorbis_File ov; + int i; +</b></pre> + </td> +</tr> +</table> + +<p>This example takes its input on stdin which is in 'text' mode by default under Windows; this will corrupt the input data unless set to binary mode. This applies only to Windows. +<br><br> +<table border=0 width=100% color=black cellspacing=0 cellpadding=7> +<tr bgcolor=#cccccc> + <td> +<pre><b> +#ifdef _WIN32 /* We need to set stdin to binary mode under Windows */ + _setmode( _fileno( stdin ), _O_BINARY ); +#endif +</b></pre> + </td> +</tr> +</table> + +<p><a href="ov_open_callbacks.html">ov_open()</a> must be +called to initialize the <a href="OggVorbis_File.html">OggVorbis_File</a> structure with default values. +<a href="ov_open_callbacks.html">ov_open_callbacks()</a> also checks to ensure that we're reading Vorbis format and not something else. + +<br><br> +<table border=0 width=100% color=black cellspacing=0 cellpadding=7> +<tr bgcolor=#cccccc> + <td> +<pre><b> + if(ov_open_callbacks(stdin,&ov,NULL,-1, OV_CALLBACKS_NOCLOSE)<0){ + printf("Could not open input as an OggVorbis file.\n\n"); + exit(1); + } + +</b></pre> + </td> +</tr> +</table> + +<p> +First we check to make sure the stream is seekable using <a href="ov_seekable.html">ov_seekable</a>. + +<p>Then we seek to 100 random spots in the bitstream using <a href="ov_time_seek.html">ov_time_seek</a> with randomly generated values. + +<br><br> +<table border=0 width=100% color=black cellspacing=0 cellpadding=7> +<tr bgcolor=#cccccc> + <td> +<pre><b> + + /* print details about each logical bitstream in the input */ + if(ov_seekable(&ov)){ + double length=ov_time_total(&ov,-1); + printf("testing seeking to random places in %g seconds....\n",length); + for(i=0;i<100;i++){ + double val=(double)rand()/RAND_MAX*length; + ov_time_seek(&ov,val); + printf("\r\t%d [%gs]... ",i,val); + fflush(stdout); + } + + printf("\r \nOK.\n\n"); + }else{ + printf("Standard input was not seekable.\n"); + } + +</b></pre> + </td> +</tr> +</table> +<p> +When we're done seeking, we need to call <a href="ov_clear.html">ov_clear()</a> to release the bitstream. + +<br><br> +<table border=0 width=100% color=black cellspacing=0 cellpadding=7> +<tr bgcolor=#cccccc> + <td> +<pre><b> + ov_clear(&ov); + return 0; +} +</b></pre> + </td> +</tr> +</table> + +<p> +The full source for seeking_test.c can be found with the vorbis +distribution in <a href="seeking_test_c.html">seeking_test.c</a>. + +<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/">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> |