Implemented WebRTC peer-to-peer screen-roadcasting

This commit is contained in:
rainbow napkin 2026-09-28 03:25:56 -04:00
parent 62fc69489d
commit 96cdcfc840
5 changed files with 120 additions and 29 deletions

View file

@ -944,6 +944,7 @@ class WebRTCLivestreamHandler extends rawFileBase{
//Call derived constructor
super(client, player, media, "webrtc");
//Define RTCHandler related listeners
this.defineListeners();
}
@ -968,18 +969,22 @@ class WebRTCLivestreamHandler extends rawFileBase{
};
//If we're not streaming
if(!this.client.webRTCHandler.isStreaming){
if(!this.client.webRTCHandler.isBroadcasting){
//Send stream request
await this.client.webRTCHandler.requestStream();
//otherwise
}else{
//Load broadcasting stream into the player for local playback
this.startStream(this.client.webRTCHandler.broadcastingStream);
}
}
start(){
//call derived start function
super.start();
startStream(stream){
//Set video source object to stream
this.video.srcObject = stream;
//Lock the player
this.setPlayerLock(true);
//Autoplay Stream
this.video.play();
}
setVideoTitle(title){
@ -996,4 +1001,12 @@ class WebRTCLivestreamHandler extends rawFileBase{
//Inject glowspan into title in a way that allows it to be easily replaced
this.player.title.prepend(glowSpan);
}
end(){
//Let the webRTC handler know the stream ended
this.client.webRTCHandler.end();
//Call derived method
super.end();
}
}