summaryrefslogtreecommitdiff
path: root/js/app/live-video-test.js
blob: e4a3e73084474b557e066d41426f643962af6ea1 (plain)
  1. var websocket_server = null;
  2. if(window.location.protocol === 'http:')
  3. websocket_server = "ws://" + window.location.hostname + "/janus-ws";
  4. else
  5. websocket_server = "wss://" + window.location.hostname + "/janus-ws";
  6. var janus = null;
  7. var streaming = null;
  8. Janus.init({callback: function() {
  9. janus = new Janus(
  10. {
  11. server: [websocket_server, "/janus"],
  12. iceServers: [{url: "turn:turn.homebase.dk", username: "myturn", credential: "notsecure"}],
  13. ipv6: false,
  14. success: function() {
  15. janus.attach(
  16. {
  17. plugin: "janus.plugin.streaming",
  18. opaqueId: "streaming-"+Janus.randomString(12),
  19. success: function(pluginHandle) {
  20. streaming = pluginHandle;
  21. streaming.send({"message": { "request": "watch", id: 2}});
  22. },
  23. onmessage: function(msg, jsep) {
  24. if(jsep !== undefined && jsep !== null) {
  25. streaming.createAnswer(
  26. {
  27. jsep: jsep,
  28. media: { audioSend: false, videoSend: false },
  29. success: function(jsep) {
  30. var body = { "request": "start" };
  31. streaming.send({"message": body, "jsep": jsep});
  32. },
  33. });
  34. }
  35. },
  36. onremotestream: function(stream) {
  37. Janus.attachMediaStream(document.getElementById('live-video-test'), stream);
  38. },
  39. });
  40. },
  41. });
  42. }});