Commit c825b51e authored by conrad's avatar conrad

oggzinfo: handle multiple files on the commandline


git-svn-id: http://svn.annodex.net/liboggz/trunk@1083 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 5e9ca4da
......@@ -169,8 +169,12 @@ ot_page_identify (const ogg_page * og, char ** info)
if (og->body_len >= ident->bos_str_len &&
memcmp (og->body, ident->bos_str, ident->bos_str_len) == 0) {
ret = ident->content_type;
if (info && ident->info_func) {
*info = ident->info_func (og->body, og->body_len);
if (info) {
if (ident->info_func) {
*info = ident->info_func (og->body, og->body_len);
} else {
*info = NULL;
}
}
break;
}
......
......@@ -51,7 +51,7 @@ static void
usage (char * progname)
{
printf ("Usage: %s [options] filename ...\n", progname);
printf ("Display information about an Ogg file and the bitstreams it contains\n");
printf ("Display information about one or more Ogg files and their bitstreams\n");
printf ("\nDisplay options\n");
printf (" -l, --length Display content lengths\n");
printf (" -b, --bitrate Display bitrate information\n");
......@@ -65,6 +65,8 @@ usage (char * progname)
printf ("Please report bugs to <ogg-dev@xiph.org>\n");
}
#define SEP "------------------------------------------------------------"
typedef struct _OI_Info OI_Info;
typedef struct _OI_Stats OI_Stats;
typedef struct _OI_TrackInfo OI_TrackInfo;
......@@ -358,6 +360,7 @@ main (int argc, char ** argv)
int i;
int show_all = 0;
int many_files = 0;
char * infilename;
OGGZ * oggz;
OI_Info info;
......@@ -445,44 +448,54 @@ main (int argc, char ** argv)
show_packet_stats = 1;
}
infilename = argv[optind++];
if ((oggz = oggz_open (infilename, OGGZ_READ|OGGZ_AUTO)) == NULL) {
printf ("unable to open file %s\n", argv[1]);
return (1);
if (argc > optind+1) {
many_files = 1;
}
info.tracks = oggz_table_new ();
info.length_total = 0;
oi_pass1 (oggz, &info);
while (optind < argc) {
infilename = argv[optind++];
oggz_seek_units (oggz, 0, SEEK_END);
info.duration = oggz_tell_units (oggz);
oi_pass2 (oggz, &info);
oggz_close (oggz);
if ((oggz = oggz_open (infilename, OGGZ_READ|OGGZ_AUTO)) == NULL) {
printf ("unable to open file %s\n", argv[1]);
return (1);
}
/* Print summary information */
fputs ("Content-Duration: ", stdout);
ot_print_time ((double)info.duration / 1000.0);
putchar ('\n');
info.tracks = oggz_table_new ();
info.length_total = 0;
oi_pass1 (oggz, &info);
oggz_seek_units (oggz, 0, SEEK_END);
info.duration = oggz_tell_units (oggz);
oi_pass2 (oggz, &info);
oggz_close (oggz);
/* Print summary information */
if (many_files)
printf ("Filename: %s\n", infilename);
fputs ("Content-Duration: ", stdout);
ot_print_time ((double)info.duration / 1000.0);
putchar ('\n');
if (show_length) {
printf ("Content-Length: %ld bytes\n", info.length_total);
}
if (show_bitrate) {
printf ("Content-Bitrate-Average: %ld bps\n",
oi_bitrate (info.length_total, info.duration));
}
if (show_length) {
printf ("Content-Length: %ld bytes\n", info.length_total);
}
oggzinfo_apply (oit_print, &info);
oggzinfo_apply (oit_delete, &info);
oggz_table_delete (info.tracks);
if (show_bitrate) {
printf ("Content-Bitrate-Average: %ld bps\n",
oi_bitrate (info.length_total, info.duration));
if (optind < argc) puts (SEP);
}
oggzinfo_apply (oit_print, &info);
oggzinfo_apply (oit_delete, &info);
oggz_table_delete (info.tracks);
exit_ok:
exit (0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment