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_AMLPLAYER)
28 #include "cores/amlplayer/AMLPlayer.h"
30 #if defined(HAS_OMXPLAYER)
31 #include "cores/omxplayer/OMXPlayer.h"
33 #include "cores/ExternalPlayer/ExternalPlayer.h"
35 #include "network/upnp/UPnPPlayer.h"
37 #include "utils/log.h"
39 class CPlayerCoreConfig
41 friend class CPlayerCoreFactory;
44 CPlayerCoreConfig(CStdString name, const EPLAYERCORES eCore, const TiXmlElement* pConfig, const CStdString& id = "")
49 m_bPlaysAudio = false;
50 m_bPlaysVideo = false;
54 m_config = (TiXmlElement*)pConfig->Clone();
55 const char *szAudio = pConfig->Attribute("audio");
56 const char *szVideo = pConfig->Attribute("video");
57 m_bPlaysAudio = szAudio && stricmp(szAudio, "true") == 0;
58 m_bPlaysVideo = szVideo && stricmp(szVideo, "true") == 0;
64 CLog::Log(LOGDEBUG, "CPlayerCoreConfig::<ctor>: created player %s for core %d", m_name.c_str(), m_eCore);
67 virtual ~CPlayerCoreConfig()
69 SAFE_DELETE(m_config);
72 const CStdString& GetName() const
77 const CStdString& GetId() const
82 const EPLAYERCORES& GetType() const
87 IPlayer* CreatePlayer(IPlayerCallback& callback) const
93 // TODO: this hack needs removal until we have a better player selection
94 #if defined(HAS_OMXPLAYER)
96 pPlayer = new COMXPlayer(callback);
97 CLog::Log(LOGINFO, "Created player %s for core %d / OMXPlayer forced as DVDPlayer", "OMXPlayer", m_eCore);
100 pPlayer = new COMXPlayer(callback);
101 CLog::Log(LOGINFO, "Created player %s for core %d / OMXPlayer forced as PAPLayer", "OMXPlayer", m_eCore);
104 case EPC_DVDPLAYER: pPlayer = new CDVDPlayer(callback); break;
105 case EPC_PAPLAYER: pPlayer = new PAPlayer(callback); break;
107 case EPC_EXTPLAYER: pPlayer = new CExternalPlayer(callback); break;
108 #if defined(HAS_AMLPLAYER)
109 case EPC_AMLPLAYER: pPlayer = new CAMLPlayer(callback); break;
111 #if defined(HAS_OMXPLAYER)
112 case EPC_OMXPLAYER: pPlayer = new COMXPlayer(callback); break;
114 #if defined(HAS_UPNP)
115 case EPC_UPNPPLAYER: pPlayer = new UPNP::CUPnPPlayer(callback, m_id.c_str()); break;
117 default: return NULL;
120 if (pPlayer->Initialize(m_config))
126 SAFE_DELETE(pPlayer);
136 EPLAYERCORES m_eCore;
137 TiXmlElement* m_config;