-
-
Save beniroquai/e1cb9e22d5b5974043154e6b18c83f86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<docs lang="markdown"> | |
[TODO: write documentation for this plugin.] | |
</docs> | |
<config lang="json"> | |
{ | |
"name": "UC2-Streamer", | |
"type": "window", | |
"tags": [], | |
"ui": "", | |
"version": "0.1.0", | |
"cover": "", | |
"description": "[TODO: describe this plugin with one sentence.]", | |
"icon": "extension", | |
"inputs": null, | |
"outputs": null, | |
"api_version": "0.1.8", | |
"env": "", | |
"permissions": [], | |
"requirements": [ | |
"https://horrible-fly-95.telebit.io/libs/request.min.js", | |
"https://horrible-fly-95.telebit.io/libs/adapter.min.js", | |
"https://horrible-fly-95.telebit.io/webrtcstreamer.js"], | |
"dependencies": [], | |
"defaults": {"w": 20, "h": 10, "fullscreen": true} | |
} | |
</config> | |
<script lang="javascript"> | |
class ImJoyPlugin { | |
async setup() { | |
api.log('initialized') | |
} | |
async run(ctx) { | |
var webrtcConfig = { | |
url: "https://horrible-fly-95.telebit.io" , | |
options: "rtptransport=tcp&timeout=60", | |
layoutextraoptions: "&width=320&height=0", | |
defaultvideostream: "Bunny" | |
} | |
if (location.search.slice(1)) { | |
var url = { video:"mmal service 16.1" }; | |
var options = webrtcConfig.options; | |
if (typeof URLSearchParams != 'undefined') { | |
var params = new URLSearchParams(location.search); | |
if (params.has("video") || params.has("audio")) { | |
url = { video:params.get("video"), audio:params.get("audio") }; | |
} | |
if (params.has("options")) { | |
options = params.get("options"); | |
} | |
} | |
const webRtcServer = new WebRtcStreamer("video", webrtcConfig.url); | |
document.getElementById("title").innerHTML=url.video; | |
webRtcServer.connect(url.video,url.audio,options); | |
request("GET" , webrtcConfig.url + "/api/version").done( function (response) { | |
document.getElementById("footer").innerHTML = "<p><a href='https://github.com/mpromonet/webrtc-streamer'>WebRTC-Streamer</a> " + JSON.parse(response.body).split(" ")[0] + "</p>"; | |
}); | |
// window.onbeforeunload = function() { this.webRtcServer.disconnect() } | |
} else { | |
if (typeof URLSearchParams != 'undefined') { | |
alert("WebRTC stream name to connect is missing\n\nUsage :" + window.location + "?video=<WebRTC video stream name>&audio=<WebRTC audio stream name>&options=<WebRTC options>") | |
} else { | |
alert("WebRTC stream name to connect is missing\n\nUsage :" + window.location + "?<WebRTC video stream name>") | |
} | |
} | |
} | |
} | |
api.export(new ImJoyPlugin()) | |
</script> | |
<window lang="html"> | |
<div> | |
<h2 id="title"></h2> | |
<video id="video" muted></video> | |
<footer id="footer"></footer> | |
</div> | |
</window> | |
<style lang="css"> | |
#video { | |
width: 100%; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment