From e3bb5253d057e78032381bab70545ed74e8f1ba8 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Wed, 27 Feb 2013 15:39:10 +0100 Subject: [PATCH] Working encoder detection --- src/controller/controller.cpp | 11 +++++++++++ src/info.cpp | 9 ++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index 4fcb1d64..09c3a877 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "controller_storage.h" #include "controller_connectors.h" #include "controller_streams.h" @@ -243,6 +244,10 @@ int main(int argc, char ** argv){ Controller::ConnectedUser * uplink = 0; Controller::Log("CONF", "Controller started"); conf.activate(); + + //Create a converter class and automatically load in all encoders. + Converter::Converter myConverter; + while (API_Socket.connected() && conf.is_active){ usleep(10000); //sleep for 10 ms - prevents 100% CPU time @@ -450,6 +455,11 @@ int main(int argc, char ** argv){ if (Request.isMember("capabilities")){ Controller::checkCapable(Response["capabilities"]); } + if (Request.isMember("conversion")){ + if (Request["conversion"].isMember("encoders")) { + Response["conversion"]["encoders"] = myConverter.getEncoders(); + } + } if (Request.isMember("save")){ Controller::WriteFile(conf.getString("configFile"), Controller::Storage.toString()); Controller::Log("CONF", "Config written to file on request through API"); @@ -472,6 +482,7 @@ int main(int argc, char ** argv){ Controller::Storage["log"].null(); Controller::Storage["statistics"].null(); } + } jsonp = ""; if (it->H.GetVar("callback") != ""){ diff --git a/src/info.cpp b/src/info.cpp index 01f85095..ee007d22 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace Info { int getInfo(int argc, char* argv[]) { @@ -16,11 +17,13 @@ namespace Info { DTSC::File F(argv[1]); JSON::Value fileSpecs = F.getMeta(); if( !fileSpecs ) { - std::vector cmd; - cmd.push_back("ffprobe"); - cmd.push_back(argv[1]); + char ** cmd = (char**)malloc(3*sizeof(char*)); + cmd[0] = "ffprobe"; + cmd[1] = argv[1]; + cmd[2] = NULL; int outFD = -1; Util::Procs::StartPiped("FFProbe", cmd, 0, 0, &outFD); + while( Util::Procs::isActive("FFProbe")){ Util::sleep(100); } FILE * outFile = fdopen( outFD, "r" ); char * fileBuf = 0; size_t fileBufLen = 0;