summaryrefslogtreecommitdiff
path: root/rotord/src/rendercontext.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-09-07 14:57:23 +0100
committerTim Redfern <tim@eclectronics.org>2013-09-07 14:57:23 +0100
commit6f0f7600e22590b28fc6b0d11a28fa7a42931e20 (patch)
treeb18450ac2d291c6de46385e17bcbd13928e410b6 /rotord/src/rendercontext.cpp
parentfea5bf3ffeac6f7a4c5cccb69c5ce51e4a42dbaf (diff)
refactoring
Diffstat (limited to 'rotord/src/rendercontext.cpp')
-rw-r--r--rotord/src/rendercontext.cpp64
1 files changed, 2 insertions, 62 deletions
diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp
index cebe003..1cc440a 100644
--- a/rotord/src/rendercontext.cpp
+++ b/rotord/src/rendercontext.cpp
@@ -23,7 +23,7 @@ void Render_context::runTask() {
processors.push_back(dynamic_cast<Audio_processor*>(a.second));
}
}
- if (load_audio(graph.audio_filename,processors)) {
+ if (graph.load_audio(graph.audio_filename,processors)) {
graph.audio_loaded=true;
state=IDLE;
}
@@ -272,7 +272,7 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H
//check file exists
Poco::File f=Poco::File(video_filename);
if (f.exists()) {
- if (load_video(command.commands[2],video_filename)) {
+ if (graph.load_video(command.commands[2],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;
@@ -439,63 +439,3 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H
}
}
-bool Render_context::load_audio(const string &filename,vector<Audio_processor*> processors){
- Logger& logger = Logger::get("Rotor");
- logger.information("Analysing "+filename);
-
- libav::audioloader loader;
- loader.setup(filename);
-
- graph.duration=((float)loader.formatContext->duration)/AV_TIME_BASE;
-
- int rate = loader.codecContext->sample_rate;
- int samples = ((loader.formatContext->duration + 5000)*rate)/AV_TIME_BASE; //why 5000 more?
- int channels= loader.codecContext->channels;
- int bits = 16; //???why can't we read this loader.codecContext->bits_per_raw_sample;
-
- for (auto p: processors) {
- if(!p->init(channels,bits,samples,rate) ){
- logger.error("ERROR: Audio plugin failed to initialse");
- return false;
- }
- }
-
- AVFrame* frame=loader.get_frame();
- int sample_processed=0;
-
- while (frame)
- {
- //now we can pass the data to the processor(s)
- for (auto p: processors) {
- p->process_frame(frame->data[0],frame->nb_samples);
- }
- sample_processed+=frame->nb_samples;
- //mutex.lock();
- progress=((float)sample_processed)/samples; //atomic on 64 bit?
- //mutex.unlock();
-
- frame=loader.get_frame();
- }
-
- loader.close();
-
- for (auto p: processors) {
- p->cleanup();
- p->print_summary();
- }
-
- logger.information("Finished audio analysis");
- return true;
-}
-bool Render_context::load_video(const string &nodeID,const string &filename){
- //this is a good standard example of how to find
- //a node of a specific type by ID and do something
- if (graph.nodes.find(nodeID)!=graph.nodes.end()){
- if (graph.nodes[nodeID]->type=="video_loader") {
- if (((Video_loader*)graph.nodes[nodeID])->load(filename)) {
- return true;
- }
- }
- }
- return false;
-}