[DEV] continue configuration
This commit is contained in:
parent
5b858de808
commit
8cd0fe0b88
@ -21,7 +21,7 @@ void eaudiofx::GeneratorSignal::init() {
|
|||||||
|
|
||||||
eaudiofx::GeneratorSignal::GeneratorSignal() :
|
eaudiofx::GeneratorSignal::GeneratorSignal() :
|
||||||
m_phase(0),
|
m_phase(0),
|
||||||
m_output(*this, "out", "Output sinus generated", "{ type:'audio', freq:48000, format:'int16', channels:2}") {
|
m_output(*this, "out", "Output sinus generated", "{ type:'audio', freq:48000, format:['int16','int32'], channels:2}") {
|
||||||
addObjectType("eaudiofx::GeneratorSignal");
|
addObjectType("eaudiofx::GeneratorSignal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,3 +207,43 @@ void eaudiofx::BlockMeta::flowLinkInput() {
|
|||||||
// Call upper class
|
// Call upper class
|
||||||
eaudiofx::Block::flowLinkInput();
|
eaudiofx::Block::flowLinkInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void eaudiofx::BlockMeta::flowCheckAllCompatibility() {
|
||||||
|
EAUDIOFX_INFO("[" << getId() << "] Meta block check compatibilities: '" << getName() << "'");
|
||||||
|
// find in sub elements.
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if (it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it->flowCheckAllCompatibility();
|
||||||
|
}
|
||||||
|
// Call upper class
|
||||||
|
eaudiofx::Block::flowCheckAllCompatibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
void eaudiofx::BlockMeta::flowAllocateOutput() {
|
||||||
|
EAUDIOFX_INFO("[" << getId() << "] Meta block allocate output: '" << getName() << "'");
|
||||||
|
// find in sub elements.
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if (it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it->flowAllocateOutput();
|
||||||
|
}
|
||||||
|
// Call upper class
|
||||||
|
eaudiofx::Block::flowAllocateOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
void eaudiofx::BlockMeta::flowGetInput() {
|
||||||
|
EAUDIOFX_INFO("[" << getId() << "] Meta block get input ... : '" << getName() << "'");
|
||||||
|
// find in sub elements.
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if (it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it->flowGetInput();
|
||||||
|
}
|
||||||
|
// Call upper class
|
||||||
|
eaudiofx::Block::flowGetInput();
|
||||||
|
}
|
||||||
|
@ -84,6 +84,9 @@ namespace eaudiofx {
|
|||||||
|
|
||||||
virtual std::shared_ptr<eaudiofx::Block> getBlockNamed(const std::string& _name);
|
virtual std::shared_ptr<eaudiofx::Block> getBlockNamed(const std::string& _name);
|
||||||
virtual void flowLinkInput();
|
virtual void flowLinkInput();
|
||||||
|
virtual void flowCheckAllCompatibility();
|
||||||
|
virtual void flowAllocateOutput();
|
||||||
|
virtual void flowGetInput();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,14 +41,19 @@ int32_t eaudiofx::Processing::waitEndOfProcess() {
|
|||||||
bool eaudiofx::Processing::stateStart() {
|
bool eaudiofx::Processing::stateStart() {
|
||||||
EAUDIOFX_INFO("Start Processing : '" << getName() << "'");
|
EAUDIOFX_INFO("Start Processing : '" << getName() << "'");
|
||||||
// TODO : Add return code ... and test all of theses events ...
|
// TODO : Add return code ... and test all of theses events ...
|
||||||
|
EAUDIOFX_ERROR("======================================");
|
||||||
// Init request flow update:
|
// Init request flow update:
|
||||||
flowLinkInput();
|
flowLinkInput();
|
||||||
|
EAUDIOFX_ERROR("======================================");
|
||||||
// check if the IOs are compatible
|
// check if the IOs are compatible
|
||||||
flowCheckAllCompatibility();
|
flowCheckAllCompatibility();
|
||||||
|
EAUDIOFX_ERROR("======================================");
|
||||||
// Allocate all Outputs
|
// Allocate all Outputs
|
||||||
flowAllocateOutput();
|
flowAllocateOutput();
|
||||||
|
EAUDIOFX_ERROR("======================================");
|
||||||
// Get pointer on all Inputs
|
// Get pointer on all Inputs
|
||||||
flowGetInput();
|
flowGetInput();
|
||||||
|
EAUDIOFX_ERROR("======================================");
|
||||||
// init algorithm
|
// init algorithm
|
||||||
int32_t ret = algoInit();
|
int32_t ret = algoInit();
|
||||||
if (ret != eaudiofx::ERR_NONE) {
|
if (ret != eaudiofx::ERR_NONE) {
|
||||||
|
@ -27,9 +27,10 @@ eaudiofx::flow::Base::Base(eaudiofx::flow::Interface& _flowInterfaceLink,
|
|||||||
m_ref = std::make_shared<BaseReference>(this);
|
m_ref = std::make_shared<BaseReference>(this);
|
||||||
// add a reference on the current signal ...
|
// add a reference on the current signal ...
|
||||||
m_flowInterfaceLink.flowAdd(this);
|
m_flowInterfaceLink.flowAdd(this);
|
||||||
m_formatAvaillable.parse(_formatAvaillable);
|
m_formatAvaillable = std::make_shared<ejson::Document>();
|
||||||
|
m_formatAvaillable->parse(_formatAvaillable);
|
||||||
EAUDIOFX_INFO("Create flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' prop:");
|
EAUDIOFX_INFO("Create flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' prop:");
|
||||||
m_formatAvaillable.display();
|
m_formatAvaillable->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
eaudiofx::flow::Base::~Base() {
|
eaudiofx::flow::Base::~Base() {
|
||||||
@ -46,8 +47,9 @@ void eaudiofx::flow::Base::link() {
|
|||||||
EAUDIOFX_INFO(" link flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' (no code)");
|
EAUDIOFX_INFO(" link flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' (no code)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void eaudiofx::flow::Base::checkCompatibility() {
|
int32_t eaudiofx::flow::Base::checkCompatibility() {
|
||||||
EAUDIOFX_INFO(" chack flow : '" << m_name << "' (no code)");
|
EAUDIOFX_INFO(" check flow : '" << m_name << "' (no code)");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void eaudiofx::flow::Base::getInputBuffer() {
|
void eaudiofx::flow::Base::getInputBuffer() {
|
||||||
|
@ -24,7 +24,7 @@ namespace eaudiofx {
|
|||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_description;
|
std::string m_description;
|
||||||
bool m_input;
|
bool m_input;
|
||||||
ejson::Document m_formatAvaillable;
|
std::shared_ptr<ejson::Document> m_formatAvaillable;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a parameter with a specific type.
|
* @brief Create a parameter with a specific type.
|
||||||
@ -56,7 +56,7 @@ namespace eaudiofx {
|
|||||||
bool isOutput() {
|
bool isOutput() {
|
||||||
return !m_input;
|
return !m_input;
|
||||||
}
|
}
|
||||||
const ejson::Object& getCapabilities() {
|
std::shared_ptr<const ejson::Object> getCapabilities() {
|
||||||
return m_formatAvaillable;
|
return m_formatAvaillable;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -82,7 +82,7 @@ namespace eaudiofx {
|
|||||||
const std::string& _flowLinkName);
|
const std::string& _flowLinkName);
|
||||||
public:
|
public:
|
||||||
virtual void link();
|
virtual void link();
|
||||||
virtual void checkCompatibility();
|
virtual int32_t checkCompatibility();
|
||||||
virtual void getInputBuffer();
|
virtual void getInputBuffer();
|
||||||
//virtual std::shared_ptr<eaudiofx::Block> getBlockNamed(const std::string& _name);
|
//virtual std::shared_ptr<eaudiofx::Block> getBlockNamed(const std::string& _name);
|
||||||
};
|
};
|
||||||
|
@ -105,7 +105,7 @@ namespace eaudiofx {
|
|||||||
template<typename T> class Output : public Flow<T> {
|
template<typename T> class Output : public Flow<T> {
|
||||||
protected:
|
protected:
|
||||||
std::vector<std::weak_ptr<BaseReference>> m_remoteFlow; //!< List of reference on the remote flow (multiple childs).
|
std::vector<std::weak_ptr<BaseReference>> m_remoteFlow; //!< List of reference on the remote flow (multiple childs).
|
||||||
ejson::Document m_formatMix; //!< current format that is now availlable on the flow (can be on error) represent the intersection of all flow connected
|
std::shared_ptr<ejson::Document> m_formatMix; //!< current format that is now availlable on the flow (can be on error) represent the intersection of all flow connected
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a parameter with a specific type.
|
* @brief Create a parameter with a specific type.
|
||||||
@ -128,6 +128,26 @@ namespace eaudiofx {
|
|||||||
virtual void addReference(const std::shared_ptr<BaseReference>& _reference) {
|
virtual void addReference(const std::shared_ptr<BaseReference>& _reference) {
|
||||||
m_remoteFlow.push_back(_reference);
|
m_remoteFlow.push_back(_reference);
|
||||||
}
|
}
|
||||||
|
virtual int32_t checkCompatibility() {
|
||||||
|
EAUDIOFX_INFO(" check for : '" << Base::m_name << "' to " << m_remoteFlow.size() << " links");
|
||||||
|
std::vector<std::shared_ptr<const ejson::Object>> list;
|
||||||
|
list.push_back(Base::getCapabilities());
|
||||||
|
for (auto &it : m_remoteFlow) {
|
||||||
|
std::shared_ptr<BaseReference> tmp = it.lock();
|
||||||
|
if (tmp != nullptr) {
|
||||||
|
if (tmp->getBase() != nullptr) {
|
||||||
|
list.push_back(tmp->getBase()->getCapabilities());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_formatMix = Base::m_flowInterfaceLink.getFlowIntersection(list);
|
||||||
|
|
||||||
|
// TODO : Check input property
|
||||||
|
EAUDIOFX_INFO("[" << Base::m_name << "] mix signal : ");
|
||||||
|
m_formatMix->display();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
|
@ -74,7 +74,7 @@ void eaudiofx::flow::Interface::flowSetLinkWith(const std::string& _flowName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void eaudiofx::flow::Interface::flowLinkInput() {
|
void eaudiofx::flow::Interface::flowLinkInput() {
|
||||||
EAUDIOFX_INFO(" Block update the flows links");
|
EAUDIOFX_INFO(" Block update the flows links (" << m_list.size() << " flows)");
|
||||||
for (auto &it : m_list) {
|
for (auto &it : m_list) {
|
||||||
if(it != nullptr) {
|
if(it != nullptr) {
|
||||||
it->link();
|
it->link();
|
||||||
@ -83,7 +83,7 @@ void eaudiofx::flow::Interface::flowLinkInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void eaudiofx::flow::Interface::flowCheckAllCompatibility() {
|
void eaudiofx::flow::Interface::flowCheckAllCompatibility() {
|
||||||
EAUDIOFX_INFO(" Block Check the flows Capabilities");
|
EAUDIOFX_INFO(" Block Check the flows Capabilities (" << m_list.size() << " flows)");
|
||||||
for (auto &it : m_list) {
|
for (auto &it : m_list) {
|
||||||
if(it != nullptr) {
|
if(it != nullptr) {
|
||||||
it->checkCompatibility();
|
it->checkCompatibility();
|
||||||
@ -117,4 +117,129 @@ std::shared_ptr<eaudiofx::flow::BaseReference> eaudiofx::flow::Interface::getFlo
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::shared_ptr<ejson::Value> intersect(const std::shared_ptr<const ejson::Value>& _obj1, const std::shared_ptr<const ejson::Value>& _obj2) {
|
||||||
|
std::shared_ptr<ejson::Value> out = ejson::Object::create();
|
||||||
|
|
||||||
|
if (_obj1 == nullptr) {
|
||||||
|
if (_obj2 == nullptr) {
|
||||||
|
EAUDIOFX_ERROR("intersect 2 null ptr ...");
|
||||||
|
return ejson::Null::create();
|
||||||
|
} else {
|
||||||
|
return _obj2->clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_obj2 == nullptr) {
|
||||||
|
return _obj1->clone();
|
||||||
|
}
|
||||||
|
if (_obj1->isNull() == true) {
|
||||||
|
return _obj2->clone();
|
||||||
|
}
|
||||||
|
if (_obj1->isNumber() == true) {
|
||||||
|
// just a single output value ... just check if it is the same value
|
||||||
|
double value = _obj1->toNumber()->get();
|
||||||
|
if (_obj2->isNumber() == true) {
|
||||||
|
if (value == _obj2->toNumber()->get()) {
|
||||||
|
return ejson::Number::create(value);
|
||||||
|
}
|
||||||
|
EAUDIOFX_ERROR("Not the same number value");
|
||||||
|
}
|
||||||
|
if (_obj2->isArray() == true) {
|
||||||
|
std::shared_ptr<const ejson::Array> obj = _obj2->toArray();
|
||||||
|
for (int32_t iii=0; iii<obj->size(); ++iii) {
|
||||||
|
if ((*obj)[iii]->isNumber() == true) {
|
||||||
|
if (value == (*obj)[iii]->toNumber()->get()) {
|
||||||
|
return ejson::Number::create(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EAUDIOFX_ERROR("Not the same values ...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_obj1->isString() == true) {
|
||||||
|
// just a single output value ... just check if it is the same value
|
||||||
|
std::string value = _obj1->toString()->get();
|
||||||
|
if (_obj2->isString() == true) {
|
||||||
|
if (value == _obj2->toString()->get()) {
|
||||||
|
return ejson::String::create(value);
|
||||||
|
}
|
||||||
|
EAUDIOFX_ERROR("Not the same string value");
|
||||||
|
}
|
||||||
|
if (_obj2->isArray() == true) {
|
||||||
|
std::shared_ptr<const ejson::Array> obj = _obj2->toArray();
|
||||||
|
for (int32_t iii=0; iii<obj->size(); ++iii) {
|
||||||
|
if ((*obj)[iii]->isString() == true) {
|
||||||
|
if (value == (*obj)[iii]->toString()->get()) {
|
||||||
|
return ejson::String::create(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EAUDIOFX_ERROR("Not the same values ...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_obj1->isArray() == true) {
|
||||||
|
EAUDIOFX_TODO(" manage array");
|
||||||
|
}
|
||||||
|
EAUDIOFX_ERROR("Can not intersect elements : (obj1)");
|
||||||
|
_obj1->display();
|
||||||
|
EAUDIOFX_ERROR(" (obj2)");
|
||||||
|
_obj2->display();
|
||||||
|
// remove sublist if it is reduce to 1
|
||||||
|
return ejson::Null::create();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<ejson::Document> eaudiofx::flow::Interface::getFlowIntersection(const std::vector<std::shared_ptr<const ejson::Object>>& _list) {
|
||||||
|
EAUDIOFX_ERROR("-------------- start intersection --------------");
|
||||||
|
std::shared_ptr<ejson::Document> out = std::make_shared<ejson::Document>();
|
||||||
|
if (_list.size() == 0) {
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
if (_list.size() == 1) {
|
||||||
|
_list[0]->cloneIn(out);
|
||||||
|
EAUDIOFX_INFO("List clone : ");
|
||||||
|
out->display();
|
||||||
|
EAUDIOFX_ERROR("-------------- stop intersection (no link ...) --------------");
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// check all same type :
|
||||||
|
for (int32_t iii=1; iii<_list.size(); ++iii) {
|
||||||
|
if (_list[iii]->getStringValue("type") != _list[0]->getStringValue("type")) {
|
||||||
|
EAUDIOFX_ERROR("All stream have not the same Type ...");
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out->add("type", ejson::String::create(_list[0]->getStringValue("type")));
|
||||||
|
if (out->getStringValue("type") == "audio") {
|
||||||
|
// check frequency:
|
||||||
|
std::shared_ptr<ejson::Value> tmp = ejson::Null::create();
|
||||||
|
for (int32_t iii=0; iii<_list.size(); ++iii) {
|
||||||
|
tmp = intersect(tmp, _list[iii]->get("freq"));
|
||||||
|
}
|
||||||
|
out->add("freq", tmp);
|
||||||
|
// check format:
|
||||||
|
tmp = ejson::Null::create();
|
||||||
|
for (int32_t iii=0; iii<_list.size(); ++iii) {
|
||||||
|
tmp = intersect(tmp, _list[iii]->get("format"));
|
||||||
|
}
|
||||||
|
out->add("format", tmp);
|
||||||
|
|
||||||
|
// check channels:
|
||||||
|
tmp = ejson::Null::create();
|
||||||
|
for (int32_t iii=0; iii<_list.size(); ++iii) {
|
||||||
|
tmp = intersect(tmp, _list[iii]->get("channels"));
|
||||||
|
}
|
||||||
|
out->add("channels", tmp);
|
||||||
|
|
||||||
|
} else if (out->getStringValue("type") == "video") {
|
||||||
|
for (int32_t iii=1; iii<_list.size(); ++iii) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EAUDIOFX_ERROR("not manage interface for mix ... '" << out->getStringValue("type") << "'");
|
||||||
|
}
|
||||||
|
out->display();
|
||||||
|
EAUDIOFX_ERROR("-------------- stop intersection --------------");
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <ejson/ejson.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class Block;
|
class Block;
|
||||||
@ -81,6 +82,8 @@ namespace eaudiofx {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
std::shared_ptr<eaudiofx::flow::BaseReference> getFlowReference(const std::string& _name);
|
std::shared_ptr<eaudiofx::flow::BaseReference> getFlowReference(const std::string& _name);
|
||||||
|
public:
|
||||||
|
std::shared_ptr<ejson::Document> getFlowIntersection(const std::vector<std::shared_ptr<const ejson::Object>>& _list);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user