libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moDsGraph.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moDsGraph.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29 
30 *******************************************************************************/
31 
32 /*==============================================
33 
34 
35 Class: moDsGraph
36 
37 Description: DirectShow Device.
38 
39 Todo:
40 
41 Example:
42 
43 
44 ==============================================*/
45 
46 #ifndef __MO_DSGRAPH_H
47 #define __MO_DSGRAPH_H
48 
49 #include "moTypes.h"
50 
51 #ifdef MO_DIRECTSHOW
52 
53 #ifndef __STREAMS__
54 #include "streams.h"
55 #include "qedit.h"
56 #include "dvdmedia.h"
57 #endif
58 
59 #include "moVideoGraph.h"
60 
61 class LIBMOLDEO_API moDsFramework : public moVideoFramework {
62 
63  public:
64 
65  moDsFramework();
66  virtual ~moDsFramework();
67 
68  virtual moCaptureDevices* LoadCaptureDevices();
69  virtual moCaptureDevices* UpdateCaptureDevices();
70 
71  virtual bool CheckCaptureDevice( int i );
72 
73  //DirectX
74  bool ShowError( HRESULT hr );
75 
76  private:
77  ICreateDevEnum *m_pDevEnum;
78  IEnumMoniker *m_pEnum;
79 
80 };
81 
82 class LIBMOLDEO_API moDsSampleGrabberCB : public ISampleGrabberCB
83 {
84 private:
85  moBucketsPool *m_pBucketsPool;
86 
87 public:
88 
89  // These will get set by the main thread below. We need to
90  // know this in order to write out the bmp
91  long Width;
92  long Height;
93 
94  // Fake out any COM ref counting
95  //
96  STDMETHODIMP_(ULONG) AddRef() { return 2; }
97  STDMETHODIMP_(ULONG) Release() { return 1; }
98 
99  STDMETHODIMP SetBucketsPool( moBucketsPool *pBucketsPool ) {
100 
101  m_pBucketsPool = pBucketsPool;
102 
103  return 0;
104  }
105 
106  // Fake out any COM QI'ing
107  //
108  STDMETHODIMP QueryInterface(REFIID riid, void ** ppv)
109  {
110  CheckPointer(ppv,E_POINTER);
111 
112  if( riid == IID_ISampleGrabberCB || riid == IID_IUnknown )
113  {
114  *ppv =(void *) static_cast<ISampleGrabberCB*>( this );
115  return NOERROR;
116  }
117 
118  return E_NOINTERFACE;
119  }
120 
121 
122  // We don't implement this one
123  //
124  STDMETHODIMP SampleCB( double SampleTime, IMediaSample * pSample )
125  {
126  return 0;
127  }
128 
129 
130  // The sample grabber is calling us back on its deliver thread.
131  // This is NOT the main app thread!
132  //
133  STDMETHODIMP BufferCB( double SampleTime, BYTE * pBuffer, long BufferSize )
134  {
135  //
136  // Convert the buffer into a bitmap
137  //
138 
139  //Add el bucket!!!
140 
141  moBucket *pbucket=NULL;
142 
143  if(!m_pBucketsPool->IsFull()) {
144  pbucket = new moBucket();
145  if(pbucket!=NULL) {
146 
147  pbucket->SetBuffer( BufferSize,(MOubyte*)pBuffer );
148 
149  if(m_pBucketsPool->AddBucket( pbucket )) {
150 
151  //Width = 720;
152  //Height = 480;
153  }
154  }
155  }
156 
157  return 0;
158  }
159 };
160 
161 
162 class LIBMOLDEO_API moDsGraph : public moVideoGraph {
163 
164 public:
165 
166  moDsGraph();
167  virtual ~moDsGraph();
168 
169 //================================================
170 // INITIALIZATION AND FINALIZATION METHODS
171 //================================================
172  virtual bool InitGraph();
173  virtual bool FinishGraph();
174  bool BuildLiveGraph( moBucketsPool *pBucketsPool, moCaptureDevice p_capdev);
175 
176 //================================================
177 // FILTER METHODS CONSTRUCTION
178 //================================================
179  bool CreateFilterByName( moText p_name, IBaseFilter **ppF);
180  bool CreateCaptureDeviceByPath( moText p_Path, IBaseFilter **ppF );
181  bool SetCaptureDevice( moText deviceport , MOint idevice = 0);
182  bool BuildLiveDVGraph( moBucketsPool *pBucketsPool, MOint idevice = 0);
183  bool BuildLiveWebcamGraph( moBucketsPool *pBucketsPool, MOint idevice = 0);
184  bool BuildLiveVideoGraph( moText filename , moBucketsPool *pBucketsPool );
185  bool BuildLiveQTVideoGraph( moText filename , moBucketsPool *pBucketsPool );
186 
187 
188 
189 //================================================
190 // CONTROL METHODS
191 //================================================
192  void Play();
193  void Stop();
194  void Pause();
195  void Seek( MOuint frame );
196  bool IsRunning();
198  MObyte* GetFrameBuffer(MOlong *size);
199 
200 //================================================
201 // MISC METHODS
202 //================================================
203  bool ShowError( HRESULT hr );
204  void SetVideoFormat( AM_MEDIA_TYPE* mt );
205  IPin * GetInPin( IBaseFilter * pFilter, int nPin );
206  IPin * GetOutPin( IBaseFilter * pFilter, int nPin );
207  HRESULT GetPin( IBaseFilter * pFilter, PIN_DIRECTION dirrequired, int iNum, IPin **ppPin);
208  void CheckMediaType( IPin* p_Pin );
209  void ShowConfigureDialog(IBaseFilter *pFilter);
210 
211 
212 private:
213 
214  IGraphBuilder *m_pFilterGraph;
215  IMediaControl *m_pMediaControl;
216  IMediaSeeking *m_pMediaSeeking;
217 
218 //========================
219 // PREFERRED FILTERS:
220 //========================
221  IBaseFilter *m_pQuicktimeFilter;
222  IBaseFilter *m_pQuicktimeDecoder;
223  IBaseFilter *m_pColorSpaceConverter;
224  IBaseFilter *m_pCaptureFilter;
225  IBaseFilter *m_pSourceFilter;
226  IBaseFilter *m_pDVDecoderFilter;
227  IBaseFilter *m_pAVIDecompressorFilter;
228  IBaseFilter *m_pSampleGrabberBase;
229  IBaseFilter *m_pNullRenderer;
230  IBaseFilter *m_pAviSplitter;
231  IBaseFilter *m_pSplitter;
232  IBaseFilter *m_pFfdshowFilter;
233 
234 //========================
235 // INTERFACES TO FILTERS:
236 //========================
237  ISampleGrabber *m_pSampleGrabber;
238  moDsSampleGrabberCB m_CB;
239  IFileSourceFilter *m_pFileSourceFilter;
240 
241  moDsFramework* m_pDsFramework;
242  moCaptureDevice m_CaptureDevice;
243 
244 };
245 
246 #endif
247 
248 #endif
virtual bool CheckCaptureDevice(int i)=0
Chequea si el dispositivos de video disponible está aún disponible.
#define MOulong
Definition: moTypes.h:392
Plataforma de reproducción de video, actualmente GStreamer para todas las plataformas.
Definition: moVideoGraph.h:496
virtual bool IsRunning()=0
Está corriendo.
#define MObyte
Definition: moTypes.h:400
#define LIBMOLDEO_API
Definition: moTypes.h:180
virtual bool FinishGraph()=0
Finalización del grafo.
clase de para manejar textos
Definition: moText.h:75
#define MOlong
Definition: moTypes.h:391
Grafo de reproducción de video.
Definition: moVideoGraph.h:584
virtual bool BuildLiveGraph(moBucketsPool *pBucketsPool, moCaptureDevice p_capdev)=0
Grafo de captura de video.
virtual MOulong GetFramesLength()=0
La cantidad de frames, el largo del stream.
#define MOint
Definition: moTypes.h:388
virtual bool BuildLiveVideoGraph(moText filename, moBucketsPool *pBucketsPool)=0
Grafo de reproducción de video en modo vivo, asyncronicamente reproducido en función del clock...
Administrador de moBucket 's.
Definition: moBuckets.h:152
virtual moCaptureDevices * LoadCaptureDevices()=0
Carga los dispositivos de video disponibles.
virtual void Stop()=0
Detener la reproducción del video.
virtual void Play()=0
Reproducir el video.
virtual bool BuildLiveQTVideoGraph(moText filename, moBucketsPool *pBucketsPool)=0
Definición de un dispositivo de video, generalmente uno de captura de video, o camara.
Definition: moVideoGraph.h:336
Espacio en memoria para compartir datos entre objetos.
Definition: moBuckets.h:53
#define MOuint
Definition: moTypes.h:387
virtual bool InitGraph()=0
Inicialización del grafo.
void SetBuffer(MOlong size, MOubyte *pbuf)
Crea un espacio de memoria y asigna los valores desde un puntero a otro espacio de memoria...
Definition: moBuckets.cpp:87
virtual MObyte * GetFrameBuffer(MOlong *size)=0
Puntero al frame buffer.
virtual void Seek(MOuint frame, float rate=1.0)=0
Busca y posiciona.
#define MOubyte
Definition: moTypes.h:399
bool AddBucket(moBucket *pBucket)
Definition: moBuckets.cpp:149
virtual void Pause()=0
Pausa la reproducción del video.
virtual moCaptureDevices * UpdateCaptureDevices()=0
Actualiza los dispositivos de video disponibles.