Revision: 4435
          http://pd-gem.svn.sourceforge.net/pd-gem/?rev=4435&view=rev
Author:   zmoelnig
Date:     2011-08-08 14:26:47 +0000 (Mon, 08 Aug 2011)

Log Message:
-----------
split pluginclass "film"  into "film" (interface) and "filmBase" (impl)

Modified Paths:
--------------
    trunk/Gem/src/plugins/Makefile.am
    trunk/Gem/src/plugins/film.cpp
    trunk/Gem/src/plugins/film.h

Added Paths:
-----------
    trunk/Gem/src/plugins/filmBase.cpp
    trunk/Gem/src/plugins/filmBase.h

Modified: trunk/Gem/src/plugins/Makefile.am
===================================================================
--- trunk/Gem/src/plugins/Makefile.am   2011-08-08 14:26:09 UTC (rev 4434)
+++ trunk/Gem/src/plugins/Makefile.am   2011-08-08 14:26:47 UTC (rev 4435)
@@ -29,6 +29,8 @@
         image.h \
         film.cpp \
         film.h \
+        filmBase.cpp \
+        filmBase.h \
         record.cpp \
         record.h \
         recordBase.cpp \

Modified: trunk/Gem/src/plugins/film.cpp
===================================================================
--- trunk/Gem/src/plugins/film.cpp      2011-08-08 14:26:09 UTC (rev 4434)
+++ trunk/Gem/src/plugins/film.cpp      2011-08-08 14:26:47 UTC (rev 4435)
@@ -15,114 +15,11 @@
 /////////////////////////////////////////////////////////
 
 #include "film.h"
-#include <stdlib.h>
+#include "plugins/PluginFactory.h"
 
