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
moVideoManager.cpp
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moVideoManager.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 
29 
30 *******************************************************************************/
31 
32 #include "moVideoManager.h"
33 
34 #ifndef MO_DIRECTSHOW
35 #ifndef MO_QUICKTIME
36 // #define MO_GSTREAMER 1
37 #endif // MO_QUICKTIME
38 #endif // MO_DIRECTSHOW
39 
40 #include "moArray.h"
41 moDefineDynamicArray(moCircularVideoBuffers)
42 moDefineDynamicArray(moVideoFrames)
43 moDefineDynamicArray(moVideoBuffers)
44 moDefineDynamicArray(moLiveSystemPtrs)
45 moDefineDynamicArray(moVideoBufferPaths)
46 
47 #include "FreeImage.h"
48 
49 //===========================================
50 //
51 // moVideoFrame
52 //
53 //===========================================
54 
56  m_FrameSize = 0;
57  hmem = NULL;
58  options = 0;
59  fif = (int)FIF_UNKNOWN;
60 }
61 
63  Finish();
64 }
65 
69  return m_bInitialized;
70 }
71 
72 //FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags FI_DEFAULT(0));
74 moVideoFrame::Init( moText bufferformat, moBitmap* pImageResult ) {
75 
76  FIBITMAP* _pImageResult = (FIBITMAP*)pImageResult;
77 
78  if (!hmem) {
79  hmem = FreeImage_OpenMemory();
80  }
81  if (hmem) {
82 
83  if ( bufferformat == moText("JPG")) {
84  fif = FIF_JPEG;
85  options = JPEG_QUALITYNORMAL;
86  } else if ( bufferformat == moText("JPGSUPERB") ) {
87  fif = FIF_JPEG;
88  options = JPEG_QUALITYSUPERB;
89  } else if ( bufferformat == moText("JPGBAD") ) {
90  fif = FIF_JPEG;
91  options = JPEG_QUALITYBAD;
92  } else if ( bufferformat == moText("JPGAVERAGE") ) {
93  fif = FIF_JPEG;
94  options = JPEG_QUALITYAVERAGE;
95  } else if ( bufferformat == moText("JPGGOOD") ) {
96  fif = FIF_JPEG;
97  options = JPEG_QUALITYGOOD;
98  } else if ( bufferformat == moText("TGA") ) {
99  fif = FIF_TARGA;
100  options = 0;
101  } else if ( bufferformat == moText("PNG") ) {
102  fif = FIF_PNG;
103  options = 0;
104  } else {
105  MODebug2->Error( moText("moVideoFrame::Init")
106  + moText(" bufferformat unsupported!!") );
107  return false;
108  }
109  FreeImage_SaveToMemory( (FREE_IMAGE_FORMAT)fif, _pImageResult, (FIMEMORY*)hmem, options );
110  m_FrameSize = FreeImage_TellMemory((FIMEMORY*)hmem);
111  if (m_FrameSize==0) {
112  MODebug2->Error( moText("moVideoFrame::Init")
113  + moText(" Couldn't save image to memory, format may be unsupported") );
114  return false;
115  }
116  }
117  return Init();
118 }
119 
120 MOboolean
122 
123  if (hmem) {
124  FreeImage_CloseMemory( (FIMEMORY*)hmem );
125  hmem = NULL;
126  }
127 
128  m_FrameSize = 0;
129  hmem = NULL;
130  fif = (int)FIF_UNKNOWN;
131 
132  return true;
133 }
134 
135 
136 //===========================================
137 //
138 // moVideoBuffer
139 //
140 //===========================================
141 
143  m_pResourceManager = NULL;
145 
146  m_XSource = 0;
147  m_YSource = 0;
148  m_SourceWidth = 0;
149  m_SourceHeight = 0;
150 }
151 
153  Finish();
154 }
155 
157 
158  if (!m_pResourceManager)
159  return false;
160 
161  return true;
162 }
163 
164 MOboolean
165 moVideoBuffer::Init( moText bufferpath, moText bufferformat, moResourceManager* p_pResourceManager, MOuint width, MOuint height, MOuint xsource, MOuint ysource, MOuint sourcewidth, MOuint sourceheight, MOint interpolation, MOint interpolationjump, MOint interpolationtime ) {
166  m_pResourceManager = p_pResourceManager;
167 
168  m_BufferPath = bufferpath;
169  m_BufferFormat = bufferformat;
170  m_XSource = xsource;
171  m_YSource = ysource;
172  m_SourceWidth = sourcewidth;
173  m_SourceHeight = sourceheight;
174 
175  BuildEmpty( width, height);
176 
177  SetInterpolation( interpolationjump, interpolationtime );
178  ActivateInterpolation( interpolation );
179 
180  /*
181  moShaderManager* SM = m_pResourceManager->GetShaderMan();
182  moTextureManager* TM = m_pResourceManager->GetTextureMan();
183 
184  m_pShaderCopy = SM->GetShader(SM->GetShaderIndex(moText("shaders/Copy.cfg"),true) );
185  */
186  m_Frames.Init( 0, NULL);
187 
188  return Init();
189 }
190 
192  for(MOuint i=0; i<m_Frames.Count(); i++) {
193  moVideoFrame* pVideoFrame = m_Frames[i];
194  if (pVideoFrame)
195  pVideoFrame->Finish();
196  delete pVideoFrame;
197  }
198  m_Frames.Empty();
199  m_pResourceManager = NULL;
200  return true;
201 }
202 
203 MOboolean
204 moVideoBuffer::LoadImage( moBitmap* pImage, int indeximage ) {
205 
206  FIBITMAP* _pImage = (FIBITMAP*)pImage;
207  FIBITMAP* pImageResult = NULL;
208  FIBITMAP* pImageCropped = NULL;
209  FIBITMAP* pImageScaled = NULL;
210 
211  if ( m_width!=FreeImage_GetWidth(_pImage) || m_height!=FreeImage_GetHeight(_pImage) ) {
212  //CROP MODE
213  pImageCropped = FreeImage_Copy( _pImage, m_XSource , m_YSource , m_XSource + m_SourceWidth , m_YSource+m_SourceHeight );
214  pImageResult = pImageCropped;
215 
216  } else pImageResult = _pImage;
217 
218  //RESCALE
219  if ( m_width != m_SourceWidth || m_height != m_SourceHeight ) {
220  /*
221  FILTER_BOX Box, pulse, Fourier window, 1st order (constant) B-Spline
222  FILTER_BILINEAR Bilinear filter
223  FILTER_BSPLINE 4th order (cubic) B-Spline
224  FILTER_BICUBIC Mitchell and Netravali's two-param cubic filter
225  FILTER_CATMULLROM Catmull-Rom spline, Overhauser spline
226  FILTER_LANCZOS3
227  */
228  pImageScaled = FreeImage_Rescale( pImageResult, m_width, m_height, FILTER_BICUBIC );
229  if (pImageScaled) {
230  FreeImage_Unload(pImageResult);
231  pImageResult = pImageScaled;
232  }
233  }
234 
235  moVideoFrame* pVideoFrame = NULL;
236 
237  if (indeximage==-1 || indeximage == (int)m_Frames.Count() ) {
238  pVideoFrame = new moVideoFrame();
239  if (pVideoFrame) {
240  pVideoFrame->Init( m_BufferFormat, pImageResult );
241  m_Frames.Add(pVideoFrame);
242  }
243  } else if ( indeximage < (int)m_Frames.Count() ) {
244  pVideoFrame = m_Frames.Get(indeximage);
245  if (pVideoFrame) {
246  pVideoFrame->Finish();
247  pVideoFrame->Init( m_BufferFormat, pImageResult );
248  }
249  }
250 
251  if (pImageResult!=_pImage)
252  FreeImage_Unload(pImageResult);
253 
254  m_nFrames = m_Frames.Count();
255  m_fFramesPerSecond = 25.0;
256 
257  return (pVideoFrame!=NULL);
258 }
259 /*
260 MOboolean moVideoBuffer::LoadFromVideo( moText p_moviefile ) {
261  //
262  return true;
263 }
264 */
265 /*
266 */
268 
269  if ( p_i<m_Frames.Count()) {
270 
271  moVideoFrame* pVideoFrame = m_Frames[p_i];
272 
273  if (pVideoFrame) {
274 
275  FIBITMAP *pImage;
276  //FIMEMORY *hmem;
277 
278  MOuint p_format;
279 
280  //MOint FrameSize =
281  FreeImage_TellMemory((FIMEMORY*)pVideoFrame->hmem);
282  FreeImage_SeekMemory( (FIMEMORY*)pVideoFrame->hmem, 0L, SEEK_SET);
283 
284  //hmem = FreeImage_OpenMemory( pVideoFrame->hmem, pVideoFrame->m_FrameSize);
285  //FreeImage_TellMemory(VideoFrame->hmem);
286  // load an image from the memory stream
287  pImage = FreeImage_LoadFromMemory( (FREE_IMAGE_FORMAT)pVideoFrame->fif, (FIMEMORY*)pVideoFrame->hmem, 0);
288 
289  if (pImage) {
290  switch (FreeImage_GetBPP(pImage))
291  {
292  case 8: // 8 bit, indexed or grayscale
293  m_param.internal_format = GL_RGB;
294  p_format = GL_LUMINANCE;
295  break;
296  case 16: // 16 bits
297  break;
298  case 24: // 24 bits
299  m_param.internal_format = GL_RGB;
300 #ifndef OPENGLESV2
301  if (FreeImage_GetBlueMask(pImage) == 0x000000FF) p_format = GL_BGR;
302  else
303 #endif
304  p_format = GL_RGB;
305  break;
306  case 32: // 32 bits
307  m_param.internal_format = GL_RGBA;
308 #ifndef OPENGLESV2
309  if (FreeImage_GetBlueMask(pImage) == 0x000000FF) p_format = GL_BGRA_EXT;
310  else
311 #endif
312  p_format = GL_RGBA;
313  break;
314  default:
315  break;
316  }
317  SetBuffer( m_width, m_height, FreeImage_GetBits(pImage), p_format);
318  FreeImage_Unload( pImage );
319 
320  this->m_ActualFrame = p_i;
321 
322  } else MODebug2->Error( moText("moVideoBuffer::GetFrame") +
323  moText("Couldn't load image from memory, texture name: ") +
324  moText(this->GetName())
325  );
326  }
327  }
328 
329 }
330 
331 //===========================================
332 //
333 // moCircularVideoBuffer
334 //
335 //===========================================
336 
338  m_pResourceManager = NULL;
340 
341  m_WriteIndex = 0;
342  m_ReadIndex = 0;
343  m_XSource = 0;
344  m_YSource = 0;
345  m_SourceWidth = 0;
346  m_SourceHeight = 0;
347 }
348 
350  Finish();
351 }
352 
354 
355  if (!m_pResourceManager)
356  return false;
357 
358  return true;
359 }
360 
361 MOboolean
362 moCircularVideoBuffer::Init( moText videoinput, moText bufferformat, moResourceManager* p_pResourceManager, MOint frames, MOint width, MOint height, MOint xsource, MOint ysource, MOint sourcewidth, MOint sourceheight ) {
363  m_pResourceManager = p_pResourceManager;
364 
365  m_VideoInput = videoinput;
366  m_BufferFormat = bufferformat;
367  m_XSource = xsource;
368  m_YSource = ysource;
369  m_SourceWidth = sourcewidth;
370  m_SourceHeight = sourceheight;
371 
372  BuildEmpty( width, height);
373 
374 
375  //DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));
376 
377  FIBITMAP* pBlack;
378  pBlack = FreeImage_Allocate( width, height, 24 );
379 
380  for(MOint i=0; i<frames; i++) {
381  moVideoFrame* pVideoFrame = new moVideoFrame();
382  if (pVideoFrame) {
383  pVideoFrame->Init( bufferformat, pBlack );
384  m_Frames.Add(pVideoFrame);
385  }
386  }
387 
388  m_nFrames = m_Frames.Count();
389 
390 
391  return Init();
392 }
393 
395  for(MOuint i=0; i<m_Frames.Count(); i++) {
396  moVideoFrame* pVideoFrame = m_Frames[i];
397  if (pVideoFrame)
398  pVideoFrame->Finish();
399  delete pVideoFrame;
400  }
401  m_Frames.Empty();
402  m_pResourceManager = NULL;
403  return true;
404 }
405 
406 MOboolean
408 
409 
410  FIBITMAP* pImage = NULL;
411  moBucket* pBucket = NULL;
412 
413  if (!pvideosample) return false;
414 
415 //DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBits(
416  //BYTE *bits, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE));
417  pBucket = (moBucket*)pvideosample->m_pSampleBuffer;
418  if (!pBucket) return false;
419  pImage = FreeImage_ConvertFromRawBits( pBucket->GetBuffer(),
420  pvideosample->m_VideoFormat.m_Width,
421  pvideosample->m_VideoFormat.m_Height,
422  pvideosample->m_VideoFormat.m_Width*3,
423  24,
424  0xFF0000,
425  0x00FF00,
426  0x0000FF);
427 
428  FIBITMAP* pImageResult = NULL;
429  FIBITMAP* pImageCropped = NULL;
430  FIBITMAP* pImageScaled = NULL;
431 
432 
433 
434 
435  if ( m_width!=FreeImage_GetWidth(pImage) || m_height!=FreeImage_GetHeight(pImage) ) {
436  //CROP MODE
437  pImageCropped = FreeImage_Copy( pImage, m_XSource , m_YSource , m_XSource + m_SourceWidth , m_YSource+m_SourceHeight );
438  pImageResult = pImageCropped;
439 
440  } else pImageResult = pImage;
441 
443  if ( m_width != m_SourceWidth || m_height != m_SourceHeight ) {
444  /*
445  FILTER_BOX Box, pulse, Fourier window, 1st order (constant) B-Spline
446  FILTER_BILINEAR Bilinear filter
447  FILTER_BSPLINE 4th order (cubic) B-Spline
448  FILTER_BICUBIC Mitchell and Netravali's two-param cubic filter
449  FILTER_CATMULLROM Catmull-Rom spline, Overhauser spline
450  FILTER_LANCZOS3
451  */
452  pImageScaled = FreeImage_Rescale( pImageResult, m_width, m_height, FILTER_BICUBIC );
453  if (pImageScaled) {
454  FreeImage_Unload(pImageResult);
455  pImageResult = pImageScaled;
456  }
457  }
458 
459  //aqui cambia
460  m_WriteIndex++;
461 
462  //Circularity
463  if ( m_WriteIndex>= (MOint)m_Frames.Count() ) {
464  m_WriteIndex = 0;
465  }
466 
467  m_ReadIndex = m_WriteIndex;
468 
469  moVideoFrame* pVideoFrame = m_Frames[m_WriteIndex];
470  if (pVideoFrame) {
471  pVideoFrame->Finish();
472  pVideoFrame->Init( m_BufferFormat, pImageResult );
473  }
474 
475  if (pImageResult!=pImage)
476  FreeImage_Unload(pImageResult);
477 
478  FreeImage_Unload(pImage);
479 
480  m_fFramesPerSecond = 25.0;
481 
482  return (pVideoFrame!=NULL);
483 }
484 /*
485 MOboolean moVideoBuffer::LoadFromVideo( moText p_moviefile ) {
486  //
487  return true;
488 }
489 */
490 /*
491 */
493 
494  if ( p_i<m_Frames.Count()) {
495 
496  MOint ddd = ( m_ReadIndex - (int)p_i);
497  if (ddd<0) ddd = m_Frames.Count() + ddd;
498  p_i = ddd % m_Frames.Count();
499 
500  moVideoFrame* pVideoFrame = m_Frames[p_i];
501 
502  if (pVideoFrame) {
503 
504  FIBITMAP *pImage;
505  //FIMEMORY *hmem;
506 
507  MOuint p_format;
508 
509  //MOint FrameSize =
510  FreeImage_TellMemory((FIMEMORY*)pVideoFrame->hmem);
511  FreeImage_SeekMemory( (FIMEMORY*)pVideoFrame->hmem, 0L, SEEK_SET);
512 
513  //hmem = FreeImage_OpenMemory( pVideoFrame->hmem, pVideoFrame->m_FrameSize);
514  //FreeImage_TellMemory(VideoFrame->hmem);
515  // load an image from the memory stream
516  pImage = FreeImage_LoadFromMemory( (FREE_IMAGE_FORMAT)pVideoFrame->fif, (FIMEMORY*)pVideoFrame->hmem, 0);
517 
518  switch (FreeImage_GetBPP(pImage))
519  {
520  case 8: // 8 bit, indexed or grayscale
521  m_param.internal_format = GL_RGB;
522  p_format = GL_LUMINANCE;
523  break;
524  case 16: // 16 bits
525  break;
526  case 24: // 24 bits
527  m_param.internal_format = GL_RGB;
528 #ifndef OPENGLESV2
529  if (FreeImage_GetBlueMask(pImage) == 0x000000FF) p_format = GL_BGR;
530  else
531 #endif
532 p_format = GL_RGB;
533  break;
534  case 32: // 32 bits
535  m_param.internal_format = GL_RGBA;
536 #ifndef OPENGLESV2
537  if (FreeImage_GetBlueMask(pImage) == 0x000000FF) p_format = GL_BGRA_EXT;
538  else
539 #endif
540 p_format = GL_RGBA;
541  break;
542  default:
543  break;
544  }
545  SetBuffer( m_width, m_height, FreeImage_GetBits(pImage), p_format);
546  FreeImage_Unload( pImage );
547  }
548  }
549 
550 }
551 
552 
553 void moCircularVideoBuffer::StartRecording( long at_position ) {
554  if (at_position!=-1 && at_position>=0 && at_position<(long)m_Frames.Count()) {
555  m_WriteIndex = at_position;
556  }
557  if (!m_RecTimer.Started()) {
558  m_RecTimer.Start();
559  } else {
560  m_RecTimer.Continue();
561  }
562 }
563 
565  m_RecTimer.Pause();
566 }
567 
569  m_RecTimer.Continue();
570 }
571 
572 void moCircularVideoBuffer::JumpRecording( long at_position ) {
573  //m_RecTimer.Start();
574  //chequear
575  if ( at_position>=0 && at_position<(long)m_Frames.Count()) {
576  m_WriteIndex = at_position;
577  }
578 }
579 
581  m_RecTimer.Stop();
582 }
583 
585  return m_RecTimer.Started();
586 }
587 
589  return m_WriteIndex;
590 }
591 
592 
593 //===========================================
594 //
595 // moVideoBufferPath
596 //
597 //===========================================
598 
600  m_ImagesProcessed = 0;
601  m_ActualImage = 0;
602  m_pResourceManager = NULL;
603  m_pDirectory = NULL;
604  m_bLoadCompleted = false;
605  m_TotalFiles = 0;
606 
607 }
608 
610  Finish();
611 }
612 
614 
615  m_bInitialized = true;
616 
617  return m_bInitialized;
618 }
619 
620 MOboolean
621 moVideoBufferPath::Init( moResourceManager* pResources, moText videobufferpath ) {
622 
623  m_pResourceManager = pResources;
624 
625  if (!m_pResourceManager)
626  return false;
627 
628  m_VideoBufferPath = videobufferpath;
629 
630  m_CompletePath = m_pResourceManager->GetDataMan()->GetDataPath() + moSlash + (moText)m_VideoBufferPath;;
631 
632  m_pDirectory = m_pResourceManager->GetFileMan()->GetDirectory( m_CompletePath );
633 
634  if (m_pDirectory) this->m_TotalFiles = (MOint)m_pDirectory->GetFiles().Count();
635 
636  return Init();
637 }
638 
640 
641  m_VideoBuffers.Empty();
642 
643  return true;
644 }
645 
646 MOboolean
648  return m_bLoadCompleted;
649 }
650 
652  return this->m_VideoBufferPath;
653 }
654 
656  return this->m_CompletePath;
657 }
658 
659 
661  return this->m_TotalFiles;
662 }
663 
665  return this->m_ImagesProcessed;
666 }
667 
669  return this->m_ActualImage;
670 }
671 
673 
674  //carga los frames desde los archivos
675  moFile* pFile;
676 
677  MOint counter = 0;
678 
679  if (!m_pDirectory) return false;
680 
681  this->m_TotalFiles = (MOint)m_pDirectory->GetFiles().Count();
682 
683  if (m_ActualImage>=(MOint)m_pDirectory->GetFiles().Count()) {
684  m_bLoadCompleted = true;
685  return true;
686  }
687 
688  if (m_ActualImage==0)
689  pFile = m_pDirectory->FindFirst();
690  else
691  pFile = m_pDirectory->Find(m_ActualImage);
692 
693  if (pFile)
694  do {
695  if ( pFile->GetType()==MO_FILETYPE_LOCAL && pFile->Exists()) {
696 
697  //LOAD AND UNCOMPRESS IMAGE
698  FREE_IMAGE_FORMAT fif;
699  fif = FreeImage_GetFileType( pFile->GetCompletePath(), 0);
700 
701  if( fif == FIF_UNKNOWN ) {
702  // try to guess the file format from the file extension
703  fif = FreeImage_GetFIFFromFilename(pFile->GetCompletePath());
704  }
705 
706  if( (fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif) ) {
707  //decodificamos el archivo
708  FIBITMAP* pImage;
709  pImage = FreeImage_Load( fif, pFile->GetCompletePath(), 0);
710 
711  //ONCE LOADED SAVE ON EVERY VIDEOBUFFER
712  if (pImage) {
713 
714  for(MOuint b = 0; b<m_VideoBuffers.Count(); b++) {
715 
716  moVideoBuffer* pVideoBuffer = m_VideoBuffers[b];
717 
718  if (pVideoBuffer)
719  pVideoBuffer->LoadImage( pImage, m_ActualImage );
720  }
721  FreeImage_Unload(pImage);
722  pImage = NULL;
723  m_ImagesProcessed++;
724  //MODebug2->Message( "image processed: "+pFile->GetCompletePath());
725  }
726  }
727  }
728 
729  m_ActualImage++;
730  counter++;
731  if (counter==maxfiles && maxfiles!=(-1))
732  break;
733 
734  } while ( (pFile = m_pDirectory->FindNext()) );
735 
736  return true;
737 }
738 
739 
740 //===========================================
741 //
742 // moVideoManager
743 //
744 //===========================================
745 
747 {
750 
751  SetName("videomanager");
752  SetLabelName("videomanager");
753 
754  m_pLiveSystems = NULL;
755 }
756 
758 {
759  Finish();
760 }
761 
763 {
764  moCaptureDevices* pPreferredDevices;
765  MOuint preferreddevices;
766  MOuint autoreconnect;
767  MOuint nvalues;
768  moText confignamecompleto;
769 
770  m_bAutoReconnect = false;
771 
772  // Loading config file.
773  if (!m_pResourceManager) return false;
774 
776 
778  m_pLiveSystems->Init(0, NULL);
779 
780 
781 
782  if (m_Config.IsConfigLoaded()) {
783 
784  moText msg = "In moVideoManager::Init from config file ***********************\n";
785  msg+= moText("Initializing Live...\n");
786  MODebug2->Message( msg );
787 
788  preferreddevices = m_Config.GetParamIndex("preferreddevices");//FIREWIRE, WEBCAMS, LIVEVIDEO[movie]
789  autoreconnect = m_Config.GetParamIndex("autoreconnect");//FIREWIRE, WEBCAMS, LIVEVIDEO[movie]
790  //MOuint videoin = m_Config.GetParamIndex("videoin");
791 
792  // moText videoinname;
793 
794 /*
795  MODebug2->Message( "VideoManager:: Generating videoin textures" );
796  for(MOuint i=0; i<m_Config.GetValuesCount(videoin); i++ ) {
797  videoinname = m_Config.GetParam(videoin).GetValue(i).GetSubValue(0).Text();
798  if(videoinname!=moText("")) {
799  int tid = m_pResourceManager->GetTextureMan()->AddTexture( MO_TYPE_TEXTURE, videoinname);
800  if(tid>-1) Images.Add( m_pResourceManager->GetTextureMan()->GetTexture(tid));
801  MODebug2->Message( moText("VideoManager:: Added ") + moText(videoinname) );
802  }
803  }
804  */
806  m_bAutoReconnect = (bool) m_Config.GetParam((MOint)autoreconnect).GetValue().GetSubValue().Int();
807 
809  pPreferredDevices = new moCaptureDevices();
810 
811  nvalues = m_Config.GetValuesCount( preferreddevices );
812  m_Config.SetCurrentParamIndex(preferreddevices);
813  /*
814  MO_LIVE_LABELNAME 0
815  MO_LIVE_DEVICENAME 1
816  MO_LIVE_COLORMODE 2
817  MO_LIVE_WIDTH 3
818  MO_LIVE_HEIGHT 4
819  MO_LIVE_BITCOUNT 5
820  MO_LIVE_SCALE_WIDTH 6
821  MO_LIVE_SCALE_HEIGHT 7
822  MO_LIVE_FLIPH 8
823  MO_LIVE_FLIPV 9
824  */
825  MODebug2->Message(moText("Setting preferred devices"));
826  for( MOuint i = 0; i < nvalues; i++) {
827 
828  m_Config.SetCurrentValueIndex(preferreddevices, i);
829 
830  MOint srcw(0),srch(0),srcbpp(0),flH(0),flV(0);
832 
833 
834  ( MO_LIVE_WIDTH < ncount ) ? srcw = m_Config.GetParam().GetValue().GetSubValue(MO_LIVE_WIDTH).Int() : srcw = 0;
835  ( MO_LIVE_HEIGHT < ncount ) ? srch = m_Config.GetParam().GetValue().GetSubValue(MO_LIVE_HEIGHT).Int() : srch = 0;
836  ( MO_LIVE_BITCOUNT < ncount ) ? srcbpp = m_Config.GetParam().GetValue().GetSubValue(MO_LIVE_BITCOUNT).Int() : srcbpp = 0;
837  ( MO_LIVE_FLIPH < ncount ) ? flH = m_Config.GetParam().GetValue().GetSubValue(MO_LIVE_FLIPH).Int() : flH = 0;
838  ( MO_LIVE_FLIPV < ncount ) ? flV = m_Config.GetParam().GetValue().GetSubValue(MO_LIVE_FLIPV).Int() : flV = 0;
839 
840  moVideoFormat VF;
841  moCaptureDevice CD( m_Config.GetParam().GetValue().GetSubValue(MO_LIVE_DEVICENAME).Text(), moText(""), moText(""), 0, srcw, srch, srcbpp, flH, flV );
842 
844 
848 
850 
851  CD.SetVideoFormat( VF );
852  CD.SetPreffered( true );
853 
854  pPreferredDevices->Add( CD );
855  MODebug2->Message(moText("Added preferred device setting: Device Name: ")+CD.GetName());
856  //for( int k = 1; k < m_Config.GetParam().GetSubCount(); k++);
857  }
858 
859 
860 
861  //INITIALIZING LiveSystems
862 
863  //try to connect to all predefined
864 
865 
866  MODebug2->Message(moText("Finally load live systems grabber for each device...."));
867 
868 
869  if (!m_pLiveSystems) return false;
870 
871  m_pLiveSystems->GetVideoFramework()->SetPreferredDevices( pPreferredDevices );
872 
874 
875  for( int c=0; c<(int)m_CaptureDevices.Count(); c++) {
876  moCaptureDevice CapDev = m_CaptureDevices.Get(c);
877  if (CapDev.IsPreferred()) {
878  moCamera* Cam = CreateCamera( CapDev );
879  if (Cam==NULL) MODebug2->Error("moVideoManager::Init > could not create Camera: " + CapDev.GetName()+ " Label: " + CapDev.GetLabelName() );
880  }
881 
882  }
883 
884  //if ( m_pLiveSystems->LoadLiveSystems( pPreferredDevices ) ) {
885  //los inicializa...
886  // for( MOuint i = 0; i < m_pLiveSystems->Count(); i++) {
887 
888  // moLiveSystemPtr pLS = m_pLiveSystems->Get(i);
889 
890  // if (pLS && pLS->GetCaptureDevice().IsPresent()) {
891 
892  // if (pLS->Init()) {
893 
894  // MODebug2->Message( moText(pLS->GetCaptureDevice().GetName()) + " initialized");
895 
896 /*
897  if ( pLS->GetVideoGraph()->GetVideoFormat().m_WaitForFormat == false && 1==2 ) {
898 
899  moBucketsPool* pBucketsPool = pLS->GetBucketsPool();
900 
901  if ( pBucketsPool!=NULL ) {
902 
903  if ( pBucketsPool->IsFull() ) {
904 
905  moBucket* pbucket = pBucketsPool->RetreiveBucket();
906 
907  if ( pbucket && pLS->GetVideoGraph() ) {
908 
909  //moVideoSample* pSample = new moVideoSample( pLS->GetVideoGraph()->GetVideoFormat(), (MOpointer) pbucket );
910 
912  pLS->GetVideoGraph()->GetState();
913 
914  //if( pSample!=NULL ) {
915 
916  //moTexture * ts =(moTexture*)Images[i];
917  moTexture* ts = pLS->GetTexture();
918 
919  if(ts!=NULL)
920  {
921 
922  if ((ts->GetGLId() <= 0) || (ts->GetWidth() != pLS->GetVideoGraph()->GetVideoFormat().m_Width))
923  {
924  if (ts->GetGLId() != 0) ts->Finish();
925  ts->BuildEmpty(pLS->GetVideoGraph()->GetVideoFormat().m_Width, pLS->GetVideoGraph()->GetVideoFormat().m_Height);
926  }
927 
928  MOubyte* pbuffer = pbucket->GetBuffer();
929 
930  if (pbuffer) {
931  pbucket->Lock();
932  ts->SetBuffer( pbuffer, GL_BGR_EXT);
933  pbucket->Unlock();
934  }
935  }
936 
937 
938  }
939 
940  }
941  }
942  }*/
943  // }
944  // }
945 
946  // }
947 
948 
949  //} else MODebug2->Error(moText("Error. No livesystems loaded??...."));
950 
951 
952  MOuint circularbuffer = m_Config.GetParamIndex("circularbuffer");
953 
954  moText videobufferinput;
955  moText videobuffername;
956  moText videobufferformat;
957  MOint xsource, ysource, width, height, sourcewidth, sourceheight, frames;
958  MOint interpolation, interpolation_jump, interpolation_time;
959 
960  if (circularbuffer>0)
961  for(MOuint i=0; i<m_Config.GetValuesCount(circularbuffer); i++ ) {
962 
963  videobufferinput = m_Config.GetParam(circularbuffer).GetValue(i).GetSubValue(MO_VIDEO_CIRCULARBUFFERINPUT).Text();
964  videobuffername = m_Config.GetParam(circularbuffer).GetValue(i).GetSubValue(MO_VIDEO_CIRCULARBUFFERNAME).Text();
965  videobufferformat = m_Config.GetParam(circularbuffer).GetValue(i).GetSubValue(MO_VIDEO_CIRCULARBUFFERFORMAT).Text();
966 
968  width = m_Config.GetParam(circularbuffer).GetValue(i).GetSubValue(MO_VIDEO_CIRCULARWIDTH).Int();
969  height = m_Config.GetParam(circularbuffer).GetValue(i).GetSubValue(MO_VIDEO_CIRCULARHEIGHT).Int();
972  sourcewidth = m_Config.GetParam(circularbuffer).GetValue(i).GetSubValue(MO_VIDEO_CIRCULARSOURCEWIDTH).Int();
973  sourceheight = m_Config.GetParam(circularbuffer).GetValue(i).GetSubValue(MO_VIDEO_CIRCULARSOURCEHEIGHT).Int();
974 
975  if(videobufferinput!=moText("")) {
976  moCircularVideoBuffer* pCircularBuffer = NULL;
978  if(tid>-1) {
980  }
981  if (pCircularBuffer) {
982  pCircularBuffer->Init( videobufferinput, videobufferformat, GetResourceManager(), frames, width, height, xsource, ysource, sourcewidth, sourceheight);
983  m_CircularVideoBuffers.Add(pCircularBuffer);
984  pCircularBuffer->StartRecording();
985  }
986  }
987 
988  }
989 
990  MOuint videobuffer = m_Config.GetParamIndex("videobuffer");
991 
992  moText videobufferpath;
993  //moText videobuffername;
994  //moText videobufferformat;
995  //MOint xsource, ysource, width, height, sourcewidth, sourceheight;
996  if (videobuffer>0)
997  for(MOuint i=0; i<m_Config.GetValuesCount(videobuffer); i++ ) {
998 
999  videobufferpath = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(0).Text();
1000 
1001  moVideoBufferPath* pVideoBufferPath = new moVideoBufferPath();
1002 
1003  if (pVideoBufferPath) {
1004 
1005  pVideoBufferPath->Init( GetResourceManager(), videobufferpath );
1006  m_VideoBufferPaths.Add(pVideoBufferPath);
1007 
1008  for(MOuint j=0; j < ( m_Config.GetParam(videobuffer).GetValue(i).GetSubValueCount() - 1 ) / 11; j++) {
1009 
1010  videobuffername = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_BUFFERNAME).Text();
1011  videobufferformat = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_BUFFERFORMAT).Text();
1012 
1013  width = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_WIDTH).Int();
1014  height = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_HEIGHT).Int();
1015  xsource = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_SOURCEXOFFSET).Int();
1016  ysource = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_SOURCEYOFFSET).Int();
1017  sourcewidth = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_SOURCEWIDTH).Int();
1018  sourceheight = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_SOURCEHEIGHT).Int();
1019 
1020  interpolation = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_SOURCEINTERPOLATION).Int();
1021  interpolation_jump = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_SOURCEINTERPOLATIONJUMP).Int();
1022  interpolation_time = m_Config.GetParam(videobuffer).GetValue(i).GetSubValue(j*11+MO_VIDEO_SOURCEINTERPOLATIONTIME).Int();
1023 
1024  if(videobufferpath!=moText("")) {
1025  moVideoBuffer* pVideoBuffer = NULL;
1026  int tid = m_pResourceManager->GetTextureMan()->AddTexture( MO_TYPE_VIDEOBUFFER, videobuffername );
1027  if(tid>-1) {
1028  pVideoBuffer = (moVideoBuffer*) m_pResourceManager->GetTextureMan()->GetTexture(tid);
1029  }
1030  if (pVideoBuffer) {
1031  pVideoBuffer->Init( videobufferpath, videobufferformat, GetResourceManager(), width, height, xsource, ysource, sourcewidth, sourceheight, interpolation, interpolation_jump, interpolation_time);
1032  pVideoBufferPath->m_VideoBuffers.Add(pVideoBuffer);
1033  }
1034  }
1035  }
1036  }
1037  }
1038 
1039  delete pPreferredDevices;
1040 
1041  } else {
1042 
1046 
1047  }
1048 
1049 
1050  m_bLoading = true;
1051  m_bInitialized = true;
1052 
1053  return true;
1054 }
1055 
1057 {
1058 
1059  if (devcode == 0 ) {
1060  if (state==MO_ON) {
1061  GetCaptureDevices(true);
1062  }
1063  }
1064  return true;
1065 }
1066 
1068 {
1069 
1070  //devcode ahora deberia ser:
1071  //LIVESYSTEM01 0
1072  //LIVESYSTEM02 1
1073  //LIVESYSTEM03 2
1074  //LIVESYSTEM04 3
1075  if (m_pLiveSystems) {
1076 
1077  return m_pLiveSystems->GetStatus( devcode );
1078 
1079  }
1080 
1081  return 0;
1082  //return(-1);
1083 }
1084 
1085 //in this device, GetValue returns the size of the buffer corresponding of a sample of the actual devicecode
1087 {
1088  if( m_pLiveSystems) {
1089 
1090  moLiveSystemPtr pLS = m_pLiveSystems->Get( devcode );
1091 
1092  if (pLS) {
1093 
1094  moVideoGraph* pVideoGraph = pLS->GetVideoGraph();
1095 
1096  if (pVideoGraph) {
1097 
1098  return pVideoGraph->GetVideoFormat().m_BufferSize;
1099 
1100  }
1101 
1102  }
1103  }
1104 
1105  return(-1);
1106 }
1107 
1109 {
1110  //SNAPSHOTS
1111  if (m_pLiveSystems) {
1112  //recorre los livesystems, y por cada nombre....chequea el codigo
1113  for(MOuint i =0; i< m_pLiveSystems->Count(); i++) {
1114  moLiveSystemPtr pLS = m_pLiveSystems->Get(i);
1115  if (pLS) {
1116  if ( pLS->GetLabelName() == strcod ) {
1117  return i;
1118  }
1119  }
1120  }
1121  }
1122 
1123  return(-1);
1124 }
1125 
1127  if (m_pLiveSystems) {
1128  return m_pLiveSystems->Get(cam_idx);
1129  }
1130  return NULL;
1131 }
1132 
1133 moCamera*
1135 
1136  MODebug2->Message("moVideoManager::CreateCamera > " + p_CapDev.GetLabelName()+" for device:"+p_CapDev.GetName()+
1137  " (Width)x(Height):" + IntToStr(p_CapDev.GetSourceWidth())+"x" + IntToStr(p_CapDev.GetSourceHeight()) );
1138 
1139  moCaptureDevice cap=p_CapDev;
1140  //cap.m_SourceWidth = 640;
1141  //cap.m_SourceHeight = 480;
1142 
1144  moLiveSystem* pLS = new moLiveSystem(cap);
1146 
1147  if (!pLS) return NULL;
1148 
1149  if (!pLS->Init()) return NULL;
1150 
1151  MODebug2->Message( moText("moVideoManager::CreateCamera > Capture Device ")
1152  + pLS->GetCaptureDevice().GetName()
1153  + " initialized");
1154 
1155  int mid = TMan->AddTexture( MO_TYPE_TEXTURE, pLS->GetLabelName() );
1156 
1157  moTexture * ts = NULL;
1158 
1159  if (mid>-1) ts = TMan->GetTexture(mid);
1160 
1161  if(ts)
1162  {
1163  pLS->SetTexture(ts);
1164  MODebug2->Message("moVideoManager::CreateCamera > texture added ok: " + ts->GetName() );
1165  } else {
1166  MODebug2->Error("moVideoManager::CreateCamera > texture not added. " +ts->GetName() );
1167  }
1168 
1169 /*
1170  if ( pLS->GetVideoGraph()->GetVideoFormat().m_WaitForFormat == false && 1==2 ) {
1171 
1172  moBucketsPool* pBucketsPool = pLS->GetBucketsPool();
1173 
1174  if ( pBucketsPool==NULL ) return NULL;
1175 
1176  if ( pBucketsPool->IsFull() ) {
1177 
1178  moBucket* pbucket = pBucketsPool->RetreiveBucket();
1179 
1180  if ( pbucket && pLS->GetVideoGraph() ) {
1181 
1182  //moVideoSample* pSample = new moVideoSample( pLS->GetVideoGraph()->GetVideoFormat(), (MOpointer) pbucket );
1183 
1185  pLS->GetVideoGraph()->GetState();
1186 
1187 
1188  int mid = TMan->AddTexture( MO_TYPE_TEXTURE, pLS->GetLabelName() );
1189  moTexture * ts = NULL;
1190  if (mid>-1) ts = TMan->GetTexture(mid);
1191  pLS->SetTexture(ts);
1192  if(ts!=NULL)
1193  {
1194  MODebug2->Log("moVideoManager::CreateCamera > texture added ok: " + ts->GetName() );
1195  if ((ts->GetGLId() <= 0) || (ts->GetWidth() != pLS->GetVideoGraph()->GetVideoFormat().m_Width))
1196  {
1197  if (ts->GetGLId() != 0) ts->Finish();
1198  ts->BuildEmpty(pLS->GetVideoGraph()->GetVideoFormat().m_Width, pLS->GetVideoGraph()->GetVideoFormat().m_Height);
1199  }
1200 
1201  MOubyte* pbuffer = pbucket->GetBuffer();
1202 
1203  if (pbuffer) {
1204  pbucket->Lock();
1205  ts->SetBuffer( pbuffer, GL_BGR_EXT);
1206  pbucket->Unlock();
1207  }
1208 
1209  }
1210  }
1211  }
1212  }
1213  */
1214 
1215  m_pLiveSystems->Add( pLS );
1216  MODebug2->Message( moText("Added LiveSystem: Label Name: ") + pLS->GetCaptureDevice().GetLabelName()
1217  + moText(" Device Name:") + pLS->GetCaptureDevice().GetName() );
1218 
1219  return (moCamera*)pLS;
1220 }
1221 
1222 moCamera*
1223 moVideoManager::GetCameraByName( const moText& camera, bool load, moCaptureDevice customCD ) {
1224 
1225  moCamera* Cam = NULL;
1226 
1227  if (m_pLiveSystems) {
1228  for( int c=0; c<(int)m_pLiveSystems->Count(); c++ ) {
1229  Cam = m_pLiveSystems->Get(c);
1230  if (Cam) {
1231  if (Cam->GetCaptureDevice().GetLabelName()==camera
1232  ||
1233  Cam->GetCaptureDevice().GetName()==camera
1234  ||
1235  ( camera=="default" && c>=0 && Cam->GetVideoGraph() )
1236  ) {
1237 MODebug2->Message("moVideoManager::GetCameraByName > camera already loaded, returnin:"+camera);
1238  return Cam;
1239  }
1240  }
1241  }
1242  }
1243 
1244  for(int d=0;d<(int)m_CaptureDevices.Count();d++) {
1245  moCaptureDevice m_CapDev = m_CaptureDevices[d];
1246  if (m_CapDev.GetName()==camera
1247  ||
1248  m_CapDev.GetLabelName()==camera
1249  ||
1250  ( camera=="default" && d>=0 && m_CapDev.IsPresent() )
1251  ) {
1253  if (load) {
1254  moCaptureDevice newCD = m_CapDev;
1255 
1257  //chequear video format
1258  newCD.GetVideoFormat().m_Width = 256;
1259  newCD.GetVideoFormat().m_Height = 256;
1260  //newCD.GetVideoFormat().m_ColorMode = (moColorMode) ;
1261  newCD.GetVideoFormat().m_BitCount = 24;
1262  newCD.GetVideoFormat().m_ColorMode = (moColorMode) 0;
1263 
1264  }
1265 
1266  // apply custom capture device values from customCD
1267  MODebug2->Message("moVideoManager::GetCameraByName > customCD: WxH:"+IntToStr(customCD.m_SourceWidth) + "x" + IntToStr(customCD.m_SourceHeight));
1268 
1269  if ( /*customCD.GetLabelName()!=""
1270  && */(customCD.GetVideoFormat().m_Width>0
1271  && customCD.GetVideoFormat().m_Height>0)
1272  || (
1273  customCD.m_SourceWidth>0
1274  &&
1275  customCD.m_SourceHeight>0
1276  ) ) {
1277  newCD = customCD;
1278  newCD.SetName( m_CapDev.GetName() );
1279  newCD.SetLabelName( m_CapDev.GetLabelName() );
1281  moMathi mathI;
1282  if ( !mathI.IsPowerOfTwo( newCD.GetVideoFormat().m_Width ) ) {
1284  }
1285  if ( !mathI.IsPowerOfTwo( newCD.GetVideoFormat().m_Height ) ) {
1287  }
1288  }
1289  }
1290 
1291  Cam = CreateCamera( newCD );
1292  return Cam;
1293  }
1294  }
1295  }
1296 
1297  return NULL;
1298 }
1299 
1301  if (m_pLiveSystems)
1302  return m_pLiveSystems->Count();
1303  return 0;
1304 }
1305 
1306 const moTextArray&
1308 
1310  return m_CameraDevices;
1314 }
1315 
1316 const moCaptureDevices&
1319  if (reload) {
1321  } /*else m_CaptureDevices = (*m_pLiveSystems->GetVideoFramework()->GetCaptureDevices());*/
1322  }
1323  return m_CaptureDevices;
1324 }
1325 
1327  return m_CircularVideoBuffers.GetRef(cb_idx);
1328 }
1329 
1331  return m_CircularVideoBuffers.Count();
1332 }
1333 
1335  return m_VideoBufferPaths.GetRef(vb_idx);
1336 }
1337 
1339  return m_VideoBufferPaths.Count();
1340 }
1341 
1343 
1344  moVideoBuffer* pVideoBuffer = NULL;
1345 
1346  moVideoBufferPath* pVideoBufferPath = m_VideoBufferPaths.GetRef(vb_idx);
1347 
1348  if (pVideoBufferPath) {
1349  if (pVideoBufferPath->m_VideoBuffers.Count()>0) {
1350  pVideoBuffer = pVideoBufferPath->m_VideoBuffers.GetRef(0);
1351  }
1352  }
1353  return pVideoBuffer;
1354 }
1355 
1357  return m_VideoBufferPaths.Count();
1358 }
1359 
1360 #include <gst/gst.h>
1361 
1363 
1364  moText timecodestr;
1365  MOulonglong years,oneyear;
1366  MOulonglong days,oneday;
1367  MOulonglong hours,onehour;
1368  MOulonglong minutes,oneminute;
1369  MOulonglong seconds,onesecond;
1370  MOulonglong miliseconds,onemilisecond;
1371  //MOulonglong nanos;
1372 
1373  //nanos = 0;
1374  onemilisecond = GST_MSECOND;
1375  onesecond = GST_SECOND;
1376  oneminute = 60 * onesecond;
1377  onehour = 60 * oneminute;
1378  oneday = 24 * onehour;
1379  oneyear = 365 * oneday;
1380 
1381  years = duration / oneyear; duration = duration - years * oneyear;
1382  days = duration / oneday; duration = duration - days * oneday;
1383  hours = duration / onehour; duration = duration - hours * onehour;
1384  minutes = duration / oneminute; duration = duration - minutes * oneminute;
1385  seconds = duration / onesecond; duration = duration - seconds * onesecond;
1386  miliseconds = duration / onemilisecond; duration = duration - miliseconds * onemilisecond;
1387  //nanos = duration - seconds * onesecond;
1388  timecodestr = "";
1389  if (years>0) timecodestr = IntToStr(years) + " years ";
1390  if (days>0) timecodestr+= IntToStr(days) + " days ";
1391  if (hours>0) { timecodestr+= IntToStr(hours,2) + ":"; }
1392  else { timecodestr+= "00:"; }
1393  if (minutes>0) { timecodestr+= IntToStr(minutes,2) + ":"; }
1394  else { timecodestr+= "00:"; }
1395  if (seconds>0) { timecodestr+= IntToStr(seconds,2) + "."; }
1396  else { timecodestr+= "00."; }
1397  if (miliseconds>0) { timecodestr+= IntToStr(miliseconds/10,2); }
1398  else { timecodestr+= "00"; }
1399  return timecodestr;
1400 }
1401 
1402 moText moVideoManager::FramesToTimecode( MOulonglong duration, double framespersecond ) {
1403 
1404  moText timecodestr;
1405  double years,oneyear;
1406  double days,oneday;
1407  double hours,onehour;
1408  double minutes,oneminute;
1409  double seconds,onesecond;
1410  double miliseconds,onemilisecond;
1411  //double nanos;
1412  double frames,durationF;
1413 
1414  //nanos = 0;
1415  onemilisecond = framespersecond/1000.0f;
1416  onesecond = framespersecond;
1417  oneminute = 60 * onesecond;
1418  onehour = 60 * oneminute;
1419  oneday = 24 * onehour;
1420  oneyear = 365 * oneday;
1421  durationF = duration;
1422 
1423  years = moMathd::Floor(durationF / oneyear); duration = duration - (long)(years * oneyear);durationF=duration;
1424  days = moMathd::Floor(durationF / oneday); duration = duration - (long)(days * oneday);durationF=duration;
1425  hours = moMathd::Floor(durationF / onehour); duration = duration - (long)(hours * onehour);durationF=duration;
1426  minutes = moMathd::Floor(durationF / oneminute); duration = duration - (long)(minutes * oneminute);durationF=duration;
1427  seconds = moMathd::Floor(durationF / onesecond); duration = duration - (long)(seconds * onesecond);durationF=duration;
1428  frames = moMathd::Floor(durationF); duration = duration - (long)(frames*1.0);durationF=duration;
1429  miliseconds = moMathd::Floor(durationF / onemilisecond); duration = duration - (long)(miliseconds * onemilisecond);durationF=duration;
1430 
1431  //nanos = duration - seconds * onesecond;
1432  timecodestr = "";
1433  if (years>0) timecodestr = IntToStr((long)years) + " years ";
1434  if (days>0) timecodestr+= IntToStr((long)days) + " days ";
1435  if (hours>0) { timecodestr+= IntToStr((long)hours) + ":"; }
1436  else { timecodestr+= "00:"; }
1437  if (minutes>0) { timecodestr+= IntToStr((long)minutes,2) + ":"; }
1438  else { timecodestr+= "00:"; }
1439  if (seconds>0) {timecodestr+= IntToStr((long)seconds,2) + ":"; }
1440  else { timecodestr+= "00:"; }
1441  if (frames>0) { timecodestr+= IntToStr((long)frames,2) + "."; }
1442  else { timecodestr+= "00."; }
1443  if (miliseconds>0) { timecodestr+= IntToStr((int)miliseconds); }
1444  else { timecodestr+= "000"; }
1445 
1446  return timecodestr;
1447 
1448 }
1449 
1450 
1451 //esto se ejecuta por cada CICLO PRINCIPAL DE moConsole(frame)
1452 //por ahora no nos sirve de nada, porque no mandamos events....ni procesamos events...
1453 //al menos que Ligia...o algun device especial(nada mas el hecho de que se haya
1454 //enchufado la camara por ejemplo
1455 //podriamos poner una funcion aqui de reconocimiento de DV....
1457 {
1458  moBucket *pbucket = NULL;
1459  moEvent *actual,*tmp;
1460  moLiveSystemPtr pLS;
1461  moVideoSample* pSample = NULL;
1462  MOubyte* pbuffer = NULL;
1463 
1464  if(!m_pLiveSystems) return;
1465 
1466  if ( GetId() == MO_MOLDEOOBJECT_UNDEFINED_ID ) return;
1467 
1468  if (m_bAutoReconnect) {
1470  }
1471 
1472  actual = p_EventList->First;
1473  //recorremos todos los events y parseamos el resultado
1474  //borrando aquellos que ya usamos
1475  while(actual!=NULL) {
1476  if(actual->deviceid == GetId() ) {
1477  pLS = m_pLiveSystems->Get(actual->devicecode);
1478  if ( pLS!=NULL ) {
1479  moBucketsPool* pBucketsPool = pLS->GetBucketsPool();
1480  if ( pBucketsPool!=NULL ) {
1481  pBucketsPool->DestroyRetreivedBucket();
1482  }
1483  pSample = (moVideoSample*)actual->pointer;
1484  delete pSample;
1485  pSample = NULL;
1486  }
1487  tmp = actual->next;
1488  p_EventList->Delete(actual);
1489  actual = tmp;
1490  } else actual = actual->next;//no es el que necesitamos...
1491  }
1492 
1493  //aquí moLive da de alta en la lista un evento con su id, devicecode, size y pointer
1494  //a cada vez que tiene un Bucket lleno....
1495  for( MOuint i =0; i< m_pLiveSystems->Count(); i++) {
1496 
1497  pLS = m_pLiveSystems->Get(i);
1498 
1499  if ( pLS!=NULL ) {
1500 
1501  moBucketsPool* pBucketsPool = pLS->GetBucketsPool();
1502 
1503  if ( pBucketsPool!=NULL ) {
1504 
1505  if ( pBucketsPool->IsFull() ) {
1506 
1507  pbucket = pBucketsPool->RetreiveBucket();
1508 
1509  if ( pbucket && pLS->GetVideoGraph() ) {
1510 
1511  pSample = new moVideoSample( pLS->GetVideoGraph()->GetVideoFormat(), (MOpointer) pbucket );
1512 
1514  pLS->GetVideoGraph()->GetState();
1515 
1516  if( pSample!=NULL ) {
1517  //moTexture * ts =(moTexture*)Images[i];
1518  moTexture* ts = (moTexture*) pLS->GetTexture();
1519 
1520  if(ts!=NULL)
1521  {
1522 
1523  if ((ts->GetGLId() == 0) || (ts->GetWidth() != pSample->m_VideoFormat.m_Width))
1524  {
1525  if (ts->GetGLId() != 0) ts->Finish();
1526  ts->BuildEmpty( pSample->m_VideoFormat.m_Width, pSample->m_VideoFormat.m_Height );
1527  }
1528 
1529  pbuffer = pbucket->GetBuffer();
1530 
1531  if (pbuffer) {
1532  pbucket->Lock();
1533 
1534 
1535  moVideoFormat vf = pSample->m_VideoFormat;
1536 
1537  if (vf.m_BitCount>0 && vf.m_BitCount<=64) {
1538 
1539  if (vf.m_RedMask==255 && vf.m_BufferSize>0) {
1541  int bypp = (vf.m_BitCount>>3);
1542  for( int a=0; a<(int)vf.m_BufferSize; a+=bypp ) {
1543  BYTE* pix = &pbuffer[a];
1544  BYTE u = pix[0];
1545  pix[0] = pix[2];
1546  pix[2] = u;
1547  }
1548  }
1549 
1550  ts->SetBuffer( pbuffer, GL_RGB);
1551 
1552  } else {
1553  //MODebug2->Error("moVideoManager::Update > error");
1554 #ifndef OPENGLESV2
1555 #ifdef MO_MACOSX
1556  ts->SetBuffer( pbuffer, GL_RGB);
1557 #else
1558  #ifdef GSTVERSION
1559  ts->SetBuffer( pbuffer, GL_RGB);
1560  #else
1561  ts->SetBuffer( pbuffer, GL_BGR_EXT);
1562  #endif
1563 #endif
1564 #else
1565  ts->SetBuffer( pbuffer, GL_RGB);
1566 #endif
1567 
1568  }
1569 
1570  pbucket->Unlock();
1571  }
1572 
1573  //Update Circular buffers
1574  for( MOuint c=0; c<m_CircularVideoBuffers.Count(); c++) {
1575 
1576  moCircularVideoBuffer* pCircularVideoBuffer;
1577  pCircularVideoBuffer = m_CircularVideoBuffers[c];
1578  if (pCircularVideoBuffer &&
1579  pCircularVideoBuffer->GetVideoInput() == ts->GetName() ) {
1580 
1581  if (pCircularVideoBuffer->IsRecording()) {
1582  pCircularVideoBuffer->LoadSample( pSample );
1583  }
1584 
1585  }
1586 
1587  }
1588  }
1589 
1590  //post to other moldeo objects
1591 
1592  //p_EventList->Add( GetId(), i, -1, (unsigned char*)pSample);
1593  delete pSample;
1594 
1595  //MODebug2->Push( moText("moVideoManager::Update Video Sample") );
1596 
1597  }
1598  pBucketsPool->DestroyRetreivedBucket();
1599 
1600  }
1601 
1602  }
1603 
1604  }
1605 
1606  }
1607  }
1608 
1609 
1610  //LOADING ROUTINE
1611  for(MOuint k=0; k<m_VideoBufferPaths.Count(); k++) {
1612 
1613  moVideoBufferPath* pVideoBufferPath = m_VideoBufferPaths[k];
1614 
1615  if (pVideoBufferPath && !pVideoBufferPath->LoadCompleted()) {
1616  pVideoBufferPath->UpdateImages( 1 );
1617  if ( (pVideoBufferPath->GetImagesProcessed() % 100) == 0) {
1618  MODebug2->Message( pVideoBufferPath->GetPath() + moText(":") + IntToStr(pVideoBufferPath->GetImagesProcessed()));
1619  }
1620  if (pVideoBufferPath->LoadCompleted()) {
1621  MODebug2->Message( "LoadCompleted:" + pVideoBufferPath->GetPath() + moText(":") + IntToStr(pVideoBufferPath->GetImagesProcessed()));
1622  }
1623  }
1624 
1625 
1626 
1627  }
1628 }
1629 
1630 //================================
1631 // Solo soporta 4 camaras DV, 4 webcams, o 2 videos en vivo
1632 //================================
1634 
1635  moBucket *pbucket;
1636 
1637  if (m_pLiveSystems) {
1638 
1639  moLiveSystemPtr pLS = m_pLiveSystems->Get( devcode );
1640 
1641  if (pLS) {
1642  if( pLS->GetBucketsPool() != NULL ) {
1643  pbucket = pLS->GetBucketsPool()->RetreivedBucket();
1644  if(pbucket!=NULL) {
1645  moVideoSample* pSample = NULL;
1646  pSample = pLS->GetVideoSample();
1647  if (pSample!=NULL) {
1648  pSample->SetVideoSample( pLS->GetVideoGraph()->GetVideoFormat(), (MOpointer) pbucket->GetBuffer());
1649  return (MOpointer)pSample;
1650  }
1651  }
1652  }
1653  }
1654 
1655  }
1656 
1657  return NULL;
1658 }
1659 
1660 
1662 {
1663  if (m_pLiveSystems) {
1665  delete m_pLiveSystems;
1666  m_pLiveSystems = NULL;
1667  }
1668  for(MOuint k=0;k<m_VideoBufferPaths.Count();k++) {
1669  moVideoBufferPath* pVideoBufferPath = m_VideoBufferPaths[k];
1670  if (pVideoBufferPath) {
1671  pVideoBufferPath->Finish();
1672  delete pVideoBufferPath;
1673  }
1674  }
1675  m_VideoBufferPaths.Empty();
1676  return true;
1677 }
1678 
1679 
1680 
1681 //=============================================================================================
1682 //
1683 //=============================================================================================
1684 
1685 
1687 
1688  m_pBucketsPool = NULL;
1689  m_pVideoGraph = NULL;
1690  m_pVideoSample = NULL;
1691 
1692  m_Type = LST_UNKNOWN;
1693 
1694 }
1695 
1696 
1698  Finish();
1699 }
1700 
1701 
1703 
1704  m_pBucketsPool = NULL;
1705  m_pVideoGraph = NULL;
1706  m_pVideoSample = NULL;
1707  m_pTexture = NULL;
1708 
1709  m_CaptureDevice = p_capdev;
1710 
1711  //en fuincion del device path: elegimos este
1712  if ( p_capdev.GetPath() != moText("") ) {
1713  m_Type = LST_VIDEOCAMERA;
1714  }
1715 }
1716 
1717 bool
1719 
1720  if ( m_pBucketsPool!=NULL ) Finish();
1721 
1722  m_pBucketsPool = new moBucketsPool();
1723 
1724  #ifdef MO_WIN32
1725  #ifdef MO_DIRECTSHOW
1726  moDsGraph* pDsGraph;
1727  pDsGraph = new moDsGraph();
1728  m_pVideoGraph = (moVideoGraph*) pDsGraph;
1729  #else
1730  moGsGraph* pGsGraph;
1731  pGsGraph = new moGsGraph();
1732  m_pVideoGraph = (moVideoGraph*) pGsGraph;
1733  #endif
1734  #else
1735  moGsGraph* pGsGraph;
1736  pGsGraph = new moGsGraph();
1737  m_pVideoGraph = (moVideoGraph*) pGsGraph;
1738  //ETC...
1739  #endif
1740 
1741  if ( m_pVideoGraph ) {
1742  if (m_pVideoGraph->InitGraph()) {
1743  if( m_pVideoGraph->BuildLiveGraph( m_pBucketsPool , m_CaptureDevice ) ) {
1744  m_CaptureDevice.SetVideoFormat( m_pVideoGraph->GetVideoFormat() );
1745  m_pVideoGraph->Play();
1746  //printf("Device initialized.....\n");
1747  m_pVideoSample = new moVideoSample( m_pVideoGraph->GetVideoFormat(), NULL );
1748  } else Finish();
1749  } else Finish();
1750  } else Finish();
1751 
1752 
1753 
1754  return (m_pBucketsPool && m_pVideoGraph && m_pVideoSample);
1755 
1756 }
1757 
1758 void
1760  if (m_pVideoGraph!=NULL) {
1761  m_pVideoGraph->FinishGraph();
1762  delete m_pVideoGraph;
1763  m_pVideoGraph = NULL;
1764  }
1765 
1766  if (m_pBucketsPool!=NULL) {
1767  delete m_pBucketsPool;
1768  m_pBucketsPool = NULL;
1769  }
1770 
1771  if (m_pVideoSample) {
1772  delete m_pVideoSample;
1773  m_pVideoSample = NULL;
1774  }
1775 }
1776 
1777 void
1779  m_pTexture = p_Texture;
1780 }
1781 
1782 void
1784  m_Type = p_Type;
1785 }
1786 
1789  return m_Type;
1790 }
1791 
1792 moText
1794  return m_CaptureDevice.GetLabelName();
1795 }
1796 
1797 moText
1799  return m_CaptureDevice.GetName();
1800 }
1801 
1802 moVideoGraph*
1804 
1805  return (moVideoGraph*)m_pVideoGraph;
1806 
1807 }
1808 
1811 
1812  return m_pVideoSample;
1813 
1814 }
1815 
1816 
1817 moTexture*
1819  return m_pTexture;
1820 }
1821 
1822 void
1824  m_CaptureDevice = p_capdev;
1825 }
1826 
1829  return m_CaptureDevice;
1830 }
1831 
1834  return m_pBucketsPool;
1835 }
1836 
1837 //=============================================================================================
1838 //
1839 //=============================================================================================
1840 
1842 
1843  m_pVideoFramework = NULL;
1844 
1845  #ifdef MO_DIRECTSHOW
1846  m_pVideoFramework = (moVideoFramework*) new moDsFramework();
1847  #endif
1848 
1849  #ifdef MO_GSTREAMER
1851  #endif
1852 
1853  #ifdef MO_QUICKTIME
1854  m_pVideoFramework = (moVideoFramework*) new moQtFramework();
1855  #endif
1856 }
1857 
1858 
1860  if (m_pVideoFramework!=NULL) {
1861  delete m_pVideoFramework;
1862  m_pVideoFramework = NULL;
1863  }
1864 }
1865 
1866 bool
1867 moLiveSystems::LoadLiveSystems( moCaptureDevices* p_pPreferredDevices ) {
1868 
1869  moText CodeStr;
1870 
1871  //genera los descriptores de dispositivos de captura...
1872  m_pVideoFramework->SetPreferredDevices( p_pPreferredDevices );
1873 
1874  moCaptureDevices* pCapDevs = m_pVideoFramework->LoadCaptureDevices();
1875 
1879  /*
1880  for( i = 0; i < (int)pCapDevs->Count(); i++) {
1881  moLiveSystemPtr pLS = new moLiveSystem( pCapDevs->Get(i) );
1882  if (pLS) {
1883 
1884  Add( pLS );
1885  moDebugManager::Message( moText("Added LiveSystem: CodeName:") + (moText)CodeStr + moText(" Device Name:") + pCapDevs->Get(i).GetName() );
1886  }
1887  }
1888 */
1889  //y el resto de los sistemas los inicializamos vacios
1890  /*
1891  for( i = pCapDevs->Count(); i < 7; i++) {
1892  moCaptureDevice Cap( moText(""), moText(""), moText("") );
1893  Cap.Present(false);
1894  moLiveSystemPtr pLS = new moLiveSystem( Cap );
1895  if (pLS) {
1896  Add( pLS );
1897  }
1898  }
1899 */
1900  return ( pCapDevs->Count() > 0 );
1901 
1902 }
1903 
1904 bool
1906 
1907  moCaptureDevices* pCapDevs = m_pVideoFramework->UpdateCaptureDevices();
1908 
1909  int oldCount = Count();
1910 
1911  for( MOuint i = 0; i < pCapDevs->Count(); i++) {
1912 
1913  if ( pCapDevs->Get(i).IsPresent() ) {
1914 
1915  moLiveSystemPtr pLS = Get(i);
1916 
1917  if ( pLS!=NULL ) {
1918  if ( pLS->GetCaptureDevice().GetPath() == moText("") &&
1919  !pLS->GetCaptureDevice().IsPresent() ) {
1920 
1921  //NEW ONE!!!!!!!!!!
1922  pLS->SetCaptureDevice( pCapDevs->Get(i) );
1923  //Check if it is really present...maybe it was unplugged entering this loop...
1925  m_pVideoFramework->SetPreferredFormat( pCapDevs->Get(i) );
1926  pLS->Init();
1927  }
1928 
1929 
1930 
1931  } else if ( pLS->GetCaptureDevice().GetPath() == pCapDevs->Get(i).GetPath() &&
1932  !pLS->GetCaptureDevice().IsPresent()) {
1933  //RECONNECT: OLD ONE
1935  moCaptureDevice Cap;
1936  Cap = pLS->GetCaptureDevice();
1937  Cap.Present(true);
1938  pLS->SetCaptureDevice( Cap );
1939  pLS->Init();
1940  }
1941  }
1942  }
1943 
1944  /*
1945  if (i>=Count()) {
1946  //ITS A NEW ONE!!! ADD A LIVESYSTEM TO HANDLE IT
1947  moLiveSystemPtr pLS = new moLiveSystem( pCapDevs->Get(i) );
1948  if (pLS) {
1949 
1950  moText CodeStr = "LIVE";
1951  CodeStr+= IntToStr(i);
1952 
1953  pLS->SetCodeName( CodeStr );
1954 
1955  Add( pLS );//beware, count = count + 1
1956  pLS->Init();
1957  }
1958  } else {
1959 
1960  //IT'S AN OLD ONE, BUT MAYBE WASNT CONNECTED BEFORE
1961  moLiveSystemPtr pLS = Get(i);
1962  if ( pLS!=NULL ) {
1963  if ( !pLS->GetVideoGraph()->IsRunning() ) {
1964  //Check if it is really present...maybe it was unplugged entering this loop...
1965  if (m_VideoFramework.CheckCaptureDevice( i )) {
1966  pLS->Init();
1967  } else {
1968  pLS->Finish();
1969  }
1970  }
1971  }
1972 
1973  } */
1974  } else {
1975 
1976  //UNCONNECT IT !!
1977  if ( i<Count() ) {
1978  moLiveSystemPtr pLS = Get(i);
1979  if ( pLS!=NULL && pLS->GetCaptureDevice().IsPresent() ) {
1980  if (pLS->GetVideoGraph()!=NULL) {
1981  if ( !pLS->GetVideoGraph()->IsRunning() ) {
1982  pLS->Finish();//we will reconnect it later if the device is present again
1983  moCaptureDevice Cap;
1984  Cap = pLS->GetCaptureDevice();
1985  Cap.Present(false);
1986  pLS->SetCaptureDevice( Cap );
1987 
1988  }
1989  }
1990  }
1991  }
1992 
1993  }
1994  }
1995 
1996 
1997  return ( (int)Count() > oldCount );
1998 
1999 }
2000 
2001 bool
2003 
2004  moLiveSystemPtr pLS = NULL;
2005 
2007 
2008  for( MOuint i= 0; i< Count(); i++ ) {
2009  pLS = Get(i);
2010  if (pLS!=NULL) {
2011  pLS->Finish();
2012  delete pLS;
2013  pLS = NULL;
2014  }
2015  }
2016  Empty();
2017  return (Count()==0);
2018 }
2019 
2022 
2023  return m_pVideoFramework;
2024 
2025 }
2026 
2027 bool
2029 
2030  moLiveSystemPtr pLS;
2031  pLS = Get( p_devcode );
2032  if (pLS!=NULL) {
2033  if (p_devcode==0) {
2034  return pLS->GetCaptureDevice().IsPresent();
2035  }
2036  return pLS->GetCaptureDevice().IsPresent();
2037  }
2038  return false;
2039 
2040 }
2041 
2042 
2043 //===========================================
2044 //
2045 // moVideoIn
2046 //
2047 //===========================================
2048 
2050 
2051 }
2052 
2054 
2055 }
2056 
2057 MOboolean
2059  return true;
2060 }
2061 
2062 MOboolean
2064  return true;
2065 }
2066 
2067 
2068 //===========================================
2069 //
2070 // moVideoOut
2071 //
2072 //===========================================
2073 
2074 
2076 
2077 }
2078 
2080 
2081 }
2082 
2083 
2084 MOboolean
2086  return true;
2087 }
2088 
2089 MOboolean
2091  return true;
2092 }
2093 
2094 
2095 
virtual MOboolean Finish()
void moBitmap
Definition: moTexture.h:44
#define MO_VIDEO_SOURCEINTERPOLATIONJUMP
virtual void JumpRecording(long at_position)
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
MOint m_SourceWidth
PUERTO DEL DISPOSITIVO.
Definition: moVideoGraph.h:475
moFile * FindFirst()
Definition: moFile.cpp:314
virtual MOboolean Finish()
var b
Definition: jquery.js:16
moEvent * next
Definition: moEventList.h:60
moFileType GetType()
Definition: moFile.cpp:442
moResourceManager * GetResourceManager()
virtual void SetInterpolation(MOuint p_FrameJump, MOuint p_InterpolationTime)
Definition: moTexture.cpp:1457
MOint GetId() const
virtual bool CheckCaptureDevice(int i)=0
Chequea si el dispositivos de video disponible está aún disponible.
buffer de texturas
Definition: moTexture.h:59
moEvent * First
Definition: moEventList.h:145
moText GetLabelName()
moVideoFormat GetVideoFormat()
Devuelve el formato de video.
Clase Evento.
Definition: moEventList.h:56
moBucketsPool * GetBucketsPool()
const moCaptureDevices & GetCaptureDevices(bool reload=true)
#define MO_VIDEO_HEIGHT
void Error(moText p_text)
Anuncia y registra un error.
Definition: moAbstract.cpp:79
GLint internal_format
Definition: moTypes.h:546
int GetSourceHeight() const
Devuelve el alto de la imagen de origen.
Definition: moVideoGraph.h:438
bool DestroyRetreivedBucket()
Definition: moBuckets.cpp:244
void SetName(const moText &p_name)
#define MO_VIDEO_CIRCULARSOURCEWIDTH
moFile * FindNext()
Definition: moFile.cpp:325
#define MO_VIDEO_BUFFERFORMAT
Plataforma de reproducción de video, actualmente GStreamer para todas las plataformas.
Definition: moVideoGraph.h:496
virtual void Start()
Inicia el temporizador.
Definition: moTimer.cpp:196
MOuint m_BufferSize
Definition: moVideoGraph.h:208
#define MO_VIDEO_CIRCULARBUFFERFORMAT
MOint deviceid
Definition: moEventList.h:62
MOpointer pointer
Definition: moEventList.h:68
moValueBase & GetSubValue(MOint p_indexsubvalue=0)
Definition: moValue.h:539
var c
Definition: jquery.js:29
MOuint m_RedMask
Definition: moVideoGraph.h:211
moColorMode
Formatos de codificacion de color.
Definition: moVideoGraph.h:123
moVideoSample * GetVideoSample()
#define MO_LIVE_SCALEWIDTH
MOboolean Delete(moEvent *ev)
MOswitch GetStatus(MOdevcode)
moDefineDynamicArray(moCircularVideoBuffers) moDefineDynamicArray(moVideoFrames) moDefineDynamicArray(moVideoBuffers) moDefineDynamicArray(moLiveSystemPtrs) moDefineDynamicArray(moVideoBufferPaths) moVideoFrame
MOboolean m_bLoading
moCamera * GetCameraByName(const moText &camera, bool load=false, moCaptureDevice customCD=moCaptureDevice())
#define MO_VIDEO_WIDTH
moColorMode m_ColorMode
Definition: moVideoGraph.h:202
virtual bool IsRunning()=0
Está corriendo.
#define MO_VIDEO_CIRCULARSOURCEHEIGHT
moRenderManager * GetRenderMan()
#define MOboolean
Definition: moTypes.h:385
void SetCaptureDevice(moCaptureDevice p_capdev)
virtual long GetRecordPosition()
virtual MOboolean Finish()
void SetType(moLiveSystemType p_Type)
virtual MOboolean Init()
Inicializa el objeto.
#define MO_VIDEO_CIRCULARWIDTH
int GetParamIndex(moText p_paramname)
Devuelve el índice correspondiente al parámetro por nombre.
Definition: moConfig.cpp:1008
MOboolean IsTextureNonPowerOf2Disabled() const
function a
Definition: jquery.js:41
virtual ~moLiveSystem()
MOfloat m_fFramesPerSecond
Definition: moTexture.h:702
bool Unlock()
Libera el acceso al buffer interno.
Definition: moBuckets.cpp:49
void SetVideoFormat(const moVideoFormat &p_videoformat)
Devuelve el formato de video del dispositivo.
Definition: moVideoGraph.h:406
MOswitch SetStatus(MOdevcode, MOswitch)
moCaptureDevices m_CaptureDevices
MOint AddTexture(MOuint p_type, moText p_name, moTexParam p_tex_param=MODefTex2DParams)
void SetResourceType(moResourceType p_restype)
moCaptureDevice GetCaptureDevice()
MOboolean BuildEmpty(MOuint p_width, MOuint p_height)
Definition: moTexture.cpp:113
virtual bool IsRecording()
#define MO_LIVE_BITCOUNT
#define MO_LIVE_LABELNAME
bool Lock()
Paraliza el acceso al buffer interno.
Definition: moBuckets.cpp:45
virtual void CleanCaptureDevices()
Limpia el arreglo de dispositivos de video.
Definition: moVideoGraph.h:566
#define MO_VIDEO_SOURCEINTERPOLATIONTIME
#define MO_LIVE_HEIGHT
#define MO_VIDEO_SOURCEXOFFSET
moFile * Find(MOint index)
Definition: moFile.cpp:352
#define MO_VIDEO_CIRCULARBUFFERFRAMES
virtual void GetFrame(MOuint p_i)
moLiveSystemType GetType()
virtual void PauseRecording()
#define MOswitch
Definition: moTypes.h:386
#define MO_LIVE_SCALEHEIGHT
moBitmapFormat fif
#define MO_LIVE_COLORMODE
MOboolean Exists()
Definition: moFile.cpp:436
static double Floor(doublefValue)
Definition: moMath.h:190
virtual MOboolean Init()
Inicializa el objeto.
virtual MOboolean Init()
moVideoFormat & GetVideoFormat()
Devuelve el formato de video del dispositivo.
Definition: moVideoGraph.h:400
virtual bool FinishGraph()=0
Finalización del grafo.
virtual moText GetVideoInput()
Lista de eventos.
Definition: moEventList.h:139
clase de para manejar textos
Definition: moText.h:75
moTexture * GetTexture(MOuint p_moid)
virtual MOboolean ActivateInterpolation(MOboolean activate=true)
Definition: moTexture.cpp:1562
MOuint GetValuesCount(int p_paramindex)
Devuelve la cantidad de valores que contiene el parámetro indexado.
Definition: moConfig.cpp:1019
virtual MOboolean Init()
Inicializa el objeto.
moResourceManager * m_pResourceManager
Puntero al administrador de recursos.
void Stop()
Detiene el temporizador.
Definition: moTimer.h:219
Grafo de reproducción de video.
Definition: moVideoGraph.h:584
#define MOdevcode
Definition: moTypes.h:412
Dispositivo de entrada/salida, típicamente, interfaces humanas de IO y datos ( teclado, mouse, tableta, tcp, udp, serial )
Definition: moTypes.h:532
if(!b.support.opacity)
Definition: jquery.js:28
moVideoFramework * GetVideoFramework()
Muestra de video o cuadro.
Definition: moVideoGraph.h:290
moTypes MOint moText moParamIndex moParamReference int iRow int int i int i
Definition: all_f.js:18
moCamera * GetCamera(int cam_idx)
void SetCurrentValueIndex(int p_paramindex, int p_valueindex)
Posiciona el puntero de selección del valor del parámetro a la posición indicada. ...
Definition: moConfig.cpp:1470
MOboolean UpdateImages(MOint maxfiles=-1)
bool IsPresent() const
Señala y verifica si está presente el dispositivo.
Definition: moVideoGraph.h:418
moText GetName() const
Definition: moTexture.h:245
virtual bool BuildLiveGraph(moBucketsPool *pBucketsPool, moCaptureDevice p_capdev)=0
Grafo de captura de video.
#define MO_LIVE_DEVICENAME
const moText & GetLabelName() const
Devuelve el nombre de código del dispositivo.
Definition: moVideoGraph.h:428
moText0 moText
Definition: moText.h:291
moConfig m_Config
Configuración de parámetros del objeto.
Buffer de imágenes para video.
virtual ~moVideoBufferPath()
Sistema de tratamiento de una señal en vivo de video.
void SetLabelName(const moText &p_labelname)
Fija el nombre de código del dispositivo.
Definition: moVideoGraph.h:423
Clase de manipulación para el cuadro de un video en memoria.
virtual moStreamState GetState()
Estado de la reproducción.
GStreamer Graph Class.
Definition: moGsGraph.h:151
virtual MOboolean Init()
Inicializa el objeto.
void Present(bool p=true)
Fija la presencia del dispositivo.
Definition: moVideoGraph.h:413
const moText & GetName() const
Devuelve el nombre del dispositivo.
Definition: moVideoGraph.h:380
#define MO_VIDEO_SOURCEHEIGHT
static moText FramesToTimecode(MOulonglong duration, double framespersecond)
#define MOint
Definition: moTypes.h:388
#define MO_MOLDEOOBJECT_UNDEFINED_ID
moFileArray & GetFiles()
Definition: moFile.cpp:381
virtual MOboolean Finish()
Definition: moTexture.cpp:101
virtual ~moLiveSystems()
moFileManager * GetFileMan()
#define MO_VIDEO_SOURCEINTERPOLATION
static moText NanosecondsToTimecode(MOulonglong duration)
Sistema de tratamiento de señales en vivo de video.
virtual void StartRecording(long at_position=-1)
moTexture * GetTexture()
MOuint GetGLId() const
Definition: moTexture.h:224
MOboolean LoadCompleted()
static MOuint NextPowerOf2(MOuint p_seed)
Definition: moTexture.cpp:741
virtual void SetPreferredDevices(moCaptureDevices *p_pPreferredDevices)
Fija los dispositivos predeterminados.
#define MO_VIDEO_CIRCULARBUFFERNAME
clase base para el manejo de una textura
Definition: moTexture.h:78
void Pause()
Congela o pausa el temporizador.
Definition: moTimer.h:231
Administrador de moBucket 's.
Definition: moBuckets.h:152
moDirectory * GetDirectory(moText p_Path)
moText GetCompletePath()
Get inmediate folder name: return "PP" for "PP/myFileName.txt".
Definition: moFile.cpp:538
Administrador de recursos.
película
Definition: moTexture.h:56
virtual moCaptureDevices * LoadCaptureDevices()=0
Carga los dispositivos de video disponibles.
const moText & GetPath() const
Devuelve el camino al dispositivo.
Definition: moVideoGraph.h:390
virtual void StopRecording()
moVideoFramework * m_pVideoFramework
void SetLabelName(const moText &p_labelname)
void Continue()
Prosigue el temporizador.
Definition: moTimer.h:239
virtual ~moVideoFrame()
MOboolean IsConfigLoaded()
Indica si ha sido cargado con éxito el archivo de configuración.
Definition: moConfig.cpp:279
function L
Definition: jquery.js:16
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
MOint GetValue(MOdevcode)
virtual MOboolean Init()
Inicializa el objeto.
virtual void GetFrame(MOuint p_i)
MOuint m_ActualFrame
Definition: moTexture.h:707
int GetSourceWidth() const
Devuelve el ancho de la imagen de origen.
Definition: moVideoGraph.h:433
moTextArray m_CameraDevices
#define MO_VIDEO_CIRCULARSOURCEXOFFSET
void * m_pSampleBuffer
Formato de video de la muestra.
Definition: moVideoGraph.h:327
virtual void SetPreferredFormat(const moCaptureDevice &p_CaptureDevice)
Fija el formato de un dispositivo.
MOuint m_width
Definition: moTexture.h:405
virtual void Play()=0
Reproducir el video.
static moDebug * MODebug2
Clase de impresión de errores para depuración.
Definition: moAbstract.h:225
function d
Definition: jquery.js:41
void SetVideoSample(moVideoFormat p_videoformat, MOpointer p_buffer)
Fija el formato de video y puntero al buffer de datos.
Definition: moVideoGraph.h:321
moLiveSystems * m_pLiveSystems
moCircularVideoBuffers m_CircularVideoBuffers
MOint devicecode
Definition: moEventList.h:63
moDataManager * GetDataMan()
#define MO_LIVE_WIDTH
moText Text()
Definition: moValue.cpp:539
virtual MOboolean Init()
Inicializa el objeto.
Definición de un dispositivo de video, generalmente uno de captura de video, o camara.
Definition: moVideoGraph.h:336
moCamera * CreateCamera(const moCaptureDevice &p_CapDev)
virtual void Update(moEventList *p_EventList)
moTextureType m_type
Definition: moTexture.h:399
Espacio en memoria para compartir datos entre objetos.
Definition: moBuckets.h:53
#define MO_VIDEO_CIRCULARSOURCEYOFFSET
moValue & GetValue(MOint i=-1)
Definition: moParam.cpp:1204
const moTextArray & GetCameraNames()
MOlong m_FrameSize
#define MO_VIDEO_CIRCULARBUFFERINPUT
moParam & GetParam(MOint p_paramindex=-1)
Devuelve el parámetro por índice.
Definition: moConfig.cpp:984
moVideoBufferPaths m_VideoBufferPaths
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
MOpointer GetPointer(MOdevcode devcode)
#define MOulonglong
Definition: moTypes.h:394
#define MO_ON
Definition: moTypes.h:365
moMemory * hmem
bool IsPowerOfTwo(int iValue)
Definition: moMath.h:297
#define MO_VIDEO_SOURCEYOFFSET
void SetName(const moText &p_name)
Definition: moVideoGraph.h:375
MOdevcode GetCode(moText)
moVideoGraph * GetVideoGraph()
moText GetDataPath()
virtual ~moVideoBuffer()
Definition: moMath.h:64
#define MOuint
Definition: moTypes.h:387
moLiveSystemType
virtual MOboolean LoadSample(moVideoSample *pvideosample)
#define MO_LIVE_FLIPV
LIBMOLDEO_API moText0 IntToStr(int a)
Definition: moText.cpp:1070
virtual void ContinueRecording()
bool Started() const
Devuelve el estado del temporizador.
Definition: moTimer.h:248
MOubyte * GetBuffer()
Devuelve el puntero al buffer de datos.
Definition: moBuckets.cpp:58
int GetCircularVideoBufferCount()
moBucket * RetreiveBucket()
Definition: moBuckets.cpp:205
virtual bool InitGraph()=0
Inicialización del grafo.
MOuint m_BitCount
Definition: moVideoGraph.h:207
moCircularVideoBuffer * GetCircularVideoBuffer(int cb_idx)
bool GetStatus(MOdevcode p_devcode)
bool SetCurrentParamIndex(int)
Selecciona el parámetro por el índice.
Definition: moConfig.cpp:1497
MOint Int() const
Definition: moValue.cpp:773
MOuint m_height
Definition: moTexture.h:406
MOuint GetSubValueCount()
Definition: moValue.h:545
Formato de video.
Definition: moVideoGraph.h:155
una textura asociada a una animación de cuadros
Definition: moTexture.h:549
MOboolean m_bInitialized
Valor de inicialización.
Definition: moAbstract.h:223
moBucket * RetreivedBucket()
Definition: moBuckets.cpp:240
virtual ~moVideoManager()
MOboolean LoadImage(moBitmap *pImage, int indeximage=-1)
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
virtual ~moVideoIn()
Buffer Circular de imágenes para video.
moText GetDeviceName()
MOuint GetWidth() const
Definition: moTexture.h:256
void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
Definition: moAbstract.cpp:114
bool LoadLiveSystems(moCaptureDevices *p_pPreferredDevices)
#define MO_LIVE_FLIPH
virtual MOboolean Init()
#define MO_VIDEO_CIRCULARHEIGHT
#define MOpointer
Definition: moTypes.h:409
void SetTexture(moTexture *p_Texture)
virtual ~moVideoOut()
void SetType(moMoldeoObjectType p_type)
var k
Definition: jquery.js:29
#define MOubyte
Definition: moTypes.h:399
moVideoFormat m_VideoFormat
Definition: moVideoGraph.h:326
#define MO_VIDEO_SOURCEWIDTH
moVideoBuffers m_VideoBuffers
moVideoBufferPath * GetVideoBufferPath(int vb_idx)
moVideoBuffer * GetVideoBuffer(int vb_idx)
moTextureManager * GetTextureMan()
MOboolean SetBuffer(const GLvoid *p_buffer, GLenum p_format=GL_RGBA, GLenum p_type=GL_UNSIGNED_BYTE)
Definition: moTexture.cpp:371
#define MO_VIDEO_BUFFERNAME
moTexParam m_param
Definition: moTexture.h:404
virtual moCaptureDevices * UpdateCaptureDevices()=0
Actualiza los dispositivos de video disponibles.