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
moVideoGraph.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moVideoGraph.cpp
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  Andrés Colubri
29 
30 *******************************************************************************/
31 
32 
33 #include "moVideoGraph.h"
34 
35 #include "moArray.h"
36 moDefineDynamicArray(moCaptureDevices)
37 
38 
40  m_Name = moText("");
41  m_Description = moText("");
42  m_Path = moText("");
43  m_LabelName = moText("");
44  m_DevicePort = 0;
45  m_bPresent = false;
46  m_bPreferred = false;
47  m_SourceWidth = m_SourceHeight = m_SourceBpp = m_SourceFlipH = m_SourceFlipV = 0;
48  m_VideoFormat.m_Width = 0;
49  m_VideoFormat.m_Height = 0;
50 }
51 
53  const moText &p_description,
54  const moText &p_path,
55  MOint p_deviceport,
56  MOint p_sourcewidth,
57  MOint p_sourceheight,
58  MOint p_bpp,
59  MOint p_fliph,
60  MOint p_flipv ) {
61  m_Name = p_name;
62  m_LabelName = p_name;
63  m_Description = p_description;
64  m_Path = p_path;
65  m_DevicePort = p_deviceport;
66  m_bPresent = true;
67  m_bPreferred = false;
68  m_SourceWidth = p_sourcewidth;
69  m_SourceHeight = p_sourceheight;
70  m_SourceBpp = p_bpp;
71  m_SourceFlipH = p_fliph;
72  m_SourceFlipV = p_flipv;
75 }
76 
77 
78 
80 
81 }
82 
84 
85 }
86 
87 bool
89  return true;
90 }
91 
93 
95 
96 }
97 
99 
100  return m_VideoFormat;
101 
102 }
103 
105 
106  return MO_STREAMSTATE_UNKNOWN;
107 
108 }
109 
111 
112  switch((int)state) {
114  return moText("UNKNOWN");
115  break;
117  return moText("PAUSED");
118  break;
120  return moText("PLAYING");
121  break;
123  return moText("WAITING");
124  break;
126  return moText("READY");
127  break;
129  return moText("STOPPED");
130  break;
131  }
132 
133  return moText("invalid state");
134 }
135 
136 //==========================================================================
137 // moVideoFramework
138 //==========================================================================
139 
140 
142 
143 }
144 
145 
147  m_CaptureDevices.Empty();
148  m_PreferredDevices.Empty();
149 }
150 
151 
152 void
153 moVideoFramework::SetPreferredDevices( moCaptureDevices* p_pPreferredDevices ) {
154 
155  moCaptureDevice PreferredDevice;
156  moCaptureDevice CapDev;
157  MOuint i,j;
158 
159  //m_PreferredDevices.Copy( (*p_pPreferredDevices) );
160  m_PreferredDevices.Empty();
161  for( i=0; i < p_pPreferredDevices->Count(); i++ ) {
162  m_PreferredDevices.Add( p_pPreferredDevices->GetRef(i) );
163  }
164 
165 
166 
167  //update all CaptureDevices availables, with preferred formats...
168  for( j=0; j< m_PreferredDevices.Count(); j++) {
169  PreferredDevice = m_PreferredDevices.GetRef(j);
170  for( i=0; i< m_CaptureDevices.Count(); i++) {
171  CapDev = m_CaptureDevices.GetRef(i);
172  if ( CapDev.GetName() == PreferredDevice.GetName()) { //capdev founded and maybe present
173  //set preferred videoformat...and codename
174  CapDev.SetVideoFormat( PreferredDevice.GetVideoFormat() );
175  CapDev.SetLabelName( PreferredDevice.GetLabelName() );
176  //save new CapDev data
177  m_CaptureDevices.Set( i, CapDev );
178  }
179  }
180  }
181 
182 }
183 
184 void
186 
187  moCaptureDevice PreferredDevice;
188  moCaptureDevice CapDev;
189  MOuint i;
190 
191  //search for preferred configurations for the specified CaptureDevice
192  for( i=0; i< m_PreferredDevices.Count(); i++) {
193  PreferredDevice = m_PreferredDevices.GetRef(i);
194  //search by friendly name
195  if ( PreferredDevice.GetName() == m_CaptureDevice.GetName())
196  break;
197  }
198 
199  for( i=0; i< m_CaptureDevices.Count(); i++) {
200  CapDev = m_CaptureDevices.GetRef(i);
201  if ( CapDev.GetPath() == m_CaptureDevice.GetPath()) { //capdev founded and maybe present
202  //set preferred videoformat...and codename
203  CapDev.SetVideoFormat( PreferredDevice.GetVideoFormat() );
204  CapDev.SetLabelName( PreferredDevice.GetLabelName() );
205  //save new CapDev data
206  m_CaptureDevices.Set( i, CapDev );
207  }
208  }
209 
210 }
211 
moCaptureDevices m_PreferredDevices
Dispositivos de video disponibles.
Definition: moVideoGraph.h:572
MOint m_SourceWidth
PUERTO DEL DISPOSITIVO.
Definition: moVideoGraph.h:475
moText m_Description
Nombre del dispositivo.
Definition: moVideoGraph.h:470
moVideoMode GetVideoMode()
Devuelve el modo de video.
moDefineDynamicArray(moCaptureDevices) moCaptureDevice
moVideoFormat GetVideoFormat()
Devuelve el formato de video.
moCaptureDevices m_CaptureDevices
Definition: moVideoGraph.h:571
void SetVideoFormat(const moVideoFormat &p_videoformat)
Devuelve el formato de video del dispositivo.
Definition: moVideoGraph.h:406
virtual ~moVideoFramework()
moVideoFormat & GetVideoFormat()
Devuelve el formato de video del dispositivo.
Definition: moVideoGraph.h:400
virtual bool FinishGraph()=0
Finalización del grafo.
moVideoMode m_VideoMode
Definition: moVideoGraph.h:201
clase de para manejar textos
Definition: moText.h:75
MOint m_DevicePort
Formato video del dispositivo.
Definition: moVideoGraph.h:473
const moText & GetLabelName() const
Devuelve el nombre de código del dispositivo.
Definition: moVideoGraph.h:428
moText0 moText
Definition: moText.h:291
moStreamState
Definition: moVideoGraph.h:140
void SetLabelName(const moText &p_labelname)
Fija el nombre de código del dispositivo.
Definition: moVideoGraph.h:423
virtual moStreamState GetState()
Estado de la reproducción.
const moText & GetName() const
Devuelve el nombre del dispositivo.
Definition: moVideoGraph.h:380
#define MOint
Definition: moTypes.h:388
virtual void SetPreferredDevices(moCaptureDevices *p_pPreferredDevices)
Fija los dispositivos predeterminados.
moCaptureDevice()
contructor
const moText & GetPath() const
Devuelve el camino al dispositivo.
Definition: moVideoGraph.h:390
virtual void SetPreferredFormat(const moCaptureDevice &p_CaptureDevice)
Fija el formato de un dispositivo.
Definición de un dispositivo de video, generalmente uno de captura de video, o camara.
Definition: moVideoGraph.h:336
#define MOuint
Definition: moTypes.h:387
static moText StateToText(moStreamState state)
Estado de la reproducción (version texto)
Formato de video.
Definition: moVideoGraph.h:155
moText m_Name
Dispositivo preferido siempre se dan de alta cuando están presentes.
Definition: moVideoGraph.h:469
bool m_bPreferred
Presencia del dispositivo.
Definition: moVideoGraph.h:468
moVideoMode
Resoluciones de video.
Definition: moVideoGraph.h:69
moVideoFormat m_VideoFormat
Definition: moVideoGraph.h:761
moVideoFormat m_VideoFormat
Camino o clave del dispositivo.
Definition: moVideoGraph.h:472
virtual ~moVideoGraph()
moText m_Path
Descripción del dispositivo.
Definition: moVideoGraph.h:471