Ginga  0.13.6
 All Classes Namespaces Functions Variables
AVPlayer.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 AVPLAYER_H_
51 #define AVPLAYER_H_
52 
53 #include "mb/IMBDefs.h"
54 
55 #include "system/compat/SystemCompat.h"
56 using namespace ::br::pucrio::telemidia::ginga::core::system::compat;
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61  #include <pthread.h>
62  #include <string.h>
63  #include <stdio.h>
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #ifdef STx7100
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72  #include "audio_hal.h"
73  #include "video_hal.h"
74 #ifdef __cplusplus
75 }
76 #endif
77 #endif
78 
79 #ifdef GEODE
80 #include "GeodeVideo4Linux.h"
81 #endif
82 
83 #include "system/thread/Thread.h"
84 using namespace ::br::pucrio::telemidia::ginga::core::system::thread;
85 
86 #ifdef IPROVIDERLISTENER
87 #undef IPROVIDERLISTENER
88 #endif
89 
90 #include "mb/interface/IContinuousMediaProvider.h"
91 #include "mb/interface/IWindow.h"
92 #include "mb/interface/IProviderListener.h"
93 using namespace ::br::pucrio::telemidia::ginga::core::mb;
94 
95 #include "Player.h"
96 #include "PlayersComponentSupport.h"
97 
98 #if HAVE_ICRTP
99 #include "RTPListener.h"
100 #endif
101 
102 #include <vector>
103 #include <iostream>
104 using namespace std;
105 
106 namespace br {
107 namespace pucrio {
108 namespace telemidia {
109 namespace ginga {
110 namespace core {
111 namespace player {
112  class AVPlayer :
113  public Thread,
114  public Player,
115  public IProviderListener {
116 
117  private:
118  pthread_mutex_t pMutex; //provider mutex
119  pthread_mutex_t tMutex; //AV player thread mutex
120 
121 #if HAVE_ICRTP
122  RTPListener* icListener;
123 #endif
124 
125  protected:
126  bool running;
127  bool buffered;
128  bool hasVisual;
129  float soundLevel;
130 
131  private:
132  string pSym;
133  IContinuousMediaProvider* provider;
134  bool hasResized;
135  bool mainAV;
136  bool isRemote;
137  bool hasData;
138  IWindow* win;
139 
140  public:
141  AVPlayer(GingaScreenID screenId, string mrl, bool hasVisual);
142 
143 #ifdef STx7100
144  private:
145  video_t *video;
146  audio_t *audio;
147 
148  public:
149  AVPlayer(GingaScreenID screenId, video_t *video);
150  AVPlayer(GingaScreenID screenId, audio_t *audio);
151 #endif
152 
153  virtual ~AVPlayer();
154 
155  ISurface* getSurface();
156 
157  private:
158  void createProvider();
159  static void* createProviderT(void* ptr);
160 
161  public:
162  void finished();
163  double getEndTime();
164 
165  private:
166  void solveRemoteMrl();
167 
168  public:
169  static void initializeAudio(int numArgs, char* args[]);
170  static void releaseAudio();
171  bool getHasVisual();
172 
173  private:
174  void setSoundLevel(float level);
175  ISurface* createFrame();
176 
177  public:
178  void getOriginalResolution(int* width, int* height);
179  double getTotalMediaTime();
180  int64_t getVPts();
181  void timeShift(string direction);
182 
183  private:
184  double getCurrentMediaTime();
185 
186  public:
187  double getMediaTime();
188  void setMediaTime(double pos);
189  void setStopTime(double pos);
190  double getStopTime();
191  void setScope(
192  string scope,
193  short type=TYPE_PRESENTATION,
194  double begin=-1, double end=-1, double outTransDur=-1);
195 
196  bool play();
197  void pause();
198  void stop();
199  void resume();
200 
201  virtual void setPropertyValue(string name, string value);
202 
203  void addListener(IPlayerListener* listener);
204  void release();
205  void setMrl(const char* mrl);
206  string getMrl();
207  bool isPlaying();
208  bool isRunning();
209 
210  void setAVPid(int aPid, int vPid);
211 
212  //geode:
213  bool setOutWindow(GingaWindowID windowId);
214  void setAlphaBlend(int x, int y, int w, int h);
215  void checkResize();
216 
217  private:
218  bool checkVideoResizeEvent();
219  void run();
220  };
221 }
222 }
223 }
224 }
225 }
226 }
227 
228 #endif /*AVPLAYER_H_*/