Ginga  0.13.6
 All Classes Namespaces Functions Variables
FormatterMultiDevice.h
1 /******************************************************************************
2 Este arquivo eh parte da implementacao do ambiente declarativo do middleware
3 Ginga (Ginga-NCL).
4 
5 Direitos Autorais Reservados (c) 1989-2007 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: 1989-2007 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 _FormatterMultiDevice_H_
51 #define _FormatterMultiDevice_H_
52 
53 #include "config.h"
54 
55 #include "mb/ILocalScreenManager.h"
56 #include "mb/interface/IInputEventListener.h"
57 using namespace ::br::pucrio::telemidia::ginga::core::mb;
58 
59 #if HAVE_MULTIDEVICE
60 #include "multidevice/services/IDeviceDomain.h"
61 #include "multidevice/IRemoteDeviceManager.h"
62 #include "multidevice/IRemoteDeviceListener.h"
63 using namespace ::br::pucrio::telemidia::ginga::core::multidevice;
64 #else
66  public:
67  //CT: class types
68  static const int CT_BASE = 0;
69  static const int CT_PASSIVE = 1;
70  static const int CT_ACTIVE = 2;
71 
72  //FT: frame types
73  static const int FT_CONNECTIONREQUEST = 0;
74  static const int FT_ANSWERTOREQUEST = 1;
75  static const int FT_KEEPALIVE = 2;
76  static const int FT_MEDIACONTENT = 3;
77  static const int FT_SELECTIONEVENT = 4;
78  static const int FT_ATTRIBUTIONEVENT = 5;
79  static const int FT_PRESENTATIONEVENT = 6;
80 };
81 #endif //HAVE_MULTIDEVICE
82 
83 #include "ncl/layout/LayoutRegion.h"
84 using namespace ::br::pucrio::telemidia::ncl::layout;
85 
86 #include "ncl/components/Content.h"
87 #include "ncl/components/NodeEntity.h"
88 #include "ncl/components/ReferenceContent.h"
89 using namespace ::br::pucrio::telemidia::ncl::components;
90 
91 #include "gingancl/model/CascadingDescriptor.h"
92 using namespace ::br::pucrio::telemidia::ginga::ncl::model::presentation;
93 
94 #include "gingancl/model/ExecutionObject.h"
95 using namespace ::br::pucrio::telemidia::ginga::ncl::model::components;
96 
97 #include "gingancl/model/FormatterLayout.h"
98 using namespace ::br::pucrio::telemidia::ginga::ncl::model::presentation;
99 
100 #include "gingancl/adaptation/context/ContextBase.h"
101 
102 #include "IFormatterMultiDevice.h"
103 
104 #include <pthread.h>
105 
106 #include <map>
107 using namespace std;
108 
109 namespace br {
110 namespace pucrio {
111 namespace telemidia {
112 namespace ginga {
113 namespace ncl {
114 namespace multidevice {
115 #if HAVE_MULTIDEVICE
116  class FormatterMultiDevice :
117  public IFormatterMultiDevice,
118  public IInputEventListener,
119  public IRemoteDeviceListener {
120 #else
121  class FormatterMultiDevice :
122  public IFormatterMultiDevice,
123  public IInputEventListener {
124 #endif //HAVE_MULTIDEVICE
125  protected:
126  static ILocalScreenManager* dm;
127  IInputManager* im;
128  pthread_mutex_t mutex;
129 
130 #if HAVE_MULTIDEVICE
131  static IRemoteDeviceManager* rdm;
132 #else
133  static void* rdm;
134 #endif //HAVE_MULTIDEVICE
135 
136  IDeviceLayout* deviceLayout;
137  map<int, FormatterLayout*> layoutManager;
138  vector<string>* activeUris;
139  string activeBaseUri;
140  FormatterLayout* mainLayout;
141  IWindow* serialized;
142  IWindow* printScreen;
143  IWindow* bitMapScreen;
144  int xOffset;
145  int yOffset;
146  int defaultWidth;
147  int defaultHeight;
148  int deviceClass;
149  bool hasRemoteDevices;
150  bool enableMulticast;
151  IPresentationContext* presContext;
152  IFormatterFocusManager* focusManager;
153  FormatterMultiDevice* parent;
154  GingaScreenID myScreen;
155 
156  set<IPlayer*> listening;
157  pthread_mutex_t lMutex;
158 
159  static const int DV_QVGA_WIDTH = 480;
160  static const int DV_QVGA_HEIGHT = 320;
161 
162  public:
164  GingaScreenID screenId,
165  IDeviceLayout* deviceLayout,
166  int x, int y, int w, int h,
167  bool useMulticast, int srvPort);
168 
169  virtual ~FormatterMultiDevice();
170 
171  void printGingaWindows();
172  void listenPlayer(IPlayer* player);
173  void stopListenPlayer(IPlayer* player);
174  void setParent(IFormatterMultiDevice* parent);
175  void setPresentationContex(IPresentationContext* presContext);
176  void setFocusManager(IFormatterFocusManager* focusManager);
177  void setBackgroundImage(string uri);
178  void* getMainLayout();
179  void* getFormatterLayout(int devClass);
180  string getScreenShot();
181  string serializeScreen(int devClass, IWindow* mapWindow);
182 
183  protected:
184  virtual void postMediaContent(int destDevClass);
185 
186  public:
187  FormatterLayout* getFormatterLayout(
188  CascadingDescriptor* descriptor, ExecutionObject* object);
189 
190  GingaWindowID prepareFormatterRegion(
191  ExecutionObject* object, ISurface* renderedSurface);
192 
193  void showObject(ExecutionObject* executionObject);
194  void hideObject(ExecutionObject* executionObject);
195 
196  protected:
197  virtual bool newDeviceConnected(int newDevClass, int w, int h);
198  virtual void connectedToBaseDevice(unsigned int domainAddr)=0;
199 
200  virtual bool receiveRemoteEvent(
201  int remoteDevClass,
202  int eventType,
203  string eventContent);
204 
205  virtual bool receiveRemoteContent(
206  int remoteDevClass,
207  char *stream, int streamSize) {
208 
209  return false;
210  };
211 
212  virtual bool receiveRemoteContentInfo(
213  string contentId, string contentUri) {
214 
215  return false;
216  };
217 
218  void renderFromUri(IWindow* win, string uri);
219  void tapObject(int devClass, int x, int y);
220 
221  virtual bool receiveRemoteContent(
222  int remoteDevClass,
223  string contentUri) {
224 
225  return false;
226  };
227 
228  public:
229  void addActiveUris(string baseUri, vector<string>* uris);
230  virtual void updatePassiveDevices();
231 
232  protected:
233  void updateStatus(
234  short code, string parameter, short type, string value);
235 
236  virtual bool userEventReceived(IInputEvent* ev)=0;
237  };
238 }
239 }
240 }
241 }
242 }
243 }
244 
245 #endif /* _FormatterMultiDevice_H_ */
Definition: FormatterMultiDevice.h:65
HAVE_MULTIDEVICE.
Definition: FormatterMultiDevice.h:121