00001 #include "mythcdrom.h"
00002
00003 #ifdef linux
00004 #include "mythcdrom-linux.h"
00005 #elif defined(__FreeBSD__)
00006 #include "mythcdrom-freebsd.h"
00007 #endif
00008
00009 #include "mythconfig.h"
00010 #include "mythcontext.h"
00011
00012 #include <qdir.h>
00013 #include <qfileinfo.h>
00014
00015
00016
00017
00018
00019
00020 #define PATHTO_BAD_DVD_MOUNT "/video_ts"
00021
00022 #define PATHTO_DVD_DETECT "/VIDEO_TS"
00023
00024 #define PATHTO_VCD_DETECT "/vcd"
00025 #define PATHTO_SVCD_DETECT "/svcd"
00026
00027
00028 #define PATHTO_AUDIO_DETECT "/.TOC.plist"
00029
00030
00031 MythCDROM* MythCDROM::get(QObject* par, const char* devicePath, bool SuperMount,
00032 bool AllowEject) {
00033 #ifdef linux
00034 return GetMythCDROMLinux(par, devicePath, SuperMount, AllowEject);
00035 #elif defined(__FreeBSD__)
00036 return GetMythCDROMFreeBSD(par, devicePath, SuperMount, AllowEject);
00037 #elif defined(CONFIG_DARWIN)
00038 return new MythCDROM(par, devicePath, SuperMount, AllowEject);
00039 #else
00040 return NULL;
00041 #endif
00042 }
00043
00044 MythCDROM::MythCDROM(QObject* par, const char* DevicePath, bool SuperMount,
00045 bool AllowEject)
00046 : MythMediaDevice(par, DevicePath, SuperMount, AllowEject)
00047 {
00048 }
00049
00050 void MythCDROM::onDeviceMounted()
00051 {
00052 if (!QDir(m_MountPath).exists())
00053 {
00054 VERBOSE(VB_IMPORTANT, QString("Mountpoint '%1' doesn't exist")
00055 .arg(m_MountPath));
00056 m_MediaType = MEDIATYPE_UNKNOWN;
00057 m_Status = MEDIASTAT_ERROR;
00058 return;
00059 }
00060
00061 QFileInfo audio = QFileInfo(m_MountPath + PATHTO_AUDIO_DETECT);
00062 QDir dvd = QDir(m_MountPath + PATHTO_DVD_DETECT);
00063 QDir svcd = QDir(m_MountPath + PATHTO_SVCD_DETECT);
00064 QDir vcd = QDir(m_MountPath + PATHTO_VCD_DETECT);
00065 QDir bad_dvd = QDir(m_MountPath + PATHTO_BAD_DVD_MOUNT);
00066
00067
00068 m_MediaType = MEDIATYPE_DATA;
00069
00070
00071 m_Status = MEDIASTAT_MOUNTED;
00072
00073 if (dvd.exists())
00074 {
00075 VERBOSE(VB_MEDIA, "Probable DVD detected.");
00076 m_MediaType = MEDIATYPE_DVD;
00077 m_Status = MEDIASTAT_USEABLE;
00078 }
00079 else if (audio.exists())
00080 {
00081 VERBOSE(VB_MEDIA, "Probable Audio CD detected.");
00082 m_MediaType = MEDIATYPE_AUDIO;
00083 m_Status = MEDIASTAT_USEABLE;
00084 }
00085 else if (vcd.exists() || svcd.exists())
00086 {
00087 VERBOSE(VB_MEDIA, "Probable VCD/SVCD detected.");
00088 m_MediaType = MEDIATYPE_VCD;
00089 m_Status = MEDIASTAT_USEABLE;
00090 }
00091 else if (bad_dvd.exists())
00092 VERBOSE(VB_IMPORTANT,
00093 "DVD incorrectly mounted? (ISO9660 instead of UDF)");
00094 else
00095 {
00096 VERBOSE(VB_GENERAL,
00097 QString("CD/DVD '%1' contained none of\n").arg(m_MountPath) +
00098 QString("\t\t\t%1, %2, %3 or %4").arg(PATHTO_DVD_DETECT)
00099 .arg(PATHTO_AUDIO_DETECT).arg(PATHTO_VCD_DETECT)
00100 .arg(PATHTO_SVCD_DETECT));
00101 VERBOSE(VB_GENERAL, "Searching CD statistically - file by file!");
00102 }
00103
00104
00105 if (MEDIATYPE_DATA == m_MediaType)
00106 MythMediaDevice::onDeviceMounted();
00107
00108
00109
00110
00111 if (m_AllowEject)
00112 {
00113 unlock();
00114 if (m_MediaType == MEDIATYPE_DVD || m_MediaType == MEDIATYPE_VCD)
00115 unmount();
00116 }
00117 }
00118
00119 void MythCDROM::setSpeed(const char *devicePath, int speed)
00120 {
00121 VERBOSE(VB_MEDIA, QString("SetSpeed(%1,%2) - not implemented on this OS.")
00122 .arg(devicePath).arg(speed));
00123 }