[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / xbmc / playlists / PlayListFactory.cpp
blob7fe5ff6fcb9fad4e3fb06819a2354c740af13075
1 /*
2 * Copyright (C) 2005-2018 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 "PlayListFactory.h"
11 #include "FileItem.h"
12 #include "network/NetworkFileItemClassify.h"
13 #include "playlists/PlayListASX.h"
14 #include "playlists/PlayListB4S.h"
15 #include "playlists/PlayListM3U.h"
16 #include "playlists/PlayListPLS.h"
17 #include "playlists/PlayListRAM.h"
18 #include "playlists/PlayListURL.h"
19 #include "playlists/PlayListWPL.h"
20 #include "playlists/PlayListXML.h"
21 #include "playlists/PlayListXSPF.h"
22 #include "utils/StringUtils.h"
23 #include "utils/URIUtils.h"
25 namespace KODI::PLAYLIST
28 CPlayList* CPlayListFactory::Create(const std::string& filename)
30 CFileItem item(filename,false);
31 return Create(item);
34 CPlayList* CPlayListFactory::Create(const CFileItem& item)
36 if (NETWORK::IsInternetStream(item))
38 // Ensure the MIME type has been retrieved for http:// and shout:// streams
39 if (item.GetMimeType().empty())
40 const_cast<CFileItem&>(item).FillInMimeType();
42 std::string strMimeType = item.GetMimeType();
43 StringUtils::ToLower(strMimeType);
45 if (strMimeType == "video/x-ms-asf"
46 || strMimeType == "video/x-ms-asx"
47 || strMimeType == "video/x-ms-wmv"
48 || strMimeType == "video/x-ms-wma"
49 || strMimeType == "video/x-ms-wfs"
50 || strMimeType == "video/x-ms-wvx"
51 || strMimeType == "video/x-ms-wax")
52 return new CPlayListASX();
54 if (strMimeType == "audio/x-pn-realaudio")
55 return new CPlayListRAM();
57 if (strMimeType == "audio/x-scpls"
58 || strMimeType == "playlist"
59 || strMimeType == "text/html")
60 return new CPlayListPLS();
62 // online m3u8 files are for hls streaming -- do not treat as playlist
63 if (strMimeType == "audio/x-mpegurl" && !item.IsType(".m3u8"))
64 return new CPlayListM3U();
66 if (strMimeType == "application/vnd.ms-wpl")
67 return new CPlayListWPL();
69 if (strMimeType == "application/xspf+xml")
70 return new CPlayListXSPF();
73 std::string path = item.GetDynPath();
75 std::string extension = URIUtils::GetExtension(path);
76 StringUtils::ToLower(extension);
78 if (extension == ".m3u" || (extension == ".m3u8" && !NETWORK::IsInternetStream(item)) ||
79 extension == ".strm")
80 return new CPlayListM3U();
82 if (extension == ".pls")
83 return new CPlayListPLS();
85 if (extension == ".b4s")
86 return new CPlayListB4S();
88 if (extension == ".wpl")
89 return new CPlayListWPL();
91 if (extension == ".asx")
92 return new CPlayListASX();
94 if (extension == ".ram")
95 return new CPlayListRAM();
97 if (extension == ".url")
98 return new CPlayListURL();
100 if (extension == ".pxml")
101 return new CPlayListXML();
103 if (extension == ".xspf")
104 return new CPlayListXSPF();
106 return NULL;
110 bool CPlayListFactory::IsPlaylist(const CFileItem& item)
112 std::string strMimeType = item.GetMimeType();
113 StringUtils::ToLower(strMimeType);
115 /* These are a bit uncertain
116 if(strMimeType == "video/x-ms-asf"
117 || strMimeType == "video/x-ms-asx"
118 || strMimeType == "video/x-ms-wmv"
119 || strMimeType == "video/x-ms-wma"
120 || strMimeType == "video/x-ms-wfs"
121 || strMimeType == "video/x-ms-wvx"
122 || strMimeType == "video/x-ms-wax"
123 || strMimeType == "video/x-ms-asf")
124 return true;
127 // online m3u8 files are hls:// -- do not treat as playlist
128 if (NETWORK::IsInternetStream(item) && item.IsType(".m3u8"))
129 return false;
131 if(strMimeType == "audio/x-pn-realaudio"
132 || strMimeType == "playlist"
133 || strMimeType == "audio/x-mpegurl")
134 return true;
136 return IsPlaylist(item.GetDynPath());
139 bool CPlayListFactory::IsPlaylist(const CURL& url)
141 return URIUtils::HasExtension(url,
142 ".m3u|.m3u8|.b4s|.pls|.strm|.wpl|.asx|.ram|.url|.pxml|.xspf");
145 bool CPlayListFactory::IsPlaylist(const std::string& filename)
147 return URIUtils::HasExtension(filename,
148 ".m3u|.m3u8|.b4s|.pls|.strm|.wpl|.asx|.ram|.url|.pxml|.xspf");
151 } // namespace KODI::PLAYLIST