summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-15 08:58:17 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-15 08:58:17 +0200
commit413bdfe8cf09a4922149f06a18e1d44511f14aea (patch)
tree6f025a496528ba7fdaf8ea6f5ca28ac11d445b8b
parente342fc5a6006d9f5bf5df5be52f3d03d75172da8 (diff)
Add script live-video-test (forked from live-video).
-rw-r--r--js/app/live-video-test.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/app/live-video-test.js b/js/app/live-video-test.js
new file mode 100644
index 0000000..987d09e
--- /dev/null
+++ b/js/app/live-video-test.js
@@ -0,0 +1,44 @@
+var websocket_server = null;
+if(window.location.protocol === 'http:')
+ websocket_server = "ws://" + window.location.hostname + "/janus-ws";
+else
+ websocket_server = "wss://" + window.location.hostname + "/janus-ws";
+
+var janus = null;
+var streaming = null;
+
+Janus.init({callback: function() {
+ janus = new Janus(
+ {
+ server: [websocket_server, "/janus"],
+ iceServers: [{url: "turn:turn.homebase.dk", username: "myturn", credential: "notsecure"}],
+ ipv6: false,
+ success: function() {
+ janus.attach(
+ {
+ plugin: "janus.plugin.streaming",
+ opaqueId: "streaming-"+Janus.randomString(12),
+ success: function(pluginHandle) {
+ streaming = pluginHandle;
+ streaming.send({"message": { "request": "watch", id: 2}});
+ },
+ onmessage: function(msg, jsep) {
+ if(jsep !== undefined && jsep !== null) {
+ streaming.createAnswer(
+ {
+ jsep: jsep,
+ media: { audioSend: false, videoSend: false },
+ success: function(jsep) {
+ var body = { "request": "start" };
+ streaming.send({"message": body, "jsep": jsep});
+ },
+ });
+ }
+ },
+ onremotestream: function(stream) {
+ Janus.attachMediaStream(document.getElementById('live-video'), stream);
+ },
+ });
+ },
+ });
+}});