Permalink
Browse files

Enable the detection of a DVD & Bluray discs by reading the UDF forma…

…t data direct from the drive using libudf

Signed-off-by: Stuart Morgan <smorgan@mythtv.org>
  • Loading branch information...
Lawrence Rust authored and stuartm committed Jan 28, 2011
1 parent 830c5d7 commit 67674bf7b217db94126cda8f90c0e51d57aede4f
Showing with 45 additions and 0 deletions.
  1. +11 −0 mythtv/configure
  2. +5 −0 mythtv/libs/libmythbase/libmythbase.pro
  3. +29 −0 mythtv/libs/libmythbase/mythcdrom-linux.cpp
View
@@ -1330,6 +1330,7 @@ MYTHTV_CONFIG_LIST='
libfftw3
libmpeg2external
libxml2
+ libudf
lirc
mheg
opengl_video
@@ -1952,6 +1953,7 @@ enable iptv
enable ivtv
enable lamemp3
enable libxml2
+enable libudf
enable lirc
enable mheg
enable mythtranscode
@@ -4029,6 +4031,11 @@ int main(void) {
}
EOF
+enabled libudf && check_cc <<EOF || disable libudf
+#include <cdio/udf.h>
+int main(void){ return UDF_BLOCKSIZE > 0 ? 0 : 1; }
+EOF
+
enabled x11 && check_lib X11/Xlib.h XQueryExtension -lX11 || disable x11
enabled xrandr && check_lib X11/extensions/Xrandr.h XRRSelectInput -lXrandr || disable xrandr
enabled xv && check_lib X11/extensions/Xv.h XvPutStill -lXv || disable xv
@@ -4765,6 +4772,10 @@ if enabled libxml2; then
fi
fi
+if enabled libudf; then
+ append CCONFIG "using_libudf"
+fi
+
if enabled x11; then
if [ -d $x11_path ] ; then
append CONFIG_INCLUDEPATH "$x11_path"
@@ -100,6 +100,11 @@ use_hidesyms {
QMAKE_CXXFLAGS += -fvisibility=hidden
}
+using_libudf {
+ DEFINES += USING_LIBUDF
+ LIBS += -ludf
+}
+
mingw:LIBS += -lpthread -lws2_32
QT += xml sql network
@@ -14,6 +14,9 @@
#include "mythcdrom-linux.h"
#include "mythconfig.h" // for HAVE_BIGENDIAN
#include "mythverbose.h"
+#ifdef USING_LIBUDF
+#include <cdio/udf.h>
+#endif
#define LOC QString("MythCDROMLinux:")
#define LOC_ERR QString("MythCDROMLinux, Error: ")
@@ -484,7 +487,33 @@ MediaStatus MythCDROMLinux::checkMedia()
}
VERBOSE(VB_MEDIA, QString("Volume ID: %1").arg(m_VolumeID));
+#ifdef USING_LIBUDF
+ // Check for a DVD/BD disk by reading the UDF root dir.
+ // This allows DVD's to play immediately upon insertion without
+ // calling mount, which either needs pmount or changes to fstab.
+ udf_t *pUdf = udf_open(m_DevicePath.toAscii());
+ if (NULL != pUdf)
+ {
+ udf_dirent_t *pUdfRoot = udf_get_root(pUdf, true, 0);
+ if (NULL != pUdfRoot)
+ {
+ if (NULL != udf_fopen(pUdfRoot, "VIDEO_TS"))
+ m_MediaType = MEDIATYPE_DVD;
+ else if (NULL != udf_fopen(pUdfRoot, "BDMV"))
+ m_MediaType = MEDIATYPE_BD;
+ udf_dirent_free(pUdfRoot);
+ }
+ udf_close(pUdf);
+
+ if (MEDIATYPE_DATA != m_MediaType)
+ {
+ // pretend we're NOTMOUNTED so setStatus emits a signal
+ m_Status = MEDIASTAT_NOTMOUNTED;
+ return setStatus(MEDIASTAT_USEABLE, OpenedHere);
+ }
+ }
+#endif
// the base class's onDeviceMounted will do fine
// grained detection of the type of data on this disc
if (isMounted())

0 comments on commit 67674bf

Please sign in to comment.