Finished mediahandler placeholder, fixed most scheduler bugs with webrtc scheduling, started pushing iceServers w/ media object instead of clientmetadata.

This commit is contained in:
rainbow napkin 2026-07-11 03:54:23 -04:00
parent b68d55b7ef
commit 3517a1499a
7 changed files with 72 additions and 12 deletions

View file

@ -236,7 +236,7 @@ class connectedUser{
const chatBuffer = this.channel.chatBuffer.buffer;
//Send off the metadata to our user's clients
this.emit("clientMetadata", {user: userObj, flairList, queueLock, chatBuffer, streamType: chanDB.settings.streamType, iceServers: config.iceServers});
this.emit("clientMetadata", {user: userObj, flairList, queueLock, chatBuffer, streamType: chanDB.settings.streamType});
}
/**

View file

@ -333,6 +333,7 @@ class queue{
let title = "Livestream";
let filename = '/';
let streamURL = '/';
let rawLink = {combo: [['default', config.iceServers]]};
if(data != null && data.title != null){
//If the title is too long
@ -386,6 +387,7 @@ class queue{
//Kill schedule timers to prevent items from starting during the stream
await this.stopScheduleTimers();
//If we're streaming via HLS
if(chanDB.settings.streamType == "livehls"){
//Syntatic sugar because I'm lazy :P
streamURL = chanDB.settings.streamURL;
@ -406,6 +408,8 @@ class queue{
//Otherwise, hand over the filename
filename = filename[1];
}
rawLink = {combo:[['default',streamURL]]};
}
//Create queued media object from stream URL and set it to nowPlaying
@ -416,7 +420,7 @@ class queue{
streamURL,
chanDB.settings.streamType,
0,
streamURL,
rawLink,
new Date().getTime()
);
@ -1266,7 +1270,7 @@ class queue{
}
//If we're ending an HLS Livestream
if(wasPlaying.type == "livehls"){
if(wasPlaying.type == "livehls" || wasPlaying.type == "webrtc"){
//Redirect to the endLivestream function
return this.endLivestream(wasPlaying, chanDB)
}
@ -1574,7 +1578,7 @@ class queue{
const stoppedMedia = this.nowPlaying;
//Ignore early end for livestreams
if(this.nowPlaying.type != 'livehls'){
if(this.nowPlaying.type != 'livehls' && this.nowPlaying.type != 'webrtc'){
//Get difference between current time and start time and set as early end
stoppedMedia.earlyEnd = (new Date().getTime() - stoppedMedia.startTime) / 1000;
}
@ -1811,7 +1815,7 @@ class queue{
const now = new Date().getTime();
//If something was playing
if(chanDB.media.nowPlaying != null && chanDB.media.nowPlaying.type != 'livehls'){
if(chanDB.media.nowPlaying != null && (chanDB.media.nowPlaying.type != 'livehls' && chanDB.media.nowPlaying.type != 'webrtc')){
//Rehydrate the currently playing item int oa queued media object
const wasPlaying = chanDB.media.nowPlaying.rehydrate();