libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo es el conjunto de objetos y funciones, que permiten ejecutar las operaciones básicas de la plataforma Moldeo, y que compone su núcleo.
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Amigas 'defines' Grupos Páginas
moGsGraph.h
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moGsGraph.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 Class: moGsGraph
35 
36 Description: DirectShow Device.
37 
38 Todo:
39 
40 Example:
41 
42 
43 ==============================================*/
44 
45 #include "moConfig.h"
46 #include "moTypes.h"
47 
48 #include "moThread.h"
49 #include "moBuckets.h"
50 
51 #include "moVideoGraph.h"
52 
53 #ifndef __MO_GSGRAPH_H
54 #define __MO_GSGRAPH_H
55 
56 #ifndef MO_GSTREAMER
57 #define MO_GSTREAMER
58 #endif
59 #ifdef MO_GSTREAMER
60 
61 
62 typedef void moGstElement;
63 typedef void moGstPad;
64 typedef void moGstBus;
65 typedef void moGstBuffer;
66 typedef void moGstCaps;
67 typedef void moGstMessage;
68 typedef void* moGPointer;
69 typedef void* moGUserData;
70 typedef bool moGBoolean;
72 typedef void moGMainLoop;
73 typedef void moGMainContext;
74 typedef int moGstCallbackReturn;
75 typedef void moGstPadProbeInfo;
76 typedef void moGstAppSink;
77 typedef int moGstFlowReturn;
78 
79 
80 typedef enum {
95 
96 /***
97 All functions related to GStreamer Framework
98 
99  in Linux:
100 
101  use the dv1394src for DV
102  and the v4l2src for Webcams
103 
104  it's important to grant permission to device in linux running in terminal:
105  sudo chmod 666 raw1394
106 
107  in Windows:
108  dshowvideosrc is used from the dshowvideowrapper
109 
110 
111  To test gstreamer in linux run:
112  gst-launch -v -m v4l2src ! decodebin ! ffmpegcolorspace ! autovideosink
113 
114  To test gstreamer in windows run:
115  gst-launch -v -m dv1394src ! decodebin ! ffmpegcolorspace ! autovideosink
116 
117  ( tested with last gstreamer in linux: 0.10.20 )
118  ( tested with last gstreamer in windows: 0.10.10 from windows official vinaries and special wrapper dshowvideowrapper )
119 
120 */
122 
123  public:
124 
125  moGsFramework();
126  virtual ~moGsFramework();
127 
128  virtual moCaptureDevices* LoadCaptureDevices();
129  virtual moCaptureDevices* UpdateCaptureDevices();
130 
131  virtual bool CheckCaptureDevice( int i );
132  virtual bool AddCaptureDevice( moCaptureDevice& p_capdev );
133 
134 
135 
136  private:
137 
138  #ifdef MO_WIN32
139  //ICreateDevEnum *m_pDevEnum;
140  //IEnumMoniker *m_pEnum;
141  #endif
142 
143 };
144 
146 
152 
153 public:
154 
156  moGsGraph();
157 
159  virtual ~moGsGraph();
160 
161 //================================================
162 // INITIALIZATION AND FINALIZATION METHODS
163 //================================================
164  virtual bool InitGraph();
165  virtual bool FinishGraph();
166  bool BuildLiveGraph( moBucketsPool *pBucketsPool, moCaptureDevice p_capdev);
167 
168 //================================================
169 // FILTER METHODS CONSTRUCTION
170 //================================================
171  bool SetCaptureDevice( moText deviceport , MOint idevice = 0);
172  bool BuildLiveDVGraph( moBucketsPool *pBucketsPool, moCaptureDevice &p_capdev );
173  bool BuildLiveWebcamGraph( moBucketsPool *pBucketsPool, moCaptureDevice &p_capdev );
174  bool BuildLiveVideoGraph( moText filename , moBucketsPool *pBucketsPool );
175  bool BuildLiveQTVideoGraph( moText filename , moBucketsPool *pBucketsPool );
176 
177  bool BuildLiveSound( moText filename );
178 
179  bool BuildLiveStreamingGraph( moBucketsPool *pBucketsPool, moText p_location );
180  bool BuildRecordGraph( moText filename, moBucketsPool* pBucketsPool);
181 
182  virtual moStreamState GetState();
183 //================================================
184 // CONTROL METHODS
185 //================================================
186  void Play();
187  void Stop();
188  void Pause();
189  void Seek( MOuint frame, float rate = 1.0 );
190  bool IsRunning();
192  MOulong GetSamplesLength();
194  MObyte* GetFrameBuffer(MOlong *size);
195  virtual MOulong GetDuration();
196  virtual MOulong GetPosition();
197  virtual MOulong GetPositionMS();
199 //================================================
200 // MISC METHODS
201 //================================================
205  void SetVolume( float volume );
206  void SetBalance( float balance );
207 
208  void SetPitch( float pitch );
209  void SetEchoDelay( float delay );
210  void SetEchoIntensity( float intensity );
211  void SetEchoFeedback( float feedback );
212 
214  void SetBrightness( float brightness );
215  void SetContrast( float contrast );
216  void SetSaturation( float saturation );
217  void SetHue( float hue );
218 
219  void BuildAudioFilters();
220 
221  void SetVideoFormat( moGstCaps* caps, moGstBuffer* buffer = NULL );
222  void SetAudioFormat( moGstCaps* caps, moGstBuffer* buffer = NULL );
223  /*
224  bool ShowError( HRESULT hr );
225  void SetVideoFormat( AM_MEDIA_TYPE* mt );
226  IPin * GetInPin( IBaseFilter * pFilter, int nPin );
227  IPin * GetOutPin( IBaseFilter * pFilter, int nPin );
228  HRESULT GetPin( IBaseFilter * pFilter, PIN_DIRECTION dirrequired, int iNum, IPin **ppPin);
229  void CheckMediaType( IPin* p_Pin );
230  void ShowConfigureDialog(IBaseFilter *pFilter);
231  */
232  /*static moGBoolean bus_call (moGstBus *bus,
233  moGstMessage *msg,
234  moGPointer user_data);
235  */
236 #ifndef GSTVERSION
237  static moGBoolean cb_have_data (moGstPad *pad,
238  moGstBuffer *buffer,
239  moGPointer u_data);
240 #else
241  static moGstCallbackReturn cb_have_data (moGstPad *pad,
242  moGstPadProbeInfo *info,
243  moGPointer u_data);
244 #endif
245 
246  static moGBoolean cb_buffer_disconnected (
247  moGPointer u_data
248  );
249 
251 
252  static void on_rtsppadd_added( moGstElement *rtspsrc,
253  moGstPad *pad,
254  moGPointer u_data );
256 
257 #ifndef GSTVERSION
258  static void cb_newpad ( moGstElement *decodebin,
259  moGstPad *pad,
260  moGBoolean last,
261  moGPointer u_data);
262 #else
263  static void cb_pad_added_new ( moGstElement *decodebin,
264  moGstPad *pad,
265  moGPointer u_data);
266 
267  static moGstFlowReturn appsink_new_sample( moGstAppSink* appsink, moGPointer user_data );
268  static moGstFlowReturn appsink_new_preroll( moGstAppSink* appsink, moGPointer user_data );
269  static void appsink_eos( moGstAppSink* appsink, moGPointer user_data );
270 
271 #endif
272 
273  static void cb_pad_added ( moGstElement *decodebin2,
274  moGstPad *pad,
275  moGPointer u_data);
276 
279 #ifndef GSTVERSION
280  static void cb_handoff ( moGstElement *fakesrc,
281  moGstBuffer *buffer,
282  moGstPad *pad,
283  moGPointer user_data);
284 #endif
286 
287  bool CheckState( moGstStateChangeReturn state_change_result, bool waitforsync = false);
288  void RetreivePads( moGstElement* FilterElement);
289  void WaitForFormatDefinition( MOulong timeout );
290 
291  void CopyVideoFrame( void* bufferdst, int size );
292  virtual bool IsEOS();
293  virtual void SetEOS(bool iseos);
294 
295 private:
296 
297 
298  moBucketsPool *m_pBucketsPool;
299 
300  moGsFramework* m_pGsFramework;
301 
302  moCaptureDevice m_CaptureDevice;
303 
305  moGstElement *m_pGstPipeline;
308  moGstElement *m_pFileSource;
309  moGstElement *m_pRTSPSource;
310  moGstElement *m_pRTSPDepay;
311  moGstElement *m_pHTTPSource;
312  moGstElement *m_pMultipartDemux;
313  moGstElement *m_pJpegDecode;
314  moGstElement *m_pFinalSource;
315  moGstElement *m_pColorSpace;
316  moGstElement *m_pCapsFilter;
317  moGstElement *m_pTypeFind;
318  moGstElement *m_pIdentity;
320  moGstElement *m_pVideoScale;
321  moGstElement *m_pVideoDeinterlace;
322  moGstElement *m_pVideoBalance;
323  moGstElement *m_pColorSpaceInterlace;
325  moGstElement *m_pDecoderBin;
326  moGstElement *m_pFakeSink;
327  moGstElement *m_pVideoTestSrc;
329  moGstElement *m_pFakeSource;
330  moGstElement *m_pEncoder;
331  moGstElement *m_pMultiplexer;
332  moGstElement *m_pFileSink;
334  moGstElement *m_pAudioSink;
337  moGstElement *m_pAudioConverter;
338  moGstElement *m_pAudioConverter2;
339  moGstElement *m_pAudioConverter3;
340  moGstElement *m_pAudioConverter4;
342  moGstElement *m_pAudioPanorama;
344  moGstElement *m_pAudioEcho;
346  moGstElement *m_pAudioSpeed;
348  moGstElement *m_pAudioVolume;
350  moGstElement *m_pAudioAmplify;
351 
352  //GstElement *m_pAudioConverter;
353 
355  moGstPad *m_pVideoPad;
356  moGstPad *m_pAudioPad;
359  moGstPad *m_pRTSPDepaySink;
360  moGstPad *m_pRTSPSrcVideo;
361  moGstPad *m_pRTSPSrcAudio;
362 
364  moGstBus *m_pGstBus;
366  moGMainLoop *m_pGMainLoop;
367  moGMainContext *m_pGMainContext;
368 
369  MOulong m_Duration;
370  MOulong m_FramesLength;
371  MOulong m_SamplesLength;
372 
373  bool m_bEOS;
374 
375 
376 };
377 
378 #endif
379 
380 #endif
bool moGBoolean
Definition: moGsGraph.h:70
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
void moGstAppSink
Definition: moGsGraph.h:76
void moGMainLoop
Definition: moGsGraph.h:72
virtual bool IsRunning()=0
Está corriendo.
virtual void SetEOS(bool iseos)=0
void * moGPointer
Definition: moGsGraph.h:68
long signal_handoff_id
Definition: moGsGraph.h:285
#define MObyte
Definition: moTypes.h:400
int moGstStateChangeReturn
Definition: moGsGraph.h:71
virtual bool AddCaptureDevice(moCaptureDevice &p_capdev)=0
Agrega un dispositivo de video.
int moGstFlowReturn
Definition: moGsGraph.h:77
#define LIBMOLDEO_API
Definition: moTypes.h:180
virtual void SetVolume(float volume)=0
Fija el nivel de volumen.
virtual bool FinishGraph()=0
Finalización del grafo.
clase de para manejar textos
Definition: moText.h:75
void moGstMessage
Definition: moGsGraph.h:67
#define MOlong
Definition: moTypes.h:391
virtual MOulong GetPosition()=0
La posición del stream en cuadros.
Grafo de reproducción de video.
Definition: moVideoGraph.h:584
void * moGUserData
Definition: moGsGraph.h:69
void moGstBuffer
Definition: moGsGraph.h:65
moTypes MOint moText moParamIndex moParamReference int iRow int int i int i
Definition: all_f.js:18
void moGstPadProbeInfo
Definition: moGsGraph.h:75
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.
moStreamState
Definition: moVideoGraph.h:140
void moGstElement
Definition: moGsGraph.h:62
virtual moStreamState GetState()
Estado de la reproducción.
GStreamer Graph Class.
Definition: moGsGraph.h:151
virtual void SetSaturation(float saturation)=0
virtual bool BuildRecordGraph(moText filename, moBucketsPool *pBucketsPool)=0
Grafo de grabación.
#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...
void moGMainContext
Definition: moGsGraph.h:73
GstVideoTestSrcPattern
Definition: moGsGraph.h:80
void moGstBus
Definition: moGsGraph.h:64
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.
void moGstCaps
Definition: moGsGraph.h:66
virtual void SetContrast(float contrast)=0
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
virtual void SetHue(float hue)=0
fn[c] delay
Definition: jquery.js:71
void moGstPad
Definition: moGsGraph.h:63
int moGstCallbackReturn
Definition: moGsGraph.h:74
virtual bool IsEOS()=0
#define MOuint
Definition: moTypes.h:387
virtual bool InitGraph()=0
Inicialización del grafo.
virtual void SetBrightness(float brightness)=0
virtual void SetBalance(float balance)=0
Fija el balance entre canal izquierdo y derecho en caso de haberlos.
virtual MObyte * GetFrameBuffer(MOlong *size)=0
Puntero al frame buffer.
virtual void Seek(MOuint frame, float rate=1.0)=0
Busca y posiciona.
long m_BusWatchId
Definition: moGsGraph.h:278
long cb_have_data_handler_id
Definition: moGsGraph.h:250
virtual void Pause()=0
Pausa la reproducción del video.
long signal_newpad_id
Definition: moGsGraph.h:277
long signal_rtsppad_added_id
Definition: moGsGraph.h:255
virtual moCaptureDevices * UpdateCaptureDevices()=0
Actualiza los dispositivos de video disponibles.
virtual MOulong GetDuration()=0
La duración total del stream en nanosegundos.