Added streamlock to disable refreshNextTimer() while streaming. Fixed bug in HLS Livestream Media Handler.
This commit is contained in:
parent
dd00a11b92
commit
a927b31919
|
|
@ -49,6 +49,8 @@ module.exports = class{
|
||||||
this.preSwitchTimer = null;
|
this.preSwitchTimer = null;
|
||||||
//Create variable to hold currently playing media object
|
//Create variable to hold currently playing media object
|
||||||
this.nowPlaying = null;
|
this.nowPlaying = null;
|
||||||
|
//Create variable to lock standard queuing functions during livestreams
|
||||||
|
this.streamLock = false;
|
||||||
|
|
||||||
//create boolean to hold schedule lock
|
//create boolean to hold schedule lock
|
||||||
this.locked = false;
|
this.locked = false;
|
||||||
|
|
@ -302,6 +304,9 @@ module.exports = class{
|
||||||
|
|
||||||
//Broadcast new media object to users
|
//Broadcast new media object to users
|
||||||
this.sendMedia();
|
this.sendMedia();
|
||||||
|
|
||||||
|
//Throw stream lock
|
||||||
|
this.streamLock = true;
|
||||||
}catch(err){
|
}catch(err){
|
||||||
return loggerUtils.socketExceptionHandler(socket, err);
|
return loggerUtils.socketExceptionHandler(socket, err);
|
||||||
}
|
}
|
||||||
|
|
@ -359,13 +364,18 @@ module.exports = class{
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshNextTimer(volatile = false){
|
refreshNextTimer(volatile = false){
|
||||||
|
//If we're streamlocked
|
||||||
|
if(this.streamLock){
|
||||||
|
//Stop while we're ahead since the stream hasn't ended yet
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Grab the next item
|
//Grab the next item
|
||||||
const nextItem = this.getNextItem();
|
const nextItem = this.getNextItem();
|
||||||
|
|
||||||
//Get current item
|
//Get current item
|
||||||
const currentItem = this.getItemAtEpoch()
|
const currentItem = this.getItemAtEpoch()
|
||||||
|
|
||||||
|
|
||||||
//Clear out any stale timers to prevent ghost queueing
|
//Clear out any stale timers to prevent ghost queueing
|
||||||
clearTimeout(this.nextTimer);
|
clearTimeout(this.nextTimer);
|
||||||
clearTimeout(this.preSwitchTimer);
|
clearTimeout(this.preSwitchTimer);
|
||||||
|
|
@ -946,6 +956,9 @@ module.exports = class{
|
||||||
|
|
||||||
async endLivestream(chanDB){
|
async endLivestream(chanDB){
|
||||||
try{
|
try{
|
||||||
|
//Disable stream lock
|
||||||
|
this.streamLock = false;
|
||||||
|
|
||||||
//Refresh next timer
|
//Refresh next timer
|
||||||
this.refreshNextTimer();
|
this.refreshNextTimer();
|
||||||
|
|
||||||
|
|
@ -960,19 +973,7 @@ module.exports = class{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async stop(chanDB){
|
stop(){
|
||||||
//If we wheren't handed a channel
|
|
||||||
if(chanDB == null){
|
|
||||||
//DO everything ourselves since we don't have a fance end() function to do it
|
|
||||||
chanDB = await channelModel.findOne({name:this.channel.name});
|
|
||||||
}
|
|
||||||
|
|
||||||
//If we wheren't handed a channel
|
|
||||||
if(chanDB == null){
|
|
||||||
//Complain about the lack of a channel
|
|
||||||
throw loggerUtils.exceptionSmith(`Channel not found!`, "queue");
|
|
||||||
}
|
|
||||||
|
|
||||||
//If we're not currently playing anything
|
//If we're not currently playing anything
|
||||||
if(this.nowPlaying == null){
|
if(this.nowPlaying == null){
|
||||||
//If an originating socket was provided for this request
|
//If an originating socket was provided for this request
|
||||||
|
|
|
||||||
|
|
@ -605,10 +605,15 @@ class hlsLiveStreamHandler extends hlsBase{
|
||||||
//Call derived method
|
//Call derived method
|
||||||
super.onSeek(event);
|
super.onSeek(event);
|
||||||
|
|
||||||
|
//If we stopped playing the video
|
||||||
|
if(this.video == null){
|
||||||
|
//Don't worry about it
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Calculate distance to end of stream
|
//Calculate distance to end of stream
|
||||||
const difference = this.video.duration - this.video.currentTime;
|
const difference = this.video.duration - this.video.currentTime;
|
||||||
|
|
||||||
|
|
||||||
//If we where buffering under sync lock
|
//If we where buffering under sync lock
|
||||||
if(this.reSync){
|
if(this.reSync){
|
||||||
//Set reSync to false
|
//Set reSync to false
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue