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(){
|
void Input::quitPlay(){
|
||||||
playing = 0;
|
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);
|
static void callbackWrapper(char * data, size_t len, unsigned int id);
|
||||||
virtual bool setup() = 0;
|
virtual bool setup() = 0;
|
||||||
virtual bool readHeader() = 0;
|
virtual bool readHeader() = 0;
|
||||||
|
virtual bool readExistingHeader();
|
||||||
virtual bool atKeyFrame();
|
virtual bool atKeyFrame();
|
||||||
virtual void getNext(bool smart = true) {};
|
virtual void getNext(bool smart = true) {};
|
||||||
virtual void seek(int seekTime){};
|
virtual void seek(int seekTime){};
|
||||||
|
|
|
@ -49,23 +49,13 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inputFLV::readHeader() {
|
bool inputFLV::readHeader() {
|
||||||
JSON::Value lastPack;
|
if (!inFile){return false;}
|
||||||
if (!inFile) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//See whether a separate header file exists.
|
//See whether a separate header file exists.
|
||||||
DTSC::File tmp(config->getString("input") + ".dtsh");
|
if (readExistingHeader()){return true;}
|
||||||
if (tmp){
|
|
||||||
myMeta = tmp.getMeta();
|
|
||||||
if (myMeta){
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
myMeta = DTSC::Meta();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Create header file from FLV data
|
//Create header file from FLV data
|
||||||
fseek(inFile, 13, SEEK_SET);
|
fseek(inFile, 13, SEEK_SET);
|
||||||
AMF::Object amf_storage;
|
AMF::Object amf_storage;
|
||||||
|
JSON::Value lastPack;
|
||||||
long long int lastBytePos = 13;
|
long long int lastBytePos = 13;
|
||||||
while (!feof(inFile) && !FLV::Parse_Error){
|
while (!feof(inFile) && !FLV::Parse_Error){
|
||||||
if (tmpTag.FileLoader(inFile)){
|
if (tmpTag.FileLoader(inFile)){
|
||||||
|
@ -80,9 +70,7 @@ namespace Mist {
|
||||||
std::cerr << FLV::Error_Str << std::endl;
|
std::cerr << FLV::Error_Str << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
|
myMeta.toFile(config->getString("input") + ".dtsh");
|
||||||
oFile << myMeta.toJSON().toNetPacked();
|
|
||||||
oFile.close();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,17 +47,9 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inputMP3::readHeader() {
|
bool inputMP3::readHeader() {
|
||||||
if (!inFile) {
|
if (!inFile){return false;}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//See whether a separate header file exists.
|
//See whether a separate header file exists.
|
||||||
DTSC::File tmp(config->getString("input") + ".dtsh");
|
if (readExistingHeader()){return true;}
|
||||||
if (tmp){
|
|
||||||
myMeta = tmp.getMeta();
|
|
||||||
if (myMeta){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myMeta = DTSC::Meta();
|
myMeta = DTSC::Meta();
|
||||||
myMeta.tracks[1].trackID = 1;
|
myMeta.tracks[1].trackID = 1;
|
||||||
myMeta.tracks[1].type = "audio";
|
myMeta.tracks[1].type = "audio";
|
||||||
|
@ -93,9 +85,7 @@ namespace Mist {
|
||||||
|
|
||||||
fseek(inFile, 0, SEEK_SET);
|
fseek(inFile, 0, SEEK_SET);
|
||||||
timestamp = 0;
|
timestamp = 0;
|
||||||
std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
|
myMeta.toFile(config->getString("input") + ".dtsh");
|
||||||
oFile << myMeta.toJSON().toNetPacked();
|
|
||||||
oFile.close();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,11 +222,7 @@ namespace Mist {
|
||||||
getNext();
|
getNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
|
myMeta.toFile(config->getString("input") + ".dtsh");
|
||||||
oFile << myMeta.toJSON().toNetPacked();
|
|
||||||
oFile.close();
|
|
||||||
|
|
||||||
//myMeta.toPrettyString(std::cout);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue