Started work on WebRTC Negotation Relay Backend
This commit is contained in:
parent
8f02be793f
commit
b68d55b7ef
7 changed files with 108 additions and 6 deletions
|
|
@ -331,8 +331,8 @@ class queue{
|
|||
try{
|
||||
//Define and/or declare required variables
|
||||
let title = "Livestream";
|
||||
let filename;
|
||||
let streamURL;
|
||||
let filename = '/';
|
||||
let streamURL = '/';
|
||||
|
||||
if(data != null && data.title != null){
|
||||
//If the title is too long
|
||||
|
|
@ -368,10 +368,10 @@ class queue{
|
|||
return;
|
||||
}
|
||||
|
||||
if(chanDB.settings.streamType == "webrtc"){
|
||||
/*if(chanDB.settings.streamType == "webrtc"){
|
||||
console.log("WEBRTC ENABLED, BAILING!");
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
//If something is playing
|
||||
if(this.nowPlaying != null){
|
||||
|
|
|
|||
81
src/app/channel/media/webRTCHandler.js
Normal file
81
src/app/channel/media/webRTCHandler.js
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024-2026 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
/**
|
||||
* Object to relay WebRTC Negotiation data for a single channel
|
||||
*/
|
||||
class webRTCHandler{
|
||||
/**
|
||||
* Instantiates a new object to relay WebRTC Negotiation data for a single channel
|
||||
* @param {channelManager} server - Parent server object
|
||||
* @param {activeChannel} channel - Parent Channel object
|
||||
*/
|
||||
constructor(server, channel){
|
||||
/**
|
||||
* Parent Server Object
|
||||
*/
|
||||
this.server = server
|
||||
|
||||
/**
|
||||
* Parent Channel Object
|
||||
*/
|
||||
this.channel = channel;
|
||||
|
||||
/**
|
||||
* Declare class property to hold socked it of the current device/browser-tab we're streaming from
|
||||
*/
|
||||
this.currentStreamer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines server-side socket.io listeners for newly connected sockets
|
||||
* @param {Socket} socket - Newly connected socket to define listeners against
|
||||
*/
|
||||
defineListeners(socket){
|
||||
//Queueing Functions
|
||||
socket.on("relayRTCData", (data) => {this.relayRTCData(socket, data)});
|
||||
}
|
||||
|
||||
startStream(socket){
|
||||
this.currentStreamer = socket.id;
|
||||
}
|
||||
|
||||
endStream(){
|
||||
this.currentStreamer = null;
|
||||
}
|
||||
|
||||
relayRTCData(socket, data){
|
||||
//Set the recipient to the current streamer by default, assuming that this isn't coming from the streaming socket
|
||||
let recipientID = this.currentStreamer;
|
||||
|
||||
//if data is being relayed from streaming socket to a viewer
|
||||
if(socket.id == this.currentStreamer){
|
||||
//Change recipient to reflect streaming socket's request
|
||||
recipientID = data.recipient;
|
||||
}
|
||||
|
||||
//Get recipient socket
|
||||
const recipient = this.server.io.sockets.sockets.get(recipientID);
|
||||
|
||||
//Relay RTC Data
|
||||
recipient.emit("RTCData", {
|
||||
type: data.type,
|
||||
body: data.body
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = webRTCHandler;
|
||||
Loading…
Add table
Add a link
Reference in a new issue