Ginga  0.13.6
 All Classes Namespaces Functions Variables
Player.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 PLAYER_H_
51 #define PLAYER_H_
52 
53 #include "system/fs/IGingaLocatorFactory.h"
54 using namespace ::br::pucrio::telemidia::ginga::core::system::fs;
55 
56 #include "system/compat/SystemCompat.h"
57 using namespace ::br::pucrio::telemidia::ginga::core::system::compat;
58 
59 #include "system/thread/Thread.h"
60 using namespace ::br::pucrio::telemidia::ginga::core::system::thread;
61 
62 #include "mb/IInputManager.h"
63 #include "mb/ILocalScreenManager.h"
64 #include "mb/interface/IInputEventListener.h"
65 #include "mb/interface/CodeMap.h"
66 using namespace ::br::pucrio::telemidia::ginga::core::mb;
67 
68 #include "IPlayer.h"
69 
70 #include <pthread.h>
71 
72 #ifndef HAVE_CLOCKTIME
73 #define HAVE_CLOCKTIME 1
74 #endif
75 
76 #include <iostream>
77 #include <set>
78 #include <vector>
79 #include <map>
80 #include <string>
81 using namespace std;
82 
83 namespace br {
84 namespace pucrio {
85 namespace telemidia {
86 namespace ginga {
87 namespace core {
88 namespace player {
89  typedef struct LockedPlayerLitenerAction {
91  bool isAdd;
93 
94  typedef struct PendingNotification {
95  short code;
96  string parameter;
97  short type;
98  string value;
99  set<IPlayerListener*>* clone;
101 
102  class Player : public IPlayer {
103  private:
104  pthread_mutex_t listM;
105  pthread_mutex_t lockedListM;
106  pthread_mutex_t referM;
107  pthread_mutex_t pnMutex;
108 
109  bool notifying;
110 
111  map<string, string> properties;
112  set<IPlayerListener*> listeners;
113  vector<LockedPlayerListener*> lockedListeners;
114  vector<PendingNotification*> pendingNotifications;
115 
116  protected:
117  GingaScreenID myScreen;
118  short status;
119  static const short NONE = 0;
120  static const short PLAY = 1;
121  static const short PAUSE = 2;
122  static const short STOP = 3;
123 
124  string mrl;
125  static ILocalScreenManager* dm;
126  ISurface* surface;
127  IWindow* outputWindow;
128  double initTime, elapsedTime, elapsedPause, pauseTime;
129  set<IPlayer*> referredPlayers;
130  IPlayer* timeBasePlayer;
131  bool presented;
132  bool visible;
133  bool immediatelyStartVar;
134  bool forcedNaturalEnd;
135  bool notifyContentUpdate;
136  string scope;
137  short scopeType;
138  double scopeInitTime;
139  double scopeEndTime;
140  double outTransTime;
141 
142  public:
143  Player(GingaScreenID screenId, string mrl);
144  virtual ~Player();
145 
146  virtual void flip(){};
147  virtual void setMrl(string mrl, bool visible=true);
148  virtual void reset(){};
149  virtual void rebase(){};
150  //virtual void setStandByState(bool standBy){};
151  virtual void setNotifyContentUpdate(bool notify);
152  virtual void addListener(IPlayerListener* listener);
153  void removeListener(IPlayerListener* listener);
154 
155  private:
156  void performLockedListenersRequest();
157 
158  public:
159  void notifyPlayerListeners(
160  short code,
161  string parameter="",
162  short type=TYPE_PRESENTATION,
163  string value="");
164 
165  private:
166  static void* detachedNotifier(void* ptr);
167  static void ntsNotifyPlayerListeners(
168  set<IPlayerListener*>* list,
169  short code, string parameter, short type, string value);
170 
171  public:
172  virtual void setSurface(ISurface* surface);
173  virtual ISurface* getSurface();
174 
175  virtual void setMediaTime(double newTime);
176  virtual int64_t getVPts() {
177  clog << "Player::getVPts return 0" << endl;
178  return 0;
179  };
180 
181 #if HAVE_CLOCKTIME
182  double getMediaTime();
183 #else
184  virtual double getMediaTime();
185 #endif
186 
187  virtual double getTotalMediaTime();
188 
189  virtual bool setKeyHandler(bool isHandler);
190  virtual void setScope(
191  string scope,
192  short type=TYPE_PRESENTATION,
193  double begin=-1, double end=-1, double outTransDur=-1);
194 
195  virtual bool play();
196  virtual void stop();
197  virtual void abort();
198  virtual void pause();
199  virtual void resume();
200  virtual string getPropertyValue(string name);
201  virtual void setPropertyValue(string name, string value);
202 
203  virtual void setReferenceTimePlayer(IPlayer* player){};
204 
205  void addTimeReferPlayer(IPlayer* referPlayer);
206  void removeTimeReferPlayer(IPlayer* referPlayer);
207  void notifyReferPlayers(int transition);
208  void timebaseObjectTransitionCallback(int transition);
209  void setTimeBasePlayer(IPlayer* timeBasePlayer);
210  virtual bool hasPresented();
211  void setPresented(bool presented);
212  bool isVisible();
213  void setVisible(bool visible);
214  bool immediatelyStart();
215  void setImmediatelyStart(bool immediatelyStartVal);
216 
217  protected:
218  void checkScopeTime();
219 
220  private:
221  static void* scopeTimeHandler(void* ptr);
222 
223  public:
224  void forceNaturalEnd(bool forceIt);
225  bool isForcedNaturalEnd();
226  virtual bool setOutWindow(GingaWindowID windowId);
227 
228  /*Exclusive for ChannelPlayer*/
229  virtual IPlayer* getSelectedPlayer(){return NULL;};
230  virtual void setPlayerMap(map<string, IPlayer*>* objs){};
231  virtual map<string, IPlayer*>* getPlayerMap(){return NULL;};
232  virtual IPlayer* getPlayer(string objectId){return NULL;};
233  virtual void select(IPlayer* selObject){};
234 
235  /*Exclusive for Application Players*/
236  virtual void setCurrentScope(string scopeId){};
237 
238  virtual void timeShift(string direction){};
239  };
240 }
241 }
242 }
243 }
244 }
245 }
246 
247 using namespace ::br::pucrio::telemidia::ginga::core::player;
248 
249 struct notify {
250  IPlayerListener* listener;
251  short code;
252  string param;
253  short type;
254 };
255 
256 #endif /*PLAYER_H_*/
Definition: Player.h:249