diff options
Diffstat (limited to 'rotord/rotor.h')
| -rwxr-xr-x | rotord/rotor.h | 104 |
1 files changed, 32 insertions, 72 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index 8d4b712..52687ca 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -74,6 +74,8 @@ get progress #include <unordered_map> #include <deque> +#include "Poco/Net/HTTPServer.h" +#include "Poco/Net/HTTPResponse.h" #include "Poco/UUID.h" #include "Poco/UUIDGenerator.h" #include "Poco/Notification.h" @@ -81,6 +83,7 @@ get progress #include "Poco/Observer.h" #include "Poco/ThreadPool.h" #include "Poco/Thread.h" +#include "Poco/Task.h" #include "Poco/Runnable.h" #include "Poco/Mutex.h" #include "Poco/Random.h" @@ -90,6 +93,10 @@ get progress using Poco::UUID; using Poco::UUIDGenerator; +using Poco::Net::HTTPResponse; + +#include "vampHost.h" +#include "xmlIO.h" namespace Rotor { #define IDLE 0 @@ -100,9 +107,9 @@ namespace Rotor { #define RENDERING 5 #define RENDER_READY 6 -#define ANALYSE_AUDIO 0 -#define PREVIEW 1 -#define RENDER 2 +#define ANALYSE_AUDIO 1 +#define PREVIEW 2 +#define RENDER 3 //forward declaration class Node; @@ -118,86 +125,39 @@ namespace Rotor { int num_clips; }; class Command_response{ - public: - Command_response() { status=HTTPResponse::HTTP_OK; } - string description; - HTTPResponse::HTTPStatus status; + public: + Command_response() { status=Poco::Net::HTTPResponse::HTTP_OK; } + std::string description; + Poco::Net::HTTPResponse::HTTPStatus status; }; - class Render_context: public Poco::Task { //Poco task object - //manages a 'patchbay' - //high level interfaces for the wizard - //and low level interface onto the graph + class Render_context: public Poco::Task { //Poco task object + //manages a 'patchbay' + //high level interfaces for the wizard + //and low level interface onto the graph public: Render_context(const std::string& name): Task(name) { state=IDLE; }; - void runTask() { - while (!isCancelled()) { - mutex.lock(); - if (work_queue.size()){ - int cmd=work_queue[0]; - work_queue.pop_front(); - if (cmd==ANALYSE_AUDIO) { - - } - } - mutex.unlock(); - sleep(100); - } - printf("Rotor: stopping thread\n"); - } - void add_queue(int item) { - mutex.lock(); - work_queue.push_back(item); - mutex.unlock(); - } - Command_response session_command(const std::vector<std::string>& command){ - //method,id,command1,{command2,}{body} - //here we allow the controlling server to communicate with running tasks - Command_response response; - mutex.lock(); - if (command[2]=="audio") { - if (command[0]=="PUT") { //get audio file location and initiate analysis - if (command.size()>2) { - if (state==IDLE) { - //check file exists - Poco::File f=Poco::File(command[3]); - if (f.exists()) { - //pass to worker thread ??if engine is ready?? ??what if engine has finished but results aren't read?? - audio_filename=command[3]; //for now, store session variables in memory - work_queue.push_back(ANALYSE_AUDIO); - response.description="<status>Starting audio analysis: "+command[3]+"</status>\n"; - } - else { - response.status=HTTPResponse::HTTP_NOT_FOUND; - response.description="<status>File "+command[3]+" not found</status>\n"; - } - } - else { - response.status=HTTPResponse::HTTP_BAD_REQUEST; - response.description="<status>Rotor: session busy</status>\n"; - } - } - } - } - mutex.unlock(); - return response; - } + void runTask(); + void add_queue(int item); + Command_response session_command(const std::vector<std::string>& command); Render_status get_status(); - void cancel(); //interrupt locking process - int make_preview(int nodeID, float time); //starts a frame preview - returns status code - how to retrieve? + void cancel(); //interrupt locking process + int make_preview(int nodeID, float time); //starts a frame preview - returns status code - how to retrieve? int load_graph(Poco::UUID uid); - UUID save_graph(); //returns UUID of saved graph + UUID save_graph(); //returns UUID of saved graph int load_audio(string filename); Render_requirements get_requirements(); - int load_video(int num,string filename); //can be performance or clip + int load_video(int num,string filename); //can be performance or clip private: int state; - float progress; //for a locking process: audio analysis or rendering + float progress; //for a locking process: audio analysis or rendering std::deque<int> work_queue; - Poco::Mutex mutex; //lock for access from parent thread - std::string audio_filename; + Poco::Mutex mutex; //lock for access from parent thread + std::string audio_filename; + vampHost::QMAnalyser audio_analyser; + xmlIO xml; }; class Input{ public: @@ -238,9 +198,9 @@ namespace Rotor { } Image* get_output(float time){ //sample implementation gather_inputs(time); - //do something with the inputs + //do something with the inputs - //and then + //and then return ((Image_node*)image_inputs[0].connection)->image; } void get_preview(float time); |
