Working encoder detection
This commit is contained in:
parent
5db07ea5ed
commit
21a9aaab98
4 changed files with 24 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
lib_LTLIBRARIES=libmist-1.0.la
|
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_LDFLAGS = -version-info 5:1:2
|
||||||
libmist_1_0_la_CPPFLAGS=$(DEPS_CFLAGS) $(global_CFLAGS)
|
libmist_1_0_la_CPPFLAGS=$(DEPS_CFLAGS) $(global_CFLAGS)
|
||||||
libmist_1_0_la_LIBADD=$(DEPS_LIBS) $(CLOCK_LIB)
|
libmist_1_0_la_LIBADD=$(DEPS_LIBS) $(CLOCK_LIB)
|
||||||
|
@ -8,5 +8,4 @@ pkgconfigdir = $(libdir)/pkgconfig
|
||||||
pkgconfig_DATA = mist-1.0.pc
|
pkgconfig_DATA = mist-1.0.pc
|
||||||
|
|
||||||
library_includedir=$(includedir)/mist-1.0/mist
|
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
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "timing.h"
|
||||||
#include "converter.h"
|
#include "converter.h"
|
||||||
#include "procs.h"
|
#include "procs.h"
|
||||||
|
|
||||||
|
@ -10,17 +12,18 @@ namespace Converter {
|
||||||
fillFFMpegEncoders();
|
fillFFMpegEncoders();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Converter::fillFFMpegEncoders(){
|
void Converter::fillFFMpegEncoders(){
|
||||||
std::vector<std::string> cmd;
|
char ** cmd = (char**)malloc(3*sizeof(char*));
|
||||||
cmd.push_back("ffmpeg");
|
cmd[0] = "ffmpeg";
|
||||||
cmd.push_back("-encoders");
|
cmd[1] = "-encoders";
|
||||||
|
cmd[2] = NULL;
|
||||||
int outFD = -1;
|
int outFD = -1;
|
||||||
Util::Procs::StartPiped("FFMpegInfo", cmd, 0, &outFD, 0);
|
Util::Procs::StartPiped("FFMpegInfo", cmd, 0, &outFD, 0);
|
||||||
|
while( Util::Procs::isActive("FFMpegInfo")){ Util::sleep(100); }
|
||||||
FILE * outFile = fdopen( outFD, "r" );
|
FILE * outFile = fdopen( outFD, "r" );
|
||||||
char * fileBuf = 0;
|
char * fileBuf = 0;
|
||||||
size_t fileBufLen = 0;
|
size_t fileBufLen = 0;
|
||||||
while ( !(feof(outFile) || ferror(outFile))){
|
while ( !(feof(outFile) || ferror(outFile)) && (getline(&fileBuf, &fileBufLen, outFile) != -1)){
|
||||||
getline(&fileBuf, &fileBufLen, outFile);
|
|
||||||
if (strstr(fileBuf, "aac") || strstr(fileBuf, "AAC")){
|
if (strstr(fileBuf, "aac") || strstr(fileBuf, "AAC")){
|
||||||
strtok(fileBuf, " \t");
|
strtok(fileBuf, " \t");
|
||||||
allCodecs["ffmpeg"][strtok(NULL, " \t")] = "aac";
|
allCodecs["ffmpeg"][strtok(NULL, " \t")] = "aac";
|
||||||
|
@ -37,8 +40,17 @@ namespace Converter {
|
||||||
fclose( outFile );
|
fclose( outFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
converterInfo & Converter::getCodecs(){
|
||||||
converterInfo & Converter::getCodecs() {
|
|
||||||
return allCodecs;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Converter {
|
||||||
public:
|
public:
|
||||||
Converter();
|
Converter();
|
||||||
converterInfo & getCodecs();
|
converterInfo & getCodecs();
|
||||||
|
JSON::Value getEncoders();
|
||||||
private:
|
private:
|
||||||
void fillFFMpegEncoders();
|
void fillFFMpegEncoders();
|
||||||
converterInfo allCodecs;
|
converterInfo allCodecs;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/// Contains utility code, not directly related to streaming media
|
/// Contains utility code, not directly related to streaming media
|
||||||
namespace Util {
|
namespace Util {
|
||||||
|
|
Loading…
Add table
Reference in a new issue