Main Page | Modules | Data Structures | File List | Globals | Related Pages

Writing to files and file descriptors
[Writing Annodex media]

If you wish to write Annodex media to a file or file descriptor (such as a network socket), it can be directly written as follows:

This procedure is illustrated in src/examples/write-clip-file.c:

#include <stdio.h> #include <string.h> #include <annodex/annodex.h> int main (int argc, char *argv[]) { ANNODEX * anx = NULL; AnxClip my_clip; char * infilename, * outfilename; long n; if (argc != 3) { fprintf (stderr, "Usage: %s infile outfile.anx\n", argv[0]); exit (1); } /* Load all importers */ anx_init_importers ("*/*"); infilename = argv[1]; outfilename = argv[2]; /* Create an ANNODEX* writer, writing to outfilename */ anx = anx_open (outfilename, ANX_WRITE); /* Import infilename into the writer */ anx_write_import (anx, infilename, NULL /* id */, NULL /* unknown content-type */, 0 /* seek_offset */, -1 /* seek_end */, 0 /* flags */); /* Insert a clip starting at time 0 */ memset (&my_clip, 0, sizeof (AnxClip)); my_clip.anchor_href = "http://www.annodex.net/"; my_clip.anchor_text = "Find out about Annodex media"; anx_insert_clip (anx, 0, &my_clip); /* End the clip at time 2.0 seconds */ anx_insert_clip (anx, 2.0, NULL); while ((n = anx_write (anx, 1024)) > 0); anx_close (anx); exit (0); }
00001 00033 #include <stdio.h> 00034 #include <string.h> 00035 00036 #include <annodex/annodex.h> 00037 00038 int 00039 main (int argc, char *argv[]) 00040 { 00041 ANNODEX * anx = NULL; 00042 AnxClip my_clip; 00043 char * infilename, * outfilename; 00044 long n; 00045 00046 if (argc != 3) { 00047 fprintf (stderr, "Usage: %s infile outfile.anx\n", argv[0]); 00048 exit (1); 00049 } 00050 00051 /* Load all importers */ 00052 anx_init_importers ("*/*"); 00053 00054 infilename = argv[1]; 00055 outfilename = argv[2]; 00056 00057 /* Create an ANNODEX* writer, writing to outfilename */ 00058 anx = anx_open (outfilename, ANX_WRITE); 00059 00060 /* Import infilename into the writer */ 00061 anx_write_import (anx, infilename, NULL /* id */, 00062 NULL /* unknown content-type */, 00063 0 /* seek_offset */, -1 /* seek_end */, 0 /* flags */); 00064 00065 /* Insert a clip starting at time 0 */ 00066 memset (&my_clip, 0, sizeof (AnxClip)); 00067 my_clip.anchor_href = "http://www.annodex.net/"; 00068 my_clip.anchor_text = "Find out about Annodex media"; 00069 00070 anx_insert_clip (anx, 0, &my_clip); 00071 00072 /* End the clip at time 2.0 seconds */ 00073 anx_insert_clip (anx, 2.0, NULL); 00074 00075 while ((n = anx_write (anx, 1024)) > 0); 00076 00077 anx_close (anx); 00078 00079 exit (0); 00080 }


Generated on Wed Aug 18 05:27:54 2004 for libannodex by doxygen 1.3.7