diff options
Diffstat (limited to 'rotord/src/graph.cpp')
| -rw-r--r-- | rotord/src/graph.cpp | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 3d0a88b..ae9247b 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -77,7 +77,7 @@ bool Graph::preview(xmlIO &XML,string &node,string &_format,int frame,int w,int return false; } -bool Graph::video_render(const string &output_filename,const string &audio_filename,const float framerate,float& progress) { +bool Graph::video_render(const string &output_filename,const float framerate,float& progress) { vector<Node*> loaders=find_nodes("video_loader"); for (auto i:loaders){ if (!dynamic_cast<Video_loader*>(i)->isLoaded) { @@ -109,28 +109,34 @@ bool Graph::load(string data,string media_path){ if (xml.loadFromBuffer(data)){ return parseXml(media_path); } - //cerr<<"Rotor: failed to load graph from string"<<endl; + return parseJson(data,media_path); return false; } bool Graph::loadFile(string &filename,string media_path){ //if (loaded) printf("loading graph: %s\n",(filename).c_str()); - - + if (xml.loadFile(filename)){ + return parseXml(media_path); + } Poco::FileInputStream fis(filename); Poco::CountingInputStream countingIstr(fis); std::string str; Poco::StreamCopier::copyToString(countingIstr, str); - //msg.Message(Poco::format(" Write/Read check : %s", std::string(0 == str.compare(ostrBackup.str()) ? "OK":"NG"))); - //msg.Message(Poco::format(" Characters : %d", countingIstr.chars())); - //msg.Message(Poco::format(" Lines : %d", countingIstr.lines())); - //cerr<<countingIstr.chars()<<" chars, "<<countingIstr.lines()<<endl; - //cerr<<str.size()<<" json chars found"<<endl; - if (xml.loadFile(filename)){ - return parseXml(media_path); - } return parseJson(str,media_path); } +bool Graph::check_audio(string audio,string path){ + if (audio!="") { + Poco::File f=Poco::File(path+audio); + if (f.exists()) { + audio_filename=path+audio; + audio_loaded=true; + cerr<<"Rotor: loading "<<path+audio<<" from graph"<<endl; + return true; + } + cerr<<"Rotor: audio file "<<path+audio<<" not found"<<endl; + } + return false; +} bool Graph::parseJson(string &data,string &media_path){ //cerr<<data<<endl; //cerr<<"Trying to load JSON"<<endl; @@ -145,9 +151,8 @@ bool Graph::parseJson(string &data,string &media_path){ return false; } //we know the json validates so clear the existing graph - if (loaded) nodes.clear(); - string audiotrack=root["audio"].asString(); - if (audiotrack!="") cerr<<"audio track :"<<endl; //need to deal with + nodes.clear(); + check_audio(root["audio"].asString(),media_path); init(root["ID"].asString(),root["description"].asString()); Json::Value jnodes = root["nodes"]; for ( int i = 0; i < jnodes.size(); ++i ) { @@ -254,7 +259,8 @@ bool Graph::parseJson(string &data,string &media_path){ return true; } bool Graph::parseXml(string media_path){ - if (loaded) nodes.clear(); + nodes.clear(); + check_audio(xml.getAttribute("patchbay","audio","",0),media_path); init(xml.getAttribute("patchbay","ID","",0),xml.getValue("patchbay","",0)); if(xml.pushTag("patchbay")) { int n1=xml.getNumTags("node"); |
