[droid] add new internal player for amlogic based SoCs
[vuplus_xbmc] / xbmc / cores / playercorefactory / PlayerCoreConfig.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2008 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, write to
18  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19  *  http://www.gnu.org/copyleft/gpl.html
20  *
21  */
22
23 #include "utils/XBMCTinyXML.h"
24 #include "cores/IPlayer.h"
25 #include "PlayerCoreFactory.h"
26 #include "cores/dvdplayer/DVDPlayer.h"
27 #include "cores/paplayer/PAPlayer.h"
28 #if defined(HAS_AMLPLAYER)
29 #include "cores/amlplayer/AMLPlayer.h"
30 #endif
31 #include "cores/ExternalPlayer/ExternalPlayer.h"
32 #include "utils/log.h"
33
34 class CPlayerCoreConfig
35 {
36 friend class CPlayerCoreFactory;
37
38 public:
39   CPlayerCoreConfig(CStdString name, const EPLAYERCORES eCore, const TiXmlElement* pConfig)
40   {
41     m_name = name;
42     m_eCore = eCore;
43     m_bPlaysAudio = false;
44     m_bPlaysVideo = false;
45
46     if (pConfig)
47     {
48       m_config = (TiXmlElement*)pConfig->Clone();
49       const char *szAudio = pConfig->Attribute("audio");
50       const char *szVideo = pConfig->Attribute("video");
51       m_bPlaysAudio = szAudio && stricmp(szAudio, "true") == 0;
52       m_bPlaysVideo = szVideo && stricmp(szVideo, "true") == 0;
53     }
54     else
55     {
56       m_config = NULL;
57     }
58     CLog::Log(LOGDEBUG, "CPlayerCoreConfig::<ctor>: created player %s for core %d", m_name.c_str(), m_eCore);
59   }
60
61   virtual ~CPlayerCoreConfig()
62   {
63     SAFE_DELETE(m_config);
64   }
65
66   const CStdString& GetName() const
67   {
68     return m_name;
69   }
70
71   IPlayer* CreatePlayer(IPlayerCallback& callback) const
72   {
73     IPlayer* pPlayer;
74     switch(m_eCore)
75     {
76       case EPC_MPLAYER:
77       case EPC_DVDPLAYER: pPlayer = new CDVDPlayer(callback); break;
78       case EPC_PAPLAYER: pPlayer = new PAPlayer(callback); break;
79       case EPC_EXTPLAYER: pPlayer = new CExternalPlayer(callback); break;
80 #if defined(HAS_AMLPLAYER)
81       case EPC_AMLPLAYER: pPlayer = new CAMLPlayer(callback); break;
82 #endif
83       default: return NULL;
84     }
85
86     if (pPlayer->Initialize(m_config))
87     {
88       return pPlayer;
89     }
90     else
91     {
92       SAFE_DELETE(pPlayer);
93       return NULL;
94     }
95   }
96
97 private:
98   CStdString m_name;
99   bool m_bPlaysAudio;
100   bool m_bPlaysVideo;
101   EPLAYERCORES m_eCore;
102   TiXmlElement* m_config;
103 };