[Windows] Remove redundant DirectSound error codes
[xbmc.git] / xbmc / video / VideoFileItemClassify.cpp
blobafeaafcb65c95b4630483e64b4aff3386a7c3aab
1 /*
2 * Copyright (C) 2005-2020 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 "video/VideoFileItemClassify.h"
11 #include "FileItem.h"
12 #include "ServiceBroker.h"
13 #include "URL.h"
14 #include "utils/FileExtensionProvider.h"
15 #include "utils/FileUtils.h"
16 #include "utils/StringUtils.h"
17 #include "utils/URIUtils.h"
18 #include "video/VideoInfoTag.h"
20 namespace KODI::VIDEO
23 bool IsBDFile(const CFileItem& item)
25 const std::string strFileName = URIUtils::GetFileName(item.GetDynPath());
26 return (StringUtils::EqualsNoCase(strFileName, "index.bdmv") ||
27 StringUtils::EqualsNoCase(strFileName, "MovieObject.bdmv") ||
28 StringUtils::EqualsNoCase(strFileName, "INDEX.BDM") ||
29 StringUtils::EqualsNoCase(strFileName, "MOVIEOBJ.BDM"));
32 bool IsDiscStub(const CFileItem& item)
34 if (IsVideoDb(item) && item.HasVideoInfoTag())
36 CFileItem dbItem(item.m_bIsFolder ? item.GetVideoInfoTag()->m_strPath
37 : item.GetVideoInfoTag()->m_strFileNameAndPath,
38 item.m_bIsFolder);
39 return IsDiscStub(dbItem);
42 return URIUtils::HasExtension(item.GetPath(),
43 CServiceBroker::GetFileExtensionProvider().GetDiscStubExtensions());
46 bool IsDVDFile(const CFileItem& item, bool bVobs /*= true*/, bool bIfos /*= true*/)
48 const std::string strFileName = URIUtils::GetFileName(item.GetDynPath());
49 if (bIfos)
51 if (StringUtils::EqualsNoCase(strFileName, "video_ts.ifo"))
52 return true;
53 if (StringUtils::StartsWithNoCase(strFileName, "vts_") &&
54 StringUtils::EndsWithNoCase(strFileName, "_0.ifo") && strFileName.length() == 12)
55 return true;
57 if (bVobs)
59 if (StringUtils::EqualsNoCase(strFileName, "video_ts.vob"))
60 return true;
61 if (StringUtils::StartsWithNoCase(strFileName, "vts_") &&
62 StringUtils::EndsWithNoCase(strFileName, ".vob"))
63 return true;
66 return false;
69 bool IsProtectedBlurayDisc(const CFileItem& item)
71 const std::string path = URIUtils::AddFileToFolder(item.GetPath(), "AACS", "Unit_Key_RO.inf");
72 return CFileUtils::Exists(path);
75 bool IsBlurayPlaylist(const CFileItem& item)
77 return StringUtils::EqualsNoCase(URIUtils::GetExtension(item.GetDynPath()), ".mpls");
80 bool IsSubtitle(const CFileItem& item)
82 return URIUtils::HasExtension(item.GetPath(),
83 CServiceBroker::GetFileExtensionProvider().GetSubtitleExtensions());
86 bool IsVideo(const CFileItem& item)
88 /* check preset mime type */
89 if (StringUtils::StartsWithNoCase(item.GetMimeType(), "video/"))
90 return true;
92 if (item.HasVideoInfoTag())
93 return true;
95 if (item.HasGameInfoTag())
96 return false;
98 if (item.HasMusicInfoTag())
99 return false;
101 if (item.HasPictureInfoTag())
102 return false;
104 // TV recordings are videos...
105 if (!item.m_bIsFolder && URIUtils::IsPVRTVRecordingFileOrFolder(item.GetPath()))
106 return true;
108 // ... all other PVR items are not.
109 if (item.IsPVR())
110 return false;
112 if (URIUtils::IsDVD(item.GetPath()))
113 return true;
115 std::string extension;
116 if (StringUtils::StartsWithNoCase(item.GetMimeType(), "application/"))
117 { /* check for some standard types */
118 extension = item.GetMimeType().substr(12);
119 if (StringUtils::EqualsNoCase(extension, "ogg") ||
120 StringUtils::EqualsNoCase(extension, "mp4") || StringUtils::EqualsNoCase(extension, "mxf"))
121 return true;
124 //! @todo If the file is a zip file, ask the game clients if any support this
125 // file before assuming it is video.
127 return URIUtils::HasExtension(item.GetPath(),
128 CServiceBroker::GetFileExtensionProvider().GetVideoExtensions());
131 bool IsVideoAssetFile(const CFileItem& item)
133 if (item.m_bIsFolder || !IsVideoDb(item))
134 return false;
136 // @todo maybe in the future look for prefix videodb://movies/videoversions in path instead
137 // @todo better encoding of video assets as path, they won't always be tied with movies.
138 return CURL(item.GetPath()).HasOption("videoversionid");
141 bool IsVideoDb(const CFileItem& item)
143 return URIUtils::IsVideoDb(item.GetPath());
146 bool IsVideoExtrasFolder(const CFileItem& item)
148 return item.m_bIsFolder &&
149 StringUtils::EqualsNoCase(URIUtils::GetFileOrFolderName(item.GetPath()), "extras");
152 } // namespace KODI::VIDEO