Changeset 1191

Show
Ignore:
Timestamp:
2005-03-30 05:04:32 (4 years ago)
Author:
conrad
Message:

add "-c content-type" option to oggzdump; eg:
$ oggzdump -c theora pants.ogg
will just dump the theora stream, and
$ oggzdump -c theora -n pants.ogg
will just dump the theora BOS.
(theora, vorbis, speex, cmml supported, as for oggzrip, via oggz_tools.c)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • liboggz/trunk/doc/oggzdump.1

    r351 r1191  
    1 ...\" $Header: /var/lib/cvsd/annodex/liboggz/doc/oggzdump.1,v 1.1 2004/01/04 05:28:25 zen Exp $ 
    2 ...\" 
    3 ...\" transcript compatibility for postscript use. 
    4 ...\" 
    5 ...\" synopsis:  .P! <file.ps> 
    6 ...\" 
     1.\" $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/cmd/docbook-to-man.sh,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $ 
     2.\" 
     3.\"   transcript compatibility for postscript use. 
     4.\" 
     5.\"   synopsis:  .P! <file.ps> 
     6.\" 
    77.de P! 
    88.fl 
     
    1616\!!/showpage{}def 
    1717.fl                     \" prolog 
    18 .sy sed -e 's/^/!/' \\$1\" bring in postscript file 
     18.sy sed \-e 's/^/!/' \\$1\" bring in postscript file 
    1919\!!psv restore 
    2020. 
     
    5959.SH "SYNOPSIS"  
    6060.PP  
    61 \fBoggzdump\fR [-b  | --binary ]  [-x  | --hexadecimal ]  [-n  | --new ]  [-o \fBfilename\fR  | --output \fBfilename\fR ]  [-s \fBserialno\fR  | --serialno \fBserialno\fR ]  [-O  | --hide-offset ]  [-S  | --hide-serialno ]  [-G  | --hide-granulepos ]  [-P  | --hide-packetno ]  [-h  | --help ] filename   
     61\fBoggzdump\fR [-b  | --binary ]  [-x  | --hexadecimal ]  [-n  | --new ]  [-o \fBfilename\fR  | --output \fBfilename\fR ]  [-c \fBcontent-type\fR  | --content-type \fBcontent-type\fR ]  [-s \fBserialno\fR  | --serialno \fBserialno\fR ]  [-O  | --hide-offset ]  [-S  | --hide-serialno ]  [-G  | --hide-granulepos ]  [-P  | --hide-packetno ]  [-h  | --help ] filename   
    6262.PP  
    6363\fBoggzdump\fR [-r  | --revert ]  [-o \fBfilename\fR  | --output \fBfilename\fR ] filename   
     
    7676Generate a binary dump of each packet  
    7777  
    78 .IP "-x, --hexadeciaml" 10  
     78.IP "-x, --hexadecimal" 10  
    7979Generate a hexadecimal dump of each packet  
    8080  
     
    8484bitstream found; for correctly formed Ogg files, this dumps  
    8585only the beginning-of-stream packets.  
     86  
     87.IP "-c \fBcontent-type\fR, --content-type \fBcontent-type\fR" 10  
     88Dump only the logical bitstreams for a specific  
     89\fBcontent-type\fR. The following codec names  
     90are currently detected: "theora", "vorbis", "speex", "cmml"  
    8691  
    8792.IP "-s \fBserialno\fR, --serialno \fBserialno\fR" 10  
     
    148153\fBxxd\fP\fB(1)\fP,  
    149154\fBhexdump\fP\fB(1)\fP       
    150 ...\" created by instant / docbook-to-man, Wed 19 Nov 2003, 11:46  
     155.\" created by instant / docbook-to-man, Wed 30 Mar 2005, 23:06  
  • liboggz/trunk/doc/oggzdump.1.sgml

    r414 r1191  
    8080 
    8181      <group> 
     82        <arg choice="opt">-c <parameter>content-type</parameter></arg> 
     83        <arg choice="opt">--content-type <parameter>content-type</parameter></arg> 
     84      </group> 
     85 
     86      <group> 
    8287        <arg choice="opt">-s <parameter>serialno</parameter></arg> 
    8388        <arg choice="opt">--serialno <parameter>serialno</parameter></arg> 
     
    161166              bitstream found; for correctly formed Ogg files, this dumps 
    162167              only the beginning-of-stream packets. 
     168            </para></listitem> 
     169        </varlistentry> 
     170 
     171        <varlistentry> 
     172          <term>-c <parameter>content-type</parameter>, --content-type <parameter>content-type</parameter></term> 
     173          <listitem><para>Dump only the logical bitstreams for a specific 
     174              <parameter>content-type</parameter>. The following codec names 
     175              are currently detected: "theora", "vorbis", "speex", "cmml" 
    163176            </para></listitem> 
    164177        </varlistentry> 
  • liboggz/trunk/src/tools/oggzdump.c

    r1189 r1191  
    5555#define MIN(a,b) (((a)<(b))?(a):(b)) 
    5656 
     57typedef struct { 
     58  OggzTable * content_types_table; 
     59  OggzReadPacket read_packet; 
     60} ODData; 
     61 
    5762static char * progname; 
    5863static FILE * outfile = NULL; 
    5964static int dump_bits = 0; 
    6065static int dump_char = 1; 
    61 static int dump_all_serialnos = 1; 
    6266static int truth = 1; 
    6367 
     
    7781  printf ("\nFiltering options\n"); 
    7882  printf ("  -n, --new              Only dump the first packet of each logical bitstream\n"); 
     83  printf ("  -c content-type, --content-type content-type\n"); 
     84  printf ("                         Dump only the logical bitstreams for a specified\n"); 
     85  printf ("                         content-type. The following codecs are currently\n"); 
     86  printf ("                         detected: theora, vorbis, speex, cmml\n"); 
    7987  printf ("  -s serialno, --serialno serialno\n"); 
    8088  printf ("                         Dump only the logical bitstream with specified serialno\n"); 
     
    95103} 
    96104 
     105static ODData * 
     106oddata_new () 
     107{ 
     108  ODData * oddata = malloc (sizeof (ODData)); 
     109  memset (oddata, 0, sizeof (ODData)); 
     110 
     111  oddata->content_types_table = oggz_table_new (); 
     112 
     113  return oddata; 
     114} 
     115 
     116static void 
     117oddata_delete (ODData * oddata) 
     118{ 
     119  oggz_table_delete (oddata->content_types_table); 
     120 
     121  free (oddata); 
     122} 
     123 
    97124static void 
    98125dump_char_line (unsigned char * buf, long n) 
     
    239266 
    240267  fprintf (outfile, "\n"); 
     268 
     269  return 0; 
     270} 
     271 
     272static int 
     273filter_page (OGGZ * oggz, const ogg_page * og, long serialno, void * user_data) 
     274{ 
     275  ODData * oddata = (ODData *) user_data; 
     276  const char * ident; 
     277  int i, n; 
     278 
     279  if (ogg_page_bos ((ogg_page *)og)) { 
     280    ident = ot_page_identify (og, NULL); 
     281    n = oggz_table_size (oddata->content_types_table); 
     282    for (i = 0; i < n; i++) { 
     283      char * c = oggz_table_nth (oddata->content_types_table, i, NULL); 
     284      if (strcasecmp (c, ident) == 0) { 
     285        oggz_set_read_callback (oggz, serialno, oddata->read_packet, NULL); 
     286      } 
     287    } 
     288  } 
    241289 
    242290  return 0; 
     
    391439  int show_help = 0; 
    392440 
     441  ODData * oddata; 
    393442  OGGZ * oggz; 
    394443  char * infilename = NULL, * outfilename = NULL; 
     
    396445  OggzTable * table = NULL; 
    397446  long serialno; 
    398   OggzReadPacket my_read_packet = read_packet; 
    399447  int i, size; 
    400448  long n; 
     449 
     450  int filter_serialnos = 0; 
     451  int filter_content_types = 0; 
    401452 
    402453  ot_init (); 
     
    409460  } 
    410461 
     462  oddata = oddata_new (); 
     463 
     464  oddata->read_packet = read_packet; 
     465 
    411466  table = oggz_table_new(); 
    412467 
    413468  while (1) { 
    414     char * optstring = "hvbxnro:s:OSGP"; 
     469    char * optstring = "hvbxnro:s:c:OSGP"; 
    415470 
    416471#ifdef HAVE_GETOPT_LONG 
     
    424479      {"output", required_argument, 0, 'o'}, 
    425480      {"serialno", required_argument, 0, 's'}, 
     481      {"content-type", required_argument, 0, 'c'}, 
    426482      {"hide-offset", no_argument, 0, 'O'}, 
    427483      {"hide-serialno", no_argument, 0, 'S'}, 
     
    452508      break; 
    453509    case 'n': /* new */ 
    454       my_read_packet = read_new_packet; 
     510      oddata->read_packet = read_new_packet; 
    455511      break; 
    456512    case 'o': /* output */ 
     
    461517      break; 
    462518    case 's': /* serialno */ 
    463       dump_all_serialnos = 0
     519      filter_serialnos = 1
    464520      serialno = atol (optarg); 
    465521      oggz_table_insert (table, serialno, &truth); 
     522      break; 
     523    case 'c': /* content-type */ 
     524      filter_content_types = 1; 
     525      n = (long)oggz_table_size (oddata->content_types_table); 
     526      oggz_table_insert (oddata->content_types_table, (long)n, optarg); 
    466527      break; 
    467528    case 'O': /* hide offset */ 
     
    539600    } 
    540601 
    541     if (dump_all_serialnos) { 
    542       oggz_set_read_callback (oggz, -1, my_read_packet, NULL); 
     602    if (!filter_serialnos && !filter_content_types) { 
     603      oggz_set_read_callback (oggz, -1, oddata->read_packet, NULL); 
    543604    } else { 
    544       size = oggz_table_size (table); 
    545       for (i = 0; i < size; i++) { 
    546         oggz_table_nth (table, i, &serialno); 
    547         oggz_set_read_callback (oggz, serialno, my_read_packet, NULL); 
     605      if (filter_serialnos) { 
     606        size = oggz_table_size (table); 
     607        for (i = 0; i < size; i++) { 
     608          oggz_table_nth (table, i, &serialno); 
     609          oggz_set_read_callback (oggz, serialno, oddata->read_packet, NULL); 
     610        } 
     611      } 
     612       
     613      if (filter_content_types) { 
     614        oggz_set_read_page (oggz, -1, filter_page, oddata); 
    548615      } 
    549616    } 
     
    555622 
    556623 exit_ok: 
     624  oddata_delete (oddata); 
    557625  oggz_table_delete (table); 
    558626  exit (0); 
    559627 
    560628 exit_err: 
     629  oddata_delete (oddata); 
    561630  oggz_table_delete (table); 
    562631  exit (1);