From 65e6cf33ca7ece7af00f2e87375c5f66903bd485 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 26 Apr 2003 14:24:44 +0000 Subject: [PATCH] cd-info: Use libvcdinfo if it is around to list out general Video CD properties (format version, album description, preparer id, volume number and count). cd-info output changed slightly. --- configure.ac | 25 +++++++++++-- src/Makefile.am | 4 +-- src/cd-info.c | 66 +++++++++++++++++++++++++++++++++-- test/cdda.right | 2 +- test/check_cue.sh.in | 10 ++++-- test/check_nrg.sh | 16 +++++---- test/check_opts0.right | 2 +- test/check_opts1.right | 2 +- test/check_opts4.right | 2 +- test/check_opts5.right | 2 +- test/check_opts6.right | 2 +- test/check_opts7.right | 2 +- test/isofs-m1.right | 2 +- test/monvoisin.right | 2 +- test/svcd_ogt_test_ntsc.right | 2 +- test/svcdgs.right | 2 +- test/vcd_demo.right | 2 +- test/videocd.right | 2 +- 18 files changed, 117 insertions(+), 30 deletions(-) diff --git a/configure.ac b/configure.ac index ca039041..2fb04331 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. -AC_REVISION([$Id: configure.ac,v 1.18 2003/04/25 21:26:47 rocky Exp $])dnl +AC_REVISION([$Id: configure.ac,v 1.19 2003/04/26 14:24:44 rocky Exp $])dnl AC_INIT(lib/cdio.c) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(libcdio, 0.5) @@ -66,10 +66,15 @@ AC_STDC_HEADERS AC_CHECK_HEADERS(stdint.h inttypes.h stdbool.h) AC_CHECK_HEADER(cddb/cddb.h, , - [ AC_MSG_RESULT([*** CDDB support be disabled from cdinfo program]) + [ AC_MSG_RESULT([*** CDDB support disabled from cdinfo program]) enable_cddb=no ], ) +AC_CHECK_HEADER(libvcd/info.h, , + [ AC_MSG_RESULT([*** Video CD info disabled from cdinfo program]) + enable_vcdinfo=no ], + ) + dnl compiler AC_C_BIGENDIAN AC_C_CONST @@ -226,8 +231,21 @@ fi AC_SUBST(CDDB_LIB) +if test x$enable_vcdinfo = x; then +AC_ARG_ENABLE(vcdinfo, + [ --disable-vcdinfo don't include Video CD Info from libvcd], + enable_vcdinfo=no, + enable_vcdinfo=yes) +fi +if test x$enable_vcdinfo = xyes; then + AC_DEFINE([HAVE_VCDINFO],1, [Define this if you have libvcdinfo installed]) + VCDINFO_LIB="-lvcd -lvcdinfo" +fi + +AC_SUBST(VCDINFO_LIB) + AC_CONFIG_COMMANDS([checks], - [chmod +x test/check_cue.sh + [chmod +x test/check_cue.sh; chmod +x test/check_nrg.sh ]) AC_OUTPUT([ \ @@ -239,6 +257,7 @@ AC_OUTPUT([ \ include/cdio/version.h \ lib/Makefile \ src/Makefile \ + test/check_nrg.sh \ test/check_cue.sh \ test/Makefile \ ]) diff --git a/src/Makefile.am b/src/Makefile.am index 6ae64ffd..8959e487 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.5 2003/04/25 21:28:39 rocky Exp $ +# $Id: Makefile.am,v 1.6 2003/04/26 14:24:44 rocky Exp $ # # Copyright (C) 2003 Rocky Bernstein # @@ -23,7 +23,7 @@ CDDB_LIB=@CDDB_LIB@ if BUILD_CDINFO cd_info_SOURCES = cd-info.c -cd_info_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(CDDB_LIB) +cd_info_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(CDDB_LIB) $(VCDINFO_LIB) if BUILD_CDINFO_LINUX cdinfo_linux_SOURCES = cdinfo-linux.c cdinfo_linux_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) diff --git a/src/cd-info.c b/src/cd-info.c index 2254fcaf..dd2a90a8 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.1 2003/04/25 21:28:39 rocky Exp $ + $Id: cd-info.c,v 1.2 2003/04/26 14:24:44 rocky Exp $ Copyright (C) 2003 Rocky Bernstein Copyright (C) 1996,1997,1998 Gerd Knorr @@ -46,6 +46,12 @@ #include #endif +#ifdef HAVE_VCDINFO +#include +#include +#include +#endif + #include #include #include @@ -246,6 +252,9 @@ struct arguments int no_cddb; int cddb_port; /* port number to contact CDDB server. */ int cddb_http; /* 1 if use http proxy */ +#endif +#ifdef HAVE_VCDINFO + int no_vcd; #endif int debug_level; int silent; @@ -301,6 +310,10 @@ struct poptOption optionsTable[] = { "Lookup CDDB via HTTP proxy (default no proxy)"}, #endif +#ifdef HAVE_VCDINFO + {"no-vcd", 'v', POPT_ARG_NONE, &opts.no_vcd, 0, + "Don't look up Video CD information"}, +#endif {"no-ioctl", 'I', POPT_ARG_NONE, &opts.no_ioctl, 0, "Don't show ioctl() information"}, @@ -782,6 +795,46 @@ print_cddb_info() { } #endif +#ifdef HAVE_VCDINFO +static void +print_vcd_info(void) { + vcdinfo_open_return_t open_rc; + vcdinfo_obj_t obj; + open_rc = vcdinfo_open(&obj, &source_name, VCDINFO_SOURCE_AUTO, NULL); + switch (open_rc) { + case VCDINFO_OPEN_VCD: + if (vcdinfo_get_format_version (&obj) == VCD_TYPE_INVALID) { + fprintf(stderr, "VCD format detection failed"); + vcdinfo_close(&obj); + return; + } + fprintf (stdout, "format: %s\n", vcdinfo_get_format_version_str(&obj)); + fprintf (stdout, "album id: `%.16s'\n", vcdinfo_get_album_id(&obj)); + fprintf (stdout, "volume count: %d\n", vcdinfo_get_volume_count(&obj)); + fprintf (stdout, "volume number: %d\n", vcdinfo_get_volume_num(&obj)); + fprintf (stdout, "system id: `%s'\n", vcdinfo_get_system_id(&obj)); + fprintf (stdout, "volume id: `%s'\n", vcdinfo_get_volume_id(&obj)); + fprintf (stdout, "volumeset id: `%s'\n", vcdinfo_get_volumeset_id(&obj)); + fprintf (stdout, "publisher id: `%s'\n", vcdinfo_get_publisher_id(&obj)); + fprintf (stdout, "preparer id: `%s'\n", vcdinfo_get_preparer_id(&obj)); + fprintf (stdout, "application id: `%s'\n", + vcdinfo_get_application_id(&obj)); + + break; + case VCDINFO_OPEN_ERROR: + fprintf (stderr, "Error in Video CD opening of %s\n", source_name); + return; + break; + case VCDINFO_OPEN_OTHER: + fprintf (stderr, "Even though we thought this was a Video CD, " + " further inspection says it is not.\n"); + break; + } + vcdinfo_close(&obj); + +} +#endif + static void print_analysis(int fs, int num_audio) { @@ -858,8 +911,15 @@ print_analysis(int fs, int num_audio) need_lf += printf("CD-Plus/Extra "); if (fs & BOOTABLE) need_lf += printf("bootable CD "); - if (fs & VIDEOCDI && num_audio == 0) + if (fs & VIDEOCDI && num_audio == 0) { need_lf += printf("Video CD "); +#ifdef HAVE_VCDINFO + if (!opts.no_vcd) { + printf("\n"); + print_vcd_info(); + } +#endif + } if (fs & CVD) need_lf += printf("Chaoji Video CD"); if (need_lf) puts(""); @@ -1043,7 +1103,7 @@ main(int argc, const char *argv[]) #endif /*CDIO_IOCTL_FINISHED*/ if (!opts.no_analysis) { - printf(STRONG "try to find out what sort of CD this is\n" NORMAL); + printf(STRONG "CD Analysis Report\n" NORMAL); /* try to find out what sort of CD we have */ if (0 == num_data) { diff --git a/test/cdda.right b/test/cdda.right index ae47a2c1..dc928678 100644 --- a/test/cdda.right +++ b/test/cdda.right @@ -8,5 +8,5 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 audio 170: 00:06:02 000302 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report Audio CD, CDDB disc ID is 02000401 diff --git a/test/check_cue.sh.in b/test/check_cue.sh.in index ef866d48..4d153a52 100644 --- a/test/check_cue.sh.in +++ b/test/check_cue.sh.in @@ -1,9 +1,13 @@ #!/bin/sh -#$Id: check_cue.sh.in,v 1.1 2003/04/22 12:09:09 rocky Exp $ +#$Id: check_cue.sh.in,v 1.2 2003/04/26 14:24:45 rocky Exp $ if test -n "@CDDB_LIB@" ; then cddb_opt='--no-cddb' fi +if test -n "@VCD_LIB@" ; then + vcd_opt='--no-vcd' +fi + if test -z $srcdir ; then srcdir=`pwd` fi @@ -33,7 +37,7 @@ fi fname=vcd_demo testnum='Video CD' if test -f ${srcdir}/${fname}.cue ; then - test_cdinfo "-c ${srcdir}/vcd_demo.cue" \ + test_cdinfo "-c ${srcdir}/vcd_demo.cue $vcd_opt" \ ${fname}.dump ${srcdir}/${fname}.right RC=$? check_result $RC "cdinfo CUE test $testnum" @@ -44,7 +48,7 @@ fi fname=svcd_ogt_test_ntsc testnum='Super Video CD' if test -f ${srcdir}/${fname}.bin ; then - test_cdinfo "--cue-file ${srcdir}/${fname}.cue" \ + test_cdinfo "--cue-file ${srcdir}/${fname}.cue $vcd_opt" \ ${fname}.dump ${srcdir}/${fname}.right RC=$? check_result $RC "cdinfo CUE test $testnum" diff --git a/test/check_nrg.sh b/test/check_nrg.sh index f4f45f7c..4a532fd3 100755 --- a/test/check_nrg.sh +++ b/test/check_nrg.sh @@ -1,5 +1,9 @@ #!/bin/sh -#$Id: check_nrg.sh,v 1.2 2003/04/24 02:45:04 rocky Exp $ +#$Id: check_nrg.sh,v 1.3 2003/04/26 14:24:45 rocky Exp $ + +if test -n "-lvcd -lvcdinfo" ; then + vcd_opt='--no-vcd' +fi if test -z $srcdir ; then srcdir=`pwd` @@ -10,19 +14,19 @@ fi BASE=`basename $0 .sh` fname=videocd -test_cdinfo "--nrg-file ${srcdir}/${fname}.nrg" \ +test_cdinfo "--nrg-file ${srcdir}/${fname}.nrg $vcd_opt " \ ${fname}.dump ${srcdir}/${fname}.right RC=$? -check_result $RC 'cdinfo NRG test 1' +check_result $RC 'cd-info NRG test 1' BASE=`basename $0 .sh` nrg_file=${srcdir}/monvoisin.nrg if test -f $nrg_file ; then - test_cdinfo "--nrg-file $nrg_file" \ + test_cdinfo "--nrg-file $nrg_file $vcd_opt " \ monvoisin.dump ${srcdir}/monvoisin.right RC=$? - check_result $RC 'cdinfo NRG test 1' + check_result $RC 'cd-info NRG test 1' else echo "Don't see NRG file ${nrg_file}. Test skipped." exit $SKIP_TEST_EXITCODE @@ -33,7 +37,7 @@ if test -f $nrg_file ; then test_cdinfo "--nrg-file $nrg_file" \ svcdgs.dump ${srcdir}/svcdgs.right RC=$? - check_result $RC 'cdinfo NRG test 2' + check_result $RC 'cd-info NRG test 2' exit $RC else diff --git a/test/check_opts0.right b/test/check_opts0.right index a7262a52..2106f636 100644 --- a/test/check_opts0.right +++ b/test/check_opts0.right @@ -3,6 +3,6 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 64 blocks, label `CDROM ' diff --git a/test/check_opts1.right b/test/check_opts1.right index a7262a52..2106f636 100644 --- a/test/check_opts1.right +++ b/test/check_opts1.right @@ -3,6 +3,6 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 64 blocks, label `CDROM ' diff --git a/test/check_opts4.right b/test/check_opts4.right index dc3c6bd5..067233b9 100644 --- a/test/check_opts4.right +++ b/test/check_opts4.right @@ -8,6 +8,6 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 64 blocks, label `CDROM ' diff --git a/test/check_opts5.right b/test/check_opts5.right index dc3c6bd5..067233b9 100644 --- a/test/check_opts5.right +++ b/test/check_opts5.right @@ -8,6 +8,6 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 64 blocks, label `CDROM ' diff --git a/test/check_opts6.right b/test/check_opts6.right index dc3c6bd5..067233b9 100644 --- a/test/check_opts6.right +++ b/test/check_opts6.right @@ -8,6 +8,6 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 64 blocks, label `CDROM ' diff --git a/test/check_opts7.right b/test/check_opts7.right index dc3c6bd5..067233b9 100644 --- a/test/check_opts7.right +++ b/test/check_opts7.right @@ -8,6 +8,6 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 64 blocks, label `CDROM ' diff --git a/test/isofs-m1.right b/test/isofs-m1.right index dc3c6bd5..067233b9 100644 --- a/test/isofs-m1.right +++ b/test/isofs-m1.right @@ -8,6 +8,6 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 64 blocks, label `CDROM ' diff --git a/test/monvoisin.right b/test/monvoisin.right index 56f1a843..31544e5c 100644 --- a/test/monvoisin.right +++ b/test/monvoisin.right @@ -9,7 +9,7 @@ CD-ROM Track List (1 - 2) 2: 00:18:51 001251 XA 170: 00:39:71 002846 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem ISO 9660: 1101 blocks, label `MONVOISIN ' XA sectors Video CD diff --git a/test/svcd_ogt_test_ntsc.right b/test/svcd_ogt_test_ntsc.right index bcb18dcb..69b688b6 100644 --- a/test/svcd_ogt_test_ntsc.right +++ b/test/svcd_ogt_test_ntsc.right @@ -9,7 +9,7 @@ CD-ROM Track List (1 - 2) 2: 00:09:01 000526 XA 170: 00:56:56 004106 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem ISO 9660: 376 blocks, label `SVCD_OGT_TEST_NTSC ' XA sectors diff --git a/test/svcdgs.right b/test/svcdgs.right index 3140f440..3264d140 100644 --- a/test/svcdgs.right +++ b/test/svcdgs.right @@ -9,7 +9,7 @@ CD-ROM Track List (1 - 2) 2: 00:22:53 001553 XA 170: 01:17:62 005687 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with ISO 9660 filesystem ISO 9660: 6610 blocks, label `SVCD ' XA sectors Chaoji Video CD diff --git a/test/vcd_demo.right b/test/vcd_demo.right index 240e8c27..95d988e2 100644 --- a/test/vcd_demo.right +++ b/test/vcd_demo.right @@ -10,7 +10,7 @@ CD-ROM Track List (1 - 3) 3: 00:24:71 001721 XA 170: 00:30:10 002110 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem ISO 9660: 1032 blocks, label `V0469 ' XA sectors Video CD diff --git a/test/videocd.right b/test/videocd.right index 7cdc4dda..aa377a1a 100644 --- a/test/videocd.right +++ b/test/videocd.right @@ -12,7 +12,7 @@ CD-ROM Track List (1 - 5) 5: 00:22:01 001501 XA 170: 00:25:01 001726 leadout __________________________________ -try to find out what sort of CD this is +CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem ISO 9660: 676 blocks, label `SVIDEOCD ' XA sectors