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