Skip to content
Permalink
Browse files

Add a new DVDInfo class.

This is a simple DVD helper that simply opens the device and retrieves
the name and serial number of the disc. A complete DVD device, as
implemented in DVDRingBuffer, can be expensive to fully create and open
and when performing the initial DVD bookmark check, we need nothing more
than the basics.

For remote, storage group based playback this can knock up to 5 seconds
off the time taken to start a disc.
  • Loading branch information
Mark Kendall
Mark Kendall committed May 9, 2011
1 parent 8089760 commit 70bcc33f032002cde82c2efd1f001d4e93894e20
@@ -33,6 +33,49 @@ static const char *dvdnav_menu_table[] =
"Part",
};

DVDInfo::DVDInfo(const QString &filename)
: m_nav(NULL), m_name(NULL), m_serialnumber(NULL)
{
QString name = filename;
if (name.left(6) == "dvd://")
name.remove(0,5);
else if (name.left(5) == "dvd:/")
name.remove(0,4);
else if (name.left(4) == "dvd:")
name.remove(0,4);

QByteArray fname = name.toLocal8Bit();
dvdnav_status_t res = dvdnav_open(&m_nav, fname.constData());
if (res == DVDNAV_STATUS_ERR)
{
VERBOSE(VB_IMPORTANT, QString("DVDInfo: Failed to open device at %1")
.arg(fname.constData()));
return;
}

res = dvdnav_get_title_string(m_nav, &m_name);
if (res == DVDNAV_STATUS_ERR)
VERBOSE(VB_IMPORTANT, QString("DVDInfo: Failed to get name."));
res = dvdnav_get_serial_string(m_nav, &m_serialnumber);
if (res == DVDNAV_STATUS_ERR)
VERBOSE(VB_IMPORTANT, QString("DVDInfo: Failed to get serial number."));
}

DVDInfo::~DVDInfo(void)
{
if (m_nav)
dvdnav_close(m_nav);
}

bool DVDInfo::GetNameAndSerialNum(QString &name, QString &serial)
{
name = QString(m_name);
serial = QString(m_serialnumber);
if (name.isEmpty() && serial.isEmpty())
return false;
return true;
}

DVDRingBuffer::DVDRingBuffer(const QString &lfilename) :
m_dvdnav(NULL), m_dvdBlockReadBuf(NULL),
m_dvdBlockRPos(0), m_dvdBlockWPos(0),
@@ -27,6 +27,20 @@ extern "C" {

class MythDVDPlayer;

class MTV_PUBLIC DVDInfo
{
public:
DVDInfo(const QString &filename);
~DVDInfo(void);
bool IsValid(void) { return m_nav != NULL; }
bool GetNameAndSerialNum(QString &name, QString &serialnum);

protected:
dvdnav_t *m_nav;
const char *m_name;
const char *m_serialnumber;
};

class MTV_PUBLIC DVDRingBuffer : public RingBuffer
{
public:
@@ -804,26 +804,29 @@ static int internal_play_media(const QString &mrl, const QString &plot,

if (pginfo->IsVideoDVD())
{
RingBuffer *tmprbuf = RingBuffer::Create(pginfo->GetPathname(), false);

if (!tmprbuf)
{
delete pginfo;
return res;
}
QString name;
QString serialid;
if (tmprbuf->IsDVD() &&
tmprbuf->DVD()->GetNameAndSerialNum(name, serialid))
DVDInfo *dvd = new DVDInfo(pginfo->GetPathname());
if (dvd && dvd->IsValid())
{
QStringList fields = pginfo->QueryDVDBookmark(serialid);
if (!fields.empty())
QString name;
QString serialid;
if (dvd->GetNameAndSerialNum(name, serialid))
{
QStringList::Iterator it = fields.begin();
pos = (int64_t)((*++it).toLongLong() & 0xffffffffLL);
QStringList fields = pginfo->QueryDVDBookmark(serialid);
if (!fields.empty())
{
QStringList::Iterator it = fields.begin();
pos = (int64_t)((*++it).toLongLong() & 0xffffffffLL);
}
}
}
delete tmprbuf;
else
{
if (dvd)
delete dvd;
delete pginfo;
return res;
}
delete dvd;
}
else if (pginfo->IsVideo())
pos = pginfo->QueryBookmark();

0 comments on commit 70bcc33

Please sign in to comment.
You can’t perform that action at this time.