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 }
BlurayMetadata::m_aacsHandled
bool m_aacsHandled
Definition: bluraymetadata.h:86
BlurayMetadata::m_bdplusDetected
bool m_bdplusDetected
Definition: bluraymetadata.h:87
BlurayMetadata::m_libbdplusDetected
bool m_libbdplusDetected
Definition: bluraymetadata.h:88
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:636
BlurayMetadata::m_libaacsDetected
bool m_libaacsDetected
Definition: bluraymetadata.h:85
BlurayMetadata::m_alttitle
QString m_alttitle
Definition: bluraymetadata.h:68
mythdirs.h
BlurayMetadata::m_disctotal
uint m_disctotal
Definition: bluraymetadata.h:72
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
BlurayMetadata::m_language
QString m_language
Definition: bluraymetadata.h:69
BlurayMetadata::m_numUnsupportedTitles
uint32_t m_numUnsupportedTitles
Definition: bluraymetadata.h:83
BlurayMetadata::IsOpen
bool IsOpen()
Definition: bluraymetadata.h:33
BlurayMetadata::m_bdnav
BLURAY * m_bdnav
Definition: bluraymetadata.h:65
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
BlurayMetadata::toMap
void toMap(InfoMap &metadataMap)
Definition: bluraymetadata.cpp:87
BlurayMetadata::ParseDisc
bool ParseDisc(void)
Definition: bluraymetadata.cpp:36
BlurayMetadata::m_numBDJTitles
uint32_t m_numBDJTitles
Definition: bluraymetadata.h:82
uint
unsigned int uint
Definition: compat.h:140
BlurayMetadata::m_images
QStringList m_images
Definition: bluraymetadata.h:77
BlurayMetadata::m_path
QString m_path
Definition: bluraymetadata.h:74
BlurayMetadata::m_aacsDetected
bool m_aacsDetected
Definition: bluraymetadata.h:84
BlurayMetadata::m_firstPlaySupported
bool m_firstPlaySupported
Definition: bluraymetadata.h:80
BlurayMetadata::m_bdplusHandled
bool m_bdplusHandled
Definition: bluraymetadata.h:89
BlurayMetadata::m_title
QString m_title
Definition: bluraymetadata.h:67
BlurayMetadata::m_discnumber
uint m_discnumber
Definition: bluraymetadata.h:71
bluraymetadata.h
BlurayMetadata::~BlurayMetadata
~BlurayMetadata() override
Definition: bluraymetadata.cpp:16
BlurayMetadata::m_titles
BlurayTitles m_titles
Definition: bluraymetadata.h:76
BlurayMetadata::OpenDisc
bool OpenDisc(void)
Definition: bluraymetadata.cpp:22
BlurayMetadata::m_numHDMVTitles
uint32_t m_numHDMVTitles
Definition: bluraymetadata.h:81
BlurayMetadata::m_topMenuSupported
bool m_topMenuSupported
Definition: bluraymetadata.h:79