<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>libcmml: Example Documentation</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.3.4 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="examples.html">Examples</a></div> <h1>cmml-seek-offset.c</h1><b>Seeking to a temporal offset into a CMML file</b><p> Sometimes you'll need to seek to a temporal offset in seconds into a CMML file. Note: The seconds offset is calculated with respect to the basetime attribute of the stream tag. libcmml provides an API for this functionality through the <a class="el" href="cmml_8h.html#a52">cmml_skip_to_secs()</a> function.<p> The procedure is illustrated in cmml-seek-offset.c, which seeks to an offset given in seconds and prints out the descriptions of all the following clips: <div class="fragment"><pre> <span class="preprocessor">#include <stdio.h></span> <span class="preprocessor">#include <<a class="code" href="cmml_8h.html">cmml.h</a>></span> <span class="preprocessor">#define BUFSIZE 100000</span> <span class="preprocessor"></span> <span class="keyword">static</span> <span class="keywordtype">int</span> <a name="a17"></a><a class="code" href="cmml-validate_8c.html#a5">read_clip</a> (<a class="code" href="cmml_8h.html#a0">CMML</a> * cmml, <span class="keyword">const</span> <a name="_a18"></a><a class="code" href="structCMML__Clip.html">CMML_Clip</a> * clip, <span class="keywordtype">void</span> * user_data) { puts(clip-><a name="a19"></a><a class="code" href="structCMML__Clip.html#o28">desc_text</a>); <span class="keywordflow">return</span> 0; } <span class="keywordtype">int</span> <a name="a20"></a><a class="code" href="cmml-validate_8c.html#a6">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) { <span class="keywordtype">char</span> *filename = NULL; <a class="code" href="cmml_8h.html#a0">CMML</a> * doc; <span class="keywordtype">double</span> seconds = 0.0; <span class="keywordtype">long</span> n = 0; <span class="keywordflow">if</span> (argc < 2) { fprintf (stderr, <span class="stringliteral">"Usage: %s <CMMLfile> <seconds>\n"</span>, argv[0]); exit (1); } filename = argv[1]; <span class="keywordflow">if</span> (argv[2]) seconds = atof(argv[2]); doc = <a name="a21"></a><a class="code" href="cmml_8h.html#a37">cmml_open</a>(filename); <span class="comment">/* seek to time offset; if not found, to file end */</span> <a name="a22"></a><a class="code" href="cmml_8h.html#a52">cmml_skip_to_secs</a> (doc, seconds); <a name="a23"></a><a class="code" href="cmml_8h.html#a41">cmml_set_read_callbacks</a> (doc, NULL, NULL, read_clip, NULL); <span class="keywordflow">while</span> (((n = <a name="a24"></a><a class="code" href="cmml_8h.html#a42">cmml_read</a> (doc, BUFSIZE)) > 0)); <a name="a25"></a><a class="code" href="cmml_8h.html#a40">cmml_close</a>(doc); <span class="keywordflow">return</span> 0; } </pre></div> <hr size="1"><address style="align: right;"><small>Generated on Thu Jan 26 12:26:56 2006 for libcmml by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.4 </small></address> </body> </html>