Add Janus to Cycle view. Remove debug Alert() messages
This commit is contained in:
parent
aeefc512ab
commit
2beffeb1b4
|
@ -1117,12 +1117,13 @@ bool Monitor::connect() {
|
||||||
//End ONVIF Setup
|
//End ONVIF Setup
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//janus setup.
|
#if HAVE_LIBCURL //janus setup. Depends on libcurl.
|
||||||
if (janus_enabled && (path.find("rtsp://") != std::string::npos)) {
|
if (janus_enabled && (path.find("rtsp://") != std::string::npos)) {
|
||||||
if (add_to_janus() != 0) {
|
if (add_to_janus() != 0) {
|
||||||
Warning("Failed to add monitor stream to Janus!");
|
Warning("Failed to add monitor stream to Janus!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} else if (!shared_data->valid) {
|
} else if (!shared_data->valid) {
|
||||||
Error("Shared data not initialised by capture daemon for monitor %s", name.c_str());
|
Error("Shared data not initialised by capture daemon for monitor %s", name.c_str());
|
||||||
|
@ -3206,10 +3207,11 @@ int Monitor::Close() {
|
||||||
soap = nullptr;
|
soap = nullptr;
|
||||||
} //End ONVIF
|
} //End ONVIF
|
||||||
#endif
|
#endif
|
||||||
//Janus Teardown
|
#if HAVE_LIBCURL //Janus Teardown
|
||||||
if (janus_enabled && (purpose == CAPTURE)) {
|
if (janus_enabled && (purpose == CAPTURE)) {
|
||||||
remove_from_janus();
|
remove_from_janus();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
packetqueue.clear();
|
packetqueue.clear();
|
||||||
if (audio_fifo) {
|
if (audio_fifo) {
|
||||||
|
|
|
@ -192,4 +192,6 @@ xhtmlHeaders(__FILE__, translate('CycleWatch'));
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script>
|
||||||
|
<script src="<?php echo cache_bust('js/janus.js') ?>"></script>
|
||||||
<?php xhtmlFooter() ?>
|
<?php xhtmlFooter() ?>
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
var server;
|
||||||
|
var janus = null;
|
||||||
|
var streaming2;
|
||||||
var intervalId;
|
var intervalId;
|
||||||
var pauseBtn = $j('#pauseBtn');
|
var pauseBtn = $j('#pauseBtn');
|
||||||
var playBtn = $j('#playBtn');
|
var playBtn = $j('#playBtn');
|
||||||
|
@ -46,6 +49,68 @@ function initCycle() {
|
||||||
intervalId = setInterval(nextCycleView, cycleRefreshTimeout);
|
intervalId = setInterval(nextCycleView, cycleRefreshTimeout);
|
||||||
var scale = $j('#scale').val();
|
var scale = $j('#scale').val();
|
||||||
if ( scale == '0' || scale == 'auto' ) changeScale();
|
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() {
|
function changeSize() {
|
||||||
|
|
|
@ -20,7 +20,8 @@ monitorData[monitorData.length] = {
|
||||||
'url': '<?php echo $monitor->UrlToIndex() ?>',
|
'url': '<?php echo $monitor->UrlToIndex() ?>',
|
||||||
'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $monitor->Id() ?>' );},
|
'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $monitor->Id() ?>' );},
|
||||||
'type': '<?php echo $monitor->Type() ?>',
|
'type': '<?php echo $monitor->Type() ?>',
|
||||||
'refresh': '<?php echo $monitor->Refresh() ?>'
|
'refresh': '<?php echo $monitor->Refresh() ?>',
|
||||||
|
'janusEnabled': <?php echo $monitor->JanusEnabled() ?>
|
||||||
};
|
};
|
||||||
<?php
|
<?php
|
||||||
} // end foreach monitor
|
} // end foreach monitor
|
||||||
|
|
|
@ -373,8 +373,7 @@ function attachVideo(janus, i) {
|
||||||
var status = result["status"];
|
var status = result["status"];
|
||||||
}
|
}
|
||||||
} else if(msg["error"] !== undefined && msg["error"] !== null) {
|
} else if(msg["error"] !== undefined && msg["error"] !== null) {
|
||||||
alert(msg["error"]);
|
Janus.error(msg["error"]);
|
||||||
stopStream();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(jsep !== undefined && jsep !== null) {
|
if(jsep !== undefined && jsep !== null) {
|
||||||
|
@ -393,7 +392,6 @@ function attachVideo(janus, i) {
|
||||||
},
|
},
|
||||||
error: function(error) {
|
error: function(error) {
|
||||||
Janus.error("WebRTC error:", error);
|
Janus.error("WebRTC error:", error);
|
||||||
alert("WebRTC error... " + JSON.stringify(error));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -937,8 +937,7 @@ function initPage() {
|
||||||
var status = result["status"];
|
var status = result["status"];
|
||||||
}
|
}
|
||||||
} else if(msg["error"] !== undefined && msg["error"] !== null) {
|
} else if(msg["error"] !== undefined && msg["error"] !== null) {
|
||||||
alert(msg["error"]);
|
Janus.error(msg["error"]);
|
||||||
stopStream();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(jsep !== undefined && jsep !== null) {
|
if(jsep !== undefined && jsep !== null) {
|
||||||
|
@ -957,7 +956,6 @@ function initPage() {
|
||||||
},
|
},
|
||||||
error: function(error) {
|
error: function(error) {
|
||||||
Janus.error("WebRTC error:", error);
|
Janus.error("WebRTC error:", error);
|
||||||
alert("WebRTC error... " + JSON.stringify(error));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue