Ginga  0.13.6
 All Classes Namespaces Functions Variables
LuaPlayer.h
1 /******************************************************************************
2 Este arquivo eh parte da implementacao do ambiente declarativo do middleware
3 Ginga (Ginga-NCL).
4 
5 Direitos Autorais Reservados (c) 2006-2012 PUC-Rio/Laboratorio TeleMidia
6 
7 Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob
8 os termos da Licenca Publica Geral GNU versao 2 conforme publicada pela Free
9 Software Foundation.
10 
11 Este programa eh distribuido na expectativa de que seja util, porem, SEM
12 NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU
13 ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do
14 GNU versao 2 para mais detalhes.
15 
16 Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto
17 com este programa; se nao, escreva para a Free Software Foundation, Inc., no
18 endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
19 
20 Para maiores informacoes:
21 ncl @ telemidia.puc-rio.br
22 http://www.ncl.org.br
23 http://www.ginga.org.br
24 http://www.telemidia.puc-rio.br
25 ******************************************************************************
26 This file is part of the declarative environment of middleware Ginga (Ginga-NCL)
27 
28 Copyright: 2006-2012 PUC-RIO/LABORATORIO TELEMIDIA, All Rights Reserved.
29 
30 This program is free software; you can redistribute it and/or modify it under
31 the terms of the GNU General Public License version 2 as published by
32 the Free Software Foundation.
33 
34 This program is distributed in the hope that it will be useful, but WITHOUT ANY
35 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
36 PARTICULAR PURPOSE. See the GNU General Public License version 2 for more
37 details.
38 
39 You should have received a copy of the GNU General Public License version 2
40 along with this program; if not, write to the Free Software
41 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
42 
43 For further information contact:
44 ncl @ telemidia.puc-rio.br
45 http://www.ncl.org.br
46 http://www.ginga.org.br
47 http://www.telemidia.puc-rio.br
48 *******************************************************************************/
49 
50 #ifndef LUAPLAYER_H
51 #define LUAPLAYER_H
52 
53 #include <list>
54 #include <string>
55 
56 #include <ncluaw.h>
57 #include <pthread.h>
58 
59 using namespace std;
60 
61 #include "Player.h"
62 #include "util/functions.h"
63 #include "mb/interface/IWindow.h"
64 #include "mb/interface/IFontProvider.h"
65 #include "mb/IInputManager.h"
66 using namespace::br::pucrio::telemidia::ginga::core::mb;
67 
68 #include "system/compat/SystemCompat.h"
69 using namespace::br::pucrio::telemidia::ginga::core::system::compat;
70 
71 #define LUAPLAYER_BEGIN_DECLS NAMESPACE_GINGA_CORE_PLAYER_BEGIN
72 #define LUAPLAYER_END_DECLS NAMESPACE_GINGA_CORE_PLAYER_END
73 
74 LUAPLAYER_BEGIN_DECLS
75 
76 class LuaPlayer : public Player, public IInputEventListener
77 {
78 private:
79 
80  ncluaw_t *nw; // the NCLua state
81  bool hasExecuted; // true if script was executed
82  bool isKeyHandler; // true if player has the focus
83  string scope; // the label of the active anchor
84  pthread_mutex_t mutex; // sync access to player
85  IInputManager *im;
86 
87  // Update thread.
88  static list <LuaPlayer *> *nw_update_list;
89  static pthread_mutex_t nw_update_mutex;
90  static pthread_t nw_update_tid;
91  static void *nw_update_thread (void *data);
92  static void nw_update_insert (LuaPlayer *player);
93 
94 public:
95  static void nw_update_remove (LuaPlayer *player);
96 
97 public:
98  LuaPlayer (GingaScreenID screenId, string mrl);
99  virtual ~LuaPlayer (void);
100 
101  // TODO: Make private.
102  void lock (void);
103  void unlock (void);
104  bool doPlay (void);
105  void doStop (void);
106 
107  // Player interface.
108  void abort (void);
109  void pause (void);
110  bool play (void);
111  void resume (void);
112  void stop (void);
113  virtual bool hasPresented (void);
114  void setCurrentScope (string scopeId);
115  bool setKeyHandler (bool isHandler);
116  virtual void setPropertyValue (string name, string value);
117 
118  // Input event callback.
119  bool userEventReceived (IInputEvent * evt);
120 
121  // Required by LuaCanvas.cpp.
122  GingaScreenID getScreenId (void);
123  ILocalScreenManager *getScreenManager (void);
124  void refreshContent (void);
125 };
126 
127 LUAPLAYER_END_DECLS
128 
129 #endif // LUAPLAYER_H
130 
131 // Local variables:
132 // mode: c++
133 // c-file-style: "k&r"
134 // End:
Definition: LuaPlayer.h:76