Some random fixes to metadata. Yay random.
This commit is contained in:
parent
559b4cacce
commit
d52e05fbd2
2 changed files with 17 additions and 14 deletions
|
@ -270,9 +270,7 @@ void DTSC::Stream::addPacket(JSON::Value & newPack){
|
||||||
buffercount = buffers.size();
|
buffercount = buffers.size();
|
||||||
if (buffercount < 2){buffercount = 2;}
|
if (buffercount < 2){buffercount = 2;}
|
||||||
}
|
}
|
||||||
if (metadata.bufferWindow < timeBuffered){
|
metadata.bufferWindow = timeBuffered;
|
||||||
metadata.bufferWindow = timeBuffered;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (buffers.size() > buffercount){
|
while (buffers.size() > buffercount){
|
||||||
|
@ -290,17 +288,16 @@ void DTSC::Stream::cutOneBuffer(){
|
||||||
std::cerr << "Warning - track " << trid << " doesn't have enough keyframes to be reliably served." << std::endl;
|
std::cerr << "Warning - track " << trid << " doesn't have enough keyframes to be reliably served." << std::endl;
|
||||||
}
|
}
|
||||||
keyframes[trid].erase(buffers.begin()->first);
|
keyframes[trid].erase(buffers.begin()->first);
|
||||||
int keySize = metadata.tracks[trid].keys.size();
|
|
||||||
for (int i = 0; i < metadata.tracks[trid].keys[0].getParts(); i++){
|
for (int i = 0; i < metadata.tracks[trid].keys[0].getParts(); i++){
|
||||||
metadata.tracks[trid].parts.pop_front();
|
metadata.tracks[trid].parts.pop_front();
|
||||||
}
|
}
|
||||||
metadata.tracks[trid].keys.pop_front();
|
metadata.tracks[trid].keys.pop_front();
|
||||||
|
metadata.tracks[trid].firstms = metadata.tracks[trid].keys[0].getTime();
|
||||||
// delete fragments of which the beginning can no longer be reached
|
// delete fragments of which the beginning can no longer be reached
|
||||||
while (metadata.tracks[trid].fragments.size() && metadata.tracks[trid].fragments[0].getNumber() < metadata.tracks[trid].keys[0].getNumber()){
|
while (metadata.tracks[trid].fragments.size() && metadata.tracks[trid].fragments[0].getNumber() < metadata.tracks[trid].keys[0].getNumber()){
|
||||||
metadata.tracks[trid].firstms = metadata.tracks[trid].keys[0].getTime();
|
|
||||||
metadata.tracks[trid].fragments.pop_front();
|
metadata.tracks[trid].fragments.pop_front();
|
||||||
// increase the missed fragments counter
|
// increase the missed fragments counter
|
||||||
metadata.tracks[trid].missedFrags ++;
|
metadata.tracks[trid].missedFrags++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffers.erase(buffers.begin());
|
buffers.erase(buffers.begin());
|
||||||
|
|
|
@ -261,10 +261,10 @@ namespace DTSC {
|
||||||
Key newKey;
|
Key newKey;
|
||||||
newKey.setTime(pack["time"].asInt());
|
newKey.setTime(pack["time"].asInt());
|
||||||
newKey.setParts(0);
|
newKey.setParts(0);
|
||||||
newKey.setLength(pack["time"].asInt());
|
newKey.setLength(0);
|
||||||
if (keys.size()){
|
if (keys.size()){
|
||||||
newKey.setNumber(keys[keys.size() - 1].getNumber() + 1);
|
newKey.setNumber(keys[keys.size() - 1].getNumber() + 1);
|
||||||
keys[keys.size() - 1].setLength(pack["time"].asInt() - keys[keys.size() - 1].getLength());
|
keys[keys.size() - 1].setLength(pack["time"].asInt() - keys[keys.size() - 1].getTime());
|
||||||
}else{
|
}else{
|
||||||
newKey.setNumber(1);
|
newKey.setNumber(1);
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ namespace DTSC {
|
||||||
}
|
}
|
||||||
|
|
||||||
void readOnlyMeta::send(Socket::Connection & conn){
|
void readOnlyMeta::send(Socket::Connection & conn){
|
||||||
int dataLen = 16 + (vod ? 14 : 0) + (live ? 15 : 0) + (merged ? 17 : 0) + 21;
|
int dataLen = 16 + (vod ? 14 : 0) + (live ? 15 : 0) + (merged ? 17 : 0) + (bufferWindow ? 24 : 0) + 21;
|
||||||
for (std::map<int,readOnlyTrack>::iterator it = tracks.begin(); it != tracks.end(); it++){
|
for (std::map<int,readOnlyTrack>::iterator it = tracks.begin(); it != tracks.end(); it++){
|
||||||
dataLen += it->second.getSendLen();
|
dataLen += it->second.getSendLen();
|
||||||
}
|
}
|
||||||
|
@ -621,13 +621,17 @@ namespace DTSC {
|
||||||
conn.SendNow("\000\006merged\001", 9);
|
conn.SendNow("\000\006merged\001", 9);
|
||||||
conn.SendNow(convertLongLong(1), 8);
|
conn.SendNow(convertLongLong(1), 8);
|
||||||
}
|
}
|
||||||
|
if (bufferWindow){
|
||||||
|
conn.SendNow("\000\015buffer_window\001", 16);
|
||||||
|
conn.SendNow(convertLongLong(bufferWindow), 8);
|
||||||
|
}
|
||||||
conn.SendNow("\000\012moreheader\001", 13);
|
conn.SendNow("\000\012moreheader\001", 13);
|
||||||
conn.SendNow(convertLongLong(moreheader), 8);
|
conn.SendNow(convertLongLong(moreheader), 8);
|
||||||
conn.SendNow("\000\000\356", 3);//End global object
|
conn.SendNow("\000\000\356", 3);//End global object
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meta::send(Socket::Connection & conn){
|
void Meta::send(Socket::Connection & conn){
|
||||||
int dataLen = 16 + (vod ? 14 : 0) + (live ? 15 : 0) + (merged ? 17 : 0) + 21;
|
int dataLen = 16 + (vod ? 14 : 0) + (live ? 15 : 0) + (merged ? 17 : 0) + (bufferWindow ? 24 : 0) + 21;
|
||||||
for (std::map<int,Track>::iterator it = tracks.begin(); it != tracks.end(); it++){
|
for (std::map<int,Track>::iterator it = tracks.begin(); it != tracks.end(); it++){
|
||||||
dataLen += it->second.getSendLen();
|
dataLen += it->second.getSendLen();
|
||||||
}
|
}
|
||||||
|
@ -650,6 +654,10 @@ namespace DTSC {
|
||||||
conn.SendNow("\000\006merged\001", 9);
|
conn.SendNow("\000\006merged\001", 9);
|
||||||
conn.SendNow(convertLongLong(1), 8);
|
conn.SendNow(convertLongLong(1), 8);
|
||||||
}
|
}
|
||||||
|
if (bufferWindow){
|
||||||
|
conn.SendNow("\000\015buffer_window\001", 16);
|
||||||
|
conn.SendNow(convertLongLong(bufferWindow), 8);
|
||||||
|
}
|
||||||
conn.SendNow("\000\012moreheader\001", 13);
|
conn.SendNow("\000\012moreheader\001", 13);
|
||||||
conn.SendNow(convertLongLong(moreheader), 8);
|
conn.SendNow(convertLongLong(moreheader), 8);
|
||||||
conn.SendNow("\000\000\356", 3);//End global object
|
conn.SendNow("\000\000\356", 3);//End global object
|
||||||
|
@ -743,7 +751,6 @@ namespace DTSC {
|
||||||
JSON::Value Meta::toJSON(){
|
JSON::Value Meta::toJSON(){
|
||||||
JSON::Value result;
|
JSON::Value result;
|
||||||
for (std::map<int,Track>::iterator it = tracks.begin(); it != tracks.end(); it++){
|
for (std::map<int,Track>::iterator it = tracks.begin(); it != tracks.end(); it++){
|
||||||
if (!it->second.trackID){continue;}
|
|
||||||
result["tracks"][it->second.getIdentifier()] = it->second.toJSON();
|
result["tracks"][it->second.getIdentifier()] = it->second.toJSON();
|
||||||
}
|
}
|
||||||
if (vod){
|
if (vod){
|
||||||
|
@ -756,7 +763,7 @@ namespace DTSC {
|
||||||
result["merged"] = 1ll;
|
result["merged"] = 1ll;
|
||||||
}
|
}
|
||||||
if (bufferWindow){
|
if (bufferWindow){
|
||||||
result["buffer_window"];
|
result["buffer_window"] = bufferWindow;
|
||||||
}
|
}
|
||||||
result["moreheader"] = moreheader;
|
result["moreheader"] = moreheader;
|
||||||
return result;
|
return result;
|
||||||
|
@ -765,7 +772,6 @@ namespace DTSC {
|
||||||
JSON::Value readOnlyMeta::toJSON(){
|
JSON::Value readOnlyMeta::toJSON(){
|
||||||
JSON::Value result;
|
JSON::Value result;
|
||||||
for (std::map<int,readOnlyTrack>::iterator it = tracks.begin(); it != tracks.end(); it++){
|
for (std::map<int,readOnlyTrack>::iterator it = tracks.begin(); it != tracks.end(); it++){
|
||||||
if (!it->second.trackID){continue;}
|
|
||||||
result["tracks"][it->second.getIdentifier()] = it->second.toJSON();
|
result["tracks"][it->second.getIdentifier()] = it->second.toJSON();
|
||||||
}
|
}
|
||||||
if (vod){
|
if (vod){
|
||||||
|
@ -779,7 +785,7 @@ namespace DTSC {
|
||||||
}
|
}
|
||||||
result["moreheader"] = moreheader;
|
result["moreheader"] = moreheader;
|
||||||
if (bufferWindow){
|
if (bufferWindow){
|
||||||
result["buffer_window"];
|
result["buffer_window"] = bufferWindow;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue