Skip to content
Permalink
Browse files

libmythmetadata: Add a BlurayMetadata class.

Class will open and parse a given Blu-ray path and if metadata is present, makes it available, including a list of the available titles, a list of thumbnail paths, title, alternate title, etc.  Includes a toMap function for flexibility.

The hope is that this class can be used to present relevant information about a Blu-ray disc in the drive from the menu, eventually.
  • Loading branch information
Robert McNamara
Robert McNamara committed Dec 24, 2010
1 parent 00df584 commit ce457455d9399471768cad750196c06457f1379a
@@ -11,7 +11,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythdb, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20101220-1"
#define MYTH_BINARY_VERSION "0.25.20101223-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
@@ -0,0 +1,74 @@
#include <QHash>

#include "bluraymetadata.h"
#include "mythdirs.h"

BlurayMetadata::BlurayMetadata(const QString path) :
m_bdnav(NULL), m_metadata(NULL),
m_title(QString()), m_alttitle(QString()),
m_language(QString()), m_discnumber(0),
m_disctotal(0), m_path(path),
m_images(QStringList())
{
}

BlurayMetadata::~BlurayMetadata()
{
if (m_bdnav)
bd_close(m_bdnav);
}

void BlurayMetadata::Parse(void)
{
QString keyfile = QString("%1/KEYDB.cfg").arg(GetConfDir());
QByteArray keyarray = keyfile.toAscii();
const char *keyfilepath = keyarray.data();

m_bdnav = bd_open(m_path.toLatin1().data(), keyfilepath);

if (!m_bdnav)
return;

m_metadata = bd_get_meta(m_bdnav);

if (!m_metadata)
return;

m_title = QString(m_metadata->di_name);
m_alttitle = QString(m_metadata->di_alternative);
m_language = QString(m_metadata->language_code);
m_discnumber = m_metadata->di_set_number;
m_disctotal = m_metadata->di_num_sets;

for (unsigned i = 0; i < m_metadata->toc_count; i++)
{
uint num = m_metadata->toc_entries[i].title_number;
QString title = QString(m_metadata->toc_entries[i].title_name);
QPair<uint,QString> ret(num,title);
m_titles.append(ret);
}

for (unsigned i = 0; i < m_metadata->thumb_count; i++)
{
QString filepath = QString("%1/BDMV/META/DL/%2")
.arg(m_path)
.arg(m_metadata->thumbnails[i].path);
m_images.append(filepath);
}
}

void BlurayMetadata::toMap(MetadataMap &metadataMap)
{
metadataMap["title"] = m_title;
metadataMap["alttitle"] = m_alttitle;
metadataMap["language"] = m_language;

metadataMap["discnumber"] = QString::number(m_discnumber);
metadataMap["disctotal"] = QString::number(m_disctotal);
metadataMap["discseries"] = QObject::tr("%1 of %2")
.arg(m_discnumber)
.arg(m_disctotal);

metadataMap["numtitles"] = m_titles.count();
metadataMap["numthumbs"] = m_images.count();
}
@@ -0,0 +1,57 @@
#ifndef BLURAYMETADATA_H_
#define BLURAYMETADATA_H_

#include <QList>
#include <QPair>
#include <QString>

#include "mythimage.h"
#include "mythexp.h"
#include "bluray.h"
#include "bdnav/meta_data.h"

typedef QList< QPair < uint,QString > > BlurayTitles;

typedef QHash<QString,QString> MetadataMap;

class MPUBLIC BlurayMetadata : public QObject
{
public:
BlurayMetadata(const QString path);
~BlurayMetadata();

void toMap(MetadataMap &metadataMap);

void Parse(void);

QString GetTitle(void) { return m_title; };
QString GetAlternateTitle(void) { return m_alttitle; };
QString GetDiscLanguage(void) { return m_language; };

uint GetCurrentDiscNumber(void) { return m_discnumber; };
uint GetTotalDiscNumber(void) { return m_disctotal; };

uint GetTitleCount(void) { return m_titles.count(); };
BlurayTitles GetTitles(void) { return m_titles; };

uint GetThumbnailCount(void) { return m_images.count(); };
QStringList GetThumbnails(void) {return m_images; };

private:
BLURAY *m_bdnav;
meta_dl *m_metadata;

QString m_title;
QString m_alttitle;
QString m_language;

uint m_discnumber;
uint m_disctotal;

QString m_path;

BlurayTitles m_titles;
QStringList m_images;
};

#endif
@@ -14,19 +14,21 @@ QMAKE_CLEAN += version.cpp
HEADERS += cleanup.h dbaccess.h dirscan.h globals.h parentalcontrols.h
HEADERS += videoscan.h videoutils.h videometadata.h videometadatalistmanager.h
HEADERS += quicksp.h metadatacommon.h metadatadownload.h metadataimagedownload.h
HEADERS += bluraymetadata.h

SOURCES += cleanup.cpp dbaccess.cpp dirscan.cpp globals.cpp
SOURCES += parentalcontrols.cpp videoscan.cpp videoutils.cpp
SOURCES += videometadata.cpp videometadatalistmanager.cpp
SOURCES += metadatacommon.cpp metadatadownload.cpp metadataimagedownload.cpp
SOURCES += bluraymetadata.cpp

INCLUDEPATH += ../libmythdb
INCLUDEPATH += ../.. ../ ./ ../libmythupnp ../libmythui
INCLUDEPATH += ../../external/FFmpeg ../libmyth
INCLUDEPATH += ../../external/FFmpeg ../libmyth ../libmythbluray
DEPENDPATH += ../libmythsamplerate ../libmythsoundtouch
DEPENDPATH += ../libmythfreesurround
DEPENDPATH += ../ ../libmythui ../libmythdb
DEPENDPATH += ../libmythupnp ../libmythtv ../libmyth
DEPENDPATH += ../libmythupnp ../libmythtv ../libmyth ../libmythbluray

LIBS += -L../libmythsamplerate -lmythsamplerate-$${LIBVERSION}
LIBS += -L../libmythsoundtouch -lmythsoundtouch-$${LIBVERSION}
@@ -38,6 +40,7 @@ LIBS += -L../../external/FFmpeg/libavcodec -lmythavcodec
LIBS += -L../../external/FFmpeg/libavcore -lmythavcodec
LIBS += -L../../external/FFmpeg/libavutil -lmythavutil
LIBS += -L../libmyth -lmyth-$${LIBVERSION}
LIBS += -L../libmythbluray -lmythbluray-$$LIBVERSION

mingw {

@@ -49,6 +52,7 @@ inc.path = $${PREFIX}/include/mythtv/metadata/
inc.files = cleanup.h dbaccess.h dirscan.h globals.h parentalcontrols.h
inc.files += videoscan.h videoutils.h videometadata.h videometadatalistmanager.h
inc.files += quicksp.h metadatacommon.h metadatadownload.h metadataimagedownload.h
inc.files += bluraymetadata.h

INSTALLS += inc

0 comments on commit ce45745

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