2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 %module(directors="1") xbmc
25 #include "interfaces/legacy/Player.h"
26 #include "interfaces/legacy/RenderCapture.h"
27 #include "interfaces/legacy/Keyboard.h"
28 #include "interfaces/legacy/ModuleXbmc.h"
29 #include "interfaces/legacy/Monitor.h"
31 using namespace XBMCAddon;
34 #if defined(__GNUG__) && (__GNUC__>4) || (__GNUC__==4 && __GNUC_MINOR__>=2)
35 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
39 // This is all about warning suppression. It's OK that these base classes are
40 // not part of what swig parses.
41 %feature("knownbasetypes") XBMCAddon::xbmc "AddonClass,IPlayerCallback,AddonCallback"
42 %feature("knownapitypes") XBMCAddon::xbmc "XBMCAddon::xbmcgui::ListItem,XBMCAddon::xbmc::PlayListItem"
44 %include "interfaces/legacy/swighelper.h"
46 %feature("python:coerceToUnicode") XBMCAddon::xbmc::getLocalizedString "true"
48 %include "interfaces/legacy/ModuleXbmc.h"
50 %feature("director") Player;
52 %feature("python:method:play") Player
55 PyObject *pObject = NULL;
56 PyObject *pObjectListItem = NULL;
57 char bWindowed = false;
58 static const char *keywords[] = { "item", "listitem", "windowed", NULL };
60 if (!PyArg_ParseTupleAndKeywords(
74 Player* player = ((Player*)retrieveApiInstance((PyObject*)self,&PyXBMCAddon_xbmc_Player_Type,"play","XBMCAddon::xbmc::Player"));
76 // set fullscreen or windowed
77 bool windowed = (0 != bWindowed);
80 player->playCurrent(windowed);
81 else if ((PyString_Check(pObject) || PyUnicode_Check(pObject)))
84 PyXBMCGetUnicodeString(item,pObject,"item","Player::play");
85 XBMCAddon::xbmcgui::ListItem* pListItem =
87 (XBMCAddon::xbmcgui::ListItem *)retrieveApiInstance(pObjectListItem,"p.XBMCAddon::xbmcgui::ListItem","XBMCAddon::xbmc::","play") :
89 player->playStream(item,pListItem,windowed);
91 else // pObject must be a playlist
92 player->playPlaylist((PlayList *)retrieveApiInstance(pObject,"p.XBMCAddon::xbmc::PlayList","XBMCAddon::xbmc::","play"), windowed);
94 catch (const XbmcCommons::Exception& e)
96 CLog::Log(LOGERROR,"Leaving Python method 'XBMCAddon_xbmc_Player_play'. Exception from call to 'play' '%s' ... returning NULL", e.GetMessage());
97 PyErr_SetString(PyExc_RuntimeError, e.GetMessage());
102 CLog::Log(LOGERROR,"Unknown exception thrown from the call 'play'");
103 PyErr_SetString(PyExc_RuntimeError, "Unknown exception thrown from the call 'play'");
111 %feature("python:nokwds") XBMCAddon::xbmc::Keyboard::Keyboard "true"
112 %feature("python:nokwds") XBMCAddon::xbmc::Player::Player "true"
113 %feature("python:nokwds") XBMCAddon::xbmc::PlayList::PlayList "true"
115 %include "interfaces/legacy/Player.h"
117 // TODO: This needs to be done with a class that holds the Image
118 // data. A memory buffer type. Then a typemap needs to be defined
120 %feature("python:method:getImage") RenderCapture
122 RenderCapture* rc = ((RenderCapture*)retrieveApiInstance((PyObject*)self,&PyXBMCAddon_xbmc_RenderCapture_Type,"getImage","XBMCAddon::xbmc::RenderCapture"));
123 if (rc->GetUserState() != CAPTURESTATE_DONE)
125 PyErr_SetString(PyExc_SystemError, "illegal user state");
129 Py_ssize_t size = rc->getWidth() * rc->getHeight() * 4;
130 return PyByteArray_FromStringAndSize((const char *)rc->GetPixels(), size);
133 %include "interfaces/legacy/RenderCapture.h"
135 %include "interfaces/legacy/InfoTagMusic.h"
136 %include "interfaces/legacy/InfoTagVideo.h"
137 %include "interfaces/legacy/Keyboard.h"
138 %include "interfaces/legacy/PlayList.h"
140 %feature("director") Monitor;
142 %include "interfaces/legacy/Monitor.h"