Revision: 4428 http://pd-gem.svn.sourceforge.net/pd-gem/?rev=4428&view=rev Author: zmoelnig Date: 2011-08-08 14:21:51 +0000 (Mon, 08 Aug 2011)
Log Message: ----------- split 'record' class into interface and baseclass Modified Paths: -------------- trunk/Gem/src/plugins/Makefile.am trunk/Gem/src/plugins/record.cpp trunk/Gem/src/plugins/record.h Added Paths: ----------- trunk/Gem/src/plugins/recordBase.cpp trunk/Gem/src/plugins/recordBase.h Modified: trunk/Gem/src/plugins/Makefile.am =================================================================== --- trunk/Gem/src/plugins/Makefile.am 2011-08-08 14:21:15 UTC (rev 4427) +++ trunk/Gem/src/plugins/Makefile.am 2011-08-08 14:21:51 UTC (rev 4428) @@ -31,6 +31,8 @@ film.h \ record.cpp \ record.h \ + recordBase.cpp \ + recordBase.h \ video.cpp \ video.h @@ -43,4 +45,5 @@ imageloader.h \ imagesaver.h \ record.h \ + recordBase.h \ video.h Modified: trunk/Gem/src/plugins/record.cpp =================================================================== --- trunk/Gem/src/plugins/record.cpp 2011-08-08 14:21:15 UTC (rev 4427) +++ trunk/Gem/src/plugins/record.cpp 2011-08-08 14:21:51 UTC (rev 4428) @@ -7,137 +7,19 @@ // 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 +// Copyright (c) G\xFCnther Geiger. +// Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::f\xFCr::uml\xE4ute. IEM // For information on usage and redistribution, and for a DISCLAIMER OF ALL // WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. // ///////////////////////////////////////////////////////// #include "plugins/record.h" -#include "Gem/RTE.h" +#include "plugins/PluginFactory.h" -#include <stdlib.h> - -using namespace gem::plugins; - -class record :: PIMPL { -public: - bool running; - PIMPL(void) : - running(false) - {} -}; - - -///////////////////////////////////////////////////////// -// -// record -// -///////////////////////////////////////////////////////// -// Constructor -// -///////////////////////////////////////////////////////// - -record :: record() : m_pimpl(new PIMPL()) -{} - -///////////////////////////////////////////////////////// -// Destructor -// -///////////////////////////////////////////////////////// -record :: ~record() -{ - if(m_pimpl->running) { - error("record: implementation forgot to call close() - please report a bug!"); - } - delete m_pimpl; - m_pimpl=NULL; +gem::plugins::record*gem::plugins::record::getInstance(void) { + return NULL; } -void record :: close(void) -{} -///////////////////////////////////////////////////////// -// open a file ! -// -///////////////////////////////////////////////////////// -bool record :: start(const std::string filename, gem::Properties&props) -{ - if(m_pimpl->running)close(); - m_pimpl->running=false; - m_props=props; - - m_pimpl->running=open(filename); - - return m_pimpl->running; -} -void record :: stop() -{ - if(m_pimpl->running) - close(); - m_pimpl->running=false; -} - -bool record::write(imageStruct*img) { - if(!m_pimpl->running) - return false; - if(!img) { - return true; - } - m_pimpl->running=putFrame(img); - return m_pimpl->running; -} - -bool record :: open(const std::string filename) -{ - return false; -} - -///////////////////////////////////////////////////////// -// set the codec -// -///////////////////////////////////////////////////////// -bool record :: dialog() -{ - return false; -} - -///////////////////////////////////////////////////////// -// get number of codecs -// -///////////////////////////////////////////////////////// -std::vector<std::string>record :: getCodecs() -{ - std::vector<std::string>result; - m_codecdescriptions.clear(); - return result; -} -const std::string record :: getCodecDescription(const std::string name) -{ - std::map<std::string,std::string>::iterator it = m_codecdescriptions.find(name); - - if(it==m_codecdescriptions.end()) { - return name; - } - - return it->second; -} - - -///////////////////////////////////////////////////////// -// set codec by name -// -///////////////////////////////////////////////////////// -bool record :: setCodec(const std::string name) -{ - return false; -} - -bool record :: enumProperties(gem::Properties&props) -{ - props.clear(); - return false; -} - INIT_RECORDFACTORY(); Modified: trunk/Gem/src/plugins/record.h =================================================================== --- trunk/Gem/src/plugins/record.h 2011-08-08 14:21:15 UTC (rev 4427) +++ trunk/Gem/src/plugins/record.h 2011-08-08 14:21:51 UTC (rev 4428) @@ -3,7 +3,7 @@ GEM - Graphics Environment for Multimedia Load an digital video (like AVI, Mpeg, Quicktime) into a pix block -(OS independant parent-class) +(OS independant interface) Copyright (c) 2010-2011 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 @@ -16,8 +16,6 @@ #include "Gem/Image.h" #include "Gem/Properties.h" -#include "plugins/PluginFactory.h" - #include <string> @@ -37,91 +35,61 @@ namespace gem { namespace plugins { class GEM_EXTERN record { - protected: - +public: ////////// - // compress and write the next frame - /* this is the core-function of this class !!!! - * when called it returns something depending on success - * (what? the framenumber and -1 (0?) on failure?) + // start recording + /* + * returns TRUE if opening was successfull, FALSE otherwise */ - virtual bool putFrame(imageStruct*)=0; + virtual bool start(const std::string filename, gem::Properties&props) = 0; ////////// - // open a movie up - /* open the record "filename" (think better about URIs ?) - */ - /* returns TRUE if opening was successfull, FALSE otherwise */ - virtual bool open(const std::string filename); - ////////// - // close the movie file - /* stop recording, close the file and clean up temporary things */ - virtual void close(void); + // stop recording + virtual void stop (void) = 0; -public: - - ////////// - // popup a dialog to set the codec interactively (interesting on os-x and w32) - virtual bool dialog(); + // record a frame (wrapper around putFrame() + virtual bool write(imageStruct*) = 0; /** * get a list of supported codecs (short-form names, e.g. "mjpa") */ - virtual std::vector<std::string>getCodecs(void); + virtual std::vector<std::string>getCodecs(void) = 0; /** * get a human readable description of the given codec (e.g. "Motion Jpeg A") */ - virtual const std::string getCodecDescription(const std::string codecname); + virtual const std::string getCodecDescription(const std::string codecname) = 0; /** * set the current codec */ - virtual bool setCodec(const std::string name); + virtual bool setCodec(const std::string name) = 0; /** * list all properties the currently selected codec supports * if the enumeration fails, this returns <code>false</code> */ - virtual bool enumProperties(gem::Properties&props); + virtual bool enumProperties(gem::Properties&props) = 0; - - public: - ////////// - // Constructor - - /* initialize the recordloader - */ - record(void); + // popup a dialog to set the codec interactively (interesting on os-x and w32) + virtual bool dialog() = 0; - //////// - // Destructor - /* free what is apropriate */ - virtual ~record(); ////////// - // start/stop recording - /* these are the handles for pix_record to open/close - * returns TRUE if opening was successfull, FALSE otherwise */ - bool start(const std::string filename, gem::Properties&props); - void stop (void); - ////////// - // record a frame (wrapper around putFrame() - bool write(imageStruct*); - - protected: - // map codec-names to codec-descriptions - std::map<std::string, std::string>m_codecdescriptions; - // write properties - gem::Properties m_props; - - private: - class PIMPL; - PIMPL*m_pimpl; + // returns an instance wrapping all plugins or NULL + // if NULL is returned, you might still try your luck with manually accessing the + // PluginFactory + static record*getInstance(void); }; }; }; + +/* + * factory code: + * to use these macros, you have to include "plugins/PluginFactory.h" + */ + /** * \fn REGISTER_RECORDFACTORY(const char *id, Class recordClass) * registers a new class "recordClass" with the record-factory Copied: trunk/Gem/src/plugins/recordBase.cpp (from rev 4427, trunk/Gem/src/plugins/record.cpp) =================================================================== --- trunk/Gem/src/plugins/recordBase.cpp (rev 0) +++ trunk/Gem/src/plugins/recordBase.cpp 2011-08-08 14:21:51 UTC (rev 4428) @@ -0,0 +1,141 @@ +//////////////////////////////////////////////////////// +// +// 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 "plugins/recordBase.h" +#include "Gem/RTE.h" + +#include <stdlib.h> + +using namespace gem::plugins; + +class recordBase :: PIMPL { +public: + bool running; + PIMPL(void) : + running(false) + {} +}; + + +///////////////////////////////////////////////////////// +// +// recordBase +// +///////////////////////////////////////////////////////// +// Constructor +// +///////////////////////////////////////////////////////// + +recordBase :: recordBase() : m_pimpl(new PIMPL()) +{} + +///////////////////////////////////////////////////////// +// Destructor +// +///////////////////////////////////////////////////////// +recordBase :: ~recordBase() +{ + if(m_pimpl->running) { + error("record: implementation forgot to call close() - please report a bug!"); + } + delete m_pimpl; + m_pimpl=NULL; +} + +void recordBase :: close(void) +{} + +///////////////////////////////////////////////////////// +// open a file ! +// +///////////////////////////////////////////////////////// +bool recordBase :: start(const std::string filename, gem::Properties&props) +{ + if(m_pimpl->running)close(); + m_pimpl->running=false; + m_props=props; + + m_pimpl->running=open(filename); + + return m_pimpl->running; +} +void recordBase :: stop() +{ + if(m_pimpl->running) + close(); + m_pimpl->running=false; +} + +bool recordBase::write(imageStruct*img) { + if(!m_pimpl->running) + return false; + if(!img) { + return true; + } + m_pimpl->running=putFrame(img); + return m_pimpl->running; +} + +bool recordBase :: open(const std::string filename) +{ + return false; +} + +///////////////////////////////////////////////////////// +// set the codec +// +///////////////////////////////////////////////////////// +bool recordBase :: dialog() +{ + return false; +} + +///////////////////////////////////////////////////////// +// get number of codecs +// +///////////////////////////////////////////////////////// +std::vector<std::string>recordBase :: getCodecs() +{ + std::vector<std::string>result; + m_codecdescriptions.clear(); + return result; +} +const std::string recordBase :: getCodecDescription(const std::string name) +{ + std::map<std::string,std::string>::iterator it = m_codecdescriptions.find(name); + + if(it==m_codecdescriptions.end()) { + return name; + } + + return it->second; +} + + +///////////////////////////////////////////////////////// +// set codec by name +// +///////////////////////////////////////////////////////// +bool recordBase :: setCodec(const std::string name) +{ + return false; +} + +bool recordBase :: enumProperties(gem::Properties&props) +{ + props.clear(); + return false; +} Copied: trunk/Gem/src/plugins/recordBase.h (from rev 4427, trunk/Gem/src/plugins/record.h) =================================================================== --- trunk/Gem/src/plugins/recordBase.h (rev 0) +++ trunk/Gem/src/plugins/recordBase.h 2011-08-08 14:21:51 UTC (rev 4428) @@ -0,0 +1,110 @@ +/* ----------------------------------------------------------------- + +GEM - Graphics Environment for Multimedia + +Load an digital video (like AVI, Mpeg, Quicktime) into a pix block +(OS independant parent-class) + +Copyright (c) 2010-2011 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_PLUGINS_RECORDBASE_H_ +#define INCLUDE_PLUGINS_RECORDBASE_H_ + +#include "plugins/record.h" +#include <map> + +/*----------------------------------------------------------------- + ------------------------------------------------------------------- + CLASS + recordBase + + parent class for the system- and library-dependent record-loader classes + + KEYWORDS + pix record movie + + DESCRIPTION + + -----------------------------------------------------------------*/ +namespace gem { namespace plugins { + GEM_EXTERN class recordBase : public record +{ + protected: + + ////////// + // compress and write the next frame + /* this is the core-function of this class !!!! + * when called it returns something depending on success + * (what? the framenumber and -1 (0?) on failure?) + */ + virtual bool putFrame(imageStruct*)=0; + + ////////// + // open a movie up + /* open the record "filename" (think better about URIs ?) + */ + /* returns TRUE if opening was successfull, FALSE otherwise */ + virtual bool open(const std::string filename); + ////////// + // close the movie file + /* stop recording, close the file and clean up temporary things */ + virtual void close(void); + +public: + virtual bool start(const std::string filename, gem::Properties&props); + virtual void stop (void); + virtual bool write(imageStruct*); + + /* + * default implementation: return FALSE + */ + virtual bool dialog(void); + + /** + * default implementation: return empty list + */ + virtual std::vector<std::string>getCodecs(void); + /** + * default implementation: return empty string + */ + virtual const std::string getCodecDescription(const std::string codecname); + /** + * default implementation: return FALSE + */ + virtual bool setCodec(const std::string name); + /** + * default implementation: return empty propset + */ + virtual bool enumProperties(gem::Properties&props); + + public: + + ////////// + // Constructor + + /* initialize the recordloader + */ + recordBase(void); + + //////// + // Destructor + /* free what is apropriate */ + virtual ~recordBase(void); + + protected: + // map codec-names to codec-descriptions + std::map<std::string, std::string>m_codecdescriptions; + // write properties + gem::Properties m_props; + + private: + class PIMPL; + PIMPL*m_pimpl; + }; +}; }; + +#endif // for header file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ BlackBerry® 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