From f1d1c9849c8e27cccb46cf9c0d0ccb59da3f91f9 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 6 Aug 2001 18:00:00 +0200 Subject: Version 0.90 - Modified the display of the channel group separators (thanks to Markus Lang for this suggestion). - Added support for replaying DVDs (thanks to Andreas Schultz). See INSTALL for instructions on how to compile VDR with DVD support. - Fixed replay progress display in case replay is paused while watching an ongoing recording. - Ringbuffer uses semaphores to signal empty/full conditions. - Fixed calculating the timeout value in cFile::FileReady() (thanks to Wolfgang Henselmann-Weiss). --- dvd.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 dvd.c (limited to 'dvd.c') diff --git a/dvd.c b/dvd.c new file mode 100644 index 0000000..841e998 --- /dev/null +++ b/dvd.c @@ -0,0 +1,148 @@ +/* + * dvd.c: Functions for handling DVDs + * + * See the main source file 'vdr.c' for copyright information and + * how to reach the author. + * + * Initially written by Andreas Schultz + * + * $Id: dvd.c 1.3 2001/08/06 16:07:44 kls Exp $ + */ + +#ifdef DVDSUPPORT + +//#define DVDSUPPORTDEBUG 1 +//#define DEBUG_BUFFER 1 + +#include +#include +#include +#include +#include + +#include "dvd.h" + +// --- cDVD ---------------------------------------------------------------------------- + +const char *cDVD::deviceName = "/dev/dvd"; +cDVD *cDVD::dvdInstance = NULL; + +cDVD *cDVD::getDVD(void) +{ + if (!dvdInstance) + new cDVD; + return dvdInstance; +} + +cDVD::cDVD(void) +{ + dvd = NULL; + title = NULL; + vmg_file = NULL; + vts_file = NULL; + dvdInstance = this; +} + +cDVD::~cDVD() +{ + Close(); +} + +int cDVD::Command(int Cmd) +{ + int result = -1; + int f; + if ((f = open(deviceName, O_RDONLY | O_NONBLOCK)) > 0) { + result = ioctl(f, Cmd, 0); + close(f); + } + return result; +} + +void cDVD::SetDeviceName(const char *DeviceName) +{ + deviceName = strdup(DeviceName); +} + +const char *cDVD::DeviceName(void) +{ + return deviceName; +} + +bool cDVD::DriveExists(void) +{ + return access(deviceName, F_OK) == 0; +} + +bool cDVD::DiscOk(void) +{ + return Command(CDROM_DRIVE_STATUS) == CDS_DISC_OK; +} + +void cDVD::Eject(void) +{ + if (dvdInstance) + dvdInstance->Close(); + Command(CDROMEJECT); +} + +void cDVD::Open(void) +{ + if (!dvd) + dvd = DVDOpen(deviceName); +} + +void cDVD::Close(void) +{ +#ifdef DVDSUPPORTDEBUG + dsyslog(LOG_INFO, "DVD: cDVD::Close(%p): vts: %p, vmg: %p, title: %p, dvd: %p", this, vts_file, vmg_file, title, dvd); +#endif + if (vts_file) + ifoClose(vts_file); + if (vmg_file) + ifoClose(vmg_file); + if (title) + DVDCloseFile(title); + if (dvd) + DVDClose(dvd); + vts_file = NULL; + vmg_file = NULL; + title = NULL; + dvd = NULL; +} + +ifo_handle_t *cDVD::openVMG(void) +{ + if (!isValid()) + return NULL; + if (!vmg_file) + vmg_file = ifoOpen(dvd, 0); + return vmg_file; +} + +ifo_handle_t *cDVD::openVTS(int TitleSet) +{ + if (!isValid()) + return NULL; + if (vts_file && (titleset != TitleSet)) { + ifoClose(vts_file); + vts_file = NULL; + } + if (!vts_file) { + titleset = TitleSet; + vts_file = ifoOpen(dvd, TitleSet); + } + return vts_file; +} + +dvd_file_t *cDVD::openTitle(int Title, dvd_read_domain_t domain) +{ + if (!isValid()) + return NULL; + if (title) + DVDCloseFile(title); + title = DVDOpenFile(dvd, Title, domain); + return title; +} + +#endif //DVDSUPPORT -- cgit v1.2.3