3 * Copyright (C) 2005-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include "utils/XBMCTinyXML.h"
23 #include "cores/IPlayer.h"
24 #include "PlayerCoreFactory.h"
25 #include "cores/dvdplayer/DVDPlayer.h"
26 #include "cores/paplayer/PAPlayer.h"
27 #if defined(HAS_OMXPLAYER)
28 #include "cores/omxplayer/OMXPlayer.h"
30 #include "cores/ExternalPlayer/ExternalPlayer.h"
32 #include "network/upnp/UPnPPlayer.h"
34 #include "utils/log.h"
36 class CPlayerCoreConfig
38 friend class CPlayerCoreFactory;
41 CPlayerCoreConfig(CStdString name, const EPLAYERCORES eCore, const TiXmlElement* pConfig, const CStdString& id = "")
46 m_bPlaysAudio = false;
47 m_bPlaysVideo = false;
51 m_config = (TiXmlElement*)pConfig->Clone();
52 const char *szAudio = pConfig->Attribute("audio");
53 const char *szVideo = pConfig->Attribute("video");
54 m_bPlaysAudio = szAudio && stricmp(szAudio, "true") == 0;
55 m_bPlaysVideo = szVideo && stricmp(szVideo, "true") == 0;
61 CLog::Log(LOGDEBUG, "CPlayerCoreConfig::<ctor>: created player %s for core %d", m_name.c_str(), m_eCore);
64 virtual ~CPlayerCoreConfig()
66 SAFE_DELETE(m_config);
69 const CStdString& GetName() const
74 const CStdString& GetId() const
79 const EPLAYERCORES& GetType() const
84 IPlayer* CreatePlayer(IPlayerCallback& callback) const
90 // TODO: this hack needs removal until we have a better player selection
91 #if defined(HAS_OMXPLAYER)
93 pPlayer = new COMXPlayer(callback);
94 CLog::Log(LOGINFO, "Created player %s for core %d / OMXPlayer forced as DVDPlayer", "OMXPlayer", m_eCore);
97 pPlayer = new COMXPlayer(callback);
98 CLog::Log(LOGINFO, "Created player %s for core %d / OMXPlayer forced as PAPLayer", "OMXPlayer", m_eCore);
101 case EPC_DVDPLAYER: pPlayer = new CDVDPlayer(callback); break;
102 case EPC_PAPLAYER: pPlayer = new PAPlayer(callback); break;
104 case EPC_EXTPLAYER: pPlayer = new CExternalPlayer(callback); break;
105 #if defined(HAS_OMXPLAYER)
106 case EPC_OMXPLAYER: pPlayer = new COMXPlayer(callback); break;
108 #if defined(HAS_UPNP)
109 case EPC_UPNPPLAYER: pPlayer = new UPNP::CUPnPPlayer(callback, m_id.c_str()); break;
111 default: return NULL;
114 if (pPlayer->Initialize(m_config))
120 SAFE_DELETE(pPlayer);
130 EPLAYERCORES m_eCore;
131 TiXmlElement* m_config;