Changeset 2571
- Timestamp:
- 2006-12-10 02:56:22 (2 years ago)
- Files:
-
- liboggz/trunk/src/examples/read-file.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
liboggz/trunk/src/examples/read-file.c
r1347 r2571 31 31 */ 32 32 33 #include "config.h" 34 33 35 #include <stdio.h> 34 36 #include <stdlib.h> 37 #ifdef HAVE_INTTYPES_H 38 # include <inttypes.h> 39 #else 40 # define PRId64 "I64d" 41 #endif 42 35 43 #include <oggz/oggz.h> 36 44 37 45 static int got_an_eos = 0; 38 46 47 static void 48 print_granulepos (ogg_int64_t granulepos, int granuleshift) 49 { 50 if (granuleshift < 1) { 51 printf ("%" PRId64, granulepos); 52 } else { 53 ogg_int64_t iframe, pframe; 54 iframe = granulepos >> granuleshift; 55 pframe = granulepos - (iframe << granuleshift); 56 57 printf ("%" PRId64 "|%" PRId64, iframe, pframe); 58 } 59 } 60 61 39 62 static int 40 63 read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data) 41 64 { 42 #if 0 43 if (got_an_eos) { 44 printf ("[%010ld]\t%ld bytes\tgranulepos %ld\n", serialno, op->bytes, 45 (long)op->granulepos); 46 } 47 #endif 65 int granuleshift; 66 67 granuleshift = oggz_get_granuleshift (oggz, serialno); 68 69 printf ("%010ld: op->granulepos: ", serialno); 70 print_granulepos (op->granulepos, granuleshift); 71 printf (" oggz_tell_granulepos(): "); 72 print_granulepos (oggz_tell_granulepos (oggz), granuleshift); 48 73 49 74 if (op->b_o_s) { 50 printf (" %010ld: [%lld] BOS %8s\n", serialno, op->granulepos, op->packet);75 printf (" *** bos"); 51 76 } 52 77 53 78 if (op->e_o_s) { 54 79 got_an_eos = 1; 55 printf (" %010ld: [%lld] EOS\n", serialno, op->granulepos);80 printf (" *** eos"); 56 81 } 82 83 printf ("\n"); 57 84 58 85 return 0; … … 63 90 { 64 91 OGGZ * oggz; 65 long n;66 92 67 93 if (argc < 2) { … … 76 102 oggz_set_read_callback (oggz, -1, read_packet, NULL); 77 103 78 while ((n = oggz_read (oggz, 1024)) > 0);104 oggz_run (oggz); 79 105 80 106 oggz_close (oggz);