[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / xbmc / video / VideoGeneratedImageFileLoader.cpp
blob416a710136c36f03acbd0d9c6cc7a893a879d7d8
1 /*
2 * Copyright (C) 2023 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 "VideoGeneratedImageFileLoader.h"
11 #include "DVDFileInfo.h"
12 #include "FileItem.h"
13 #include "ServiceBroker.h"
14 #include "URL.h"
15 #include "filesystem/DirectoryCache.h"
16 #include "guilib/Texture.h"
17 #include "imagefiles/ImageFileURL.h"
18 #include "settings/Settings.h"
19 #include "settings/SettingsComponent.h"
20 #include "utils/URIUtils.h"
21 #include "video/VideoFileItemClassify.h"
22 #include "video/VideoInfoTag.h"
24 #include <charconv>
26 namespace KODI::VIDEO
29 bool CVideoGeneratedImageFileLoader::CanLoad(const std::string& specialType) const
31 return specialType == "video";
34 namespace
36 void SetupRarOptions(CFileItem& item, const std::string& path)
38 std::string path2(path);
39 if (IsVideoDb(item) && item.HasVideoInfoTag())
40 path2 = item.GetVideoInfoTag()->m_strFileNameAndPath;
41 CURL url(path2);
42 std::string opts = url.GetOptions();
43 if (opts.find("flags") != std::string::npos)
44 return;
45 if (opts.size())
46 opts += "&flags=8";
47 else
48 opts = "?flags=8";
49 url.SetOptions(opts);
50 if (IsVideoDb(item) && item.HasVideoInfoTag())
51 item.GetVideoInfoTag()->m_strFileNameAndPath = url.Get();
52 else
53 item.SetPath(url.Get());
54 g_directoryCache.ClearDirectory(url.GetWithoutFilename());
56 } // namespace
58 std::unique_ptr<CTexture> CVideoGeneratedImageFileLoader::Load(
59 const IMAGE_FILES::CImageFileURL& imageFile) const
61 if (!CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
62 CSettings::SETTING_MYVIDEOS_EXTRACTTHUMB))
64 return {};
67 const std::string& filePath = imageFile.GetTargetFile();
68 CFileItem item{filePath, false};
70 if (URIUtils::IsInRAR(filePath))
71 SetupRarOptions(item, filePath);
73 std::string chapterOption = imageFile.GetOption("chapter");
74 int chapter = 0;
75 std::from_chars(chapterOption.data(), chapterOption.data() + chapterOption.size(), chapter);
77 return CDVDFileInfo::ExtractThumbToTexture(item, chapter);
80 } // namespace KODI::VIDEO