Commit 92e31370 authored by zmoelnig's avatar zmoelnig
Browse files

moved record into gem::plugins namespace

git-svn-id: https://pd-gem.svn.sourceforge.net/svnroot/pd-gem/trunk/Gem@4292 49b2a0ca-c541-4d49-a7ef-d785e4371512
parent a950a6ca
......@@ -18,15 +18,15 @@ public:
~PIMPL(void) {};
struct codechandle {
codechandle(gem::record*h, const std::string c):handle(h), codec(c) {}
codechandle(gem::plugins::record*h, const std::string c):handle(h), codec(c) {}
gem::record*handle;
gem::plugins::record*handle;
std::string codec;
};
std::map<std::string, std::vector<codechandle> >m_codechandle;
std::vector<std::string>m_codecs;
void addCodecHandle(gem::record*handle, const std::string codec) {
void addCodecHandle(gem::plugins::record*handle, const std::string codec) {
#ifdef __GNUC__
# warning better handling of duplicate codecs
#endif
......@@ -111,8 +111,8 @@ pix_record :: pix_record(int argc, t_atom *argv):
m_outInfo = outlet_new(this->x_obj, 0);
gem::PluginFactory<gem::record>::loadPlugins("record");
std::vector<std::string>ids=gem::PluginFactory<gem::record>::getIDs();
gem::PluginFactory<gem::plugins::record>::loadPlugins("record");
std::vector<std::string>ids=gem::PluginFactory<gem::plugins::record>::getIDs();
addHandle(ids, "QT");
addHandle(ids, "QT4L");
addHandle(ids);
......@@ -171,10 +171,10 @@ bool pix_record :: addHandle( std::vector<std::string>available, std::string ID)
verbose(2, "trying to add '%s' as backend", key.c_str());
if(std::find(m_ids.begin(), m_ids.end(), key)==m_ids.end()) {
// not yet added, do so now!
gem::record *handle=NULL;
gem::plugins::record *handle=NULL;
startpost("backend #%d='%s'\t", m_allhandles.size(), key.c_str());
try {
handle=gem::PluginFactory<gem::record>::getInstance(key);
handle=gem::PluginFactory<gem::plugins::record>::getInstance(key);
} catch (GemException ex) {
}
if(NULL==handle) {
......@@ -213,7 +213,7 @@ void pix_record :: startRecording()
unsigned int i=0;
for(i=0; i<m_handles.size(); i++) {
// check whether the handle supports the requested codec
gem::record *handle=m_handles[i];
gem::plugins::record *handle=m_handles[i];
if(!codec.empty() && !handle->setCodec(codec))
continue;
if(handle->start(m_filename, m_props)) {
......@@ -386,7 +386,7 @@ void pix_record :: getCodecList()
std::vector<PIMPL::codechandle>handles=m_pimpl->m_codechandle[id];
unsigned int j=0;
for(j=0; j<handles.size(); j++) {
gem::record*handle=handles[j].handle;
gem::plugins::record*handle=handles[j].handle;
const std::string codecname=handles[j].codec;
const std::string descr=handle->getCodecDescription(codecname);
......@@ -445,7 +445,7 @@ void pix_record :: codecMess(t_atom *argv)
m_handles.clear();
unsigned int i=0;
for(i=0; i<handles.size(); i++) {
gem::record*handle=handles[i].handle;
gem::plugins::record*handle=handles[i].handle;
std::string codec=handles[i].codec;
if(handle->setCodec(codec)) {
m_codec=codec;
......
......@@ -112,10 +112,10 @@ class GEM_EXTERN pix_record : public GemBase
private:
bool m_recording;
gem::record *m_handle;
gem::plugins::record *m_handle;
std::vector<std::string>m_ids;
std::vector<gem::record*>m_handles;
std::vector<gem::record*>m_allhandles;
std::vector<gem::plugins::record*>m_handles;
std::vector<gem::plugins::record*>m_allhandles;
virtual bool addHandle(std::vector<std::string>available_ids, std::string id=std::string(""));
//////////
// static member functions
......
......@@ -15,11 +15,21 @@
/////////////////////////////////////////////////////////
#include "plugins/record.h"
using namespace gem;
#include "Gem/RTE.h"
#include <stdlib.h>
using namespace gem::plugins;
class record :: PIMPL {
public:
bool running;
PIMPL(void) :
running(false)
{}
};
/////////////////////////////////////////////////////////
//
// record
......@@ -29,7 +39,7 @@ using namespace gem;
//
/////////////////////////////////////////////////////////
record :: record()
record :: record() : m_pimpl(new PIMPL())
{}
/////////////////////////////////////////////////////////
......@@ -38,7 +48,11 @@ record :: record()
/////////////////////////////////////////////////////////
record :: ~record()
{
close();
if(m_pimpl->running) {
error("record: implementation forgot to call close() - please report a bug!");
}
delete m_pimpl;
m_pimpl=NULL;
}
void record :: close(void)
......@@ -50,29 +64,29 @@ void record :: close(void)
/////////////////////////////////////////////////////////
bool record :: start(const std::string filename, gem::Properties&props)
{
if(m_running)close();
m_running=false;
if(m_pimpl->running)close();
m_pimpl->running=false;
m_props=props;
m_running=open(filename);
m_pimpl->running=open(filename);
return m_running;
return m_pimpl->running;
}
void record :: stop()
{
if(m_running)
if(m_pimpl->running)
close();
m_running=false;
m_pimpl->running=false;
}
bool record::write(imageStruct*img) {
if(!m_running)
if(!m_pimpl->running)
return false;
if(!img) {
return true;
}
m_running=putFrame(img);
return m_running;
m_pimpl->running=putFrame(img);
return m_pimpl->running;
}
bool record :: open(const std::string filename)
......
......@@ -34,36 +34,18 @@ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
DESCRIPTION
-----------------------------------------------------------------*/
namespace gem { class GEM_EXTERN record
namespace gem { namespace plugins {
class GEM_EXTERN record
{
public:
//////////
// Constructor
/* initialize the recordloader
*
* set the default colour-space to format (like GL_RGBA)
* if format==0, the default is set by the recordloader
* (for instance: the fastest colour-space)
*/
record(void);
////////
// Destructor
/* free what is apropriate */
virtual ~record();
protected:
//////////
// 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*);
// 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
......@@ -76,20 +58,13 @@ namespace gem { class GEM_EXTERN record
/* stop recording, close the file and clean up temporary things */
virtual void close(void);
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?)
*/
virtual bool putFrame(imageStruct*)=0;
//////////
// popup a dialog to set the codec interactively (interesting on os-x and w32)
virtual bool dialog();
/**
* get a list of supported codecs (short-form names, e.g. "mjpa")
*/
......@@ -98,25 +73,52 @@ namespace gem { class GEM_EXTERN record
* get a human readable description of the given codec (e.g. "Motion Jpeg A")
*/
virtual const std::string getCodecDescription(const std::string codecname);
// map codec-names to codec-descriptions
std::map<std::string, std::string>m_codecdescriptions;
/**
* set the current codec
*/
virtual bool setCodec(const std::string name);
/**
* list all properties the currently selected codec supports
* if the enumeration fails, this returns <code>false</code>
*/
virtual bool enumProperties(gem::Properties&props);
gem::Properties m_props;
private:
bool m_running;
public:
//////////
// Constructor
/* initialize the recordloader
*/
record(void);
////////
// 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;
};
}; };
......@@ -127,7 +129,7 @@ namespace gem { class GEM_EXTERN record
* \param id a symbolic (const char*) ID for the given class
* \param recordClass a class derived from "record"
*/
#define REGISTER_RECORDFACTORY(id, TYP) static gem::PluginFactoryRegistrar::registrar<TYP, gem::record> fac_record_ ## TYP (gensym(id)->s_name)
#define REGISTER_RECORDFACTORY(id, TYP) static gem::PluginFactoryRegistrar::registrar<TYP, gem::plugins::record> fac_record_ ## TYP (gensym(id)->s_name)
/**
......@@ -136,7 +138,7 @@ namespace gem { class GEM_EXTERN record
* \note call this before any externals register themselves
*/
#define INIT_RECORDFACTORY() \
static gem::PluginFactoryRegistrar::dummy<gem::record> fac_recorddummy
static gem::PluginFactoryRegistrar::dummy<gem::plugins::record> fac_recorddummy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment