diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-02-25 17:51:10 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-02-25 17:51:10 +0000 |
| commit | 58792f6cfd314499264183a5f63d8539e8b1e5e5 (patch) | |
| tree | 4e504f7a901a06a5d6929656d3791d8fbad6fd64 | |
| parent | d5193b058ca06db9bda772ccdf49a8c4976c7274 (diff) | |
threads stopping and starting
| -rw-r--r-- | rotord/Makefile | 14 | ||||
| -rw-r--r-- | rotord/av/avCodec.cpp (renamed from rotord/avCodec.cpp) | 0 | ||||
| -rw-r--r-- | rotord/av/avCodec.d | 66 | ||||
| -rw-r--r-- | rotord/av/avCodec.h (renamed from rotord/avCodec.h) | 0 | ||||
| -rw-r--r-- | rotord/av/avCodec.o | bin | 0 -> 183784 bytes | |||
| -rw-r--r-- | rotord/rotord.cbp | 41 | ||||
| -rwxr-xr-x | rotord/rotord.cpp | 106 | ||||
| -rwxr-xr-x | rotord/rotord.h | 6 |
8 files changed, 184 insertions, 49 deletions
diff --git a/rotord/Makefile b/rotord/Makefile index 6d0e513..c69db89 100644 --- a/rotord/Makefile +++ b/rotord/Makefile @@ -31,7 +31,7 @@ HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp # The pre-processor and compiler options. # Users can override those variables from the command line. CFLAGS = -g -O2 -CXXFLAGS= -g -O2 +CXXFLAGS= # The C program compiler. #CC = gcc @@ -87,7 +87,17 @@ LINK.cxx = $(CXX) $(MY_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) # Delete the default suffixes .SUFFIXES: -all: $(PROGRAM) +all: Release + +Release: CXXFLAGS += -O2 + +Release: $(PROGRAM) + +Debug: CXXFLAGS += -g3 + +Debug: $(PROGRAM) + + # Rules for creating dependency files (.d). #------------------------------------------ diff --git a/rotord/avCodec.cpp b/rotord/av/avCodec.cpp index 61c201b..61c201b 100644 --- a/rotord/avCodec.cpp +++ b/rotord/av/avCodec.cpp diff --git a/rotord/av/avCodec.d b/rotord/av/avCodec.d new file mode 100644 index 0000000..4bc3a37 --- /dev/null +++ b/rotord/av/avCodec.d @@ -0,0 +1,66 @@ +./avCodec.o: avCodec.cpp avCodec.h /usr/include/math.h \ + /usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \ + /usr/include/i386-linux-gnu/sys/cdefs.h \ + /usr/include/i386-linux-gnu/bits/wordsize.h \ + /usr/include/i386-linux-gnu/gnu/stubs.h \ + /usr/include/i386-linux-gnu/gnu/stubs-32.h \ + /usr/include/i386-linux-gnu/bits/huge_val.h \ + /usr/include/i386-linux-gnu/bits/huge_valf.h \ + /usr/include/i386-linux-gnu/bits/huge_vall.h \ + /usr/include/i386-linux-gnu/bits/inf.h \ + /usr/include/i386-linux-gnu/bits/nan.h \ + /usr/include/i386-linux-gnu/bits/mathdef.h \ + /usr/include/i386-linux-gnu/bits/mathcalls.h \ + /usr/include/i386-linux-gnu/bits/mathinline.h \ + ../ffmpeg/libavcodec/avcodec.h /usr/include/errno.h \ + /usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \ + /usr/include/asm-generic/errno-base.h ../ffmpeg/libavutil/samplefmt.h \ + /usr/lib/gcc/i686-linux-gnu/4.7/include/stdint.h /usr/include/stdint.h \ + /usr/include/i386-linux-gnu/bits/wchar.h ../ffmpeg/libavutil/avutil.h \ + ../ffmpeg/libavutil/common.h /usr/include/ctype.h \ + /usr/include/i386-linux-gnu/bits/types.h \ + /usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/endian.h \ + /usr/include/i386-linux-gnu/bits/endian.h \ + /usr/include/i386-linux-gnu/bits/byteswap.h /usr/include/xlocale.h \ + /usr/include/inttypes.h \ + /usr/lib/gcc/i686-linux-gnu/4.7/include-fixed/limits.h \ + /usr/lib/gcc/i686-linux-gnu/4.7/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/i386-linux-gnu/bits/posix1_lim.h \ + /usr/include/i386-linux-gnu/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/i386-linux-gnu/bits/posix2_lim.h \ + /usr/include/i386-linux-gnu/bits/xopen_lim.h \ + /usr/include/i386-linux-gnu/bits/stdio_lim.h /usr/include/stdio.h \ + /usr/lib/gcc/i686-linux-gnu/4.7/include/stddef.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i686-linux-gnu/4.7/include/stdarg.h \ + /usr/include/i386-linux-gnu/bits/sys_errlist.h \ + /usr/include/i386-linux-gnu/bits/stdio.h \ + /usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/stdlib.h \ + /usr/include/i386-linux-gnu/bits/waitflags.h \ + /usr/include/i386-linux-gnu/bits/waitstatus.h \ + /usr/include/i386-linux-gnu/sys/types.h /usr/include/time.h \ + /usr/include/i386-linux-gnu/sys/select.h \ + /usr/include/i386-linux-gnu/bits/select.h \ + /usr/include/i386-linux-gnu/bits/sigset.h \ + /usr/include/i386-linux-gnu/bits/time.h \ + /usr/include/i386-linux-gnu/bits/select2.h \ + /usr/include/i386-linux-gnu/sys/sysmacros.h \ + /usr/include/i386-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/i386-linux-gnu/bits/stdlib.h /usr/include/string.h \ + /usr/include/i386-linux-gnu/bits/string3.h \ + ../ffmpeg/libavutil/attributes.h ../ffmpeg/libavutil/version.h \ + /usr/include/libavutil/avconfig.h ../ffmpeg/libavutil/mem.h \ + ../ffmpeg/libavutil/error.h ../ffmpeg/libavutil/mathematics.h \ + ../ffmpeg/libavutil/rational.h ../ffmpeg/libavutil/intfloat.h \ + ../ffmpeg/libavutil/intfloat_readwrite.h ../ffmpeg/libavutil/log.h \ + ../ffmpeg/libavutil/pixfmt.h ../ffmpeg/libavutil/version.h \ + ../ffmpeg/libavutil/old_pix_fmts.h ../ffmpeg/libavutil/avutil.h \ + ../ffmpeg/libavutil/cpu.h ../ffmpeg/libavutil/channel_layout.h \ + ../ffmpeg/libavutil/dict.h ../ffmpeg/libavutil/log.h \ + ../ffmpeg/libavutil/pixfmt.h ../ffmpeg/libavutil/rational.h \ + ../ffmpeg/libavcodec/version.h ../ffmpeg/libavcodec/old_codec_ids.h \ + ../ffmpeg/libavutil/common.h ../ffmpeg/libavutil/opt.h \ + ../ffmpeg/libavutil/dict.h ../ffmpeg/libavutil/samplefmt.h \ + ../ffmpeg/libavutil/imgutils.h ../ffmpeg/libavutil/pixdesc.h \ + ../ffmpeg/libavutil/mathematics.h diff --git a/rotord/avCodec.h b/rotord/av/avCodec.h index 7e1815a..7e1815a 100644 --- a/rotord/avCodec.h +++ b/rotord/av/avCodec.h diff --git a/rotord/av/avCodec.o b/rotord/av/avCodec.o Binary files differnew file mode 100644 index 0000000..e270b4b --- /dev/null +++ b/rotord/av/avCodec.o diff --git a/rotord/rotord.cbp b/rotord/rotord.cbp new file mode 100644 index 0000000..e776043 --- /dev/null +++ b/rotord/rotord.cbp @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="rotord" /> + <Option pch_mode="2" /> + <Option compiler="gcc" /> + <Build> + <Target title="Debug"> + <Option output="rotord" prefix_auto="1" extension_auto="1" /> + <Option object_output="/home/tim/workspace/rotor/rotord//.objs" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-g" /> + </Compiler> + </Target> + <Target title="Release"> + <Option output="rotord" prefix_auto="1" extension_auto="1" /> + <Option object_output="/home/tim/workspace/rotor/rotord//.objs" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-O2" /> + </Compiler> + <Linker> + <Add option="-s" /> + </Linker> + </Target> + </Build> + <Compiler> + <Add option="-Wall" /> + </Compiler> + <Extensions> + <envvars /> + <code_completion /> + <debugger /> + <lib_finder disable_auto="1" /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp index cb106d0..f9e1d21 100755 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -35,7 +35,7 @@ RotorRequestHandler::RotorRequestHandler(const std::string& format): _format(for } void RotorRequestHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) { - + Timestamp now; std::string dt(DateTimeFormatter::format(now, _format)); @@ -60,7 +60,7 @@ void AudioAnalyserHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe response.setChunkedTransferEncoding(true); response.setContentType("text/html"); - + //string audioData=vampHost::runPlugin(); std::ostream& ostr = response.send(); @@ -81,13 +81,13 @@ RenderContextHandler::RenderContextHandler(const std::string _content,const HTTP void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) { - response.setChunkedTransferEncoding(true); - response.setContentType("text/html"); + response.setChunkedTransferEncoding(true); + response.setContentType("text/html"); response.setStatus(status); - - std::ostream& ostr = response.send(); - - ostr << "<?xml version='1.0' encoding='ISO-8859-1'?>"; + + std::ostream& ostr = response.send(); + + ostr << "<?xml version='1.0' encoding='ISO-8859-1'?>\n"; ostr << content; } @@ -95,17 +95,17 @@ void RenderContextHandler::handleRequest(HTTPServerRequest& request,HTTPServerRe HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPServerRequest& request){ Application& app = Application::instance(); - + Poco::URI theuri=Poco::URI(request.getURI()); std::vector <std::string> command; theuri.getPathSegments(command); - + app.logger().information(request.clientAddress().toString()+" "+request.getMethod()); - + string content=""; HTTPResponse::HTTPStatus status=HTTPResponse::HTTP_OK; - - + + /* if (segments.size() == 0) { return new RotorRequestHandler(_format); @@ -113,7 +113,7 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS else if (segments[0]=="vamp"&&segments.size()>3) { // vamp/plugin/filter/filename // how do deal with error condition? - + //Settings(string _so="",string _filter="",string _id="",string _input=""); return new AudioAnalyserHandler(vampHost::Settings(segments[1],segments[2],segments[3])); //string audioData=runPlugin(string myname, string soname, string id, @@ -123,61 +123,79 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS } else if (segments[0]=="new") { // create a new render context - + return 0; } else { return 0; } */ - - + + //at this point we are within app - //making a new contexthandler? + //making a new contexthandler? //how will this have access to the thread that it refers to //how will messages be passed - //we need to do testing etc here and - + //we need to do testing etc here and + //what does the handler do? //it gets passed the response- gets to set response code - - + + if (command.size()) { if (command[0]=="new") { - string sID=idGen.create().toString(); + string sID=idGen.createOne().toString(); //create() seems to cause problems + //Creates a new time-based UUID, using the MAC address of one of the system's ethernet adapters. + //Throws a SystemException if no MAC address can be obtained. + // + //seems to hang, to me printf("Rotor: starting thread\n"); manager.start(new Rotor::Render_context(sID)); content="<sID>"+sID+"</sID>\n"; } else if (command[0]=="list") { - std::list < Poco::AutoPtr < Poco::Task > >::iterator it; - it=manager.taskList().begin(); - for (it=manager.taskList().begin();it !=manager.taskList().end();++it) { - content+="<sID>"+(*it)->name()+"</sID>\n"; - } + //std::list < Poco::AutoPtr < Poco::Task > >::iterator it; + //it=manager.taskList().begin(); + //for (it=manager.taskList().begin();it !=manager.taskList().end();++it) { + //content+="<sID>"+(*it)->name()+"</sID>\n"; + //} + + //massive problems making an iterator for the tasklist, the above crashes + //solution: auto type range-based for-loop + //this is c++11 specific but works + + for (auto& task: manager.taskList()) + { + content+="<sID>"+task->name()+" </sID>\n"; + } } else { - std::unordered_map<std::string,Rotor::Render_context>::iterator iter = context.find(command[0]); - if (iter!=context.end()) { - //successfully located context - if (command.size()==1) { - //just invoking sID - if (request.getMethod()=="DELETE") { - - } - } - else { - - } - } - else { + bool found=false; + for (auto& task: manager.taskList()) + { + if(task->name()==command[0]) { + found=true; + if (command.size()==1) { + //just invoking sID + if (request.getMethod()=="DELETE") { + task->cancel(); + content="<status>1</status>\n"; + } + else { + status=HTTPResponse::HTTP_BAD_REQUEST; + content="<status>Rotor: render context invoked with no command</status>\n"; + } + } + } + } + if (!found) { status=HTTPResponse::HTTP_NOT_FOUND; - content="<body>Rotor: render context not found</body>\n"; + content="<status>Rotor: render context not found</status>\n"; } } } else { - content="<body>Rotor: empty request</body>"; + content="<status>Rotor: empty request</status>"; } return new RenderContextHandler(content, status); } diff --git a/rotord/rotord.h b/rotord/rotord.h index b948577..99e588a 100755 --- a/rotord/rotord.h +++ b/rotord/rotord.h @@ -43,7 +43,7 @@ using Poco::Util::OptionCallback; using Poco::Util::HelpFormatter; #include "vampHost.h" -#include "avCodec.h" +//#include "avCodec.h" #include "rotor.h" class RotorRequestHandler: public HTTPRequestHandler @@ -98,11 +98,11 @@ class RotorServer: public Poco::Util::ServerApplication int main(const std::vector<std::string>& args); private: bool _helpRequested; - + }; int main(int argc, char** argv) { RotorServer app; return app.run(argc, argv); -}
\ No newline at end of file +} |
