summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-08-16 00:56:32 +0100
committerComment <tim@gray.(none)>2013-08-16 00:56:32 +0100
commit1af93fbfe4c8cfa214331d2d96327637ffe749bf (patch)
treef452a61b83e16993c5b4702f3a46c85d7d0829b6
parentf91c866884819bee50b39b7b370209ef6b94ec53 (diff)
adding render log
-rw-r--r--rotord/src/cvimage.h15
-rw-r--r--rotord/src/nodes_drawing.h1
-rw-r--r--rotord/src/rendercontext.cpp115
-rw-r--r--rotord/src/rendercontext.h10
-rwxr-xr-xrotord/src/rotor.cpp6
-rwxr-xr-xrotord/src/rotor.h8
-rwxr-xr-xrotord/src/rotord.cpp25
7 files changed, 111 insertions, 69 deletions
diff --git a/rotord/src/cvimage.h b/rotord/src/cvimage.h
index feb7298..4921f78 100644
--- a/rotord/src/cvimage.h
+++ b/rotord/src/cvimage.h
@@ -93,12 +93,17 @@ namespace Rotor {
int getStride(){
return w*3;
}
+ bool clear(){
+ rgb.setTo(0);
+ };
bool setup(int _w,int _h){ //set up with internal data
- rgb.create(_h,_w,CV_8UC3);
- RGBdata=rgb.data; //can move to use the bare pointer eventually
- ownsRGBdata=false; //will not be necessary
- w=_w;
- h=_h;
+ if (w!=_w|h!=h){
+ rgb.create(_h,_w,CV_8UC3);
+ RGBdata=rgb.data; //can move to use the bare pointer eventually
+ ownsRGBdata=false; //will not be necessary
+ w=_w;
+ h=_h;
+ }
return true;
/*
if (w!=_w||h!=_h||!ownsRGBdata||!ownsAdata||!ownsZdata){
diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h
index c44527d..91771f8 100644
--- a/rotord/src/nodes_drawing.h
+++ b/rotord/src/nodes_drawing.h
@@ -21,6 +21,7 @@ namespace Rotor {
if (in){
image=(*in);
}
+ else image.clear();
//convert to 32 bit - this can probably be optimised further
cv::Mat chans;
cv::cvtColor(image.rgb, chans, CV_BGR2RGBA, 4);
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<std::string>& command,xmlIO& XML,HTTPResponse::HTTPStatus& status){
+//const std::vector<std::string>& 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:"<<command.uid<<" method:"<<command.method<<" id:"<<command.id\
+ <<" commands:"<<s<<"body:"<<command.body<<endl;
+
Logger& logger = Logger::get("Rotor");
status=HTTPResponse::HTTP_BAD_REQUEST; //error by default
- if (command[2]=="resolution") {
- if (command[0]=="PUT") {
- if (command.size()>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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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");
diff --git a/rotord/src/rendercontext.h b/rotord/src/rendercontext.h
index 738ce38..26b39fa 100644
--- a/rotord/src/rendercontext.h
+++ b/rotord/src/rendercontext.h
@@ -8,6 +8,13 @@
#include "rotor.h"
namespace Rotor {
+ class Session_command {
+ public:
+ Session_command(){body="";};
+
+ string uid,method,id,body;
+ vector<string> commands;
+ };
class Render_context: public Poco::Task { //Poco task object
//manages a 'patchbay'
//high level interfaces for the wizard
@@ -31,8 +38,7 @@ namespace Rotor {
~Render_context(){delete audio_thumb;};
void runTask();
void add_queue(int item);
- Command_response session_command(const std::vector<std::string>& command);
- void session_command(const std::vector<std::string>& command,xmlIO& XML,Poco::Net::HTTPResponse::HTTPStatus& status);
+ void session_command(const Session_command& command,xmlIO& XML,Poco::Net::HTTPResponse::HTTPStatus& status);
void cancel(); //interrupt locking process
int make_preview(int nodeID, float time); //starts a frame preview - returns status code - how to retrieve?
bool load_audio(const string &filename,vector<Audio_processor*> processors);
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index 99fe396..5f6d6b3 100755
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -269,7 +269,11 @@ bool Video_loader::load(const string &_filename){
string uri="file://"+_filename;
isLoaded=player.open(uri);
if (isLoaded){
- logger.information("Video_loader loaded "+_filename+": "+ofToString(player.getNumberOfFrames())+" frames, "+ofToString(player.getFrameRate())+" fps, "+ofToString(player.getWidth())+"x"+ofToString(player.getHeight()));
+ logger.information("Video_loader loaded "+_filename+": "\
+ +ofToString(player.getNumberOfFrames())+" frames, "\
+ +ofToString(player.getFrameRate())+" fps, "\
+ +ofToString(player.getWidth())+"x"+ofToString(player.getHeight())\
+ +", channels:"+ofToString(player.getNumberOfChannels()));
return true;
}
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 937a884..1f345d1 100755
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -123,6 +123,9 @@ namespace Rotor {
class Parameter: public Signal_input{
public:
virtual ~Parameter(){};
+ void init(const float &_val){
+ value=_val;
+ }
Parameter(const string &_type,const string &_desc,const string &_title,float _value,float _min,float _max,Node* _connect): Signal_input(_desc,_title,_connect),value(_value),min(_min),max(_max),type(_type){};
float value,min,max;
float get(const Time_spec& time);
@@ -182,6 +185,11 @@ namespace Rotor {
attributes[a.first]->init(find_setting(settings,a.first,""));
}
}
+ for (auto p: parameters){
+ if (find_setting(settings,p.first,"")!="") {
+ parameters[p.first]->init(find_setting(settings,p.first,0));
+ }
+ }
}
void update(const Time_spec &time){
for (auto p: parameters){
diff --git a/rotord/src/rotord.cpp b/rotord/src/rotord.cpp
index fefca8e..33031e7 100755
--- a/rotord/src/rotord.cpp
+++ b/rotord/src/rotord.cpp
@@ -139,15 +139,22 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS
//on the other hand, some commands need to know state of the renderer?
- vector<string> sc; //method,id,command1,{command2,}{body}
- sc.push_back(request.getMethod());
- for (auto& i: command){
- sc.push_back(i);
- }
- sc.push_back(body);
-
- ((Poco::AutoPtr<Rotor::Render_context>)task)->session_command(sc,XML,status);
-
+ Session_command SC;
+ vector<string> sc; //uid,method,id,command1,{command2,}{body}
+ SC.uid=idGen.createOne().toString();
+ sc.push_back(request.getMethod());
+ SC.method=request.getMethod();
+ for (auto& i: command){
+ sc.push_back(i);
+ SC.commands.push_back(i);
+ }
+ sc.push_back(body);
+ SC.body=body;
+
+ ((Poco::AutoPtr<Rotor::Render_context>)task)->session_command(SC,XML,status);
+ if (XML.tagExists("render_id")){
+ //cerr<<"render started: "<<SC.uid<<" in context: "<<command[0]<<endl;
+ }
}
}
}