diff --git a/lib/Makefile.am b/lib/Makefile.am index 0c43b95a..9f68f05d 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,5 +1,5 @@ lib_LTLIBRARIES=libmist-1.0.la -libmist_1_0_la_SOURCES=amf.h amf.cpp auth.h auth.cpp base64.h base64.cpp config.h config.cpp dtsc.h dtsc.cpp flv_tag.h flv_tag.cpp http_parser.h http_parser.cpp json.h json.cpp procs.h procs.cpp rtmpchunks.h rtmpchunks.cpp socket.h socket.cpp mp4.h mp4.cpp ftp.h ftp.cpp filesystem.h filesystem.cpp stream.h stream.cpp timing.h timing.cpp ts_packet.cpp ts_packet.h +libmist_1_0_la_SOURCES=amf.h amf.cpp auth.h auth.cpp base64.h base64.cpp config.h config.cpp dtsc.h dtsc.cpp flv_tag.h flv_tag.cpp http_parser.h http_parser.cpp json.h json.cpp procs.h procs.cpp rtmpchunks.h rtmpchunks.cpp socket.h socket.cpp mp4.h mp4.cpp ftp.h ftp.cpp filesystem.h filesystem.cpp stream.h stream.cpp timing.h timing.cpp ts_packet.cpp ts_packet.h converter.cpp converter.h libmist_1_0_la_LDFLAGS = -version-info 5:1:2 libmist_1_0_la_CPPFLAGS=$(DEPS_CFLAGS) $(global_CFLAGS) libmist_1_0_la_LIBADD=$(DEPS_LIBS) $(CLOCK_LIB) @@ -8,5 +8,4 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = mist-1.0.pc library_includedir=$(includedir)/mist-1.0/mist -library_include_HEADERS = amf.h auth.h base64.h config.h dtsc.h flv_tag.h http_parser.h json.h procs.h rtmpchunks.h socket.h mp4.h ftp.h filesystem.h stream.h timing.h nal.h ts_packet.h - +library_include_HEADERS = amf.h auth.h base64.h config.h dtsc.h flv_tag.h http_parser.h json.h procs.h rtmpchunks.h socket.h mp4.h ftp.h filesystem.h stream.h timing.h nal.h ts_packet.h converter.h diff --git a/lib/converter.cpp b/lib/converter.cpp index a0f27485..65320ab1 100644 --- a/lib/converter.cpp +++ b/lib/converter.cpp @@ -1,6 +1,8 @@ #include +#include #include +#include "timing.h" #include "converter.h" #include "procs.h" @@ -10,17 +12,18 @@ namespace Converter { fillFFMpegEncoders(); } - void Converter::fillFFMpegEncoders(){ - std::vector cmd; - cmd.push_back("ffmpeg"); - cmd.push_back("-encoders"); + void Converter::fillFFMpegEncoders(){ + char ** cmd = (char**)malloc(3*sizeof(char*)); + cmd[0] = "ffmpeg"; + cmd[1] = "-encoders"; + cmd[2] = NULL; int outFD = -1; Util::Procs::StartPiped("FFMpegInfo", cmd, 0, &outFD, 0); + while( Util::Procs::isActive("FFMpegInfo")){ Util::sleep(100); } FILE * outFile = fdopen( outFD, "r" ); char * fileBuf = 0; size_t fileBufLen = 0; - while ( !(feof(outFile) || ferror(outFile))){ - getline(&fileBuf, &fileBufLen, outFile); + while ( !(feof(outFile) || ferror(outFile)) && (getline(&fileBuf, &fileBufLen, outFile) != -1)){ if (strstr(fileBuf, "aac") || strstr(fileBuf, "AAC")){ strtok(fileBuf, " \t"); allCodecs["ffmpeg"][strtok(NULL, " \t")] = "aac"; @@ -37,8 +40,17 @@ namespace Converter { fclose( outFile ); } - - converterInfo & Converter::getCodecs() { + converterInfo & Converter::getCodecs(){ return allCodecs; } + + JSON::Value Converter::getEncoders(){ + JSON::Value Result; + for (converterInfo::iterator convIt = allCodecs.begin(); convIt != allCodecs.end(); convIt++){ + for (codecInfo::iterator codIt = convIt->second.begin(); codIt != convIt->second.end(); codIt++){ + Result[convIt->first][codIt->first] = codIt->second; + } + } + return Result; + } } diff --git a/lib/converter.h b/lib/converter.h index 31b18b80..b572e52e 100644 --- a/lib/converter.h +++ b/lib/converter.h @@ -11,6 +11,7 @@ namespace Converter { public: Converter(); converterInfo & getCodecs(); + JSON::Value getEncoders(); private: void fillFFMpegEncoders(); converterInfo allCodecs; diff --git a/lib/procs.h b/lib/procs.h index 4a0343da..32fdd46d 100644 --- a/lib/procs.h +++ b/lib/procs.h @@ -5,6 +5,7 @@ #include #include #include +#include /// Contains utility code, not directly related to streaming media namespace Util {