First cut at a C++ wrapper for libcdio libcdio++. What's not done are
audio and MMC commands. No doubt it may be a little rough and I expect further changes.
This commit is contained in:
@@ -19,7 +19,7 @@ define(RELEASE_NUM, 77)
|
|||||||
define(CDIO_VERSION_STR, 0.$1cvs)
|
define(CDIO_VERSION_STR, 0.$1cvs)
|
||||||
|
|
||||||
AC_PREREQ(2.52)
|
AC_PREREQ(2.52)
|
||||||
AC_REVISION([$Id: configure.ac,v 1.180 2005/10/27 03:47:32 rocky Exp $])dnl
|
AC_REVISION([$Id: configure.ac,v 1.181 2005/11/10 11:11:15 rocky Exp $])dnl
|
||||||
AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM))
|
AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM))
|
||||||
AC_CONFIG_SRCDIR(src/cd-info.c)
|
AC_CONFIG_SRCDIR(src/cd-info.c)
|
||||||
|
|
||||||
@@ -337,6 +337,7 @@ LIBCDIO_CDDA_LIBS='$(top_builddir)/lib/cdda_interface/libcdio_cdda.la'
|
|||||||
LIBCDIO_CFLAGS='-I$(top_srcdir)/lib/driver -I$(top_srcdir)/include/'
|
LIBCDIO_CFLAGS='-I$(top_srcdir)/lib/driver -I$(top_srcdir)/include/'
|
||||||
LIBCDIO_LIBS='$(top_builddir)/lib/driver/libcdio.la'
|
LIBCDIO_LIBS='$(top_builddir)/lib/driver/libcdio.la'
|
||||||
LIBCDIO_DEPS="$LIBCDIO_LIBS"
|
LIBCDIO_DEPS="$LIBCDIO_LIBS"
|
||||||
|
LIBCDIOPP_LIBS='$(top_builddir)/lib/cdio++/libcdio++.la'
|
||||||
LIBCDIO_PARANOIA_LIBS='$(top_builddir)/lib/paranoia/libcdio_paranoia.la'
|
LIBCDIO_PARANOIA_LIBS='$(top_builddir)/lib/paranoia/libcdio_paranoia.la'
|
||||||
LIBISO9660_CFLAGS='-I$(top_srcdir)/lib/iso9660/'
|
LIBISO9660_CFLAGS='-I$(top_srcdir)/lib/iso9660/'
|
||||||
LIBISO9660_LIBS='$(top_builddir)/lib/iso9660/libiso9660.la'
|
LIBISO9660_LIBS='$(top_builddir)/lib/iso9660/libiso9660.la'
|
||||||
@@ -346,6 +347,7 @@ AC_SUBST(LIBCDIO_CDDA_LIBS)
|
|||||||
AC_SUBST(LIBCDIO_CFLAGS)
|
AC_SUBST(LIBCDIO_CFLAGS)
|
||||||
AC_SUBST(LIBISO9660_CFLAGS)
|
AC_SUBST(LIBISO9660_CFLAGS)
|
||||||
AC_SUBST(LIBCDIO_LIBS)
|
AC_SUBST(LIBCDIO_LIBS)
|
||||||
|
AC_SUBST(LIBCDIOPP_LIBS)
|
||||||
AC_SUBST(LIBCDIO_DEPS)
|
AC_SUBST(LIBCDIO_DEPS)
|
||||||
AC_SUBST(LIBCDIO_PARANOIA_LIBS)
|
AC_SUBST(LIBCDIO_PARANOIA_LIBS)
|
||||||
AC_SUBST(LIBISO9660_LIBS)
|
AC_SUBST(LIBISO9660_LIBS)
|
||||||
@@ -615,14 +617,17 @@ dnl
|
|||||||
AC_CONFIG_FILES([ \
|
AC_CONFIG_FILES([ \
|
||||||
Makefile \
|
Makefile \
|
||||||
example/C++/Makefile \
|
example/C++/Makefile \
|
||||||
|
example/C++/OO/Makefile \
|
||||||
example/Makefile \
|
example/Makefile \
|
||||||
include/Makefile \
|
include/Makefile \
|
||||||
include/cdio/Makefile \
|
include/cdio/Makefile \
|
||||||
|
include/cdio++/Makefile \
|
||||||
include/cdio/version.h \
|
include/cdio/version.h \
|
||||||
doc/doxygen/Doxyfile \
|
doc/doxygen/Doxyfile \
|
||||||
doc/Makefile \
|
doc/Makefile \
|
||||||
lib/Makefile \
|
lib/Makefile \
|
||||||
lib/cdda_interface/Makefile \
|
lib/cdda_interface/Makefile \
|
||||||
|
lib/cdio++/Makefile \
|
||||||
lib/driver/Makefile \
|
lib/driver/Makefile \
|
||||||
lib/iso9660/Makefile \
|
lib/iso9660/Makefile \
|
||||||
lib/paranoia/Makefile \
|
lib/paranoia/Makefile \
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.6 2005/11/07 07:53:40 rocky Exp $
|
# $Id: Makefile.am,v 1.7 2005/11/10 11:11:15 rocky Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
# Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
#
|
#
|
||||||
@@ -16,10 +16,12 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
####################################################
|
##########################################################
|
||||||
# Things to regression testing
|
# Sample C++ programs using libcdio (without OO wrapper)
|
||||||
####################################################
|
#########################################################
|
||||||
#
|
#
|
||||||
|
SUBDIRS = OO
|
||||||
|
|
||||||
if BUILD_CD_PARANOIA
|
if BUILD_CD_PARANOIA
|
||||||
paranoia_progs = paranoia paranoia2
|
paranoia_progs = paranoia paranoia2
|
||||||
endif
|
endif
|
||||||
@@ -52,9 +54,11 @@ iso3_SOURCES = iso3.cpp
|
|||||||
iso3_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV)
|
iso3_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV)
|
||||||
|
|
||||||
mmc1_SOURCES = mmc1.cpp
|
mmc1_SOURCES = mmc1.cpp
|
||||||
|
mmc1_DEPENDENCIES = $(LIBCDIO_DEPS)
|
||||||
mmc1_LDADD = $(LIBCDIO_LIBS)
|
mmc1_LDADD = $(LIBCDIO_LIBS)
|
||||||
|
|
||||||
mmc2_SOURCES = mmc2.cpp
|
mmc2_SOURCES = mmc2.cpp
|
||||||
|
mmc2_DEPENDENCIES = $(LIBCDIO_DEPS)
|
||||||
mmc2_LDADD = $(LIBCDIO_LIBS)
|
mmc2_LDADD = $(LIBCDIO_LIBS)
|
||||||
|
|
||||||
# iso programs create file "copying"
|
# iso programs create file "copying"
|
||||||
|
|||||||
9
example/C++/OO/.cvsignore
Normal file
9
example/C++/OO/.cvsignore
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
.deps
|
||||||
|
.libs
|
||||||
|
Makefile
|
||||||
|
Makefile.am
|
||||||
|
Makefile.in
|
||||||
|
cdtext
|
||||||
|
device
|
||||||
|
eject
|
||||||
|
tracks
|
||||||
94
example/C++/OO/cdtext.cpp
Normal file
94
example/C++/OO/cdtext.cpp
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
$Id: cdtext.cpp,v 1.1 2005/11/10 11:11:15 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Simple program to list CD-Text info of a Compact Disc using libcdio. */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <cdio++/cdio.hpp>
|
||||||
|
|
||||||
|
/* Set up a CD-DA image to test on which is in the libcdio distribution. */
|
||||||
|
#define CDDA_IMAGE_PATH "../../../test/"
|
||||||
|
#define CDDA_IMAGE CDDA_IMAGE_PATH "cdda.cue"
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_cdtext_track_info(CdioDevice *device, track_t i_track,
|
||||||
|
const char *psz_msg) {
|
||||||
|
cdtext_t *cdtext = device->getCdtext(0);
|
||||||
|
if (NULL != cdtext) {
|
||||||
|
cdtext_field_t i;
|
||||||
|
int j=0;
|
||||||
|
|
||||||
|
printf("%s\n", psz_msg);
|
||||||
|
|
||||||
|
for (j=0; j < MAX_CDTEXT_FIELDS; j++) {
|
||||||
|
i = (cdtext_field_t) j;
|
||||||
|
if (cdtext->field[i]) {
|
||||||
|
printf("\t%s: %s\n", cdtext_field2str(i), cdtext->field[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_disc_info(CdioDevice *device, track_t i_tracks, track_t i_first_track) {
|
||||||
|
track_t i_last_track = i_first_track+i_tracks;
|
||||||
|
discmode_t cd_discmode = device->getDiscmode();
|
||||||
|
|
||||||
|
printf("%s\n", discmode2str[cd_discmode]);
|
||||||
|
|
||||||
|
print_cdtext_track_info(device, 0, "\nCD-Text for Disc:");
|
||||||
|
for ( ; i_first_track < i_last_track; i_first_track++ ) {
|
||||||
|
char psz_msg[50];
|
||||||
|
sprintf(psz_msg, "CD-Text for Track %d:", i_first_track);
|
||||||
|
print_cdtext_track_info(device, i_first_track, psz_msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
track_t i_first_track;
|
||||||
|
track_t i_tracks;
|
||||||
|
CdioDevice *device = new CdioDevice;
|
||||||
|
const char *psz_drive = NULL;
|
||||||
|
|
||||||
|
if (!device->open(CDDA_IMAGE, DRIVER_BINCUE)) {
|
||||||
|
printf("Couldn't open " CDDA_IMAGE " with BIN/CUE driver.\n");
|
||||||
|
} else {
|
||||||
|
i_first_track = device->getFirstTrackNum();
|
||||||
|
i_tracks = device->getNumTracks();
|
||||||
|
print_disc_info(device, i_tracks, i_first_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1) psz_drive = argv[1];
|
||||||
|
|
||||||
|
if (!device->open(psz_drive, DRIVER_DEVICE)) {
|
||||||
|
printf("Couldn't find CD\n");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
i_first_track = device->getFirstTrackNum();
|
||||||
|
i_tracks = device->getNumTracks();
|
||||||
|
print_disc_info(device, i_tracks, i_first_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(device);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
127
example/C++/OO/device.cpp
Normal file
127
example/C++/OO/device.cpp
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
$Id: device.cpp,v 1.1 2005/11/10 11:11:15 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Simple program to show drivers installed and what the default
|
||||||
|
CD-ROM drive is. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STDIO_H
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cdio++/cdio.hpp>
|
||||||
|
|
||||||
|
#define _(x) x
|
||||||
|
|
||||||
|
/* Prints out drive capabilities */
|
||||||
|
static void
|
||||||
|
print_drive_capabilities(cdio_drive_read_cap_t i_read_cap,
|
||||||
|
cdio_drive_write_cap_t i_write_cap,
|
||||||
|
cdio_drive_misc_cap_t i_misc_cap)
|
||||||
|
{
|
||||||
|
if (CDIO_DRIVE_CAP_ERROR == i_misc_cap) {
|
||||||
|
printf("Error in getting drive hardware properties\n");
|
||||||
|
} else {
|
||||||
|
printf(_("Hardware : %s\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_FILE
|
||||||
|
? "Disk Image" : "CD-ROM or DVD");
|
||||||
|
printf(_("Can eject : %s\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_EJECT ? "Yes" : "No");
|
||||||
|
printf(_("Can close tray : %s\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_CLOSE_TRAY ? "Yes" : "No");
|
||||||
|
printf(_("Can disable manual eject : %s\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_LOCK ? "Yes" : "No");
|
||||||
|
printf(_("Can select juke-box disc : %s\n\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_DISC ? "Yes" : "No");
|
||||||
|
|
||||||
|
printf(_("Can set drive speed : %s\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_SPEED ? "Yes" : "No");
|
||||||
|
printf(_("Can detect if CD changed : %s\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED ? "Yes" : "No");
|
||||||
|
printf(_("Can read multiple sessions : %s\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_MULTI_SESSION ? "Yes" : "No");
|
||||||
|
printf(_("Can hard reset device : %s\n\n"),
|
||||||
|
i_misc_cap & CDIO_DRIVE_CAP_MISC_RESET ? "Yes" : "No");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (CDIO_DRIVE_CAP_ERROR == i_read_cap) {
|
||||||
|
printf("Error in getting drive reading properties\n");
|
||||||
|
} else {
|
||||||
|
printf("Reading....\n");
|
||||||
|
printf(_(" Can play audio : %s\n"),
|
||||||
|
i_read_cap & CDIO_DRIVE_CAP_READ_AUDIO ? "Yes" : "No");
|
||||||
|
printf(_(" Can read CD-R : %s\n"),
|
||||||
|
i_read_cap & CDIO_DRIVE_CAP_READ_CD_R ? "Yes" : "No");
|
||||||
|
printf(_(" Can read CD-RW : %s\n"),
|
||||||
|
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
|
||||||
|
printf(_(" Can read DVD-ROM : %s\n"),
|
||||||
|
i_read_cap & CDIO_DRIVE_CAP_READ_DVD_ROM ? "Yes" : "No");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (CDIO_DRIVE_CAP_ERROR == i_write_cap) {
|
||||||
|
printf("Error in getting drive writing properties\n");
|
||||||
|
} else {
|
||||||
|
printf("\nWriting....\n");
|
||||||
|
printf(_(" Can write CD-RW : %s\n"),
|
||||||
|
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
|
||||||
|
printf(_(" Can write DVD-R : %s\n"),
|
||||||
|
i_write_cap & CDIO_DRIVE_CAP_READ_DVD_R ? "Yes" : "No");
|
||||||
|
printf(_(" Can write DVD-RAM : %s\n"),
|
||||||
|
i_write_cap & CDIO_DRIVE_CAP_READ_DVD_RAM ? "Yes" : "No");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
CdioDevice device;
|
||||||
|
|
||||||
|
if (device.open(NULL)) {
|
||||||
|
char *default_device = device.getDefaultDevice();
|
||||||
|
cdio_drive_read_cap_t i_read_cap;
|
||||||
|
cdio_drive_write_cap_t i_write_cap;
|
||||||
|
cdio_drive_misc_cap_t i_misc_cap;
|
||||||
|
|
||||||
|
printf("The driver selected is %s\n", device.getDriverName());
|
||||||
|
|
||||||
|
if (default_device)
|
||||||
|
printf("The default device for this driver is %s\n", default_device);
|
||||||
|
|
||||||
|
device.getDriveCap(i_read_cap, i_write_cap, i_misc_cap);
|
||||||
|
print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap);
|
||||||
|
|
||||||
|
free(default_device);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
printf("Problem in trying to find a driver.\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
79
example/C++/OO/eject.cpp
Normal file
79
example/C++/OO/eject.cpp
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
$Id: eject.cpp,v 1.1 2005/11/10 11:11:15 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Simple program to eject a CD-ROM drive door and then close it again.
|
||||||
|
|
||||||
|
If a single argument is given, it is used as the CD-ROM device to
|
||||||
|
eject/close. Otherwise a CD-ROM drive will be scanned for.
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cdio++/cdio.hpp>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
driver_return_code_t ret;
|
||||||
|
driver_id_t driver_id = DRIVER_DEVICE;
|
||||||
|
char *psz_drive = NULL;
|
||||||
|
CdioDevice device;
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
psz_drive = strdup(argv[1]);
|
||||||
|
|
||||||
|
if (!psz_drive) {
|
||||||
|
psz_drive = device.getDefaultDevice(driver_id);
|
||||||
|
if (!psz_drive) {
|
||||||
|
printf("Can't find a CD-ROM to eject\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = device.ejectMedia(psz_drive);
|
||||||
|
switch(ret) {
|
||||||
|
case DRIVER_OP_UNSUPPORTED:
|
||||||
|
printf("Eject not supported for %s.\n", psz_drive);
|
||||||
|
break;
|
||||||
|
case DRIVER_OP_SUCCESS:
|
||||||
|
printf("CD-ROM drive %s ejected.\n", psz_drive);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("Eject of CD-ROM drive %s failed.\n", psz_drive);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DRIVER_OP_SUCCESS == device.closeTray(psz_drive, driver_id)) {
|
||||||
|
printf("Closed tray of CD-ROM drive %s.\n", psz_drive);
|
||||||
|
} else {
|
||||||
|
printf("Closing tray of CD-ROM drive %s failed.\n", psz_drive);
|
||||||
|
}
|
||||||
|
free(psz_drive);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
65
example/C++/OO/tracks.cpp
Normal file
65
example/C++/OO/tracks.cpp
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
$Id: tracks.cpp,v 1.1 2005/11/10 11:11:15 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Simple program to list track numbers and logical sector numbers of
|
||||||
|
a Compact Disc using libcdio. */
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#include <cdio++/cdio.hpp>
|
||||||
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
CdioDevice device;
|
||||||
|
track_t i_first_track;
|
||||||
|
track_t i_tracks;
|
||||||
|
int j, i;
|
||||||
|
CdioTrack *track;
|
||||||
|
|
||||||
|
if (!device.open (NULL)) {
|
||||||
|
printf("Couldn't find a driver.. leaving.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i_tracks = device.getNumTracks();
|
||||||
|
i_first_track = i = device.getFirstTrackNum();
|
||||||
|
|
||||||
|
printf("CD-ROM Track List (%i - %i)\n", i_first_track, i_tracks);
|
||||||
|
|
||||||
|
printf(" #: LSN\n");
|
||||||
|
|
||||||
|
for (j = 0; j < i_tracks; i++, j++) {
|
||||||
|
track = device.getTrackFromNum(i);
|
||||||
|
lsn_t lsn = track->getLsn();
|
||||||
|
if (CDIO_INVALID_LSN != lsn)
|
||||||
|
printf("%3d: %06lu\n", (int) i, (long unsigned int) lsn);
|
||||||
|
delete(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
track = device.getTrackFromNum(CDIO_CDROM_LEADOUT_TRACK);
|
||||||
|
printf("%3X: %06lu leadout\n", CDIO_CDROM_LEADOUT_TRACK,
|
||||||
|
(long unsigned int) track->getLsn());
|
||||||
|
delete(track);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
|
|
||||||
SUBDIRS = cdio
|
SUBDIRS = cdio cdio++
|
||||||
|
|||||||
32
include/cdio++/Makefile.am
Normal file
32
include/cdio++/Makefile.am
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# $Id: Makefile.am,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
#
|
||||||
|
# Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
########################################################
|
||||||
|
# Things to make the install (public) libcdio++ headers
|
||||||
|
########################################################
|
||||||
|
#
|
||||||
|
|
||||||
|
libcdioincludedir=$(includedir)/cdio++
|
||||||
|
libcdioinclude_HEADERS = \
|
||||||
|
cdio.hpp \
|
||||||
|
cdtext.hpp \
|
||||||
|
device.hpp \
|
||||||
|
devices.hpp \
|
||||||
|
disc.hpp \
|
||||||
|
read.hpp \
|
||||||
|
track.hpp
|
||||||
117
include/cdio++/cdio.hpp
Normal file
117
include/cdio++/cdio.hpp
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/* -*- C++ -*-
|
||||||
|
$Id: cdio.hpp,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file cdio.hpp
|
||||||
|
*
|
||||||
|
* \brief C++ class for libcdio: the CD Input and Control
|
||||||
|
* library. Applications use this for anything regarding libcdio.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CDIO_HPP__
|
||||||
|
#define __CDIO_HPP__
|
||||||
|
|
||||||
|
#include <cdio/cdio.h>
|
||||||
|
|
||||||
|
class Cdio {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Other member functions
|
||||||
|
#include "devices.hpp"
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A class relating to tracks. A track object basically saves device
|
||||||
|
and track number information so that in track operations these
|
||||||
|
don't have be specified. Note use invalid track number 0 to specify
|
||||||
|
CD-Text for the CD (as opposed to a specific track).
|
||||||
|
*/
|
||||||
|
class CdioCDText
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CdioCDText(cdtext_t *p)
|
||||||
|
{
|
||||||
|
p_cdtext = p;
|
||||||
|
cdtext_init(p); // make sure we're initialized on the C side
|
||||||
|
}
|
||||||
|
|
||||||
|
~CdioCDText()
|
||||||
|
{
|
||||||
|
cdtext_destroy(p_cdtext);
|
||||||
|
p_cdtext = (cdtext_t *) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other member functions
|
||||||
|
#include "cdtext.hpp"
|
||||||
|
|
||||||
|
private:
|
||||||
|
cdtext_t *p_cdtext;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A class relating to tracks. A track object basically saves device
|
||||||
|
and track number information so that in track operations these
|
||||||
|
don't have be specified.
|
||||||
|
*/
|
||||||
|
class CdioTrack
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
CdioTrack(CdIo_t *p, track_t t)
|
||||||
|
{
|
||||||
|
i_track = t;
|
||||||
|
p_cdio = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other member functions
|
||||||
|
#include "track.hpp"
|
||||||
|
|
||||||
|
private:
|
||||||
|
track_t i_track;
|
||||||
|
CdIo_t *p_cdio;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A class relating to a CD-ROM device or pseudo CD-ROM device with
|
||||||
|
has a particular CD image. A device basically saves the libcdio
|
||||||
|
"object" (of type CdIo *).
|
||||||
|
*/
|
||||||
|
class CdioDevice
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
CdioDevice(CdIo_t *p = (CdIo_t *) NULL)
|
||||||
|
{
|
||||||
|
p_cdio=p;
|
||||||
|
};
|
||||||
|
|
||||||
|
~CdioDevice()
|
||||||
|
{
|
||||||
|
cdio_destroy(p_cdio);
|
||||||
|
p_cdio = (CdIo_t *) NULL;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Other member functions
|
||||||
|
#include "device.hpp"
|
||||||
|
#include "disc.hpp"
|
||||||
|
#include "read.hpp"
|
||||||
|
|
||||||
|
private:
|
||||||
|
CdIo_t *p_cdio;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __CDIO_HPP__ */
|
||||||
91
include/cdio++/cdtext.hpp
Normal file
91
include/cdio++/cdtext.hpp
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
$Id: cdtext.hpp,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file cdtext.hpp
|
||||||
|
* \brief methods relating to CD-Text information. This file
|
||||||
|
* should not be #included directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! Return string representation of the enum values above */
|
||||||
|
const char *field2str (cdtext_field_t i)
|
||||||
|
{
|
||||||
|
return cdtext_field2str (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! returns an allocated string associated with the given field. NULL is
|
||||||
|
returned if key is CDTEXT_INVALID or the field is not set.
|
||||||
|
|
||||||
|
The user needs to free the string when done with it.
|
||||||
|
|
||||||
|
@see getConst to retrieve a constant string that doesn't
|
||||||
|
have to be freed.
|
||||||
|
|
||||||
|
*/
|
||||||
|
char *get (cdtext_field_t key)
|
||||||
|
{
|
||||||
|
return cdtext_get (key, p_cdtext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! returns the C cdtext_t pointer associated with this object. */
|
||||||
|
cdtext_t *get ()
|
||||||
|
{
|
||||||
|
return p_cdtext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! returns a const string associated with the given field. NULL is
|
||||||
|
returned if key is CDTEXT_INVALID or the field is not set.
|
||||||
|
|
||||||
|
Don't use the string when the cdtext object (i.e. the CdIo_t object
|
||||||
|
you got it from) is no longer valid.
|
||||||
|
|
||||||
|
@see cdio_get to retrieve an allocated string that persists past the
|
||||||
|
cdtext object.
|
||||||
|
|
||||||
|
*/
|
||||||
|
const char *getConst (cdtext_field_t key)
|
||||||
|
{
|
||||||
|
return cdtext_get_const (key, p_cdtext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns enum of keyword if key is a CD-Text keyword,
|
||||||
|
returns MAX_CDTEXT_FIELDS non-zero otherwise.
|
||||||
|
*/
|
||||||
|
cdtext_field_t isKeyword (const char *key)
|
||||||
|
{
|
||||||
|
return cdtext_is_keyword (key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
sets cdtext's keyword entry to field
|
||||||
|
*/
|
||||||
|
void set (cdtext_field_t key, const char *value)
|
||||||
|
{
|
||||||
|
cdtext_set (key, value, p_cdtext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* c-file-style: "gnu"
|
||||||
|
* tab-width: 8
|
||||||
|
* indent-tabs-mode: nil
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
495
include/cdio++/device.hpp
Normal file
495
include/cdio++/device.hpp
Normal file
@@ -0,0 +1,495 @@
|
|||||||
|
/* -*- C++ -*-
|
||||||
|
$Id: device.hpp,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file device.hpp
|
||||||
|
*
|
||||||
|
* \brief C++ header for driver- or device-related libcdio calls.
|
||||||
|
* ("device" includes CD-image reading devices.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Free resources associated with CD-ROM Device/Image. After this we
|
||||||
|
must do another open before any more reading.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
close()
|
||||||
|
{
|
||||||
|
cdio_destroy(p_cdio);
|
||||||
|
p_cdio = (CdIo_t *) NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Close media tray in CD drive if there is a routine to do so.
|
||||||
|
|
||||||
|
@param psz_drive the name of CD-ROM to be closed.
|
||||||
|
@param driver_id is the driver to be used or that got used if
|
||||||
|
it was DRIVER_UNKNOWN or DRIVER_DEVICE; If this is NULL, we won't
|
||||||
|
report back the driver used.
|
||||||
|
*/
|
||||||
|
driver_return_code_t closeTray (const char *psz_drive,
|
||||||
|
/*in/out*/ driver_id_t &driver_id)
|
||||||
|
{
|
||||||
|
return cdio_close_tray (psz_drive, &driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Close media tray in CD drive if there is a routine to do so.
|
||||||
|
|
||||||
|
@param psz_drive the name of CD-ROM to be closed.
|
||||||
|
*/
|
||||||
|
driver_return_code_t closeTray (const char *psz_drive)
|
||||||
|
{
|
||||||
|
driver_id_t driver_id = DRIVER_UNKNOWN;
|
||||||
|
return closeTray(psz_drive, driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Eject media in CD drive if there is a routine to do so.
|
||||||
|
|
||||||
|
If the CD is ejected, object is destroyed.
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
ejectMedia ()
|
||||||
|
{
|
||||||
|
return cdio_eject_media(&p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Eject media in CD drive if there is a routine to do so.
|
||||||
|
|
||||||
|
If the CD is ejected, object is destroyed.
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
ejectMedia (const char *psz_drive)
|
||||||
|
{
|
||||||
|
return cdio_eject_media_drive(psz_drive);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get a string decribing driver_id.
|
||||||
|
|
||||||
|
@param driver_id the driver you want the description for
|
||||||
|
@return a sring of driver description
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
driverDescribe (driver_id_t driver_id)
|
||||||
|
{
|
||||||
|
return cdio_driver_describe(driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Free device list returned by GetDevices
|
||||||
|
|
||||||
|
@param device_list list returned by GetDevices
|
||||||
|
|
||||||
|
@see GetDevices
|
||||||
|
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
freeDeviceList (char * device_list[])
|
||||||
|
{
|
||||||
|
cdio_free_device_list(device_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the value associatied with key.
|
||||||
|
|
||||||
|
@param key the key to retrieve
|
||||||
|
@return the value associatd with "key" or NULL if p_cdio is NULL
|
||||||
|
or "key" does not exist.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
getArg (const char key[])
|
||||||
|
{
|
||||||
|
return cdio_get_arg (p_cdio, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return an opaque CdIo_t pointer for the given track object.
|
||||||
|
*/
|
||||||
|
CdIo_t *getCdIo()
|
||||||
|
{
|
||||||
|
return p_cdio;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return an opaque CdIo_t pointer for the given track object.
|
||||||
|
*/
|
||||||
|
cdtext_t *getCdtext(track_t i_track)
|
||||||
|
{
|
||||||
|
return cdio_get_cdtext (p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the default CD device.
|
||||||
|
|
||||||
|
@return a string containing the default CD device or NULL is
|
||||||
|
if we couldn't get a default device.
|
||||||
|
|
||||||
|
In some situations of drivers or OS's we can't find a CD device if
|
||||||
|
there is no media in it and it is possible for this routine to return
|
||||||
|
NULL even though there may be a hardware CD-ROM.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
getDefaultDevice ()
|
||||||
|
{
|
||||||
|
return cdio_get_default_device(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return a string containing the default CD device if none is specified.
|
||||||
|
if p_driver_id is DRIVER_UNKNOWN or DRIVER_DEVICE
|
||||||
|
then find a suitable one set the default device for that.
|
||||||
|
|
||||||
|
NULL is returned if we couldn't get a default device.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
getDefaultDevice(/*in/out*/ driver_id_t &driver_id)
|
||||||
|
{
|
||||||
|
return cdio_get_default_device_driver(&driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Return an array of device names. If you want a specific
|
||||||
|
devices for a driver, give that device. If you want hardware
|
||||||
|
devices, give DRIVER_DEVICE and if you want all possible devices,
|
||||||
|
image drivers and hardware drivers give DRIVER_UNKNOWN.
|
||||||
|
|
||||||
|
NULL is returned if we couldn't return a list of devices.
|
||||||
|
|
||||||
|
In some situations of drivers or OS's we can't find a CD device if
|
||||||
|
there is no media in it and it is possible for this routine to return
|
||||||
|
NULL even though there may be a hardware CD-ROM.
|
||||||
|
*/
|
||||||
|
char **
|
||||||
|
getDevices(driver_id_t driver_id)
|
||||||
|
{
|
||||||
|
return cdio_get_devices(driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Like GetDevices above, but we may change the p_driver_id if we
|
||||||
|
were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because
|
||||||
|
often one wants to get a drive name and then *open* it
|
||||||
|
afterwards. Giving the driver back facilitates this, and speeds
|
||||||
|
things up for libcdio as well.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char **
|
||||||
|
getDevices (driver_id_t &driver_id)
|
||||||
|
{
|
||||||
|
return cdio_get_devices_ret(&driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get an array of device names in search_devices that have at least
|
||||||
|
the capabilities listed by the capabities parameter. If
|
||||||
|
search_devices is NULL, then we'll search all possible CD drives.
|
||||||
|
|
||||||
|
If "b_any" is set false then every capability listed in the
|
||||||
|
extended portion of capabilities (i.e. not the basic filesystem)
|
||||||
|
must be satisified. If "any" is set true, then if any of the
|
||||||
|
capabilities matches, we call that a success.
|
||||||
|
|
||||||
|
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
|
||||||
|
|
||||||
|
@return the array of device names or NULL if we couldn't get a
|
||||||
|
default device. It is also possible to return a non NULL but
|
||||||
|
after dereferencing the the value is NULL. This also means nothing
|
||||||
|
was found.
|
||||||
|
*/
|
||||||
|
char **
|
||||||
|
getDevices(/*in*/ char *ppsz_search_devices[],
|
||||||
|
cdio_fs_anal_t capabilities, bool b_any)
|
||||||
|
{
|
||||||
|
return cdio_get_devices_with_cap(ppsz_search_devices, capabilities, b_any);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Like GetDevices above but we return the driver we found
|
||||||
|
as well. This is because often one wants to search for kind of drive
|
||||||
|
and then *open* it afterwards. Giving the driver back facilitates this,
|
||||||
|
and speeds things up for libcdio as well.
|
||||||
|
*/
|
||||||
|
char **
|
||||||
|
getDevices(/*in*/ char* ppsz_search_devices[],
|
||||||
|
cdio_fs_anal_t capabilities, bool b_any,
|
||||||
|
/*out*/ driver_id_t &driver_id)
|
||||||
|
{
|
||||||
|
return cdio_get_devices_with_cap_ret(ppsz_search_devices, capabilities,
|
||||||
|
b_any, &driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the what kind of device we've got.
|
||||||
|
|
||||||
|
@param p_read_cap pointer to return read capabilities
|
||||||
|
@param p_write_cap pointer to return write capabilities
|
||||||
|
@param p_misc_cap pointer to return miscellaneous other capabilities
|
||||||
|
|
||||||
|
In some situations of drivers or OS's we can't find a CD device if
|
||||||
|
there is no media in it and it is possible for this routine to return
|
||||||
|
NULL even though there may be a hardware CD-ROM.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
getDriveCap (cdio_drive_read_cap_t &read_cap,
|
||||||
|
cdio_drive_write_cap_t &write_cap,
|
||||||
|
cdio_drive_misc_cap_t &misc_cap)
|
||||||
|
{
|
||||||
|
cdio_get_drive_cap(p_cdio, &read_cap, &write_cap, &misc_cap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the drive capabilities for a specified device.
|
||||||
|
|
||||||
|
@return a list of device capabilities.
|
||||||
|
|
||||||
|
In some situations of drivers or OS's we can't find a CD device if
|
||||||
|
there is no media in it and it is possible for this routine to return
|
||||||
|
NULL even though there may be a hardware CD-ROM.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
getDriveCap (const char *device,
|
||||||
|
cdio_drive_read_cap_t &read_cap,
|
||||||
|
cdio_drive_write_cap_t &write_cap,
|
||||||
|
cdio_drive_misc_cap_t &misc_cap)
|
||||||
|
{
|
||||||
|
cdio_get_drive_cap(p_cdio, &read_cap, &write_cap, &misc_cap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get a string containing the name of the driver in use.
|
||||||
|
|
||||||
|
@return a string with driver name or NULL if CdIo_t is NULL (we
|
||||||
|
haven't initialized a specific device.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
getDriverName ()
|
||||||
|
{
|
||||||
|
return cdio_get_driver_name(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the driver id.
|
||||||
|
if CdIo_t is NULL (we haven't initialized a specific device driver),
|
||||||
|
then return DRIVER_UNKNOWN.
|
||||||
|
|
||||||
|
@return the driver id..
|
||||||
|
*/
|
||||||
|
driver_id_t
|
||||||
|
getDriverId ()
|
||||||
|
{
|
||||||
|
return cdio_get_driver_id(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
|
||||||
|
False is returned if we had an error getting the information.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
getHWinfo ( /*out*/ cdio_hwinfo_t &hw_info )
|
||||||
|
{
|
||||||
|
return cdio_get_hwinfo(p_cdio, &hw_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Get the LSN of the first track of the last session of
|
||||||
|
on the CD.
|
||||||
|
|
||||||
|
@param i_last_session pointer to the session number to be returned.
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
getLastSession (/*out*/ lsn_t &i_last_session)
|
||||||
|
{
|
||||||
|
return cdio_get_last_session(p_cdio, &i_last_session);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Find out if media has changed since the last call.
|
||||||
|
@return 1 if media has changed since last call, 0 if not. Error
|
||||||
|
return codes are the same as driver_return_code_t
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
getMediaChanged()
|
||||||
|
{
|
||||||
|
return cdio_get_media_changed(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! True if CD-ROM understand ATAPI commands. */
|
||||||
|
bool_3way_t
|
||||||
|
haveATAPI ()
|
||||||
|
{
|
||||||
|
return cdio_have_atapi(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Like cdio_have_xxx but uses an enumeration instead. */
|
||||||
|
bool
|
||||||
|
haveDriver (driver_id_t driver_id)
|
||||||
|
{
|
||||||
|
return cdio_have_driver(driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
Sets up to read from the device specified by psz_source. An open
|
||||||
|
routine should be called before using any read routine. If device
|
||||||
|
object was previously opened it is "closed".
|
||||||
|
|
||||||
|
@return true if open succeeded or false if error.
|
||||||
|
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
open(const char *psz_source)
|
||||||
|
{
|
||||||
|
if (p_cdio) cdio_destroy(p_cdio);
|
||||||
|
p_cdio = cdio_open_cd(psz_source);
|
||||||
|
return NULL != p_cdio ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Sets up to read from the device specified by psz_source and
|
||||||
|
driver_id. An open routine should be called before using any read
|
||||||
|
routine. If device object was previously opened it is "closed".
|
||||||
|
|
||||||
|
@return true if open succeeded or false if error.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
open (const char *psz_source, driver_id_t driver_id)
|
||||||
|
{
|
||||||
|
if (p_cdio) cdio_destroy(p_cdio);
|
||||||
|
p_cdio = cdio_open(psz_source, driver_id);
|
||||||
|
return NULL != p_cdio ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
Sets up to read from the device specified by psz_source and access
|
||||||
|
mode. An open routine should be called before using any read
|
||||||
|
routine. If device object was previously opened it is "closed".
|
||||||
|
|
||||||
|
@return true if open succeeded or false if error.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
open (const char *psz_source, driver_id_t driver_id,
|
||||||
|
const char *psz_access_mode)
|
||||||
|
{
|
||||||
|
if (p_cdio) cdio_destroy(p_cdio);
|
||||||
|
p_cdio = cdio_open_am(psz_source, driver_id, psz_access_mode);
|
||||||
|
return NULL != p_cdio ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
Determine if bin_name is the bin file part of a CDRWIN CD disk image.
|
||||||
|
|
||||||
|
@param bin_name location of presumed CDRWIN bin image file.
|
||||||
|
@return the corresponding CUE file if bin_name is a BIN file or
|
||||||
|
NULL if not a BIN file.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
isBinFile(const char *bin_name)
|
||||||
|
{
|
||||||
|
return cdio_is_binfile(bin_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Determine if cue_name is the cue sheet for a CDRWIN CD disk image.
|
||||||
|
|
||||||
|
@return corresponding BIN file if cue_name is a CDRWIN cue file or
|
||||||
|
NULL if not a CUE file.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
isCueFile(const char *cue_name)
|
||||||
|
{
|
||||||
|
return cdio_is_cuefile(cue_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Determine if psg_nrg is a Nero CD disk image.
|
||||||
|
|
||||||
|
@param psz_nrg location of presumed NRG image file.
|
||||||
|
@return true if psz_nrg is a Nero NRG image or false
|
||||||
|
if not a NRG image.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
isNero(const char *psz_nrg)
|
||||||
|
{
|
||||||
|
return cdio_is_nrg(psz_nrg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Determine if psg_toc is a TOC file for a cdrdao CD disk image.
|
||||||
|
|
||||||
|
@param psz_toc location of presumed TOC image file.
|
||||||
|
@return true if toc_name is a cdrdao TOC file or false
|
||||||
|
if not a TOC file.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
isTocFile(const char *psz_toc)
|
||||||
|
{
|
||||||
|
return cdio_is_tocfile(psz_toc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Determine if psz_source refers to a real hardware CD-ROM.
|
||||||
|
|
||||||
|
@param psz_source location name of object
|
||||||
|
@param driver_id driver for reading object. Use DRIVER_UNKNOWN if you
|
||||||
|
don't know what driver to use.
|
||||||
|
@return true if psz_source is a device; If false is returned we
|
||||||
|
could have a CD disk image.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
isDevice(const char *psz_source, driver_id_t driver_id)
|
||||||
|
{
|
||||||
|
return cdio_is_device(psz_source, driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Set the blocksize for subsequent reads.
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
setBlocksize ( int i_blocksize )
|
||||||
|
{
|
||||||
|
return cdio_set_blocksize ( p_cdio, i_blocksize );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Set the drive speed.
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
setSpeed ( int i_speed )
|
||||||
|
{
|
||||||
|
return cdio_set_speed ( p_cdio, i_speed );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Set the arg "key" with "value" in "p_cdio".
|
||||||
|
|
||||||
|
@param key the key to set
|
||||||
|
@param value the value to assocaiate with key
|
||||||
|
*/
|
||||||
|
driver_return_code_t
|
||||||
|
setArg (const char key[], const char value[])
|
||||||
|
{
|
||||||
|
return cdio_set_arg (p_cdio, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
107
include/cdio++/devices.hpp
Normal file
107
include/cdio++/devices.hpp
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/* -*- C++ -*-
|
||||||
|
$Id: devices.hpp,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file devices.hpp
|
||||||
|
*
|
||||||
|
* \brief methods relating to getting lists of devices. This file
|
||||||
|
* should not be #included directly.
|
||||||
|
*/
|
||||||
|
/*!
|
||||||
|
Free device list returned by GetDevices
|
||||||
|
|
||||||
|
@param device_list list returned by GetDevices
|
||||||
|
|
||||||
|
@see GetDevices
|
||||||
|
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
freeDeviceList (char * device_list[])
|
||||||
|
{
|
||||||
|
cdio_free_device_list(device_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Return an array of device names. If you want a specific
|
||||||
|
devices for a driver, give that device. If you want hardware
|
||||||
|
devices, give DRIVER_DEVICE and if you want all possible devices,
|
||||||
|
image drivers and hardware drivers give DRIVER_UNKNOWN.
|
||||||
|
|
||||||
|
NULL is returned if we couldn't return a list of devices.
|
||||||
|
|
||||||
|
In some situations of drivers or OS's we can't find a CD device if
|
||||||
|
there is no media in it and it is possible for this routine to return
|
||||||
|
NULL even though there may be a hardware CD-ROM.
|
||||||
|
*/
|
||||||
|
char **
|
||||||
|
getDevices(driver_id_t driver_id)
|
||||||
|
{
|
||||||
|
return cdio_get_devices(driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Like GetDevices above, but we may change the p_driver_id if we
|
||||||
|
were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because
|
||||||
|
often one wants to get a drive name and then *open* it
|
||||||
|
afterwards. Giving the driver back facilitates this, and speeds
|
||||||
|
things up for libcdio as well.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char **
|
||||||
|
getDevices (driver_id_t &driver_id)
|
||||||
|
{
|
||||||
|
return cdio_get_devices_ret(&driver_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get an array of device names in search_devices that have at least
|
||||||
|
the capabilities listed by the capabities parameter. If
|
||||||
|
search_devices is NULL, then we'll search all possible CD drives.
|
||||||
|
|
||||||
|
If "b_any" is set false then every capability listed in the
|
||||||
|
extended portion of capabilities (i.e. not the basic filesystem)
|
||||||
|
must be satisified. If "any" is set true, then if any of the
|
||||||
|
capabilities matches, we call that a success.
|
||||||
|
|
||||||
|
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
|
||||||
|
|
||||||
|
@return the array of device names or NULL if we couldn't get a
|
||||||
|
default device. It is also possible to return a non NULL but
|
||||||
|
after dereferencing the the value is NULL. This also means nothing
|
||||||
|
was found.
|
||||||
|
*/
|
||||||
|
char **
|
||||||
|
getDevices(/*in*/ char *ppsz_search_devices[],
|
||||||
|
cdio_fs_anal_t capabilities, bool b_any)
|
||||||
|
{
|
||||||
|
return cdio_get_devices_with_cap(ppsz_search_devices, capabilities, b_any);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Like GetDevices above but we return the driver we found
|
||||||
|
as well. This is because often one wants to search for kind of drive
|
||||||
|
and then *open* it afterwards. Giving the driver back facilitates this,
|
||||||
|
and speeds things up for libcdio as well.
|
||||||
|
*/
|
||||||
|
char **
|
||||||
|
getDevices(/*in*/ char* ppsz_search_devices[],
|
||||||
|
cdio_fs_anal_t capabilities, bool b_any,
|
||||||
|
/*out*/ driver_id_t &driver_id)
|
||||||
|
{
|
||||||
|
return cdio_get_devices_with_cap_ret(ppsz_search_devices, capabilities,
|
||||||
|
b_any, &driver_id);
|
||||||
|
}
|
||||||
175
include/cdio++/disc.hpp
Normal file
175
include/cdio++/disc.hpp
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/* -*- C++ -*-
|
||||||
|
$Id: disc.hpp,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file disc.hpp
|
||||||
|
* \brief methods relating to getting Compact Disc information. This file
|
||||||
|
* should not be #included directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
|
||||||
|
that we've got. The notion of "CD" is extended a little to include
|
||||||
|
DVD's.
|
||||||
|
*/
|
||||||
|
discmode_t getDiscmode ()
|
||||||
|
{
|
||||||
|
return cdio_get_discmode(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the lsn of the end of the CD
|
||||||
|
|
||||||
|
@return the lsn. On error 0 or CDIO_INVALD_LSN.
|
||||||
|
*/
|
||||||
|
lsn_t getDiscLastLsn()
|
||||||
|
{
|
||||||
|
return cdio_get_disc_last_lsn(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the number of the first track.
|
||||||
|
|
||||||
|
@return a track object or NULL;
|
||||||
|
on error.
|
||||||
|
*/
|
||||||
|
CdioTrack *getFirstTrack()
|
||||||
|
{
|
||||||
|
track_t i_track = cdio_get_first_track_num(p_cdio);
|
||||||
|
return (CDIO_INVALID_TRACK != i_track)
|
||||||
|
? new CdioTrack(p_cdio, i_track)
|
||||||
|
: (CdioTrack *) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the number of the first track.
|
||||||
|
|
||||||
|
@return the track number or CDIO_INVALID_TRACK
|
||||||
|
on error.
|
||||||
|
*/
|
||||||
|
track_t getFirstTrackNum()
|
||||||
|
{
|
||||||
|
return cdio_get_first_track_num(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the number of the first track.
|
||||||
|
|
||||||
|
@return a track object or NULL;
|
||||||
|
on error.
|
||||||
|
*/
|
||||||
|
CdioTrack *getLastTrack()
|
||||||
|
{
|
||||||
|
track_t i_track = cdio_get_last_track_num(p_cdio);
|
||||||
|
return (CDIO_INVALID_TRACK != i_track)
|
||||||
|
? new CdioTrack(p_cdio, i_track)
|
||||||
|
: (CdioTrack *) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the number of the first track.
|
||||||
|
|
||||||
|
@return the track number or CDIO_INVALID_TRACK
|
||||||
|
on error.
|
||||||
|
*/
|
||||||
|
track_t getLastTrackNum()
|
||||||
|
{
|
||||||
|
return cdio_get_last_track_num(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return the Joliet level recognized for p_cdio.
|
||||||
|
*/
|
||||||
|
uint8_t getJolietLevel()
|
||||||
|
{
|
||||||
|
return cdio_get_joliet_level(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the media catalog number (MCN) from the CD.
|
||||||
|
|
||||||
|
@return the media catalog number r NULL if there is none or we
|
||||||
|
don't have the ability to get it.
|
||||||
|
|
||||||
|
Note: string is malloc'd so caller has to free() the returned
|
||||||
|
string when done with it.
|
||||||
|
|
||||||
|
*/
|
||||||
|
char * getMcn ()
|
||||||
|
{
|
||||||
|
return cdio_get_mcn (p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the number of tracks on the CD.
|
||||||
|
|
||||||
|
@return the number of tracks, or CDIO_INVALID_TRACK if there is
|
||||||
|
an error.
|
||||||
|
*/
|
||||||
|
track_t getNumTracks ()
|
||||||
|
{
|
||||||
|
return cdio_get_num_tracks(p_cdio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Find the track which contans lsn.
|
||||||
|
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
|
||||||
|
if there was some error.
|
||||||
|
|
||||||
|
If the lsn is before the pregap of the first track 0 is returned.
|
||||||
|
Otherwise we return the track that spans the lsn.
|
||||||
|
*/
|
||||||
|
CdioTrack *getTrackFromNum(track_t i_track)
|
||||||
|
{
|
||||||
|
return new CdioTrack(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Find the track which contans lsn.
|
||||||
|
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
|
||||||
|
if there was some error.
|
||||||
|
|
||||||
|
If the lsn is before the pregap of the first track 0 is returned.
|
||||||
|
Otherwise we return the track that spans the lsn.
|
||||||
|
*/
|
||||||
|
CdioTrack *getTrackFromLsn(lsn_t lsn)
|
||||||
|
{
|
||||||
|
track_t i_track = cdio_get_track(p_cdio, lsn);
|
||||||
|
return (CDIO_INVALID_TRACK != i_track)
|
||||||
|
? new CdioTrack(p_cdio, i_track)
|
||||||
|
: (CdioTrack *) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return true if discmode is some sort of CD.
|
||||||
|
*/
|
||||||
|
bool isDiscmodeCdrom (discmode_t discmode) {
|
||||||
|
return cdio_is_discmode_cdrom(discmode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return true if discmode is some sort of DVD.
|
||||||
|
*/
|
||||||
|
bool isDiscmodeDvd (discmode_t discmode)
|
||||||
|
{
|
||||||
|
return cdio_is_discmode_dvd (discmode) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
158
include/cdio++/read.hpp
Normal file
158
include/cdio++/read.hpp
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
/* -*- C++ -*-
|
||||||
|
$Id: read.hpp,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file read.hpp
|
||||||
|
*
|
||||||
|
* \brief methods relating to reading blocks of Compact Discs. This file
|
||||||
|
* should not be #included directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Reposition read offset
|
||||||
|
Similar to (if not the same as) libc's lseek()
|
||||||
|
|
||||||
|
@param offset amount to seek
|
||||||
|
@param whence like corresponding parameter in libc's lseek, e.g.
|
||||||
|
SEEK_SET or SEEK_END.
|
||||||
|
@return (off_t) -1 on error.
|
||||||
|
*/
|
||||||
|
|
||||||
|
off_t lseek(off_t offset, int whence)
|
||||||
|
{
|
||||||
|
return cdio_lseek(p_cdio, offset, whence);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Reads into buf the next size bytes.
|
||||||
|
Similar to (if not the same as) libc's read()
|
||||||
|
|
||||||
|
@param p_buf place to read data into. The caller should make sure
|
||||||
|
this location can store at least i_size bytes.
|
||||||
|
@param i_size number of bytes to read
|
||||||
|
|
||||||
|
@return (ssize_t) -1 on error.
|
||||||
|
*/
|
||||||
|
ssize_t read(void *p_buf, size_t i_size)
|
||||||
|
{
|
||||||
|
return cdio_read(p_cdio, p_buf, i_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Reads a number of sectors (AKA blocks).
|
||||||
|
|
||||||
|
@param p_buf place to read data into. The caller should make sure
|
||||||
|
this location is large enough. See below for size information.
|
||||||
|
@param read_mode the kind of "mode" to use in reading.
|
||||||
|
@param i_lsn sector to read
|
||||||
|
@param i_blocks number of sectors to read
|
||||||
|
@return DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations
|
||||||
|
are returned on error.
|
||||||
|
|
||||||
|
If read_mode is CDIO_MODE_AUDIO,
|
||||||
|
*p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.
|
||||||
|
|
||||||
|
If read_mode is CDIO_MODE_DATA,
|
||||||
|
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
|
||||||
|
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
|
||||||
|
sector getting read. If you don't know whether you have a Mode 1/2,
|
||||||
|
Form 1/ Form 2/Formless sector best to reserve space for the maximum
|
||||||
|
which is M2RAW_SECTOR_SIZE.
|
||||||
|
|
||||||
|
If read_mode is CDIO_MODE_M2F1,
|
||||||
|
*p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.
|
||||||
|
|
||||||
|
If read_mode is CDIO_MODE_M2F2,
|
||||||
|
*p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
driver_return_code_t readSectors(void *p_buf, lsn_t i_lsn,
|
||||||
|
cdio_read_mode_t read_mode, uint32_t i_blocks)
|
||||||
|
{
|
||||||
|
return cdio_read_sectors(p_cdio, p_buf, i_lsn, read_mode, i_blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The special case of reading a single block is a common one so we
|
||||||
|
provide a routine for that as a convenience.
|
||||||
|
*/
|
||||||
|
driver_return_code_t readSector(void *p_buf, lsn_t i_lsn,
|
||||||
|
cdio_read_mode_t read_mode)
|
||||||
|
{
|
||||||
|
return cdio_read_sectors(p_cdio, p_buf, i_lsn, read_mode, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Reads a number of data sectors (AKA blocks).
|
||||||
|
|
||||||
|
@param p_buf place to read data into. The caller should make sure
|
||||||
|
this location is large enough. See below for size information.
|
||||||
|
|
||||||
|
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
|
||||||
|
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
|
||||||
|
sector getting read. If you don't know whether you have a Mode 1/2,
|
||||||
|
Form 1/ Form 2/Formless sector best to reserve space for the maximum
|
||||||
|
which is M2RAW_SECTOR_SIZE.
|
||||||
|
|
||||||
|
@param i_lsn sector to read
|
||||||
|
|
||||||
|
@param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE,
|
||||||
|
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
|
||||||
|
|
||||||
|
@param i_blocks number of sectors to read
|
||||||
|
|
||||||
|
@return DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations
|
||||||
|
are returned on error.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
driver_return_code_t readDataBlocks(void *p_buf, lsn_t i_lsn,
|
||||||
|
uint16_t i_blocksize, uint32_t i_blocks)
|
||||||
|
{
|
||||||
|
return cdio_read_data_sectors (p_cdio, p_buf, i_lsn, i_blocksize, i_blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The special case of reading a single block is a common one so we
|
||||||
|
provide a routine for that as a convenience.
|
||||||
|
|
||||||
|
@param p_buf place to read data into. The caller should make sure
|
||||||
|
this location is large enough. See below for size information.
|
||||||
|
|
||||||
|
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
|
||||||
|
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
|
||||||
|
sector getting read. If you don't know whether you have a Mode 1/2,
|
||||||
|
Form 1/ Form 2/Formless sector best to reserve space for the maximum
|
||||||
|
which is M2RAW_SECTOR_SIZE.
|
||||||
|
|
||||||
|
@param i_lsn sector to read
|
||||||
|
|
||||||
|
@param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE,
|
||||||
|
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
|
||||||
|
|
||||||
|
@return DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations
|
||||||
|
are returned on error.
|
||||||
|
|
||||||
|
*/
|
||||||
|
driver_return_code_t readDataBlock(void *p_buf, lsn_t i_lsn,
|
||||||
|
uint16_t i_blocksize)
|
||||||
|
{
|
||||||
|
return readDataBlocks(p_buf, i_lsn, i_blocksize, 1);
|
||||||
|
}
|
||||||
148
include/cdio++/track.hpp
Normal file
148
include/cdio++/track.hpp
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/* -*- C++ -*-
|
||||||
|
$Id: track.hpp,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file track.hpp
|
||||||
|
* \brief methods relating to getting Compact Discs. This file
|
||||||
|
* should not be #included directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return an opaque CdIo_t pointer for the given track object.
|
||||||
|
*/
|
||||||
|
CdIo_t *getCdIo()
|
||||||
|
{
|
||||||
|
return p_cdio;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get CD-Text information for a CdIo_t object.
|
||||||
|
|
||||||
|
@return the CD-Text object or NULL if obj is NULL
|
||||||
|
or CD-Text information does not exist.
|
||||||
|
*/
|
||||||
|
cdtext_t *getCdtext ()
|
||||||
|
{
|
||||||
|
return cdio_get_cdtext (p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Return number of channels in track: 2 or 4; -2 if not
|
||||||
|
implemented or -1 for error.
|
||||||
|
Not meaningful if track is not an audio track.
|
||||||
|
*/
|
||||||
|
int getChannels()
|
||||||
|
{
|
||||||
|
return cdio_get_track_channels(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Return copy protection status on a track. Is this meaningful
|
||||||
|
if not an audio track?
|
||||||
|
*/
|
||||||
|
track_flag_t getCopyPermit()
|
||||||
|
{
|
||||||
|
return cdio_get_track_copy_permit(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the format (audio, mode2, mode1) of track.
|
||||||
|
*/
|
||||||
|
track_format_t getFormat()
|
||||||
|
{
|
||||||
|
return cdio_get_track_format(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return true if we have XA data (green, mode2 form1) or
|
||||||
|
XA data (green, mode2 form2). That is track begins:
|
||||||
|
sync - header - subheader
|
||||||
|
12 4 - 8
|
||||||
|
|
||||||
|
FIXME: there's gotta be a better design for this and get_track_format?
|
||||||
|
*/
|
||||||
|
bool getGreen()
|
||||||
|
{
|
||||||
|
return cdio_get_track_green(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return the ending LSN. CDIO_INVALID_LSN is returned on error.
|
||||||
|
*/
|
||||||
|
lsn_t getLastLsn()
|
||||||
|
{
|
||||||
|
return cdio_get_track_last_lsn(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the starting LBA.
|
||||||
|
|
||||||
|
@return the starting LBA or CDIO_INVALID_LBA on error.
|
||||||
|
*/
|
||||||
|
lba_t getLba()
|
||||||
|
{
|
||||||
|
return cdio_get_track_lba(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@return the starting LSN or CDIO_INVALID_LSN on error.
|
||||||
|
*/
|
||||||
|
lsn_t getLsn()
|
||||||
|
{
|
||||||
|
return cdio_get_track_lsn(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return the starting MSF (minutes/secs/frames) for track number
|
||||||
|
i_track in p_cdio.
|
||||||
|
|
||||||
|
@return true if things worked or false if there is no track entry.
|
||||||
|
*/
|
||||||
|
bool getMsf(/*out*/ msf_t &msf)
|
||||||
|
{
|
||||||
|
return cdio_get_track_msf(p_cdio, i_track,/*out*/ &msf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return the track number of the track object.
|
||||||
|
*/
|
||||||
|
track_t getTrackNum()
|
||||||
|
{
|
||||||
|
return i_track;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Get linear preemphasis status on an audio track
|
||||||
|
This is not meaningful if not an audio track?
|
||||||
|
*/
|
||||||
|
track_flag_t getPreemphasis()
|
||||||
|
{
|
||||||
|
return cdio_get_track_preemphasis(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the number of sectors between this track an the next. This
|
||||||
|
includes any pregap sectors before the start of the next track.
|
||||||
|
|
||||||
|
@return the number of sectors or 0 if there is an error.
|
||||||
|
*/
|
||||||
|
unsigned int getSecCount()
|
||||||
|
{
|
||||||
|
return cdio_get_track_sec_count(p_cdio, i_track);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.67 2005/10/24 03:12:30 rocky Exp $
|
# $Id: Makefile.am,v 1.68 2005/11/10 11:11:15 rocky Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
#
|
#
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
########################################################
|
########################################################
|
||||||
|
|
||||||
if BUILD_CD_PARANOIA
|
if BUILD_CD_PARANOIA
|
||||||
SUBDIRS = driver iso9660 cdda_interface paranoia udf
|
SUBDIRS = cdio++ driver iso9660 cdda_interface paranoia udf
|
||||||
else
|
else
|
||||||
SUBDIRS = driver iso9660 udf
|
SUBDIRS = cdio++ driver iso9660 udf
|
||||||
endif
|
endif
|
||||||
|
|||||||
8
lib/cdio++/.cvsignore
Normal file
8
lib/cdio++/.cvsignore
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.deps
|
||||||
|
.libs
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
*.o
|
||||||
|
*.lo
|
||||||
|
*.la
|
||||||
|
*.la.ver
|
||||||
56
lib/cdio++/Makefile.am
Normal file
56
lib/cdio++/Makefile.am
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# $Id: Makefile.am,v 1.1 2005/11/10 11:11:16 rocky Exp $
|
||||||
|
#
|
||||||
|
# Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
########################################################
|
||||||
|
# Things to make the libcdio++ library
|
||||||
|
########################################################
|
||||||
|
#
|
||||||
|
# From libtool documentation amended with guidance from N. Boullis:
|
||||||
|
#
|
||||||
|
# 1. Start with version information of `0:0:0' for each libtool library.
|
||||||
|
#
|
||||||
|
# 2. It is probably not a good idea to update the version information
|
||||||
|
# several times between public releases, but rather once per public
|
||||||
|
# release. (This seems to be more an aesthetic consideration than
|
||||||
|
# a hard technical one.)
|
||||||
|
#
|
||||||
|
# 3. If the library source code has changed at all since the last
|
||||||
|
# update, then increment REVISION (`C:R:A' becomes `C:R+1:A').
|
||||||
|
#
|
||||||
|
# 4. If any interfaces have been added, removed, or changed since the
|
||||||
|
# last update, increment CURRENT, and set REVISION to 0.
|
||||||
|
#
|
||||||
|
# 5. If any interfaces have been added since the last public release,
|
||||||
|
# then increment AGE.
|
||||||
|
#
|
||||||
|
# 6. If any interfaces have been removed or changed since the last
|
||||||
|
# public release, then set AGE to 0. A changed interface means an
|
||||||
|
# incompatibility with previous versions.
|
||||||
|
|
||||||
|
lib_LTLIBRARIES = libcdio++.la
|
||||||
|
|
||||||
|
libcdiopp_la_CURRENT := 0
|
||||||
|
libcdiopp_la_REVISION := 0
|
||||||
|
libcdiopp_la_AGE := 0
|
||||||
|
|
||||||
|
libcdiopp_sources = stub.cpp
|
||||||
|
|
||||||
|
libcdio___la_SOURCES = $(libcdiopp_sources)
|
||||||
|
libcdio___la_ldflags = -version-info $(libcdiopp_la_CURRENT):$(libcdiopp_la_REVISION):$(libcdiopp_la_AGE)
|
||||||
|
|
||||||
|
INCLUDES = -I$(top_srcdir)/include/
|
||||||
2
lib/cdio++/stub.cpp
Normal file
2
lib/cdio++/stub.cpp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include <cdio++/cdio.hpp>
|
||||||
|
|
||||||
Reference in New Issue
Block a user