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.
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  moBucket m_Buckets[100];
296 
297 private:
298 
299 
301 
302 
304 
306 
355 
356  //GstElement *m_pAudioConverter;
357 
366 
372 
376 
377  bool m_bEOS;
378 
379 
380 };
381 
382 #endif
383 
384 #endif
moGstElement * m_pAudioConverter4
Definition: moGsGraph.h:344
bool moGBoolean
Definition: moGsGraph.h:70
moCaptureDevice m_CaptureDevice
Definition: moGsGraph.h:305
virtual bool CheckCaptureDevice(int i)=0
Chequea si el dispositivos de video disponible está aún disponible.
moGstElement * m_pAudioConverter
Definition: moGsGraph.h:341
#define MOulong
Definition: moTypes.h:392
moGstElement * m_pColorSpace
Definition: moGsGraph.h:318
moGstElement * m_pAudioVolume
volume: volume, 0 - 10 [1]
Definition: moGsGraph.h:352
moGstPad * m_pRTSPDepaySink
Definition: moGsGraph.h:363
moGstElement * m_pRTSPSource
Definition: moGsGraph.h:312
moGstElement * m_pAudioPanorama
stereo balance-1 a 1: panorama
Definition: moGsGraph.h:346
Plataforma de reproducción de video, actualmente GStreamer para todas las plataformas.
Definition: moVideoGraph.h:496
void moGstAppSink
Definition: moGsGraph.h:76
moGstElement * m_pAudioSink
Definition: moGsGraph.h:338
moGMainContext * m_pGMainContext
Definition: moGsGraph.h:371
moGstElement * m_pVideoDeinterlace
Definition: moGsGraph.h:325
void moGMainLoop
Definition: moGsGraph.h:72
moGstElement * m_pHTTPSource
Definition: moGsGraph.h:314
virtual bool IsRunning()=0
Está corriendo.
moGstPad * m_pAudioPad
Definition: moGsGraph.h:360
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
moGstPad * m_pVideoPad
Definition: moGsGraph.h:359
moGstElement * m_pAudioConverter3
Definition: moGsGraph.h:343
virtual bool AddCaptureDevice(moCaptureDevice &p_capdev)=0
Agrega un dispositivo de video.
int moGstFlowReturn
Definition: moGsGraph.h:77
bool m_bEOS
Definition: moGsGraph.h:377
MOulong m_FramesLength
Definition: moGsGraph.h:374
#define LIBMOLDEO_API
Definition: moTypes.h:180
virtual void SetVolume(float volume)=0
Fija el nivel de volumen.
moGstElement * m_pMultiplexer
Definition: moGsGraph.h:335
virtual bool FinishGraph()=0
Finalización del grafo.
clase de para manejar textos
Definition: moText.h:75
moGstElement * m_pEncoder
Definition: moGsGraph.h:334
void moGstMessage
Definition: moGsGraph.h:67
#define MOlong
Definition: moTypes.h:391
MOulong m_SamplesLength
Definition: moGsGraph.h:375
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
void moGstPadProbeInfo
Definition: moGsGraph.h:75
moGstElement * m_pAudioEcho
echo effect : audioecho > delay [ nanoseconds 10E-9, intensity, feedback ]
Definition: moGsGraph.h:348
moGstElement * m_pCapsFilter
Definition: moGsGraph.h:319
moGstElement * m_pAudioConverter2
Definition: moGsGraph.h:342
virtual bool BuildLiveGraph(moBucketsPool *pBucketsPool, moCaptureDevice p_capdev)=0
Grafo de captura de video.
moGstBus * m_pGstBus
Definition: moGsGraph.h:368
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
moGstElement * m_pFakeSink
Definition: moGsGraph.h:330
moGstElement * m_pVideoTestSrc
Definition: moGsGraph.h:331
moGstElement * m_pDecoderBin
Definition: moGsGraph.h:329
GstVideoTestSrcPattern
Definition: moGsGraph.h:80
void moGstBus
Definition: moGsGraph.h:64
Administrador de moBucket &#39;s.
Definition: moBuckets.h:152
moGstElement * m_pJpegDecode
Definition: moGsGraph.h:316
virtual moCaptureDevices * LoadCaptureDevices()=0
Carga los dispositivos de video disponibles.
moGstElement * m_pFileSink
Definition: moGsGraph.h:336
moGstElement * m_pVideoScale
Definition: moGsGraph.h:323
moGstPad * m_pRTSPSrcVideo
Definition: moGsGraph.h:364
virtual void Stop()=0
Detener la reproducción del video.
moBucketsPool * m_pBucketsPool
Definition: moGsGraph.h:300
moGstElement * m_pFinalSource
Definition: moGsGraph.h:317
moGstElement * m_pAudioAmplify
audioamplify: amplification: -inf +inf (dangerous)
Definition: moGsGraph.h:354
moGsFramework * m_pGsFramework
Definition: moGsGraph.h:303
moGstElement * m_pAudioSpeed
speed:pitch speed 0.1 - 40.0
Definition: moGsGraph.h:350
virtual void Play()=0
Reproducir el video.
void moGstCaps
Definition: moGsGraph.h:66
moGstElement * m_pVideoFlip
Definition: moGsGraph.h:324
virtual void SetContrast(float contrast)=0
virtual bool BuildLiveQTVideoGraph(moText filename, moBucketsPool *pBucketsPool)=0
moGstElement * m_pVideoBalance
Definition: moGsGraph.h:326
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
Espacio en memoria para compartir datos entre objetos.
Definition: moBuckets.h:53
MOulong m_Duration
Definition: moGsGraph.h:373
moGMainLoop * m_pGMainLoop
Definition: moGsGraph.h:370
moGstElement * m_pTypeFind
Definition: moGsGraph.h:320
void moGstPad
Definition: moGsGraph.h:63
moGstElement * m_pMultipartDemux
Definition: moGsGraph.h:315
int moGstCallbackReturn
Definition: moGsGraph.h:74
moGstElement * m_pGstPipeline
Definition: moGsGraph.h:308
virtual bool IsEOS()=0
#define MOuint
Definition: moTypes.h:387
moGstPad * m_pRTSPSrcAudio
Definition: moGsGraph.h:365
moGstElement * m_pColorSpaceInterlace
Definition: moGsGraph.h:327
virtual bool InitGraph()=0
Inicialización del grafo.
virtual void SetBrightness(float brightness)=0
moGstElement * m_pFakeSource
Definition: moGsGraph.h:333
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
moGstElement * m_pFileSource
Definition: moGsGraph.h:311
moGstElement * m_pIdentity
Definition: moGsGraph.h:321
moGstElement * m_pRTSPDepay
Definition: moGsGraph.h:313
virtual moCaptureDevices * UpdateCaptureDevices()=0
Actualiza los dispositivos de video disponibles.
virtual MOulong GetDuration()=0
La duración total del stream en nanosegundos.