#include "rotord.h"
RotorRequestHandler::RotorRequestHandler(const std::string& format): _format(format){
}
void RotorRequestHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) {
Timestamp now;
std::string dt(DateTimeFormatter::format(now, _format));
response.setChunkedTransferEncoding(true);
response.setContentType("text/html");
std::ostream& ostr = response.send();
ostr << "
RotorServer powered by "
"POCO C++ Libraries";
ostr << "";
ostr << "";
ostr << dt;
ostr << "
";
}
RotorRequestHandlerFactory::RotorRequestHandlerFactory(const std::string& format):_format(format){
}
AudioAnalyserHandler::AudioAnalyserHandler(const vampHost::Settings& _settings): settings(_settings){
}
void AudioAnalyserHandler::handleRequest(HTTPServerRequest& request,HTTPServerResponse& response) {
response.setChunkedTransferEncoding(true);
response.setContentType("text/html");
string audioData=vampHost::
std::ostream& ostr = response.send();
ostr << "RotorServer powered by "
"POCO C++ Libraries";
ostr << "";
ostr << "";
ostr << dt;
ostr << "
";
}
AudioAnalyserFactory::AudioAnalyserFactory(const vampHost::Settings& _settings): settings(_settings){
}
HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPServerRequest& request){
Application& app = Application::instance();
Poco::URI theuri=Poco::URI(request.getURI());
std::vector segments;
theuri.getPathSegments(segments);
std::ostringstream ostr;
ostr << segments.size();
std::string out;
for (uint i=0;i3) {
// vamp/plugin/filter/filename
// how do deal with error condition?
return new RotorRequestHandler(_format);
//string audioData=runPlugin(string myname, string soname, string id,
// string output, int outputNo, string wavname,
// string outfilename, bool useFrames);
return 0;
}
else {
return 0;
}
}
RotorServer::RotorServer(): _helpRequested(false)
{
}
RotorServer::~RotorServer()
{
}
void RotorServer::initialize(Application& self){
loadConfiguration();
ServerApplication::initialize(self);
}
void RotorServer::uninitialize(){
ServerApplication::uninitialize();
}
void RotorServer::defineOptions(OptionSet& options) {
ServerApplication::defineOptions(options);
options.addOption(
Option("help", "h", "display argument help information")
.required(false)
.repeatable(false)
.callback(OptionCallback(this, &RotorServer::handleHelp)
)
);
}
void RotorServer::handleHelp(const std::string& name, const std::string& value){
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader(
"Rotor");
helpFormatter.format(std::cout);
stopOptionsProcessing();
_helpRequested = true;
}
int RotorServer::main(const std::vector& args){
if (!_helpRequested) {
unsigned short port = (unsigned short) config().getInt("port", 9980);
std::string format(config().getString("format", DateTimeFormat::SORTABLE_FORMAT));
ServerSocket svs(port);
HTTPServer srv(new RotorRequestHandlerFactory(format), svs, new HTTPServerParams);
srv.start();
waitForTerminationRequest();
srv.stop();
}
return Application::EXIT_OK;
}