Change Input::keepRunning to be more generic, override it in MistInBuffer and MistInHLS
This commit is contained in:
parent
8830a87642
commit
ee853b1ffb
6 changed files with 29 additions and 9 deletions
|
@ -894,13 +894,6 @@ namespace Mist{
|
|||
break;
|
||||
}
|
||||
|
||||
if (M.getLive() && !internalOnly){
|
||||
uint64_t currLastUpdate = M.getLastUpdated();
|
||||
if (currLastUpdate > activityCounter){activityCounter = currLastUpdate;}
|
||||
}else{
|
||||
if ((connectedUsers || isAlwaysOn()) && M.getValidTracks().size()){activityCounter = Util::bootSecs();}
|
||||
}
|
||||
|
||||
inputServeStats();
|
||||
// if not shutting down, wait 1 second before looping
|
||||
preMs = Util::bootMS() - preMs;
|
||||
|
@ -944,7 +937,14 @@ namespace Mist{
|
|||
/// For live streams, this is twice the biggest fragment duration.
|
||||
/// For non-live streams this is INPUT_TIMEOUT seconds.
|
||||
/// The default Pro implementation also allows cancelling the shutdown through the STREAM_UNLOAD trigger.
|
||||
bool Input::keepRunning(){
|
||||
bool Input::keepRunning(bool updateActCtr){
|
||||
// Default behaviour to stop an input when there's not activity after X seconds
|
||||
// This is overriden by certain inputs (buffer, HLS, more) where there is different logic
|
||||
// for updating 'activityCounter'
|
||||
if (updateActCtr){
|
||||
if ((connectedUsers || isAlwaysOn()) && M.getValidTracks().size()){activityCounter = Util::bootSecs();}
|
||||
}
|
||||
|
||||
// We keep running in serve mode if the config is still active AND either
|
||||
// - INPUT_TIMEOUT seconds haven't passed yet,
|
||||
// - this is a live stream and at least two of the biggest fragment haven't passed yet,
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace Mist{
|
|||
virtual void getNext(size_t idx = INVALID_TRACK_ID){}
|
||||
virtual void seek(uint64_t seekTime, size_t idx = INVALID_TRACK_ID){}
|
||||
virtual void finish();
|
||||
virtual bool keepRunning();
|
||||
virtual bool keepRunning(bool updateActCtr = true);
|
||||
virtual bool openStreamSource(){return readHeader();}
|
||||
virtual void closeStreamSource(){}
|
||||
virtual void parseStreamHeader(){}
|
||||
|
|
|
@ -258,6 +258,14 @@ namespace Mist{
|
|||
meta.setLive(true);
|
||||
}
|
||||
|
||||
bool InputBuffer::keepRunning(bool updateActCtr){
|
||||
if (M.getLive()){
|
||||
uint64_t currLastUpdate = M.getLastUpdated();
|
||||
if (currLastUpdate > activityCounter){activityCounter = currLastUpdate;}
|
||||
}
|
||||
return Input::keepRunning(false);
|
||||
}
|
||||
|
||||
/// Checks if removing a key from this track is allowed/safe, and if so, removes it.
|
||||
/// Returns true if a key was actually removed, false otherwise
|
||||
/// Aborts if any of the following conditions are true (while active):
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace Mist{
|
|||
bool needHeader(){return false;}
|
||||
void getNext(size_t idx = INVALID_TRACK_ID){};
|
||||
void seek(uint64_t seekTime, size_t idx = INVALID_TRACK_ID){};
|
||||
bool keepRunning(bool updateActCtr = true);
|
||||
|
||||
void removeTrack(size_t tid);
|
||||
|
||||
|
|
|
@ -1169,6 +1169,16 @@ namespace Mist{
|
|||
}
|
||||
}
|
||||
|
||||
bool InputHLS::keepRunning(bool updateActCtr){
|
||||
if (isAlwaysOn()){
|
||||
uint64_t currLastUpdate = M.getLastUpdated();
|
||||
if (currLastUpdate > activityCounter){activityCounter = currLastUpdate;}
|
||||
return Input::keepRunning(false);
|
||||
}else{
|
||||
return Input::keepRunning(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Applies any offset to the packets original timestamp
|
||||
/// \param packetTime: the original timestamp of the packet
|
||||
/// \param tid: the trackid corresponding to this track and playlist
|
||||
|
|
|
@ -147,6 +147,7 @@ namespace Mist{
|
|||
void postHeader();
|
||||
void getNext(size_t idx = INVALID_TRACK_ID);
|
||||
void seek(uint64_t seekTime, size_t idx = INVALID_TRACK_ID);
|
||||
bool keepRunning(bool updateActCtr = true);
|
||||
|
||||
bool readIndex();
|
||||
bool initPlaylist(const std::string &uri, bool fullInit = true);
|
||||
|
|
Loading…
Add table
Reference in a new issue