droid: remove legacy amlplayer
[vuplus_xbmc] / xbmc / cores / playercorefactory / PlayerCoreConfig.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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/>.
19  *
20  */
21
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"
29 #endif
30 #include "cores/ExternalPlayer/ExternalPlayer.h"
31 #ifdef HAS_UPNP
32 #include "network/upnp/UPnPPlayer.h"
33 #endif
34 #include "utils/log.h"
35
36 class CPlayerCoreConfig
37 {
38 friend class CPlayerCoreFactory;
39
40 public:
41   CPlayerCoreConfig(CStdString name, const EPLAYERCORES eCore, const TiXmlElement* pConfig, const CStdString& id = "")
42   {
43     m_name = name;
44     m_id = id;
45     m_eCore = eCore;
46     m_bPlaysAudio = false;
47     m_bPlaysVideo = false;
48
49     if (pConfig)
50     {
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;
56     }
57     else
58     {
59       m_config = NULL;
60     }
61     CLog::Log(LOGDEBUG, "CPlayerCoreConfig::<ctor>: created player %s for core %d", m_name.c_str(), m_eCore);
62   }
63
64   virtual ~CPlayerCoreConfig()
65   {
66     SAFE_DELETE(m_config);
67   }
68
69   const CStdString& GetName() const
70   {
71     return m_name;
72   }
73
74   const CStdString& GetId() const
75   {
76     return m_id;
77   }
78
79   const EPLAYERCORES& GetType() const
80   {
81     return m_eCore;
82   }
83
84   IPlayer* CreatePlayer(IPlayerCallback& callback) const
85   {
86     IPlayer* pPlayer;
87     switch(m_eCore)
88     {
89       case EPC_MPLAYER:
90       // TODO: this hack needs removal until we have a better player selection
91 #if defined(HAS_OMXPLAYER)
92       case EPC_DVDPLAYER: 
93         pPlayer = new COMXPlayer(callback); 
94         CLog::Log(LOGINFO, "Created player %s for core %d / OMXPlayer forced as DVDPlayer", "OMXPlayer", m_eCore);
95         break;
96       case EPC_PAPLAYER: 
97         pPlayer = new COMXPlayer(callback); 
98         CLog::Log(LOGINFO, "Created player %s for core %d / OMXPlayer forced as PAPLayer", "OMXPlayer", m_eCore);
99         break;
100 #else
101       case EPC_DVDPLAYER: pPlayer = new CDVDPlayer(callback); break;
102       case EPC_PAPLAYER: pPlayer = new PAPlayer(callback); break;
103 #endif
104       case EPC_EXTPLAYER: pPlayer = new CExternalPlayer(callback); break;
105 #if defined(HAS_OMXPLAYER)
106       case EPC_OMXPLAYER: pPlayer = new COMXPlayer(callback); break;
107 #endif
108 #if defined(HAS_UPNP)
109       case EPC_UPNPPLAYER: pPlayer = new UPNP::CUPnPPlayer(callback, m_id.c_str()); break;
110 #endif
111       default: return NULL;
112     }
113
114     if (pPlayer->Initialize(m_config))
115     {
116       return pPlayer;
117     }
118     else
119     {
120       SAFE_DELETE(pPlayer);
121       return NULL;
122     }
123   }
124
125 private:
126   CStdString m_name;
127   CStdString m_id;
128   bool m_bPlaysAudio;
129   bool m_bPlaysVideo;
130   EPLAYERCORES m_eCore;
131   TiXmlElement* m_config;
132 };