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