summaryrefslogtreecommitdiff
path: root/rotord/rotor.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/rotor.h')
-rwxr-xr-xrotord/rotor.h76
1 files changed, 54 insertions, 22 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h
index 594465d..8d4b712 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -85,17 +85,24 @@ get progress
#include "Poco/Mutex.h"
#include "Poco/Random.h"
#include "Poco/AutoPtr.h"
+#include "Poco/File.h"
#include <iostream>
using Poco::UUID;
using Poco::UUIDGenerator;
-#define ROTOR_READY 0
-#define ROTOR_ANALYSING_AUDIO 1
-#define ROTOR_CREATING_PREVIEW 2
-#define ROTOR_RENDERING 3
-
namespace Rotor {
+#define IDLE 0
+#define ANALYSING_AUDIO 1
+#define AUDIO_READY 2
+#define CREATING_PREVIEW 3
+#define PREVIEW_READY 4
+#define RENDERING 5
+#define RENDER_READY 6
+
+#define ANALYSE_AUDIO 0
+#define PREVIEW 1
+#define RENDER 2
//forward declaration
class Node;
@@ -110,41 +117,66 @@ namespace Rotor {
int num_performances;
int num_clips;
};
+ class Command_response{
+ public:
+ Command_response() { status=HTTPResponse::HTTP_OK; }
+ string description;
+ 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
public:
- Render_context(const std::string& name): Task(name) {
+ Render_context(const std::string& name): Task(name) {
+ state=IDLE;
};
void runTask() {
while (!isCancelled()) {
mutex.lock();
if (work_queue.size()){
- std::string out=name()+": "+work_queue[0]+"\n";
- printf(out.c_str());
+ 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(std::string item) {
+ void add_queue(int item) {
mutex.lock();
work_queue.push_back(item);
mutex.unlock();
}
- std::string session_command(const std::vector<std::string>& command){
- string response;
+ 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[1]=="audio") {
- if (command[0]=="PUT") {
- //get audio file location and initiate analysis
- if (command.size()>1) {
- //pass message to task
- work_queue.push_back(command[2]);
- response="<status>1</status>\n";
+ 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";
+ }
}
}
}
@@ -161,11 +193,11 @@ namespace Rotor {
int load_video(int num,string filename); //can be performance or clip
private:
- int status;
+ int state;
float progress; //for a locking process: audio analysis or rendering
- std::deque<std::string> work_queue;
-
- Poco::Mutex mutex; //access to notification queue
+ std::deque<int> work_queue;
+ Poco::Mutex mutex; //lock for access from parent thread
+ std::string audio_filename;
};
class Input{
public: