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.
9 #include "DiscsUtils.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"
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"
21 bool UTILS::DISCS::GetDiscInfo(UTILS::DISCS::DiscInfo
& info
, const std::string
& mediaPath
)
23 // try to probe as a DVD
24 info
= ProbeDVDDiscInfo(mediaPath
);
28 // try to probe as Blu-ray
29 info
= ProbeBlurayDiscInfo(mediaPath
);
36 UTILS::DISCS::DiscInfo
UTILS::DISCS::ProbeDVDDiscInfo(const std::string
& mediaPath
)
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();
55 UTILS::DISCS::DiscInfo
UTILS::DISCS::ProbeBlurayDiscInfo(const std::string
& mediaPath
)
59 XFILE::CBlurayDirectory bdDir
;
60 if (!bdDir
.InitializeBluray(mediaPath
))
63 info
.type
= DiscType::BLURAY
;
64 info
.name
= bdDir
.GetBlurayTitle();
65 info
.serial
= bdDir
.GetBlurayID();