diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp
index 4b136e1aa..a612e84c3 100644
--- a/src/zm_monitor.cpp
+++ b/src/zm_monitor.cpp
@@ -1117,12 +1117,13 @@ bool Monitor::connect() {
//End ONVIF Setup
#endif
- //janus setup.
+#if HAVE_LIBCURL //janus setup. Depends on libcurl.
if (janus_enabled && (path.find("rtsp://") != std::string::npos)) {
if (add_to_janus() != 0) {
Warning("Failed to add monitor stream to Janus!");
}
}
+#endif
} else if (!shared_data->valid) {
Error("Shared data not initialised by capture daemon for monitor %s", name.c_str());
@@ -3206,10 +3207,11 @@ int Monitor::Close() {
soap = nullptr;
} //End ONVIF
#endif
- //Janus Teardown
+#if HAVE_LIBCURL //Janus Teardown
if (janus_enabled && (purpose == CAPTURE)) {
remove_from_janus();
}
+#endif
packetqueue.clear();
if (audio_fifo) {
diff --git a/web/skins/classic/views/cycle.php b/web/skins/classic/views/cycle.php
index b9f779c50..279d9bba5 100644
--- a/web/skins/classic/views/cycle.php
+++ b/web/skins/classic/views/cycle.php
@@ -192,4 +192,6 @@ xhtmlHeaders(__FILE__, translate('CycleWatch'));
+
+
diff --git a/web/skins/classic/views/js/cycle.js b/web/skins/classic/views/js/cycle.js
index 767fad475..401e36760 100644
--- a/web/skins/classic/views/js/cycle.js
+++ b/web/skins/classic/views/js/cycle.js
@@ -1,3 +1,6 @@
+var server;
+var janus = null;
+var streaming2;
var intervalId;
var pauseBtn = $j('#pauseBtn');
var playBtn = $j('#playBtn');
@@ -46,6 +49,68 @@ function initCycle() {
intervalId = setInterval(nextCycleView, cycleRefreshTimeout);
var scale = $j('#scale').val();
if ( scale == '0' || scale == 'auto' ) changeScale();
+
+ if (monitorData[monIdx].janusEnabled) {
+ server = "http://" + window.location.hostname + ":8088/janus";
+ opaqueId = "streamingtest-"+Janus.randomString(12);
+ Janus.init({debug: "all", callback: function() {
+ janus = new Janus({
+ server: server,
+ success: function() {
+ janus.attach({
+ plugin: "janus.plugin.streaming",
+ opaqueId: opaqueId,
+ success: function(pluginHandle) {
+ streaming2 = pluginHandle;
+ var body = { "request": "watch", "id":monitorData[monIdx].id };
+ streaming2.send({"message": body});
+ },
+ error: function(error) {
+ Janus.error(" -- Error attaching plugin... ", error);
+ },
+ onmessage: function(msg, jsep) {
+ Janus.debug(" ::: Got a message :::");
+ Janus.debug(msg);
+ var result = msg["result"];
+ if(result !== null && result !== undefined) {
+ if(result["status"] !== undefined && result["status"] !== null) {
+ var status = result["status"];
+ }
+ } else if(msg["error"] !== undefined && msg["error"] !== null) {
+ Janus.debug(msg["error"]);
+ return;
+ }
+ if(jsep !== undefined && jsep !== null) {
+ Janus.debug("Handling SDP as well...");
+ Janus.debug(jsep);
+ // Offer from the plugin, let's answer
+ streaming2.createAnswer({
+ jsep: jsep,
+ // We want recvonly audio/video and, if negotiated, datachannels
+ media: { audioSend: false, videoSend: false, data: true },
+ success: function(jsep) {
+ Janus.debug("Got SDP!");
+ Janus.debug(jsep);
+ var body = { "request": "start"};
+ streaming2.send({"message": body, "jsep": jsep});
+ },
+ error: function(error) {
+ Janus.error("WebRTC error:", error);
+ }
+ });
+ }
+ }, //onmessage function
+ onremotestream: function(stream) {
+ Janus.debug(" ::: Got a remote track :::");
+ Janus.debug(stream);
+ Janus.attachMediaStream(document.getElementById("liveStream" + monitorData[monIdx].id), stream);
+ document.getElementById("liveStream" + monitorData[monIdx].id).play();
+ }
+ });// attach
+ } //Success functio
+ }); //new Janus
+ }}); //janus.init callback
+ } //if janus
}
function changeSize() {
diff --git a/web/skins/classic/views/js/cycle.js.php b/web/skins/classic/views/js/cycle.js.php
index 7bcd4497c..201deea76 100644
--- a/web/skins/classic/views/js/cycle.js.php
+++ b/web/skins/classic/views/js/cycle.js.php
@@ -20,7 +20,8 @@ monitorData[monitorData.length] = {
'url': 'UrlToIndex() ?>',
'onclick': function(){window.location.assign( '?view=watch&mid=Id() ?>' );},
'type': 'Type() ?>',
- 'refresh': 'Refresh() ?>'
+ 'refresh': 'Refresh() ?>',
+ 'janusEnabled': JanusEnabled() ?>
};