Generalized DTSH header reading and writing of Inputs
This commit is contained in:
parent
7518014703
commit
fedd18146e
5 changed files with 23 additions and 34 deletions
|
@ -533,5 +533,19 @@ namespace Mist {
|
|||
void Input::quitPlay(){
|
||||
playing = 0;
|
||||
}
|
||||
|
||||
bool Input::readExistingHeader(){
|
||||
DTSC::File tmpdtsh(config->getString("input") + ".dtsh");
|
||||
if (!tmpdtsh){
|
||||
return false;
|
||||
}
|
||||
if (tmpdtsh.getMeta().version != DTSH_VERSION){
|
||||
INFO_MSG("Updating wrong version header file from version %llu to %llu", tmpdtsh.getMeta().version, DTSH_VERSION);
|
||||
return false;
|
||||
}
|
||||
myMeta = tmpdtsh.getMeta();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace Mist {
|
|||
static void callbackWrapper(char * data, size_t len, unsigned int id);
|
||||
virtual bool setup() = 0;
|
||||
virtual bool readHeader() = 0;
|
||||
virtual bool readExistingHeader();
|
||||
virtual bool atKeyFrame();
|
||||
virtual void getNext(bool smart = true) {};
|
||||
virtual void seek(int seekTime){};
|
||||
|
|
|
@ -49,23 +49,13 @@ namespace Mist {
|
|||
}
|
||||
|
||||
bool inputFLV::readHeader() {
|
||||
JSON::Value lastPack;
|
||||
if (!inFile) {
|
||||
return false;
|
||||
}
|
||||
if (!inFile){return false;}
|
||||
//See whether a separate header file exists.
|
||||
DTSC::File tmp(config->getString("input") + ".dtsh");
|
||||
if (tmp){
|
||||
myMeta = tmp.getMeta();
|
||||
if (myMeta){
|
||||
return true;
|
||||
}else{
|
||||
myMeta = DTSC::Meta();
|
||||
}
|
||||
}
|
||||
if (readExistingHeader()){return true;}
|
||||
//Create header file from FLV data
|
||||
fseek(inFile, 13, SEEK_SET);
|
||||
AMF::Object amf_storage;
|
||||
JSON::Value lastPack;
|
||||
long long int lastBytePos = 13;
|
||||
while (!feof(inFile) && !FLV::Parse_Error){
|
||||
if (tmpTag.FileLoader(inFile)){
|
||||
|
@ -80,9 +70,7 @@ namespace Mist {
|
|||
std::cerr << FLV::Error_Str << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
|
||||
oFile << myMeta.toJSON().toNetPacked();
|
||||
oFile.close();
|
||||
myMeta.toFile(config->getString("input") + ".dtsh");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,17 +47,9 @@ namespace Mist {
|
|||
}
|
||||
|
||||
bool inputMP3::readHeader() {
|
||||
if (!inFile) {
|
||||
return false;
|
||||
}
|
||||
if (!inFile){return false;}
|
||||
//See whether a separate header file exists.
|
||||
DTSC::File tmp(config->getString("input") + ".dtsh");
|
||||
if (tmp){
|
||||
myMeta = tmp.getMeta();
|
||||
if (myMeta){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (readExistingHeader()){return true;}
|
||||
myMeta = DTSC::Meta();
|
||||
myMeta.tracks[1].trackID = 1;
|
||||
myMeta.tracks[1].type = "audio";
|
||||
|
@ -93,9 +85,7 @@ namespace Mist {
|
|||
|
||||
fseek(inFile, 0, SEEK_SET);
|
||||
timestamp = 0;
|
||||
std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
|
||||
oFile << myMeta.toJSON().toNetPacked();
|
||||
oFile.close();
|
||||
myMeta.toFile(config->getString("input") + ".dtsh");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,11 +222,7 @@ namespace Mist {
|
|||
getNext();
|
||||
}
|
||||
|
||||
std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
|
||||
oFile << myMeta.toJSON().toNetPacked();
|
||||
oFile.close();
|
||||
|
||||
//myMeta.toPrettyString(std::cout);
|
||||
myMeta.toFile(config->getString("input") + ".dtsh");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue