MythTV  master
bluraymetadata.cpp
Go to the documentation of this file.
1 // Qt headers
2 #include <QHash>
3 #include <QCoreApplication>
4 #include <QStringList>
5 
6 #include "libmythbase/mythdirs.h"
7 
8 #ifdef HAVE_LIBBLURAY
9 #include <libbluray/meta_data.h>
10 #else
11 #include "libbluray/bdnav/meta_data.h"
12 #endif
13 #include "bluraymetadata.h"
14 
16 {
17  if (m_bdnav)
18  bd_close(m_bdnav);
19 }
20 
22 {
23  if (IsOpen())
24  return true;
25 
26  QString keyfile = QString("%1/KEYDB.cfg").arg(GetConfDir());
27  QByteArray keyarray = keyfile.toLatin1();
28  const char *keyfilepath = keyarray.data();
29 
30  m_bdnav = bd_open(m_path.toLatin1().data(), keyfilepath);
31 
32  return m_bdnav != nullptr;
33 }
34 
36 {
37  if (!OpenDisc() && !m_bdnav)
38  return false;
39 
40  const meta_dl *metadata = bd_get_meta(m_bdnav);
41 
42  if (metadata)
43  {
44  m_title = QString(metadata->di_name);
45  m_alttitle = QString(metadata->di_alternative);
46  m_language = QString(metadata->language_code);
47  m_discnumber = metadata->di_set_number;
48  m_disctotal = metadata->di_num_sets;
49 
50  for (unsigned i = 0; i < metadata->toc_count; i++)
51  {
52  uint num = metadata->toc_entries[i].title_number;
53  QString title = QString(metadata->toc_entries[i].title_name);
54  QPair<uint,QString> ret(num,title);
55  m_titles.append(ret);
56  }
57 
58  for (unsigned i = 0; i < metadata->thumb_count; i++)
59  {
60  QString filepath = QString("%1/BDMV/META/DL/%2")
61  .arg(m_path, metadata->thumbnails[i].path);
62  m_images.append(filepath);
63  }
64  }
65 
66  const BLURAY_DISC_INFO *discinfo = bd_get_disc_info(m_bdnav);
67  if (discinfo)
68  {
69  m_topMenuSupported = (discinfo->top_menu_supported != 0U);
70  m_firstPlaySupported = (discinfo->first_play_supported != 0U);
71  m_numHDMVTitles = discinfo->num_hdmv_titles;
72  m_numBDJTitles = discinfo->num_bdj_titles;
73  m_numUnsupportedTitles = discinfo->num_unsupported_titles;
74  m_aacsDetected = (discinfo->aacs_detected != 0U);
75  m_libaacsDetected = (discinfo->libaacs_detected != 0U);
76  m_aacsHandled = (discinfo->aacs_handled != 0U);
77  m_bdplusDetected = (discinfo->bdplus_detected != 0U);
78  m_libbdplusDetected = (discinfo->libbdplus_detected != 0U);
79  m_bdplusHandled = (discinfo->bdplus_handled != 0U);
80  }
81 
82  return true;
83 }
84 
85 void BlurayMetadata::toMap(InfoMap &metadataMap)
86 {
87  metadataMap["title"] = m_title;
88  metadataMap["alttitle"] = m_alttitle;
89  metadataMap["language"] = m_language;
90 
91  metadataMap["discnumber"] = QString::number(m_discnumber);
92  metadataMap["disctotal"] = QString::number(m_disctotal);
93 
94  //: %1 and %2 are both numbers, %1 is the current position, %2 the maximum
95  metadataMap["discseries"] = QCoreApplication::translate("(Common)",
96  "%1 of %2")
97  .arg(m_discnumber)
98  .arg(m_disctotal);
99 
100  metadataMap["numtitles"] = QString::number(m_titles.count());
101  metadataMap["numthumbs"] = QString::number(m_images.count());
102 }
BlurayMetadata::m_aacsHandled
bool m_aacsHandled
Definition: bluraymetadata.h:90
BlurayMetadata::m_bdplusDetected
bool m_bdplusDetected
Definition: bluraymetadata.h:91
BlurayMetadata::m_libbdplusDetected
bool m_libbdplusDetected
Definition: bluraymetadata.h:92
BlurayMetadata::m_libaacsDetected
bool m_libaacsDetected
Definition: bluraymetadata.h:89
BlurayMetadata::m_alttitle
QString m_alttitle
Definition: bluraymetadata.h:72
mythdirs.h
BlurayMetadata::m_disctotal
uint m_disctotal
Definition: bluraymetadata.h:76
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
BlurayMetadata::m_language
QString m_language
Definition: bluraymetadata.h:73
BlurayMetadata::m_numUnsupportedTitles
uint32_t m_numUnsupportedTitles
Definition: bluraymetadata.h:87
BlurayMetadata::IsOpen
bool IsOpen()
Definition: bluraymetadata.h:37
BlurayMetadata::m_bdnav
BLURAY * m_bdnav
Definition: bluraymetadata.h:69
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:256
BlurayMetadata::toMap
void toMap(InfoMap &metadataMap)
Definition: bluraymetadata.cpp:85
BlurayMetadata::ParseDisc
bool ParseDisc(void)
Definition: bluraymetadata.cpp:35
BlurayMetadata::m_numBDJTitles
uint32_t m_numBDJTitles
Definition: bluraymetadata.h:86
uint
unsigned int uint
Definition: compat.h:81
BlurayMetadata::m_images
QStringList m_images
Definition: bluraymetadata.h:81
BlurayMetadata::m_path
QString m_path
Definition: bluraymetadata.h:78
BlurayMetadata::m_aacsDetected
bool m_aacsDetected
Definition: bluraymetadata.h:88
BlurayMetadata::m_firstPlaySupported
bool m_firstPlaySupported
Definition: bluraymetadata.h:84
BlurayMetadata::m_bdplusHandled
bool m_bdplusHandled
Definition: bluraymetadata.h:93
BlurayMetadata::m_title
QString m_title
Definition: bluraymetadata.h:71
BlurayMetadata::m_discnumber
uint m_discnumber
Definition: bluraymetadata.h:75
bluraymetadata.h
BlurayMetadata::~BlurayMetadata
~BlurayMetadata() override
Definition: bluraymetadata.cpp:15
BlurayMetadata::m_titles
BlurayTitles m_titles
Definition: bluraymetadata.h:80
BlurayMetadata::OpenDisc
bool OpenDisc(void)
Definition: bluraymetadata.cpp:21
BlurayMetadata::m_numHDMVTitles
uint32_t m_numHDMVTitles
Definition: bluraymetadata.h:85
BlurayMetadata::m_topMenuSupported
bool m_topMenuSupported
Definition: bluraymetadata.h:83