Optimized waiting for streams/tracks.
This commit is contained in:
parent
cc93a8fa4e
commit
425aa3059f
3 changed files with 16 additions and 16 deletions
|
@ -518,6 +518,7 @@ unsigned int Socket::Connection::iwrite(const void * buffer, int len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (r == 0 && (sock >= 0)) {
|
if (r == 0 && (sock >= 0)) {
|
||||||
|
DONTEVEN_MSG("Socket closed by remote");
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
up += r;
|
up += r;
|
||||||
|
@ -560,6 +561,7 @@ int Socket::Connection::iread(void * buffer, int len, int flags) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
|
DONTEVEN_MSG("Socket closed by remote");
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
down += r;
|
down += r;
|
||||||
|
|
|
@ -112,7 +112,6 @@ namespace Mist {
|
||||||
onFail();
|
onFail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectDefaultTracks();
|
|
||||||
sought = false;
|
sought = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,11 +125,16 @@ namespace Mist {
|
||||||
|
|
||||||
bool Output::isReadyForPlay() {
|
bool Output::isReadyForPlay() {
|
||||||
if (myMeta.tracks.size()){
|
if (myMeta.tracks.size()){
|
||||||
for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++){
|
if (!selectedTracks.size()){
|
||||||
if (it->second.keys.size() >= 2){
|
selectDefaultTracks();
|
||||||
|
}
|
||||||
|
if (myMeta.tracks[getMainSelectedTrack()].keys.size() >= 2){
|
||||||
return true;
|
return true;
|
||||||
|
}else{
|
||||||
|
HIGH_MSG("NOT READY YET (%lu tracks, %lu = %lu keys)", myMeta.tracks.size(), getMainSelectedTrack(), myMeta.tracks[getMainSelectedTrack()].keys.size());
|
||||||
}
|
}
|
||||||
}
|
}else{
|
||||||
|
HIGH_MSG("NOT READY YET (%lu tracks)", myMeta.tracks.size());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -167,10 +171,11 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
stats(true);
|
stats(true);
|
||||||
updateMeta();
|
updateMeta();
|
||||||
if (myMeta.live && !isReadyForPlay()){
|
selectDefaultTracks();
|
||||||
|
if (!myMeta.vod && !isReadyForPlay()){
|
||||||
unsigned long long waitUntil = Util::epoch() + 15;
|
unsigned long long waitUntil = Util::epoch() + 15;
|
||||||
while (!isReadyForPlay()){
|
while (!myMeta.vod && !isReadyForPlay()){
|
||||||
if (Util::epoch() > waitUntil){
|
if (Util::epoch() > waitUntil + 45 || (!selectedTracks.size() && Util::epoch() > waitUntil)){
|
||||||
INFO_MSG("Giving up waiting for playable tracks. Stream: %s, IP: %s", streamName.c_str(), getConnectedHost().c_str());
|
INFO_MSG("Giving up waiting for playable tracks. Stream: %s, IP: %s", streamName.c_str(), getConnectedHost().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,14 +39,7 @@ namespace Mist {
|
||||||
if (isPushing){
|
if (isPushing){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (myMeta.tracks.size()){
|
return Output::isReadyForPlay();
|
||||||
for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++){
|
|
||||||
if (it->second.keys.size() >= 2){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OutRTMP::getStatsName(){
|
std::string OutRTMP::getStatsName(){
|
||||||
|
|
Loading…
Add table
Reference in a new issue