diff options
| author | Comment <tim@gray.(none)> | 2013-04-11 15:15:06 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-04-11 15:15:06 +0100 |
| commit | 4761b802f1378f830c74bdcd695d5f74a38a7ed6 (patch) | |
| tree | db77c76ba60f9d0ae2f439c0ea4f8ccd248abdd2 /rotord/rotor.h | |
| parent | 8e6038f799b50986871325f28b4f807312502681 (diff) | |
building video renderer
Diffstat (limited to 'rotord/rotor.h')
| -rwxr-xr-x | rotord/rotor.h | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index 699aa8a..b0bfad2 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -92,7 +92,7 @@ extern "C" { #include "vampHost.h" #include "xmlIO.h" -#include "avCodec.h" +//#include "avCodec.h" namespace Rotor { #define IDLE 0 @@ -183,7 +183,7 @@ namespace Rotor { class Node{ public: virtual Node* clone(map<string,string> &_settings)=0; - UUID uid; //every usable node has a UUID + UUID uid; //every usable node has a UUID int id; vector<Signal_input*> inputs; //simple node can have signal inputs, output depends on node type void create_signal_input(const string &description) {inputs.push_back(new Signal_input(description));}; @@ -205,28 +205,17 @@ namespace Rotor { class Signal_node: public Node{ public: virtual float get_output(const Time_spec &time) { return 0.0f; }; - - /*{ //default is to pass through first input, if disconnected returns 0 - cerr << "getting output for " << type << "," << ID << endl; - if (inputs.size()) { - if (inputs[0]->connection) return ((Signal_node*)(inputs[0]->connection))->get_output(time); - } - return 0.0f; - } - */ }; class Image_node: public Node{ public: - vector<Image_input> image_inputs; //image node also has image inputs and outputs - Image* get_output(const Time_spec &time){ //sample implementation - - //do something with the inputs - - //and then + vector<Image_input> image_inputs; //image node also has image inputs and outputs + Image* get_output(const Time_spec &time){ //sample implementation + //do something with the inputs + //and then return ((Image_node*)image_inputs[0].connection)->get_output(time); } void get_preview(const Time_spec &time); - Image* image; //this can be privately allocated or just passed on as the node see fit + Image* image; //this can be privately allocated or just passed on as the node see fit private: float image_time; }; @@ -273,7 +262,6 @@ namespace Rotor { vampHost::Analyser analyser; }; class Signal_divide: public Signal_node { - //divides incoming signal by a fixed amount public: Signal_divide(){}; Signal_divide(map<string,string> &settings) { @@ -290,10 +278,6 @@ namespace Rotor { float divide_amount; }; class Is_new_integer: public Signal_node { - //outputs a 1 every time a signal passes a new integer, otherwise a 0. - //this requires knowing what the framerate is? how to do this? - //for now, assume 25 - //what to cache? for now, don't cache public: Is_new_integer(){}; Is_new_integer(map<string,string> &settings) { @@ -333,7 +317,7 @@ namespace Rotor { base_settings(settings); }; Video_output* clone(map<string,string> &_settings) { return new Video_output(_settings);}; - bool render(const float duration, const float framerate,string &filename); + bool render(const float duration, const float framerate,const string &output_filename,const string &audio_filename); }; //------------------------------------------------------------------- class Node_factory{ @@ -355,9 +339,9 @@ namespace Rotor { }; class Graph{ public: - Graph(){framerate=25.0f;duration=10.0f;loaded = false;}; + Graph(){duration=10.0f;loaded = false;}; Graph(const string& _uid,const string& _desc){init(_uid,_desc);}; - void init(const string& _uid,const string& _desc){ uid=_uid;description=_desc;framerate=25.0f;duration=10.0f;}; + void init(const string& _uid,const string& _desc){ uid=_uid;description=_desc;duration=10.0f;}; string uid; //every version of a graph has a UUID, no particular need to actually read its data(?) //?? is it faster than using strings?? string description; @@ -375,41 +359,31 @@ namespace Rotor { } return nullptr; //can be tested against }; - bool signal_render(const float _fr,string &signal_xml) { - if (_fr>.001) framerate=_fr; + bool signal_render(string &signal_xml,const float framerate) { if (find_node("signal_output")) { Signal_output *signal_output=dynamic_cast<Signal_output*>(find_node("signal_output")); return signal_output->render(duration,framerate,signal_xml); } else return false; } - bool video_render(const float _fr,string &filename) { - //things to manage: - //audio location is known by render context - //video_output can generate frames - //where do these come together? - if (_fr>.001) framerate=_fr; + bool video_render(const string &output_filename,const string &audio_filename,const float framerate) { if (find_node("video_output")) { Video_output *video_output=dynamic_cast<Video_output*>(find_node("video_output")); - return video_output->render(duration,framerate,filename,); + return video_output->render(duration,framerate,output_filename,audio_filename); } else return false; } int load(Poco::UUID uid); bool load(string &graph_filename); - UUID save(); //save to DB, returns UUID of saved graph + UUID save(); //save to DB, returns UUID of saved graph bool loaded; float duration; const string toString(); private: Node_factory factory; - float framerate; xmlIO xml; }; class Audio_thumbnailer: public Base_audio_processor { - //how to deal with the fact that frames don't correspond with pixels? - //buffer the data somehow - //draw pixels based on rms value public: Audio_thumbnailer(){ height=32; @@ -428,24 +402,24 @@ namespace Rotor { uint8_t *data; int height,width,samples_per_column; int column,out_sample,sample,samples; - //for drawing graph int offset; double scale,accum; }; 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 + //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) { audio_thumb=new Audio_thumbnailer(); state=IDLE; + output_framerate=25.0f; }; 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 + 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<Base_audio_processor*> processors); Render_requirements get_requirements(); @@ -454,14 +428,16 @@ namespace Rotor { private: int state; double progress; //for a locking process: audio analysis or rendering - //thread only does one thing at once + //thread only does one thing at once std::deque<int> work_queue; Poco::Mutex mutex; //lock for access from parent thread std::string audio_filename; + std::string output_filename; Audio_thumbnailer *audio_thumb; vampHost::QMAnalyser audio_analyser; Graph graph; Node_factory factory; + float output_framerate; }; } |
