diff options
| author | Comment <tim@gray.(none)> | 2013-09-30 11:51:58 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-09-30 11:51:58 +0100 |
| commit | 38edd2e78c326059209c1fd15bf1b543f5fd7a46 (patch) | |
| tree | dd31a0687e5f7f4ab32b3b7548412e3fd64eac0e /rotord | |
| parent | 873f295e28a20e2e774852d8d7010ff5629549b4 (diff) | |
mutex locking progress bar
Diffstat (limited to 'rotord')
| -rwxr-xr-x | rotord/preview | 49 | ||||
| -rw-r--r-- | rotord/src/graph.cpp | 2 | ||||
| -rw-r--r-- | rotord/src/graph.h | 3 | ||||
| -rw-r--r-- | rotord/src/rendercontext.cpp | 2 | ||||
| -rw-r--r-- | rotord/src/rendercontext.h | 14 | ||||
| -rw-r--r-- | rotord/src/rotord.cpp | 2 |
6 files changed, 66 insertions, 6 deletions
diff --git a/rotord/preview b/rotord/preview new file mode 100755 index 0000000..f1f70af --- /dev/null +++ b/rotord/preview @@ -0,0 +1,49 @@ +#!/usr/bin/python +import httplib +import argparse +from lxml import etree +import os, time + +method="PUT" +ip="127.0.0.1:9000" +path="/a/render" + +parser = argparse.ArgumentParser() +parser.add_argument("filename",default="",nargs='?') +parser.add_argument("start",default=0,nargs='?') +parser.add_argument("stop",default=0,nargs='?') +parser.add_argument("framerate",default="",nargs='?') +args=parser.parse_args() +connection = httplib.HTTPConnection(ip) +body=args.filename +if args.start!=0: + body=body+","+args.start + if args.stop!=0: + body=body+","+args.stop +#print method,path,body +connection.request(method,path,body) +root = etree.XML(connection.getresponse().read()) +path="" +for element in root.iter(): + if element.tag=="path": + path=element.text + +if path!="": + print path + waiting=True + query="GET a/render" + while waiting: + time.sleep(0.1) + connection.request("GET","a/render","") + root = etree.XML(connection.getresponse().read()) + for element in root.iter(): + if element.tag=="error": + waiting=False + os.popen('vlc '+path) + + + +#connection = httplib.HTTPConnection('54.228.219.55:80') +#connection = httplib.HTTPConnection('127.0.0.1:9000') + + diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index f904a9d..b70684f 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -211,7 +211,9 @@ bool Graph::video_render(const string &output_filename,const float framerate,int exporter.encodeFrame(i->RGBdata); } vf+=vstep; + mutex.lock(); progress=vf/duration; + mutex.unlock(); if (usingaudio) {delete a;}; } diff --git a/rotord/src/graph.h b/rotord/src/graph.h index a13bddf..b775c5a 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -77,6 +77,9 @@ namespace Rotor { float progress; int bitRate; + Poco::Mutex mutex; //lock for access from parent thread + + Audio_thumbnailer *audio_thumb; private: int outW,outH; diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index 1beb6cc..2a9dd62 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -490,9 +490,11 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H if (command.commands[1]=="render") { if (command.method=="GET") { if(state==RENDERING){ + graph.mutex.lock(); status=HTTPResponse::HTTP_OK; XML.addValue("status","Rendering video"); XML.addValue("progress",toString(graph.progress)); + graph.mutex.unlock(); } else { logger.error("ERROR: Render progress requested but not rendering"); diff --git a/rotord/src/rendercontext.h b/rotord/src/rendercontext.h index 130c678..0cecf49 100644 --- a/rotord/src/rendercontext.h +++ b/rotord/src/rendercontext.h @@ -82,23 +82,25 @@ namespace Rotor { } //interrupt locking process Render_status get_render_status(const string &uid){ - //cerr<<"render status requested: "<<uid<<" status: "<<renders[uid].status<<endl; - + graph.mutex.lock(); + //cerr<<"render status requested: "<<uid<<" status: "<<renders[uid].status<<endl; + if (renders.find(uid)!=renders.end()){ if (renders[uid].status==RENDERING){ renders[uid].progress=graph.progress; } + graph.mutex.unlock(); return renders[uid]; } - else return Render_status(NOT_FOUND); + graph.mutex.unlock(); + return Render_status(NOT_FOUND); + }; private: int state; //thread only does one thing at once std::deque<Session_task> work_queue; std::unordered_map<string,Render_status> renders; - Poco::Mutex mutex; //lock for access from parent thread - std::string output_filename; std::string graph_dir; std::string media_dir; @@ -106,6 +108,8 @@ namespace Rotor { std::string graph_filename; std::string graph_body; + Poco::Mutex mutex; //lock for access from parent thread + Audio_thumbnailer *audio_thumb; Graph graph; float output_framerate; diff --git a/rotord/src/rotord.cpp b/rotord/src/rotord.cpp index a22c6c3..de853e4 100644 --- a/rotord/src/rotord.cpp +++ b/rotord/src/rotord.cpp @@ -29,7 +29,7 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS theuri.getPathSegments(command); Logger& logger = Logger::get("Rotor"); - logger.information(request.clientAddress().toString()+" "+request.getMethod()); + //logger.information(request.clientAddress().toString()+" "+request.getMethod()); HTTPResponse::HTTPStatus status=HTTPResponse::HTTP_BAD_REQUEST; //by default |
