diff options
| -rwxr-xr-x[-rw-r--r--] | rotord/rotor.h | 14 | ||||
| -rwxr-xr-x[-rw-r--r--] | rotord/rotord.cpp | 72 | ||||
| -rwxr-xr-x[-rw-r--r--] | rotord/rotord.h | 10 |
3 files changed, 78 insertions, 18 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index 32b0173..b21673b 100644..100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -76,10 +76,6 @@ using Poco::UUIDGenerator; #define ROTOR_RENDERING 3 namespace Rotor { - class Command{ - //passes a command from the RESTful url to create/ alter a thread - vector<string> packets; - }; //forward declaration class Node; @@ -93,11 +89,19 @@ namespace Rotor { int num_performances; int num_clips; }; - class Render_context: public Poco::Runnable{ //Poco thread object + class Render_context: public Poco::Runnable{ //Poco thread object //manages a 'patchbay' //high level interfaces for the wizard //and low level interface onto the graph public: + void run() { + printf("Rotor: starting thread\n"); + while (1) sleep(1); + + } + ~Render_context() { + printf("Rotor: stopping thread\n"); + } 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? diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp index f20b515..c9fbbf5 100644..100755 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -73,6 +73,59 @@ void AudioAnalyserHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe ostr << "</p></body></html>"; } +RenderContextHandler::RenderContextHandler(const std::vector <std::string> _command): command(_command){ +} + + +void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) { + + response.setChunkedTransferEncoding(true); + response.setContentType("text/html"); + + std::ostream& ostr = response.send(); + string content; + + if (command.size()) { + if (command[0]=="new") { + Poco:UUID sID=idGen.create(); + context[sID]=new Rotor::Render_context(); + context[sID].run(); + content="<sID>"+sID.toString()+"</sID>"; + } + else { + Poco:UUID sID; + if (sID.tryParse(command[0]) { + iterator iter = context.find(sID); + if (iter!=context.end()) { + //successfully located context + if (command.size()==1) { + //just invoking sID + if (request.getMethod()=="DELETE") { + + } + } + else { + + } + } + else { + resp.setStatus(HTTPResponse::HTTP_NOT_FOUND); + content="<body>Rotor: render context not found</body>"; + } + } + else resp.setStatus(HTTPResponse::HTTP_BAD_REQUEST); + content="<body>Rotor: command not found</body>"; + } + } + else { + content="<body>Rotor: empty request</body>"; + } + + ostr << "<?xml version="1.0" encoding="ISO-8859-1"?>"; + ostr << content; + +} + HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPServerRequest& request){ Application& app = Application::instance(); @@ -90,8 +143,9 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS out+=" "; } - app.logger().information("Request from "+ request.clientAddress().toString()+" "+ostr.str()+" segments: "+out); + app.logger().information(request.clientAddress().toString()+" "+request.getMethod()+": "+ostr.str()+" segments: "+out); + /* if (segments.size() == 0) { return new RotorRequestHandler(_format); } @@ -107,19 +161,21 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS return 0; } else if (segments[0]=="new") { - // website creating a new render context - + // create a new render context - //Settings(string _so="",string _filter="",string _id="",string _input=""); - return new AudioAnalyserHandler(vampHost::Settings(segments[1],segments[2],segments[3])); - //string audioData=runPlugin(string myname, string soname, string id, - // string output, int outputNo, string wavname, - // string outfilename, bool useFrames); return 0; } else { return 0; } + */ + return new RenderContextHandler(segments); + + //at this point we are within app + //making a new contexthandler? + //how will this have access to the thread that it refers to + //how will messages be passed + //we need to do testing etc here and } diff --git a/rotord/rotord.h b/rotord/rotord.h index bbc566f..dc5a831 100644..100755 --- a/rotord/rotord.h +++ b/rotord/rotord.h @@ -63,19 +63,19 @@ class AudioAnalyserHandler: public HTTPRequestHandler class RenderContextHandler: public HTTPRequestHandler { public: - RenderContextHandler(const Rotor::Command& command); + RenderContextHandler(const std::vector <std::string> _command); void handleRequest(HTTPServerRequest& request,HTTPServerResponse& response); private: - //stateless + std::vector <std::string> command; }; class RotorRequestHandlerFactory: public HTTPRequestHandlerFactory { public: - RotorRequestHandlerFactory(const std::string& format); HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request); private: - std::string _format; + std::unordered_map<std::string,Rotor::Render_context*> context; + Poco::UUIDGenerator idGen; }; class RotorServer: public Poco::Util::ServerApplication @@ -91,7 +91,7 @@ class RotorServer: public Poco::Util::ServerApplication int main(const std::vector<std::string>& args); private: bool _helpRequested; - std::unordered_map<Poco::UUID,Rotor::Render_context> render_contexts; + }; int main(int argc, char** argv) |
