Small updates and fixes to the dtsc library.
This commit is contained in:
parent
f88bee5baf
commit
526feda148
2 changed files with 8 additions and 5 deletions
11
lib/dtsc.cpp
11
lib/dtsc.cpp
|
@ -212,15 +212,16 @@ void DTSC::Stream::addPacket(JSON::Value & newPack){
|
||||||
JSON::Value key;
|
JSON::Value key;
|
||||||
key["time"] = newPack["time"];
|
key["time"] = newPack["time"];
|
||||||
if (keySize){
|
if (keySize){
|
||||||
key["num"] = (*(metadata["tracks"][trackMapping[newPos.trackID]]["keys"].ArrEnd()--))["num"].asInt() + 1;
|
key["num"] = metadata["tracks"][trackMapping[newPos.trackID]]["keys"][keySize -1]["num"].asInt() + 1;
|
||||||
}else{
|
}else{
|
||||||
key["num"] = 1;
|
key["num"] = 1;
|
||||||
}
|
}
|
||||||
|
metadata["tracks"][trackMapping[newPos.trackID]]["keys"].append(key);
|
||||||
}
|
}
|
||||||
unsigned int timeBuffered = 0;
|
unsigned int timeBuffered = 0;
|
||||||
if (keySize > 1){
|
if (keySize > 1){
|
||||||
//increase buffer size if no keyframes available or too little time available
|
//increase buffer size if no keyframes available or too little time available
|
||||||
timeBuffered = (buffers.end()--)->second["time"].asInt() - buffers.begin()->second["time"].asInt();
|
timeBuffered = buffers.rbegin()->second["time"].asInt() - buffers.begin()->second["time"].asInt();
|
||||||
}
|
}
|
||||||
if (buffercount > 1 && (keyframes.size() < 2 || timeBuffered < buffertime)){
|
if (buffercount > 1 && (keyframes.size() < 2 || timeBuffered < buffertime)){
|
||||||
buffercount++;
|
buffercount++;
|
||||||
|
@ -612,8 +613,10 @@ void DTSC::File::readHeader(int pos){
|
||||||
}
|
}
|
||||||
//if there is another header, read it and replace metadata with that one.
|
//if there is another header, read it and replace metadata with that one.
|
||||||
if (metadata.isMember("moreheader") && metadata["moreheader"].asInt() > 0){
|
if (metadata.isMember("moreheader") && metadata["moreheader"].asInt() > 0){
|
||||||
readHeader(metadata["moreheader"].asInt());
|
if (metadata["moreheader"].asInt() < getBytePosEOF()){
|
||||||
return;
|
readHeader(metadata["moreheader"].asInt());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
metadata["vod"] = true;
|
metadata["vod"] = true;
|
||||||
metadata.netPrepare();
|
metadata.netPrepare();
|
||||||
|
|
|
@ -207,7 +207,7 @@ namespace DTSC {
|
||||||
void setBufferTime(unsigned int ms);
|
void setBufferTime(unsigned int ms);
|
||||||
bool isNewest(DTSC::livePos & pos);
|
bool isNewest(DTSC::livePos & pos);
|
||||||
DTSC::livePos getNext(DTSC::livePos & pos, std::set<int> & allowedTracks);
|
DTSC::livePos getNext(DTSC::livePos & pos, std::set<int> & allowedTracks);
|
||||||
private:
|
private:
|
||||||
std::map<livePos,JSON::Value> buffers;
|
std::map<livePos,JSON::Value> buffers;
|
||||||
std::map<int,std::set<livePos> > keyframes;
|
std::map<int,std::set<livePos> > keyframes;
|
||||||
void addPacket(JSON::Value & newPack);
|
void addPacket(JSON::Value & newPack);
|
||||||
|
|
Loading…
Add table
Reference in a new issue