Main Page | Modules | Data Structures | File List | Data Fields | Globals | Examples

cmml-seek-utc.c

Seeking to a utc time offset into a CMML file

Sometimes you'll need to seek to a temporal offset in utc into a CMML file. Note: The utc offset is calculated with respect to the utc and timebase attributes of the stream tag. libcmml provides an API for this functionality through the cmml_skip_to_utc() function.

The procedure is illustrated in cmml-seek-utc.c, which seeks to an offset given in utc and prints out the descriptions of all the following clips:

#include <stdio.h> #include <cmml.h> #define BUFSIZE 100000 static int read_clip (CMML * cmml, const CMML_Clip * clip, void * user_data) { puts(clip->desc_text); return 0; } int main(int argc, char *argv[]) { char *filename = NULL; CMML * doc; char *utc = NULL; long n = 0; if (argc < 2) { fprintf (stderr, "Usage: %s <CMMLfile> <utc>\n", argv[0]); exit (1); } filename = argv[1]; utc = argv[2]; doc = cmml_open(filename); /* seek to time offset; if not found, to file end */ cmml_skip_to_utc (doc, utc); cmml_set_read_callbacks (doc, NULL, NULL, read_clip, NULL); while (((n = cmml_read (doc, BUFSIZE)) > 0)); cmml_close(doc); return 0; }
00001 00031 #include <stdio.h> 00032 00033 #include <cmml.h> 00034 00045 #define BUFSIZE 100000 00046 00057 static int 00058 read_clip (CMML * cmml, const CMML_Clip * clip, void * user_data) { 00059 puts(clip->desc_text); 00060 return 0; 00061 } 00062 00069 int main(int argc, char *argv[]) 00070 { 00071 char *filename = NULL; 00072 CMML * doc; 00073 char *utc = NULL; 00074 long n = 0; 00075 00076 if (argc < 2) { 00077 fprintf (stderr, "Usage: %s <CMMLfile> <utc>\n", argv[0]); 00078 exit (1); 00079 } 00080 filename = argv[1]; 00081 utc = argv[2]; 00082 00083 doc = cmml_open(filename); 00084 00085 /* seek to time offset; if not found, to file end */ 00086 cmml_skip_to_utc (doc, utc); 00087 00088 cmml_set_read_callbacks (doc, NULL, NULL, read_clip, NULL); 00089 00090 while (((n = cmml_read (doc, BUFSIZE)) > 0)); 00091 00092 cmml_close(doc); 00093 00094 return 0; 00095 }

Generated on Fri Aug 13 21:53:11 2004 for libcmml by doxygen 1.3.7