diff options
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/graph.cpp | 27 | ||||
| -rw-r--r-- | rotord/rendercontext.cpp | 10 | ||||
| -rwxr-xr-x | rotord/rotor.h | 32 |
3 files changed, 42 insertions, 27 deletions
diff --git a/rotord/graph.cpp b/rotord/graph.cpp index 7eeeec3..69c4811 100644 --- a/rotord/graph.cpp +++ b/rotord/graph.cpp @@ -9,6 +9,33 @@ const string Graph::toString(){ } else return ""; } +vector<Node*> Graph::find_nodes(const string &type){ + vector<Node*> found; + for (std::unordered_map<string,Node*>::iterator it=nodes.begin();it!=nodes.end();++it) { + if (it->second->type==type) found.push_back(it->second); + } + return found; +}; +Node* Graph::find_node(const string &type){ + for (std::unordered_map<string,Node*>::iterator it=nodes.begin();it!=nodes.end();++it) { + if (it->second->type==type) return it->second; + } + return nullptr; //can be tested against +}; +bool Graph::signal_render(string &signal_xml,const float framerate) { + if (find_node("signal_output")) { + Signal_output *signal_output=dynamic_cast<Signal_output*>(find_node("signal_output")); + return signal_output->render(duration,framerate,signal_xml); + } + else return false; +} +bool Graph::video_render(const string &output_filename,const string &audio_filename,const float framerate) { + if (find_node("video_output")) { + Video_output *video_output=dynamic_cast<Video_output*>(find_node("video_output")); + return video_output->render(duration,framerate,output_filename,audio_filename); + } + else return false; +} bool Graph::load(string &filename){ loaded=false; printf("loading graph: %s\n",filename.c_str()); diff --git a/rotord/rendercontext.cpp b/rotord/rendercontext.cpp index dfb9021..948ef31 100644 --- a/rotord/rendercontext.cpp +++ b/rotord/rendercontext.cpp @@ -411,4 +411,14 @@ bool Render_context::load_audio(const string &filename,vector<Base_audio_process return true; } bool Render_context::load_video(string nodeID,string &filename){ + //this is a good standard example of how to find + //a node of a specific type by ID and do something + if (graph.nodes.find(nodeID)!=graph.nodes.end()){ + if (graph.nodes[nodeID]->type=="video_input") { + if (((Video_input*)graph.nodes[nodeID])->load(filename)) { + return true; + } + } + } + return false; } diff --git a/rotord/rotor.h b/rotord/rotor.h index 55beb60..ef1ae23 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -425,6 +425,7 @@ namespace Rotor { loader=new ofGstVideoUtils(); }; ~Video_input(){ delete loader; }; + bool load(const string &filename); Image *get_output(const Frame_spec &frame){ return nullptr; }; @@ -459,33 +460,10 @@ namespace Rotor { //?? is it faster than using strings?? string description; std::unordered_map<string,Node*> nodes; - vector<Node*> find_nodes(const string &type){ - vector<Node*> found; - for (std::unordered_map<string,Node*>::iterator it=nodes.begin();it!=nodes.end();++it) { - if (it->second->type==type) found.push_back(it->second); - } - return found; - }; - Node* find_node(const string &type){ - for (std::unordered_map<string,Node*>::iterator it=nodes.begin();it!=nodes.end();++it) { - if (it->second->type==type) return it->second; - } - return nullptr; //can be tested against - }; - bool signal_render(string &signal_xml,const float framerate) { - if (find_node("signal_output")) { - Signal_output *signal_output=dynamic_cast<Signal_output*>(find_node("signal_output")); - return signal_output->render(duration,framerate,signal_xml); - } - else return false; - } - bool video_render(const string &output_filename,const string &audio_filename,const float framerate) { - if (find_node("video_output")) { - Video_output *video_output=dynamic_cast<Video_output*>(find_node("video_output")); - return video_output->render(duration,framerate,output_filename,audio_filename); - } - else return false; - } + vector<Node*> find_nodes(const string &type); + Node* find_node(const string &type); + bool signal_render(string &signal_xml,const float framerate); + bool video_render(const string &output_filename,const string &audio_filename,const float framerate); int load(Poco::UUID uid); bool load(string &graph_filename); UUID save(); //save to DB, returns UUID of saved graph |
