From 1af93fbfe4c8cfa214331d2d96327637ffe749bf Mon Sep 17 00:00:00 2001 From: Comment Date: Fri, 16 Aug 2013 00:56:32 +0100 Subject: adding render log --- rotord/src/rendercontext.cpp | 115 ++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 52 deletions(-) (limited to 'rotord/src/rendercontext.cpp') diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index e582dce..e028773 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -51,14 +51,24 @@ void Render_context::add_queue(int item) { work_queue.push_back(item); mutex.unlock(); } -void Render_context::session_command(const std::vector& command,xmlIO& XML,HTTPResponse::HTTPStatus& status){ +//const std::vector& command +void Render_context::session_command(const Session_command& command,xmlIO& XML,HTTPResponse::HTTPStatus& status){ + + string s; + for (auto c:command.commands){ + s+=c; + s+=" "; + } + cerr<<"uid:"<2) { + if (command.commands[1]=="resolution") { + if (command.method=="PUT") { + if (command.body!="") { if (state==IDLE) { - Poco::StringTokenizer t1(command[3],","); + Poco::StringTokenizer t1(command.body,","); if (t1.count()>1){ int w=ofToInt(t1[0]); int h=ofToInt(t1[1]); @@ -79,23 +89,23 @@ void Render_context::session_command(const std::vector& command,xml } } } - if (command[2]=="audio") { - if (command[0]=="PUT") { //get audio file location and initiate analysis - if (command.size()>2) { + if (command.commands[1]=="audio") { + if (command.method=="PUT") { //get audio file location and initiate analysis + if (command.body!="") { if (state==IDLE) { - audio_filename=media_dir+command[3]; //for now, store session variables in memory //check file exists + audio_filename=media_dir+command.body; //for now, store session variables in memory //check file exists Poco::File f=Poco::File(audio_filename); if (f.exists()) { //pass to worker thread ??if engine is ready?? ??what if engine has finished but results aren't read?? add_queue(ANALYSE_AUDIO); status=HTTPResponse::HTTP_OK; - logger.information("Starting audio analysis: "+command[3]); - XML.addValue("status","Starting audio analysis: "+command[3]); + logger.information("Starting audio analysis: "+command.body); + XML.addValue("status","Starting audio analysis: "+command.body); } else { status=HTTPResponse::HTTP_NOT_FOUND; - logger.error("ERROR: audio file "+command[3]+" not found"); - XML.addValue("error",command[3]+" not found"); + logger.error("ERROR: audio file "+command.body+" not found"); + XML.addValue("error",command.body+" not found"); } } @@ -105,7 +115,7 @@ void Render_context::session_command(const std::vector& command,xml } } } - if (command[0]=="GET") { + if (command.method=="GET") { if (state==ANALYSING_AUDIO) { status=HTTPResponse::HTTP_OK; XML.addValue("status","Analysing audio"); @@ -126,7 +136,7 @@ void Render_context::session_command(const std::vector& command,xml XML.addValue("error","No audio loaded"); } } - if (command[0]=="DELETE") { + if (command.method=="DELETE") { if (state==IDLE) { audio_filename=""; logger.information("Audio deleted"); @@ -139,8 +149,8 @@ void Render_context::session_command(const std::vector& command,xml } } } - if (command[2]=="graph") { - if (command[0]=="GET") { + if (command.commands[1]=="graph") { + if (command.method=="GET") { if (graph.loaded) { status=HTTPResponse::HTTP_OK; //XML.addValue("patchbay",graph.toString()); @@ -152,24 +162,24 @@ void Render_context::session_command(const std::vector& command,xml XML.addValue("error","graph not loaded: check XML"); } } - if (command[0]=="PUT") { //get new graph from file - if (command.size()>2) { + if (command.method=="PUT") { //get new graph from file + if (command.body!="") { //should interrupt whatever is happening? //before begining to load from xml if (state==IDLE) { //eventually not like this - if (graph.load(command[3],media_dir)) { + if (graph.load(command.body,media_dir)) { status=HTTPResponse::HTTP_OK; logger.information("Loaded graph from http PUT body"); XML.addValue("status","Loaded graph from PUT body"); if (audio_loaded) { add_queue(ANALYSE_AUDIO); status=HTTPResponse::HTTP_OK; - logger.information("Starting audio analysis for graph: "+command[3]); - XML.addValue("status","Starting audio analysis for graph: "+command[3]); + logger.information("Starting audio analysis for graph: "+command.id); + XML.addValue("status","Starting audio analysis for graph: "+command.id); } } else { - string graph_filename=graph_dir+command[3]; + string graph_filename=graph_dir+command.body; Poco::File f=Poco::File(graph_filename); if (f.exists()) { if (graph.loadFile(graph_filename,media_dir)) { @@ -184,8 +194,8 @@ void Render_context::session_command(const std::vector& command,xml if (audio_loaded) { add_queue(ANALYSE_AUDIO); status=HTTPResponse::HTTP_OK; - logger.information("Starting audio analysis for graph: "+command[3]); - XML.addValue("status","Starting audio analysis for graph: "+command[3]); + logger.information("Starting audio analysis for graph: "+command.id); + XML.addValue("status","Starting audio analysis for graph: "+command.id); } } else { @@ -196,14 +206,14 @@ void Render_context::session_command(const std::vector& command,xml } else { status=HTTPResponse::HTTP_NOT_FOUND; - logger.error("ERROR: "+command[3]+" not found"); - XML.addValue("error",command[3]+" not found"); + logger.error("ERROR: "+command.id+" not found"); + XML.addValue("error",command.id+" not found"); } } } } } - if (command[0]=="DELETE") { + if (command.method=="DELETE") { //for now graph=Graph(); logger.information("graph deleted"); @@ -211,13 +221,13 @@ void Render_context::session_command(const std::vector& command,xml status=HTTPResponse::HTTP_OK; } } - if (command[2]=="signal") { - if (command[0]=="GET") { //generate xml from 1st signal output + if (command.commands[1]=="signal") { + if (command.method=="GET") { //generate xml from 1st signal output if (state==IDLE) { //direct call for testing float framerate=25.0f; //if (command.size()>2) { - // framerate=ofToFloat(command[3]); + // framerate=ofToFloat(command.id); //} string signal_xml; if (false) { //graph.signal_render(signal_xml,framerate)){ @@ -242,31 +252,31 @@ void Render_context::session_command(const std::vector& command,xml } } } - if (command[2]=="video") { - if (command[0]=="PUT") { //get vide file location and initiate analysis - if (command.size()>4) { //there should be a filename + a destination node + if (command.commands[1]=="video") { + if (command.method=="PUT") { //get vide file location and initiate analysis + if (command.body!="") { //there should be a filename + a destination node if (state==IDLE) { - string video_filename=media_dir+command[4]; + string video_filename=media_dir+command.body; //check file exists Poco::File f=Poco::File(video_filename); if (f.exists()) { - if (load_video(command[3],video_filename)) { + if (load_video(command.id,video_filename)) { //pass to worker thread ??if engine is ready?? ??what if engine has finished but results aren't read?? //DUMMY RESPONSE status=HTTPResponse::HTTP_OK; - logger.information("Succesfully loaded "+command[4]+" into video node "+command[3]); - XML.addValue("status","Succesfully loaded "+command[4]+" into video node "+command[3]); + logger.information("Succesfully loaded "+command.body+" into video node "+command.id); + XML.addValue("status","Succesfully loaded "+command.body+" into video node "+command.id); } else { status=HTTPResponse::HTTP_INTERNAL_SERVER_ERROR; - logger.error("ERROR: could not load "+command[4]+" into video node "+command[3]); - XML.addValue("error","could not load "+command[4]+" into video node "+command[3]); + logger.error("ERROR: could not load "+command.body+" into video node "+command.id); + XML.addValue("error","could not load "+command.body+" into video node "+command.id); } } else { status=HTTPResponse::HTTP_NOT_FOUND; - logger.error("ERROR: "+command[4]+" not found"); - XML.addValue("error",command[4]+" not found"); + logger.error("ERROR: "+command.body+" not found"); + XML.addValue("error",command.body+" not found"); } } else { @@ -282,8 +292,8 @@ void Render_context::session_command(const std::vector& command,xml } } } - if (command[2]=="render") { - if (command[0]=="GET") { + if (command.commands[1]=="render") { + if (command.method=="GET") { if(state==RENDERING){ status=HTTPResponse::HTTP_OK; XML.addValue("status","Rendering video"); @@ -294,17 +304,18 @@ void Render_context::session_command(const std::vector& command,xml XML.addValue("error","Not rendering"); } } - if (command[0]=="PUT") { - if (command.size()>2) { + if (command.method=="PUT") { + if (command.body!="") { if (state==IDLE) { - output_filename=output_dir+command[3]; - if (command.size()>3) { -// output_framerate=ofToFloat(command[4]); + output_filename=output_dir+command.body; + if (command.body!="") { +// output_framerate=ofToFloat(command.body); } add_queue(RENDER); status=HTTPResponse::HTTP_OK; - logger.information("Starting render: "+command[3]); - XML.addValue("status","Starting render: "+command[3]); + logger.information("Starting render: "+command.body); + XML.addValue("status","Starting render: "+command.body); + XML.addValue("render_id",command.uid); } else { status=HTTPResponse::HTTP_BAD_REQUEST; @@ -318,7 +329,7 @@ void Render_context::session_command(const std::vector& command,xml XML.addValue("error","No output file specified"); } } - if (command[0]=="DELETE") { + if (command.method=="DELETE") { status=HTTPResponse::HTTP_OK; logger.error("ERROR: Not implemented"); XML.addValue("status","DUMMY RESPONSE: cancelling render"); -- cgit v1.2.3