-/////////////////////////////////////////////////////////
-//
-// film
-//
-/////////////////////////////////////////////////////////
-// Constructor
-//
-/////////////////////////////////////////////////////////
-
-namespace gem { namespace plugins {
-
-class film :: PIMPL {
-public:
-  bool m_thread;
-  PIMPL(bool thread) :
-    m_thread(thread)
-  {
-  };
-};
-
-film :: film(bool threadable) : 
-  m_pimpl(new PIMPL(threadable)),
-#ifdef __APPLE__
-  m_wantedFormat(GL_YUV422_GEM), 
-#else
-  m_wantedFormat(GL_RGBA), 
-#endif
-  m_numFrames(0), m_numTracks(0),
-  m_curFrame(0), m_curTrack(0),
-  m_readNext(false),
-  m_auto(0.f),
-  m_fps(-1.0),
-  m_newfilm(false)
-{}
-
-film :: film(void) : 
-  m_pimpl(new PIMPL(true)),
-#ifdef __APPLE__
-  m_wantedFormat(GL_YUV422_GEM), 
-#else
-  m_wantedFormat(GL_RGBA), 
-#endif
-  m_numFrames(0), m_numTracks(0),
-  m_curFrame(0), m_curTrack(0),
-  m_readNext(false),
-  m_auto(0.f),
-  m_fps(-1.0),
-  m_newfilm(false)
-{}
-
-/////////////////////////////////////////////////////////
-// Destructor
-//
-/////////////////////////////////////////////////////////
-film :: ~film()
-{
-  close();
-  delete m_pimpl; m_pimpl=NULL;
+gem::plugins::film*gem::plugins::film::getInstance(void) {
+ return NULL;
 }
 
-bool film :: isThreadable(void) {
-  return m_pimpl->m_thread;
-}
 
-void film :: close(void)
-{}
-
-/////////////////////////////////////////////////////////
-// do we have a film loaded ?
-//
-/////////////////////////////////////////////////////////
-bool film :: haveFilm()
-{
-  return false;
-}
-#if 0
-/////////////////////////////////////////////////////////
-// render
-//
-/////////////////////////////////////////////////////////
-pixBlock* film :: getFrame(){
-  if(m_newfilm)m_image.newfilm=1;  m_newfilm=false;
-  m_image.newimage=1;
-  unsigned char *dummy=m_image.image.data;
-  int i = m_image.image.xsize*m_image.image.ysize*m_image.image.csize;
-  while(i--)*dummy++=rand()%256;
-  return &m_image;
-}
-#endif
-///////////////////////////////
-// get the frames-per-second
-double film :: getFPS() {
-  // we don't know, so we return "-1"
-  return m_fps;
-}
-
-void film :: setAuto(t_float incr) {
-  m_auto = incr;
-}
-
-int film :: changeImage(int imgNum, int trackNum){
-  return FILM_ERROR_DONTKNOW;
-}
-
-};}; // namespace
-
 INIT_FILMFACTORY();
-
-

Modified: trunk/Gem/src/plugins/film.h
===================================================================
--- trunk/Gem/src/plugins/film.h        2011-08-08 14:26:09 UTC (rev 4434)
+++ trunk/Gem/src/plugins/film.h        2011-08-08 14:26:47 UTC (rev 4435)
@@ -16,11 +16,9 @@
 #ifndef INCLUDE_FILM_H_
 #define INCLUDE_FILM_H_
 
-#include "Base/GemBase.h"
-#include "Gem/Image.h"
-
+#include "Gem/ExportDef.h"
+#include "Gem/GemGL.h"
 #include <string>
-#include "plugins/PluginFactory.h"
 
 /*-----------------------------------------------------------------
   -------------------------------------------------------------------
@@ -35,47 +33,30 @@
   DESCRIPTION
 
   -----------------------------------------------------------------*/
+class pixBlock;
+
 namespace gem { namespace plugins {
 class GEM_EXTERN film
 {
- private:
-  class PIMPL;
-  PIMPL*m_pimpl;
-
-  
-  //////////
-  // Constructor
- protected:  
-  /* initialize the filmloader
-   *
-   * set 'threadable' to false, if your backend is known to be not threadsafe
-   */
-  film(bool threadable);
-
  public:
-  film(void);
-  ////////
-  // Destructor
-  /* free what is apropriate */
-  virtual ~film(void);
+  static film*getInstance(void);
 
- public:
   ////////
   // returns true if instance can be used in thread
-  virtual bool isThreadable(void);
+  virtual bool isThreadable(void) = 0;
 
   //////////
   // set the wanted color-space
   /* could be used for switching the colourspace on the fly 
    * normally the colour-space of a film could be set when opening a movie
    */
-  virtual void requestColor(GLenum format){m_wantedFormat=format;}
+  virtual void requestColor(GLenum format) = 0;
   //////////
   // get the actual color-space
   /* what colour-space is in use ?
    * returns 0 for none
    */    
-  virtual int getColor() {return 0;}
+  virtual int getColor(void) = 0;
 
   //////////
   // open a movie up
@@ -92,15 +73,15 @@
   /* returns TRUE if loading was successfull, FALSE otherwise */
   virtual bool open(const std::string, int format=0) = 0;
   //////////
-  // close the movie fil
+  // close the movie file
   /* close the file and clean up temporary things */
-  virtual void close(void);
+  virtual void close(void) = 0;
 
   //////////
   // do we have a film loaded ?
   /* returns TRUE if it is possible to read frames without any more open()
    */
-  virtual bool haveFilm();
+  virtual bool haveFilm(void) = 0;
 
   //////////
   // get the next frame
@@ -114,30 +95,30 @@
    * if this is a "new" frame (e.g. freshly decoded),
    * pixblock.newimage should be set to 1
    */
-  virtual pixBlock* getFrame() = 0;
+  virtual pixBlock* getFrame(void) = 0;
 
   //////////
   // get the number of frames
   /* the number of frames can depend on the track
    * so this will return the framenum of the current track
    */
-  virtual int getFrameNum(){return m_numFrames;}
+  virtual int getFrameNum(void) = 0;
 
   // get the frames per seconds (or "-1" if unknown)
-  virtual double getFPS();
+  virtual double getFPS(void) = 0;
 
   // get xsize of the frame
-  virtual int getWidth() {return m_image.image.xsize;}
+  virtual int getWidth(void) = 0;
   // get ysize of the frame
-  virtual int getHeight() {return m_image.image.ysize;}
+  virtual int getHeight(void) = 0;
 
 
-  virtual void setAuto(t_float);
+  virtual void setAuto(double) = 0;
 
   /* some error codes */
-#define FILM_ERROR_SUCCESS 0 /* no error */
-#define FILM_ERROR_FAILURE 1
-#define FILM_ERROR_DONTKNOW 2
+  enum errCode { SUCCESS = 0,
+                FAILURE = 1,
+                DONTKNOW= 2 };
 
   //////////
   // Change which image to display
@@ -147,40 +128,7 @@
    * you could also switch between various tracks of a file (if the format 
supports it)
    * specifying trackNum as -1 means "same track as before"
    */
-  virtual int changeImage(int imgNum, int trackNum=-1);
-
- protected:
-  /* i guess every child-class might need (some of the) following variables  */
-
-  /* here the frame is stored
-   */
-  pixBlock m_image;
-  /* this is the colour-space the user requested (like GL_RGBA)
-   */
-  GLenum  m_wantedFormat;
-
-  /* probably a good idea to know how many frames/tracks there are in this 
movie
-   * the number of frames might vary between tracks, so this refers to the 
current track
-   */
-  int  m_numFrames, m_numTracks;
-  /* most often we will also want to know what the current frame/track is...
-   */
-  int  m_curFrame, m_curTrack;
-
-  /* if the (frame,track) is the same as the last time, 
-   * we probably don't want to decode this frame again.
-   * if so m_readNext should be FALSE
-   */
-  bool m_readNext;
-
-  // auto increment
-  t_float m_auto;
-
-  //////////////////////
-  // the frame-rate
-  double m_fps;
-
-  bool m_newfilm;
+  virtual errCode changeImage(int imgNum, int trackNum=-1) = 0;
 };
 
 };}; // namespace gem::plugins

Copied: trunk/Gem/src/plugins/filmBase.cpp (from rev 4434, 
trunk/Gem/src/plugins/film.cpp)
===================================================================
--- trunk/Gem/src/plugins/filmBase.cpp                          (rev 0)
+++ trunk/Gem/src/plugins/filmBase.cpp  2011-08-08 14:26:47 UTC (rev 4435)
@@ -0,0 +1,124 @@
+////////////////////////////////////////////////////////
+//
+// GEM - Graphics Environment for Multimedia
+//
+// zmoel...@iem.kug.ac.at
+//
+// Implementation file 
+//
+//    Copyright (c) 1997-1999 Mark Danks.
+//    Copyright (c) Günther Geiger.
+//    Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM
+//    For information on usage and redistribution, and for a DISCLAIMER OF ALL
+//    WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+//
+/////////////////////////////////////////////////////////
+
+#include "filmBase.h"
+#include <stdlib.h>
+
+/////////////////////////////////////////////////////////
+//
+// film
+//
+/////////////////////////////////////////////////////////
+// Constructor
+//
+/////////////////////////////////////////////////////////
+
+namespace gem { namespace plugins {
+
+class filmBase :: PIMPL {
+public:
+  bool m_thread;
+  PIMPL(bool thread) :
+    m_thread(thread)
+  {  };
+};
+
+  filmBase :: filmBase(bool threadable) : 
+  m_pimpl(new PIMPL(threadable)),
+#ifdef __APPLE__
+  m_wantedFormat(GL_YUV422_GEM), 
+#else
+  m_wantedFormat(GL_RGBA), 
+#endif
+  m_numFrames(0), m_numTracks(0),
+  m_curFrame(0), m_curTrack(0),
+  m_readNext(false),
+  m_auto(0.f),
+  m_fps(-1.0),
+  m_newfilm(false)
+{}
+
+filmBase :: filmBase(void) : 
+  m_pimpl(new PIMPL(true)),
+#ifdef __APPLE__
+  m_wantedFormat(GL_YUV422_GEM), 
+#else
+  m_wantedFormat(GL_RGBA), 
+#endif
+  m_numFrames(0), m_numTracks(0),
+  m_curFrame(0), m_curTrack(0),
+  m_readNext(false),
+  m_auto(0.f),
+  m_fps(-1.0),
+  m_newfilm(false)
+{}
+
+/////////////////////////////////////////////////////////
+// Destructor
+//
+/////////////////////////////////////////////////////////
+filmBase :: ~filmBase()
+{
+  // you must call close in the dtor! of the derived class
+  delete m_pimpl; m_pimpl=NULL;
+}
+
+bool filmBase :: isThreadable(void) {
+  return m_pimpl->m_thread;
+}
+
+void filmBase :: close(void)
+{}
+
+/////////////////////////////////////////////////////////
+// do we have a film loaded ?
+//
+/////////////////////////////////////////////////////////
+bool filmBase :: haveFilm()
+{
+  return false;
+}
+#if 0
+/////////////////////////////////////////////////////////
+// render
+//
+/////////////////////////////////////////////////////////
+pixBlock* filmBase :: getFrame(){
+  if(m_newfilm)m_image.newfilm=1;  m_newfilm=false;
+  m_image.newimage=1;
+  unsigned char *dummy=m_image.image.data;
+  int i = m_image.image.xsize*m_image.image.ysize*m_image.image.csize;
+  while(i--)*dummy++=rand()%256;
+  return &m_image;
+}
+#endif
+///////////////////////////////
+// get the frames-per-second
+double filmBase :: getFPS() {
+  // we don't know, so we return "-1"
+  return m_fps;
+}
+
+void filmBase :: setAuto(double incr) {
+  m_auto = incr;
+}
+
+filmBase::errCode filmBase :: changeImage(int imgNum, int trackNum){
+  return DONTKNOW;
+}
+
+};}; // namespace
+

Copied: trunk/Gem/src/plugins/filmBase.h (from rev 4434, 
trunk/Gem/src/plugins/film.h)
===================================================================
--- trunk/Gem/src/plugins/filmBase.h                            (rev 0)
+++ trunk/Gem/src/plugins/filmBase.h    2011-08-08 14:26:47 UTC (rev 4435)
@@ -0,0 +1,152 @@
+/* -----------------------------------------------------------------
+
+GEM - Graphics Environment for Multimedia
+
+Load an digital video (like AVI, Mpeg, Quicktime) into a pix block 
+(OS independant parent-class)
+
+Copyright (c) 1997-1999 Mark Danks. m...@danks.org
+Copyright (c) Günther Geiger. gei...@epy.co.at
+Copyright (c) 2001-2003 IOhannes m zmoelnig. forum::für::umläute. IEM. 
zmoel...@iem.kug.ac.at
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_FILMBASE_H_
+#define INCLUDE_FILMBASE_H_
+
+#include "plugins/film.h"
+#include "Gem/Image.h"
+
+#include <string>
+
+/*-----------------------------------------------------------------
+  -------------------------------------------------------------------
+  CLASS
+  film
+    
+  parent class for the system- and library-dependent film-loader classes
+    
+  KEYWORDS
+  pix film movie
+    
+  DESCRIPTION
+
+  -----------------------------------------------------------------*/
+namespace gem { namespace plugins {
+class GEM_EXTERN filmBase : public film
+{
+ private:
+  class PIMPL;
+  PIMPL*m_pimpl;
+
+  
+  //////////
+  // Constructor
+ protected:  
+  /* initialize the filmloader
+   *
+   * set 'threadable' to false, if your backend is known to be not threadsafe
+   */
+  filmBase(bool threadable);
+
+ public:
+  filmBase(void);
+  ////////
+  // Destructor
+  /* free what is apropriate */
+  virtual ~filmBase(void);
+
+ public:
+  ////////
+  // returns true if instance can be used in thread
+  virtual bool isThreadable(void);
+
+
+  void close(void);
+
+  //////////
+  // set the wanted color-space
+  /* could be used for switching the colourspace on the fly 
+   * normally the colour-space of a film could be set when opening a movie
+   */
+  virtual void requestColor(GLenum format){m_wantedFormat=format;}
+  //////////
+  // get the actual color-space
+  /* what colour-space is in use ?
+   * returns 0 for none
+   */    
+  virtual int getColor(void) {return 0;}
+
+  //////////
+  // do we have a film loaded ?
+  /* returns TRUE if it is possible to read frames without any more open()
+   */
+  virtual bool haveFilm(void);
+
+  //////////
+  // get the number of frames
+  /* the number of frames can depend on the track
+   * so this will return the framenum of the current track
+   */
+  virtual int getFrameNum(void){return m_numFrames;}
+
+  // get the frames per seconds (or "-1" if unknown)
+  virtual double getFPS(void);
+
+  // get xsize of the frame
+  virtual int getWidth(void) {return m_image.image.xsize;}
+  // get ysize of the frame
+  virtual int getHeight(void) {return m_image.image.ysize;}
+
+
+  virtual void setAuto(double);
+
+  //////////
+  // Change which image to display
+  /* this is the second core function of this class:
+   * most decoding-libraries can set the frame-number on a random-access basis.
+   * some cannot, then this might do nothing
+   * you could also switch between various tracks of a file (if the format 
supports it)
+   * specifying trackNum as -1 means "same track as before"
+   */
+  virtual errCode changeImage(int imgNum, int trackNum=-1);
+
+ protected:
+  /* i guess every child-class might need (some of the) following variables  */
+
+  /* here the frame is stored
+   */
+  pixBlock m_image;
+  /* this is the colour-space the user requested (like GL_RGBA)
+   */
+  GLenum  m_wantedFormat;
+
+  /* probably a good idea to know how many frames/tracks there are in this 
movie
+   * the number of frames might vary between tracks, so this refers to the 
current track
+   */
+  int  m_numFrames, m_numTracks;
+  /* most often we will also want to know what the current frame/track is...
+   */
+  int  m_curFrame, m_curTrack;
+
+  /* if the (frame,track) is the same as the last time, 
+   * we probably don't want to decode this frame again.
+   * if so m_readNext should be FALSE
+   */
+  bool m_readNext;
+
+  // auto increment
+  double m_auto;
+
+  //////////////////////
+  // the frame-rate
+  double m_fps;
+
+  bool m_newfilm;
+};
+
+};}; // namespace gem::plugins
+
+#endif // for header file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
pd-gem-CVS mailing list
pd-gem-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pd-gem-cvs

Reply via email to