[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / utils / DiscsUtils.cpp
blob87d06a3326872b3aafe2dd07ecf83bf9d5e67c18
1 /*
2 * Copyright (C) 2022 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "DiscsUtils.h"
11 #include "FileItem.h"
12 //! @todo it's wrong to include videoplayer scoped files, refactor
13 // dvd inputstream so they can be used by other components. Or just use libdvdnav directly.
14 #include "cores/VideoPlayer/DVDInputStreams/DVDInputStreamNavigator.h"
15 #ifdef HAVE_LIBBLURAY
16 //! @todo it's wrong to include vfs scoped files in a utils class, refactor
17 // to use libbluray directly.
18 #include "filesystem/BlurayDirectory.h"
19 #endif
21 bool UTILS::DISCS::GetDiscInfo(UTILS::DISCS::DiscInfo& info, const std::string& mediaPath)
23 // try to probe as a DVD
24 info = ProbeDVDDiscInfo(mediaPath);
25 if (!info.empty())
26 return true;
28 // try to probe as Blu-ray
29 info = ProbeBlurayDiscInfo(mediaPath);
30 if (!info.empty())
31 return true;
33 return false;
36 UTILS::DISCS::DiscInfo UTILS::DISCS::ProbeDVDDiscInfo(const std::string& mediaPath)
38 DiscInfo info;
39 CFileItem item{mediaPath, false};
40 CDVDInputStreamNavigator dvdNavigator{nullptr, item};
41 if (dvdNavigator.Open())
43 info.type = DiscType::DVD;
44 info.name = dvdNavigator.GetDVDTitleString();
45 // fallback to DVD volume id
46 if (info.name.empty())
48 info.name = dvdNavigator.GetDVDVolIdString();
50 info.serial = dvdNavigator.GetDVDSerialString();
52 return info;
55 UTILS::DISCS::DiscInfo UTILS::DISCS::ProbeBlurayDiscInfo(const std::string& mediaPath)
57 DiscInfo info;
58 #ifdef HAVE_LIBBLURAY
59 XFILE::CBlurayDirectory bdDir;
60 if (!bdDir.InitializeBluray(mediaPath))
61 return info;
63 info.type = DiscType::BLURAY;
64 info.name = bdDir.GetBlurayTitle();
65 info.serial = bdDir.GetBlurayID();
66 #endif
67 return info;