From 0a88b24b97c334d1ea402b1089748687d06fa5a7 Mon Sep 17 00:00:00 2001 From: steveseguin Date: Sun, 16 Apr 2023 14:34:38 -0400 Subject: [PATCH] publish direct to twitch with vdo.ninja --- index.html | 6 +++--- lib.js | 9 ++++++--- main.js | 18 +++++++----------- whip.html | 29 ++++++++++++++++++++++++++--- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index 847881b..80f69cd 100644 --- a/index.html +++ b/index.html @@ -56,7 +56,7 @@ - + @@ -2475,11 +2475,11 @@ // session.hidehome = true; // If used, 'hide home' will make the landing page inaccessible, along with hiding a few go-home elements. // session.record = false; // uncomment to block users from being able to record via vdo.ninja's built in recording function - + - + diff --git a/lib.js b/lib.js index 882b33e..49f78e9 100644 --- a/lib.js +++ b/lib.js @@ -32997,7 +32997,7 @@ function whipOut(){ var contentType = this.getResponseHeader('content-type'); - if (contentType == "application/sdp"){ + if (contentType.startsWith("application/sdp")){ var jsep = {}; jsep.sdp = this.responseText; jsep.type = "answer"; @@ -33052,7 +33052,7 @@ function whipOut(){ } */ warnlog("Processing answer:"); - //warnlog(jsep); + warnlog(jsep); session.whipOut.setRemoteDescription(jsep).then(function(){ warnlog("SHOULD BE CONNECTED?"); @@ -33081,6 +33081,9 @@ function whipOut(){ } else if (callback){ callback(); } + } else{ + console.warn(this.responseText); + console.error(this); } }; if (type==="trickle-ice-sdpfrag"){ @@ -33450,7 +33453,7 @@ async function whepIn(){ // PLAY WHEP responseLocation = this.getResponseHeader('location'); - if (contentType == "application/sdp"){ + if (contentType.startsWith("application/sdp")){ var jsep = {}; jsep.sdp = this.responseText; jsep.type = "answer"; diff --git a/main.js b/main.js index 28e2cac..54f96a0 100644 --- a/main.js +++ b/main.js @@ -288,24 +288,20 @@ async function main(){ // main asyncronous thread; mostly initializes the user s } } - if (urlParams.has('whippush')) { // URL or data:base64 image. Becomes local to this viewer only. This is like &avatar, but slightly different. Just CSS in this case - if (urlParams.get('whippush')){ + if (urlParams.has('whippush') || urlParams.has('whipout') || urlParams.has('pushwhip')) { // URL or data:base64 image. Becomes local to this viewer only. This is like &avatar, but slightly different. Just CSS in this case + let whippush = urlParams.get('whippush') || urlParams.get('whipout') || urlParams.get('pushwhip'); + if (whippush){ try { - session.whipOutput = decodeURIComponent(urlParams.get('whippush')); + session.whipOutput = decodeURIComponent(whippush); } catch(e){ errorlog(e); } } } - if (urlParams.has('whippushtoken')) { // URL or data:base64 image. Becomes local to this viewer only. This is like &avatar, but slightly different. Just CSS in this case - if (urlParams.get('whippushtoken')){ - try { - session.whipOutputToken = urlParams.get('whippushtoken'); - } catch(e){ - errorlog(e); - } - } + if (urlParams.has('whippushtoken') || urlParams.has('whipouttoken') || urlParams.has('pushwhiptoken')) {// URL or data:base64 image. Becomes local to this viewer only. This is like &avatar, but slightly different. Just CSS in this case + session.whipOutputToken = urlParams.get('whippushtoken') || urlParams.get('whipouttoken') || urlParams.get('pushwhiptoken') || false; } + if (urlParams.has('whepplay')) { // URL or data:base64 image. Becomes local to this viewer only. This is like &avatar, but slightly different. Just CSS in this case if (urlParams.get('whepplay')){ try { diff --git a/whip.html b/whip.html index f996b55..c200fb6 100644 --- a/whip.html +++ b/whip.html @@ -304,7 +304,7 @@ - +
@@ -313,6 +313,19 @@
+
+ +

Publish a video from VDO.Ninja to your Twitch channel

+ +
+ + + +
+
+

Setup VDO.Ninja to be a WHIP-ingestion end-point

@@ -361,6 +374,7 @@ var domain = "./"; document.querySelector("#changeText1").value = localStorage.getItem('changeText1') || ""; +document.querySelector("#changeText1t").value = localStorage.getItem('changeText1t') || ""; document.querySelector("#changeText1a").value = localStorage.getItem('changeText1a') || ""; document.querySelector("#changeText2").value = localStorage.getItem('changeText2') || ""; document.querySelector("#changeText3").value = localStorage.getItem('changeText3') || ""; @@ -369,14 +383,22 @@ function gohere1(){ if (document.getElementById('changeText1').value && document.getElementById('changeText1a').value){ localStorage.setItem('changeText1', document.getElementById('changeText1').value); localStorage.setItem('changeText1a', document.getElementById('changeText1a').value); - window.location = domain + "?whippush=" + encodeURIComponent(document.getElementById('changeText1').value) + "&whippushtoken=" + document.getElementById('changeText1a').value; + window.location = domain + "?push&whippush=" + encodeURIComponent(document.getElementById('changeText1').value) + "&whippushtoken=" + document.getElementById('changeText1a').value; } else if (document.getElementById('changeText1').value){ localStorage.setItem('changeText1', document.getElementById('changeText1').value); localStorage.setItem('changeText1a', ""); - window.location = domain + "?wc&whippush=" + encodeURIComponent(document.getElementById('changeText1').value); + window.location = domain + "?push&whippush=" + encodeURIComponent(document.getElementById('changeText1').value); } } + +function gohere1t(){ + if (document.getElementById('changeText1t').value){ + localStorage.setItem('changeText1t', document.getElementById('changeText1t').value); + window.location = domain + "?push&whippush=https%3A%2F%2Ftwitch.vdo.ninja%2F"+ document.getElementById('changeText1t').value; + } +} + function gohere2(){ if (document.getElementById('changeText2').value){ localStorage.setItem('changeText2', document.getElementById('changeText1').value); @@ -401,6 +423,7 @@ function resetHistory(){ document.querySelector("#changeText1a").value = ""; document.querySelector("#changeText2").value = ""; document.querySelector("#changeText3").value = ""; + document.querySelector("#changeText1t").value = ""; } (function (w) {