diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-04-10 18:33:57 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-04-10 18:33:57 +0100 |
| commit | 8e6038f799b50986871325f28b4f807312502681 (patch) | |
| tree | b5403ceb0a3e05beee6fe677c43431df0c289480 /rotord/rotor.cpp | |
| parent | a29217ecc368cdeee7e908fc7db3c717cc51fd70 (diff) | |
making render path
Diffstat (limited to 'rotord/rotor.cpp')
| -rw-r--r-- | rotord/rotor.cpp | 127 |
1 files changed, 75 insertions, 52 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index 360b75e..f9c39b3 100644 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -19,21 +19,27 @@ void Render_context::runTask() { work_queue.pop_front(); } mutex.unlock(); - if (cmd==ANALYSE_AUDIO) { - state=ANALYSING_AUDIO; - vector<Base_audio_processor*> processors; - processors.push_back(audio_thumb); - vector<Node*> analysers=graph.find_nodes("audio_analysis"); - for (auto a: analysers) { - processors.push_back(a); - } - if (load_audio(audio_filename,processors)) { - state=AUDIO_READY; - } - else { - //an error occurred: TODO have to clean up allocated data. autoptr? - state=IDLE; - } + switch(cmd) { + case ANALYSE_AUDIO: + state=ANALYSING_AUDIO; + vector<Base_audio_processor*> processors; + processors.push_back(audio_thumb); + vector<Node*> analysers=graph.find_nodes("audio_analysis"); + for (auto a: analysers) { + processors.push_back(a); + } + if (load_audio(audio_filename,processors)) { + state=AUDIO_READY; + } + else { + //an error occurred: TODO have to clean up allocated data. autoptr? + state=IDLE; + } + break; + case RENDER: + state=RENDERING; + /// + break; } sleep(100); } @@ -75,27 +81,28 @@ Command_response Render_context::session_command(const std::vector<std::string>& response.status=HTTPResponse::HTTP_BAD_REQUEST; 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 - add_queue(ANALYSE_AUDIO); - response.description="<status context='"+command[1]+"'>Starting audio analysis: "+command[3]+"</status>\n"; - } - else { - response.status=HTTPResponse::HTTP_NOT_FOUND; - response.description="<status context='"+command[1]+"'>File "+command[3]+" not found</status>\n"; - } + 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 + add_queue(ANALYSE_AUDIO); + response.status=HTTPResponse::HTTP_OK; + response.description="<status context='"+command[1]+"'>Starting audio analysis: "+command[3]+"</status>\n"; + } + else { + response.status=HTTPResponse::HTTP_NOT_FOUND; + response.description="<status context='"+command[1]+"'>File "+command[3]+" not found</status>\n"; + } - } - else { - response.status=HTTPResponse::HTTP_BAD_REQUEST; - response.description="<status context='"+command[1]+"'>Rotor: session busy</status>\n"; - } - } + } + else { + response.status=HTTPResponse::HTTP_BAD_REQUEST; + response.description="<status context='"+command[1]+"'>Rotor: session busy</status>\n"; + } + } } if (command[0]=="GET") { if (state==ANALYSING_AUDIO) { @@ -209,20 +216,20 @@ Command_response Render_context::session_command(const std::vector<std::string>& 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?? - //DUMMY RESPONSE - response.description="<status context='"+command[1]+"'>DUMMY RESPONSE Starting video analysis: "+command[3]+"</status>\n"; - } + 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?? + //DUMMY RESPONSE + response.description="<status context='"+command[1]+"'>DUMMY RESPONSE Starting video analysis: "+command[3]+"</status>\n"; + } else { - response.status=HTTPResponse::HTTP_NOT_FOUND; - response.description="<status context='"+command[1]+"'>File "+command[3]+" not found</status>\n"; - } + response.status=HTTPResponse::HTTP_NOT_FOUND; + response.description="<status context='"+command[1]+"'>File "+command[3]+" not found</status>\n"; + } } else { - response.status=HTTPResponse::HTTP_BAD_REQUEST; - response.description="<status context='"+command[1]+"'>Rotor: session busy</status>\n"; + response.status=HTTPResponse::HTTP_BAD_REQUEST; + response.description="<status context='"+command[1]+"'>Rotor: session busy</status>\n"; } } } @@ -241,10 +248,22 @@ Command_response Render_context::session_command(const std::vector<std::string>& response.description+="<progress>25.2</progress>\n"; } if (command[0]=="PUT") { - //DUMMY RESPONSE - //SHOULD CHECK REQUIREMENTS - response.status=HTTPResponse::HTTP_OK; - response.description="<status context='"+command[1]+"'>DUMMY RESPONSE Rotor: starting render</status>\n"; + if (command.size()>2) { + if (state==IDLE) { + output_filename=command[3]; //for now, store session variables in memory + add_queue(RENDER); + response.status=HTTPResponse::HTTP_OK; + response.description="<status context='"+command[1]+"'>Starting render: "+command[3]+"</status>\n"; + } + else { + response.status=HTTPResponse::HTTP_BAD_REQUEST; + response.description="<status context='"+command[1]+"'>Rotor: session busy</status>\n"; + } + } + else { + response.status=HTTPResponse::HTTP_BAD_REQUEST; + response.description="<status context='"+command[1]+"'>Rotor: no output file specified</status>\n"; + } } if (command[0]=="DELETE") { //DUMMY RESPONSE @@ -371,9 +390,9 @@ bool Render_context::load_audio(const string &filename,vector<Base_audio_process //now we can pass the data to the processor(s) for (auto p: processors) { - sample_processed=p->process_frame(frame->data[0],frame->nb_samples); + p->process_frame(frame->data[0],frame->nb_samples); } - + sample_processed+=frame->nb_samples; mutex.lock(); progress=((double)sample_processed)/samples; mutex.unlock(); @@ -480,6 +499,7 @@ Node_factory::Node_factory(){ add_type("divide",new Signal_divide()); add_type("==",new Is_new_integer()); add_type("signal_output",new Signal_output()); + add_type("video_output",new Video_output()); } bool Audio_thumbnailer::init(int _channels,int _bits,int _samples,int _rate) { //base_audio_processor::init(_channels,_bits,_samples); @@ -576,4 +596,7 @@ void Audio_analysis::print_features(){ for (auto i: analyser.features) { cerr<<i.second<<" "<<i.first<<endl; } +} +bool Video_output::render(const float duration, const float framerate,string &filename){ + //render out the network }
\ No newline at end of file |
