| 1 |
/* |
| 2 |
* Copyright (C) 2005-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "settings/lib/ISettingsHandler.h" |
| 12 |
#include "threads/CriticalSection.h" |
| 13 |
|
| 14 |
#include <list> |
| 15 |
#include <memory> |
| 16 |
#include <string> |
| 17 |
#include <vector> |
| 18 |
|
| 19 |
// forward references |
| 20 |
|
| 21 |
class TiXmlElement; |
| 22 |
class CFileItem; |
| 23 |
class CPlayerCoreConfig; |
| 24 |
class CPlayerSelectionRule; |
| 25 |
class CProfileManager; |
| 26 |
class CSettings; |
| 27 |
class IPlayer; |
| 28 |
class IPlayerCallback; |
| 29 |
|
| 30 |
class CPlayerCoreFactory : public ISettingsHandler |
| 31 |
{ |
| 32 |
public: |
| 33 |
CPlayerCoreFactory(const CProfileManager &profileManager); |
| 34 |
CPlayerCoreFactory(const CPlayerCoreFactory&) = delete; |
| 35 |
CPlayerCoreFactory& operator=(CPlayerCoreFactory const&) = delete; |
| 36 |
~CPlayerCoreFactory() override; |
| 37 |
|
| 38 |
void OnSettingsLoaded() override; |
| 39 |
|
| 40 |
std::shared_ptr<IPlayer> CreatePlayer(const std::string& nameId, IPlayerCallback& callback) const; |
| 41 |
void GetPlayers(const CFileItem& item, std::vector<std::string>&players) const; //Players supporting the specified file |
| 42 |
void GetPlayers(std::vector<std::string>&players, bool audio, bool video) const; //All audio players and/or video players |
| 43 |
void GetPlayers(std::vector<std::string>&players) const; //All players |
| 44 |
void GetPlayers(std::vector<std::string>&players, std::string &type) const; |
| 45 |
void GetRemotePlayers(std::vector<std::string>&players) const; //All remote players we can attach to |
| 46 |
std::string GetPlayerType(const std::string &player) const; |
| 47 |
bool IsExternalPlayer(const std::string& player) const; |
| 48 |
bool IsRemotePlayer(const std::string& player) const; |
| 49 |
bool PlaysAudio(const std::string &player) const; |
| 50 |
bool PlaysVideo(const std::string &player) const; |
| 51 |
|
| 52 |
std::string GetDefaultPlayer(const CFileItem& item) const; |
| 53 |
std::string SelectPlayerDialog(const std::vector<std::string>&players, float posX = 0, float posY = 0) const; |
| 54 |
std::string SelectPlayerDialog(float posX, float posY) const; |
| 55 |
void OnPlayerDiscovered(const std::string& id, const std::string& name); |
| 56 |
void OnPlayerRemoved(const std::string& id); |
| 57 |
|
| 58 |
private: |
| 59 |
// Construction parameters |
| 60 |
std::shared_ptr<CSettings> m_settings; |
| 61 |
const CProfileManager &m_profileManager; |
| 62 |
|
| 63 |
int GetPlayerIndex(const std::string& strCoreName) const; |
| 64 |
std::string GetPlayerName(size_t idx) const; |
| 65 |
|
| 66 |
bool LoadConfiguration(const std::string &file, bool clear); |
| 67 |
|
| 68 |
std::vector<std::unique_ptr<CPlayerCoreConfig>> m_vecPlayerConfigs; |
| 69 |
std::list<std::unique_ptr<CPlayerSelectionRule>> m_vecCoreSelectionRules; |
| 70 |
mutable CCriticalSection m_section; |
| 71 |
}; |