Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from mcottontensor/master
Browse files Browse the repository at this point in the history
Adding offer to receive support.
  • Loading branch information
lukehb committed Jul 26, 2022
2 parents 7155765 + bf76d7d commit 616f07a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions SignallingWebServer/Public/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
<div class="tgl-slider"></div>
</label>
</div>
<div id="offerToReceive" class="setting">
<div class="settings-text">Offer To Receive</div>
<label class="tgl-switch">
<input type="checkbox" id="offer-receive-tgl" class="tgl tgl-flat">
<div class="tgl-slider"></div>
</label>
</div>
<div id="preferSFU" class="setting">
<div class="settings-text">Prefer SFU</div>
<label class="tgl-switch">
Expand Down
5 changes: 4 additions & 1 deletion SignallingWebServer/cirrus.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,10 @@ playerServer.on('connection', function (ws, req) {

logIncoming(`player ${playerId}`, msg.type, msgRaw);

if (msg.type == 'answer') {
if (msg.type == 'offer') {
msg.playerId = playerId;
sendMessageToController(msg, skipSFU);
} else if (msg.type == 'answer') {
msg.playerId = playerId;
sendMessageToController(msg, skipSFU, skipStreamer);
} else if (msg.type == 'iceCandidate') {
Expand Down
14 changes: 11 additions & 3 deletions SignallingWebServer/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ let rAF = window.mozRequestAnimationFrame ||
let kbEvent = document.createEvent("KeyboardEvent");
let initMethod = typeof kbEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent";


let webRtcPlayerObj = null;
let print_stats = false;
let print_inputs = false;
Expand Down Expand Up @@ -411,6 +410,7 @@ function setupHtmlEvents() {
setupToggleWithUrlParams("force-mono-tgl", "ForceMonoAudio");
setupToggleWithUrlParams("control-tgl", "hoveringMouse");
setupToggleWithUrlParams("cursor-tgl", "hideBrowserCursor");
setupToggleWithUrlParams("offer-receive-tgl", "offerToReceive");


var streamSelector = document.getElementById('stream-select');
Expand Down Expand Up @@ -460,6 +460,10 @@ function setupToggleWithUrlParams(toggleId, urlParameterKey){
}
}

function UrlParamsCheck(urlParameterKey) {
return new URLSearchParams(window.location.search).has(urlParameterKey);
}

var streamTrackSource = null;

function updateStreamList() {
Expand Down Expand Up @@ -1037,7 +1041,9 @@ function setupWebRtcPlayer(htmlElement, config) {
createOnScreenKeyboardHelpers(htmlElement);
}

//createWebRtcOffer();
if (UrlParamsCheck('offerToReceive')) {
createWebRtcOffer();
}

return webRtcPlayerObj.video;
}
Expand Down Expand Up @@ -2307,7 +2313,9 @@ function connect() {
console.log("%c[Inbound SS (playerCount)]", "background: lightblue; color: black", msg);
} else if (msg.type === 'offer') {
console.log("%c[Inbound SS (offer)]", "background: lightblue; color: black", msg);
onWebRtcOffer(msg);
if (!UrlParamsCheck('offerToReceive')) {
onWebRtcOffer(msg);
}
} else if (msg.type === 'answer') {
console.log("%c[Inbound SS (answer)]", "background: lightblue; color: black", msg);
onWebRtcAnswer(msg);
Expand Down

0 comments on commit 616f07a

Please sign in to comment.