Fixed JIT timestamps for live
This commit is contained in:
parent
19b67e4551
commit
94e39f8323
1 changed files with 33 additions and 23 deletions
|
@ -17,7 +17,7 @@
|
||||||
#define MIN_DELAY 2500
|
#define MIN_DELAY 2500
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist{
|
||||||
JSON::Value Output::capa = JSON::Value();
|
JSON::Value Output::capa = JSON::Value();
|
||||||
|
|
||||||
int getDTSCLen(char * mapped, long long int offset){
|
int getDTSCLen(char * mapped, long long int offset){
|
||||||
|
@ -35,7 +35,7 @@ namespace Mist {
|
||||||
capa["optional"]["debug"]["type"] = "debug";
|
capa["optional"]["debug"]["type"] = "debug";
|
||||||
}
|
}
|
||||||
|
|
||||||
Output::Output(Socket::Connection & conn) : myConn(conn) {
|
Output::Output(Socket::Connection & conn) : myConn(conn){
|
||||||
firstTime = 0;
|
firstTime = 0;
|
||||||
crc = getpid();
|
crc = getpid();
|
||||||
parseData = false;
|
parseData = false;
|
||||||
|
@ -135,7 +135,7 @@ namespace Mist {
|
||||||
return myConn.getBinHost();
|
return myConn.getBinHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Output::isReadyForPlay() {
|
bool Output::isReadyForPlay(){
|
||||||
if (myMeta.tracks.size()){
|
if (myMeta.tracks.size()){
|
||||||
if (!selectedTracks.size()){
|
if (!selectedTracks.size()){
|
||||||
selectDefaultTracks();
|
selectDefaultTracks();
|
||||||
|
@ -229,14 +229,14 @@ namespace Mist {
|
||||||
unsigned int bestSoFar = 0;
|
unsigned int bestSoFar = 0;
|
||||||
unsigned int bestSoFarCount = 0;
|
unsigned int bestSoFarCount = 0;
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
jsonForEach(capa["codecs"], it) {
|
jsonForEach(capa["codecs"], it){
|
||||||
unsigned int genCounter = 0;
|
unsigned int genCounter = 0;
|
||||||
unsigned int selCounter = 0;
|
unsigned int selCounter = 0;
|
||||||
if ((*it).size() > 0){
|
if ((*it).size() > 0){
|
||||||
jsonForEach((*it), itb) {
|
jsonForEach((*it), itb){
|
||||||
if ((*itb).size() > 0){
|
if ((*itb).size() > 0){
|
||||||
bool found = false;
|
bool found = false;
|
||||||
jsonForEach(*itb, itc) {
|
jsonForEach(*itb, itc){
|
||||||
for (std::set<unsigned long>::iterator itd = selectedTracks.begin(); itd != selectedTracks.end(); itd++){
|
for (std::set<unsigned long>::iterator itd = selectedTracks.begin(); itd != selectedTracks.end(); itd++){
|
||||||
if (myMeta.tracks[*itd].codec == (*itc).asStringRef()){
|
if (myMeta.tracks[*itd].codec == (*itc).asStringRef()){
|
||||||
selCounter++;
|
selCounter++;
|
||||||
|
@ -274,11 +274,11 @@ namespace Mist {
|
||||||
MEDIUM_MSG("Trying to fill: %s", capa["codecs"][bestSoFar].toString().c_str());
|
MEDIUM_MSG("Trying to fill: %s", capa["codecs"][bestSoFar].toString().c_str());
|
||||||
//try to fill as many codecs simultaneously as possible
|
//try to fill as many codecs simultaneously as possible
|
||||||
if (capa["codecs"][bestSoFar].size() > 0){
|
if (capa["codecs"][bestSoFar].size() > 0){
|
||||||
jsonForEach(capa["codecs"][bestSoFar], itb) {
|
jsonForEach(capa["codecs"][bestSoFar], itb){
|
||||||
if ((*itb).size() && myMeta.tracks.size()){
|
if ((*itb).size() && myMeta.tracks.size()){
|
||||||
bool found = false;
|
bool found = false;
|
||||||
jsonForEach((*itb), itc) {
|
jsonForEach((*itb), itc){
|
||||||
if (found) {
|
if (found){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (std::set<unsigned long>::iterator itd = selectedTracks.begin(); itd != selectedTracks.end(); itd++){
|
for (std::set<unsigned long>::iterator itd = selectedTracks.begin(); itd != selectedTracks.end(); itd++){
|
||||||
|
@ -317,7 +317,7 @@ namespace Mist {
|
||||||
DEBUG_MSG(DLVL_MEDIUM, "Selected tracks: %s (%lu)", selected.str().c_str(), selectedTracks.size());
|
DEBUG_MSG(DLVL_MEDIUM, "Selected tracks: %s (%lu)", selected.str().c_str(), selectedTracks.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedTracks.size() == 0) {
|
if (selectedTracks.size() == 0){
|
||||||
INSANE_MSG("We didn't find any tracks which that we can use. selectedTrack.size() is 0.");
|
INSANE_MSG("We didn't find any tracks which that we can use. selectedTrack.size() is 0.");
|
||||||
for (std::map<unsigned int,DTSC::Track>::iterator trit = myMeta.tracks.begin(); trit != myMeta.tracks.end(); trit++){
|
for (std::map<unsigned int,DTSC::Track>::iterator trit = myMeta.tracks.begin(); trit != myMeta.tracks.end(); trit++){
|
||||||
INSANE_MSG("Found track/codec: %s", trit->second.codec.c_str());
|
INSANE_MSG("Found track/codec: %s", trit->second.codec.c_str());
|
||||||
|
@ -652,7 +652,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Output::run() {
|
int Output::run(){
|
||||||
DONTEVEN_MSG("MistOut client handler started");
|
DONTEVEN_MSG("MistOut client handler started");
|
||||||
while (config->is_active && myConn && (wantRequest || parseData)){
|
while (config->is_active && myConn && (wantRequest || parseData)){
|
||||||
if (wantRequest){
|
if (wantRequest){
|
||||||
|
@ -676,7 +676,7 @@ namespace Mist {
|
||||||
//slow down processing, if real time speed is wanted
|
//slow down processing, if real time speed is wanted
|
||||||
if (realTime){
|
if (realTime){
|
||||||
uint8_t i = 6;
|
uint8_t i = 6;
|
||||||
while (--i && thisPacket.getTime() > (((Util::getMS() - firstTime)*1000)+maxSkipAhead)/realTime && config->is_active && myConn) {
|
while (--i && thisPacket.getTime() > (((Util::getMS() - firstTime)*1000)+maxSkipAhead)/realTime && config->is_active && myConn){
|
||||||
Util::sleep(std::min(thisPacket.getTime() - (((Util::getMS() - firstTime)*1000)+minSkipAhead)/realTime, 1000llu));
|
Util::sleep(std::min(thisPacket.getTime() - (((Util::getMS() - firstTime)*1000)+minSkipAhead)/realTime, 1000llu));
|
||||||
stats();
|
stats();
|
||||||
}
|
}
|
||||||
|
@ -917,16 +917,26 @@ namespace Mist {
|
||||||
|
|
||||||
//if there's a timestamp mismatch, print this.
|
//if there's a timestamp mismatch, print this.
|
||||||
//except for live, where we never know the time in advance
|
//except for live, where we never know the time in advance
|
||||||
if (thisPacket.getTime() != nxt.time && nxt.time && !atLivePoint){
|
if (thisPacket.getTime() != nxt.time && nxt.time){
|
||||||
static int warned = 0;
|
if (!atLivePoint){
|
||||||
if (warned < 5){
|
static int warned = 0;
|
||||||
WARN_MSG("Loaded %s track %ld@%llu instead of %u@%llu (%dms, %s, offset %lu)", streamName.c_str(), thisPacket.getTrackId(), thisPacket.getTime(), nxt.tid, nxt.time, (int)((long long)thisPacket.getTime() - (long long)nxt.time), myMeta.tracks[nxt.tid].codec.c_str(), nxt.offset);
|
if (warned < 5){
|
||||||
if (++warned == 5){
|
WARN_MSG("Loaded %s track %ld@%llu instead of %u@%llu (%dms, %s, offset %lu)", streamName.c_str(), thisPacket.getTrackId(),
|
||||||
WARN_MSG("Further warnings about time mismatches printed on HIGH level.");
|
thisPacket.getTime(), nxt.tid, nxt.time, (int)((long long)thisPacket.getTime() - (long long)nxt.time),
|
||||||
|
myMeta.tracks[nxt.tid].codec.c_str(), nxt.offset);
|
||||||
|
if (++warned == 5){WARN_MSG("Further warnings about time mismatches printed on HIGH level.");}
|
||||||
|
}else{
|
||||||
|
HIGH_MSG("Loaded %s track %ld@%llu instead of %u@%llu (%dms, %s, offset %lu)", streamName.c_str(), thisPacket.getTrackId(),
|
||||||
|
thisPacket.getTime(), nxt.tid, nxt.time, (int)((long long)thisPacket.getTime() - (long long)nxt.time),
|
||||||
|
myMeta.tracks[nxt.tid].codec.c_str(), nxt.offset);
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
HIGH_MSG("Loaded %s track %ld@%llu instead of %u@%llu (%dms, %s, offset %lu)", streamName.c_str(), thisPacket.getTrackId(), thisPacket.getTime(), nxt.tid, nxt.time, (int)((long long)thisPacket.getTime() - (long long)nxt.time), myMeta.tracks[nxt.tid].codec.c_str(), nxt.offset);
|
|
||||||
}
|
}
|
||||||
|
nxt.time = thisPacket.getTime();
|
||||||
|
//swap out the next object in the buffer with a new one
|
||||||
|
buffer.erase(buffer.begin());
|
||||||
|
buffer.insert(nxt);
|
||||||
|
VERYHIGH_MSG("JIT reordering %u@%llu.", nxt.tid, nxt.time);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//when live, every keyframe, check correctness of the keyframe number
|
//when live, every keyframe, check correctness of the keyframe number
|
||||||
|
@ -1059,17 +1069,17 @@ namespace Mist {
|
||||||
sentHeader = true;
|
sentHeader = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Output::connectToFile(std::string file) {
|
bool Output::connectToFile(std::string file){
|
||||||
int flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
int flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
||||||
int mode = O_RDWR | O_CREAT | O_TRUNC;
|
int mode = O_RDWR | O_CREAT | O_TRUNC;
|
||||||
int outFile = open(file.c_str(), mode, flags);
|
int outFile = open(file.c_str(), mode, flags);
|
||||||
if (outFile < 0) {
|
if (outFile < 0){
|
||||||
ERROR_MSG("Failed to open file %s, error: %s", file.c_str(), strerror(errno));
|
ERROR_MSG("Failed to open file %s, error: %s", file.c_str(), strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int r = dup2(outFile, myConn.getSocket());
|
int r = dup2(outFile, myConn.getSocket());
|
||||||
if (r == -1) {
|
if (r == -1){
|
||||||
ERROR_MSG("Failed to create an alias for the socket using dup2: %s.", strerror(errno));
|
ERROR_MSG("Failed to create an alias for the socket using dup2: %s.", strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue