Save & Load Device Source.

This commit is contained in:
brunoherbelin
2020-09-25 22:03:31 +02:00
parent a4ff2a325f
commit 69c74aa103
5 changed files with 24 additions and 3 deletions

View File

@@ -221,10 +221,11 @@ void DeviceSource::setDevice(const std::string &devicename)
// test the device and get config
DeviceConfigSet confs = Device::manager().config(index);
// for( DeviceInfoSet::iterator it = confs.begin(); it != confs.end(); it++ ){
// Log::Info("config possible : %s %dx%d @ %d fps", (*it).format.c_str(), (*it).width, (*it).height, (*it).fps_numerator);
// }
// for( DeviceConfigSet::iterator it = confs.begin(); it != confs.end(); it++ ){
// Log::Info("config possible : %s %dx%d @ %d fps", (*it).format.c_str(), (*it).width, (*it).height, (*it).fps_numerator);
// }
DeviceConfigSet::reverse_iterator best = confs.rbegin();
Log::Info("Auto select optimal config for '%s': %s %dx%d @ %d fps", device_.c_str(), (*best).format.c_str(), (*best).width, (*best).height, (*best).fps_numerator);
pipeline << " ! " << (*best).format;
pipeline << ",framerate=" << (*best).fps_numerator << "/" << (*best).fps_denominator;

View File

@@ -118,6 +118,11 @@ void SessionCreator::loadSession(XMLElement *sessionNode)
new_pattern_source->accept(*this);
session_->addSource(new_pattern_source);
}
else if ( std::string(pType) == "DeviceSource") {
DeviceSource *new_pattern_source = new DeviceSource;
new_pattern_source->accept(*this);
session_->addSource(new_pattern_source);
}
// TODO : create other types of source
}
@@ -348,5 +353,11 @@ void SessionCreator::visit (PatternSource& s)
s.setPattern(p, resolution);
}
void SessionCreator::visit (DeviceSource& s)
{
const char *devname = xmlCurrent_->Attribute("device");
s.setDevice(devname);
}

View File

@@ -49,6 +49,7 @@ public:
void visit (MediaSource& s) override;
void visit (SessionSource& s) override;
void visit (PatternSource& s) override;
void visit (DeviceSource& s) override;
static std::string info(const std::string& filename);
static void XMLToNode(tinyxml2::XMLElement *xml, Node &n);

View File

@@ -8,6 +8,7 @@
#include "MediaSource.h"
#include "SessionSource.h"
#include "PatternSource.h"
#include "DeviceSource.h"
#include "ImageShader.h"
#include "ImageProcessingShader.h"
#include "MediaPlayer.h"
@@ -390,3 +391,9 @@ void SessionVisitor::visit (PatternSource& s)
resolution->InsertEndChild( XMLElementFromGLM(xmlDoc_, s.pattern()->resolution() ) );
xmlCurrent_->InsertEndChild(resolution);
}
void SessionVisitor::visit (DeviceSource& s)
{
xmlCurrent_->SetAttribute("type", "DeviceSource");
xmlCurrent_->SetAttribute("device", s.device().c_str() );
}

View File

@@ -45,6 +45,7 @@ public:
void visit (RenderSource& s) override;
void visit (CloneSource& s) override;
void visit (PatternSource& s) override;
void visit (DeviceSource& s) override;
static tinyxml2::XMLElement *NodeToXML(Node &n, tinyxml2::XMLDocument *doc);
};