[mythtv] [PATCH] VCD media monitor extension
Denys Dmytriyenko
denis at denix.org
Sun Feb 22 23:05:31 EST 2004
Hi there.
There was a patch recently adding ability to automatically play DVDs on
their insertion. I was thinking why not do the same with VCDs. The
problem appeared to be in the libmyth library where it checks for DVDs
only. So I went ahead and modified it to check also for VCDs and report
its media type back to mythdvd. BTW, I had to replace MEDIATYPE_VIDEO
with MEDIATYPE_DVD and MEDIATYPE_VCD, since "VIDEO" media type is not
specific. Anyway, here are two patches attached. Let me know what you think.
Thanks,
denix.
-------------- next part --------------
Index: libs/libmyth/mythcdrom.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcdrom.cpp,v
retrieving revision 1.4
diff -u -r1.4 mythcdrom.cpp
--- libs/libmyth/mythcdrom.cpp 2 Feb 2004 23:17:35 -0000 1.4
+++ libs/libmyth/mythcdrom.cpp 23 Feb 2004 03:40:15 -0000
@@ -21,6 +21,10 @@
#define PATHTO_DVD_DETECT "/VIDEO_TS"
#endif
+#ifndef PATHTO_VCD_DETECT
+#define PATHTO_VCD_DETECT "/VCD"
+#endif
+
MythCDROM::MythCDROM(QObject* par, const char* DevicePath, bool SuperMount,
bool AllowEject)
: MythMediaDevice(par, DevicePath, SuperMount, AllowEject)
@@ -248,20 +252,32 @@
void MythCDROM::onDeviceMounted()
{
QString DetectPath;
+ struct stat sbuf;
+
DetectPath.sprintf("%s%s", (const char*)m_MountPath, PATHTO_DVD_DETECT);
VERBOSE(VB_ALL, QString("Looking for: '%1'").arg(DetectPath));
- struct stat sbuf;
if (stat(DetectPath, &sbuf) == 0)
{
VERBOSE(VB_GENERAL, "Probable DVD detected.");
- m_MediaType = MEDIATYPE_VIDEO;
+ m_MediaType = MEDIATYPE_DVD;
// HACK make it possible to eject a DVD by unmounting it
performMountCmd(false);
m_Status = MEDIASTAT_USEABLE;
}
+
+ DetectPath.sprintf("%s%s", (const char*)m_MountPath, PATHTO_VCD_DETECT);
+ VERBOSE(VB_ALL, QString("Looking for: '%1'").arg(DetectPath));
+
+ if (stat(DetectPath, &sbuf) == 0)
+ {
+ VERBOSE(VB_GENERAL, "Probable VCD detected.");
+ m_MediaType = MEDIATYPE_VCD;
+ // HACK make it possible to eject a VCD by unmounting it
+ performMountCmd(false);
+ m_Status = MEDIASTAT_USEABLE;
+ }
if (m_AllowEject)
unlock();
}
-
Index: libs/libmyth/mythmedia.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmedia.cpp,v
retrieving revision 1.4
diff -u -r1.4 mythmedia.cpp
--- libs/libmyth/mythmedia.cpp 2 Feb 2004 23:17:35 -0000 1.4
+++ libs/libmyth/mythmedia.cpp 23 Feb 2004 03:40:16 -0000
@@ -22,7 +22,7 @@
#define PATHTO_MOUNTS "/proc/mounts"
const char* MythMediaDevice::MediaStatusStrings[] = { "MEDIASTAT_ERROR", "MEDIASTAT_UNKNOWN", "MEDIASTAT_OPEN", "MEDIASTAT_USEABLE", "MEDIASTAT_NOTMOUNTED", "MEDIASTAT_MOUNTED" };
-const char* MythMediaDevice::MediaTypeStrings[] = { "MEDIATYPE_UNKNOWN", "MEDIATYPE_DATA", "MEDIATYPE_MIXED", "MEDIATYPE_AUDIO", "MEDIATYPE_VIDEO" };
+const char* MythMediaDevice::MediaTypeStrings[] = { "MEDIATYPE_UNKNOWN", "MEDIATYPE_DATA", "MEDIATYPE_MIXED", "MEDIATYPE_AUDIO", "MEDIATYPE_DVD", "MEDIATYPE_VCD" };
const char* MythMediaDevice::MediaErrorStrings[] = { "MEDIAERR_OK", "MEDIAERR_FAILED", "MEDIAERR_UNSUPPORTED" };
MythMediaDevice::MythMediaDevice(QObject* par, const char* DevicePath,
Index: libs/libmyth/mythmedia.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmedia.h,v
retrieving revision 1.2
diff -u -r1.2 mythmedia.h
--- libs/libmyth/mythmedia.h 2 Feb 2004 23:17:35 -0000 1.2
+++ libs/libmyth/mythmedia.h 23 Feb 2004 03:40:16 -0000
@@ -18,7 +18,8 @@
MEDIATYPE_DATA=2,
MEDIATYPE_MIXED=4,
MEDIATYPE_AUDIO=8,
- MEDIATYPE_VIDEO=16
+ MEDIATYPE_DVD=16,
+ MEDIATYPE_VCD=32
} MediaType;
typedef enum {
-------------- next part --------------
Index: mythdvd/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythdvd/mythdvd/main.cpp,v
retrieving revision 1.13
diff -u -r1.13 main.cpp
--- mythdvd/main.cpp 20 Feb 2004 04:32:55 -0000 1.13
+++ mythdvd/main.cpp 23 Feb 2004 03:44:05 -0000
@@ -239,7 +239,7 @@
int mythplugin_config(void);
}
-void handleMedia(void)
+void handleDVDMedia(void)
{
switch (gContext->GetNumSetting("DVDOnInsertDVD", 1))
{
@@ -249,7 +249,7 @@
mythplugin_run();
break;
case 2 : // play DVD
- playDVD();
+ playDVD();
break;
case 3 : //Rip DVD
startDVDRipper();
@@ -257,12 +257,32 @@
}
}
+#ifdef VCD_SUPPORT
+void handleVCDMedia(void)
+{
+ switch (gContext->GetNumSetting("DVDOnInsertDVD", 1))
+ {
+ case 0 : // Do nothing
+ break;
+ case 1 : // Display menu (mythdvd)*/
+ mythplugin_run();
+ break;
+ case 2 : // play VCD
+ playVCD();
+ break;
+ case 3 : // Do nothing, cannot rip VCD?
+ break;
+ }
+}
+#endif
+
void initKeys(void)
{
REG_JUMP("Play DVD", "Play a DVD", "", playDVD);
- REG_MEDIA_HANDLER("MythDVD Media Handler", "", "", handleMedia, MEDIATYPE_VIDEO);
+ REG_MEDIA_HANDLER("MythDVD DVD Media Handler", "", "", handleDVDMedia, MEDIATYPE_DVD);
#ifdef VCD_SUPPORT
REG_JUMP("Play VCD", "Play a VCD", "", playVCD);
+ REG_MEDIA_HANDLER("MythDVD VCD Media Handler", "", "", handleVCDMedia, MEDIATYPE_VCD);
#endif
#ifdef TRANSCODE_SUPPORT
REG_JUMP("Rip DVD", "Import a DVD into your MythVideo database", "",
@@ -324,4 +344,3 @@
return 0;
}
-
More information about the mythtv-dev
mailing list