From b5857aaff7cbdc5382a398de58494b97b0616536 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 8 Nov 2013 11:21:06 +0000 Subject: catch empty features request --- rotord/src/rendercontext.cpp | 16 +++++++---- rotord/src/rotor.h | 64 ++++++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index c3d8b93..2f07c89 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -420,14 +420,20 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H if (command.commands[1]=="features") { if (command.method=="GET") { if(state==IDLE){ - //parse json to get preview spec, return XML? this is a mess - string features_node=command.commands[2]; - if (graph.print_features(XML,features_node)) { - status=HTTPResponse::HTTP_OK; + if (command.commands.size()>2){ + //parse json to get preview spec, return XML? this is a mess + string features_node=command.commands[2]; + if (graph.print_features(XML,features_node)) { + status=HTTPResponse::HTTP_OK; + } + else { + status=HTTPResponse::HTTP_BAD_REQUEST; + logger.error("ERROR: Could not print features for node /"+features_node+"/"); + } } else { status=HTTPResponse::HTTP_BAD_REQUEST; - logger.error("ERROR: Could not print features for node /"+features_node+"/"); + logger.error("ERROR: Features node not specified"); } } else { diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 2720e47..e087bac 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -356,6 +356,8 @@ namespace Rotor { //actual nodes------------------------------------------------- #define CYCLER_cut 1 #define CYCLER_mix 2 + #define CYCLER_seconds 1 + #define CYCLER_fraction 2 #define CYCLER_abs 1 #define CYCLER_rel 2 #define CYCLER_stretch 3 @@ -390,7 +392,7 @@ namespace Rotor { create_signal_input("Selector","Selector input"); create_attribute("mode","Cycling mode {cut|mix}","Mode","cut",{"cut","mix"}); create_attribute("length_mode","Transition length mode","Length mode","seconds",{"seconds","fraction"}); - //create_attribute("time_mode","Time mode {abs|rel}","time mode","abs",{"abs","rel","stretch"}); + create_attribute("time_mode","Time mode","time mode","absolute",{"absolute","relative","stretch"}); create_parameter("transition_length","number","transition length","Transition length",-1.0f,0.0f,0.0f); title="Video cycler"; description="Cycles through video inputs according to selector signal"; @@ -406,39 +408,43 @@ namespace Rotor { ~Video_cycler(){}; bool load(const string &filename); Image *output(const Frame_spec &frame){ - if (attributes["mode"]->intVal==CYCLER_mix&&image_inputs.size()>1){ - int im1=((int)inputs[0]->get((Time_spec)frame))%image_inputs.size(); - int im2=(im1+1)%image_inputs.size(); - //work out timing - float ph=inputs[0]->get((Time_spec)frame); - int seg=((int)ph); - int thisframe=((Time_spec)frame).frame(); - if(thisframe==lastframe||thisframe==lastframe+1){ - if (segment!=seg){ - //start of new segment - cerr<<"Video_cycler: segment "<get((Time_spec)frame); + int seg=((int)ph); + int thisframe=((Time_spec)frame).frame(); + if(thisframe==lastframe||thisframe==lastframe+1){ + if (segment!=seg){ + //start of new segment + cerr<<"Video_cycler: segment "<get(testframe)==seg&&testframe.frame()>0){ - testframe=testframe.lastframe(); - - } - segment_start=testframe.time; - segment=seg; + //find segment start + Time_spec testframe=(Time_spec)frame.lastframe(); + while ((int)inputs[0]->get(testframe)==seg&&testframe.frame()>0){ + testframe=testframe.lastframe(); + } + segment_start=testframe.time; + segment=seg; + cerr<<"Video_cycler: segment "<intVal==CYCLER_mix&&image_inputs.size()>1){ + int im1=((int)inputs[0]->get((Time_spec)frame))%image_inputs.size(); + int im2=(im1+1)%image_inputs.size(); float f=fmod(inputs[0]->get((Time_spec)frame),1.0f); Image *in1=image_inputs[im1]->get(frame); -- cgit v1.2.3