Merge branch 'master' into multistream
This commit is contained in:
commit
4910ec752f
|
@ -13,6 +13,7 @@ web/skins/classic/js/jquery.js
|
|||
web/skins/classic/js/moment.js
|
||||
web/skins/classic/js/video.js
|
||||
web/tools/mootools
|
||||
web/js/janus.js
|
||||
|
||||
# Cannot be parsed as JS
|
||||
web/skins/classic/includes/export_functions.php
|
||||
|
|
|
@ -16,6 +16,6 @@ jobs:
|
|||
with:
|
||||
submodules: recursive
|
||||
- name: Install ESLint
|
||||
run: npm install eslint@5.12.0 eslint-config-google@0.11.0 eslint-plugin-html@5.0.0 eslint-plugin-php-markup@0.2.5
|
||||
run: npm install eslint@8.7.0 eslint-config-google@0.14.0 eslint-plugin-html@6.2.0 eslint-plugin-php-markup@6.0.0
|
||||
- name: Run ESLint
|
||||
run: npx eslint --ext .php,.js .
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
%global _hardened_build 1
|
||||
|
||||
Name: zoneminder
|
||||
Version: 1.37.7
|
||||
Version: 1.37.8
|
||||
Release: 1%{?dist}
|
||||
Summary: A camera monitoring and analysis tool
|
||||
Group: System Environment/Daemons
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
[Unit]
|
||||
Description=ZoneMinder CCTV recording and security system
|
||||
After=network.target mysqld.service httpd.service
|
||||
Requires=mysqld.service httpd.service
|
||||
After=network.target mysqld.service httpd.service janus.service
|
||||
Requires=mysqld.service httpd.service janus.service
|
||||
|
||||
[Service]
|
||||
User=@WEB_USER@
|
||||
|
|
|
@ -314,7 +314,6 @@ Monitor::Monitor()
|
|||
server_id(0),
|
||||
storage_id(0),
|
||||
type(LOCAL),
|
||||
function(NONE),
|
||||
capturing(CAPTURING_ALWAYS),
|
||||
analysing(ANALYSING_ALWAYS),
|
||||
recording(RECORDING_ALWAYS),
|
||||
|
@ -1119,12 +1118,13 @@ bool Monitor::connect() {
|
|||
set_credentials(soap);
|
||||
Debug(1, "ONVIF Endpoint: %s", proxyEvent.soap_endpoint);
|
||||
if (proxyEvent.CreatePullPointSubscription(&request, response) != SOAP_OK) {
|
||||
Warning("Couldn't create subscription!");
|
||||
Error("Couldn't create subscription! %s, %s", soap_fault_string(soap), soap_fault_detail(soap));
|
||||
} else {
|
||||
//Empty the stored messages
|
||||
set_credentials(soap);
|
||||
if (proxyEvent.PullMessages(response.SubscriptionReference.Address, NULL, &tev__PullMessages, tev__PullMessagesResponse) != SOAP_OK) {
|
||||
Warning("Couldn't do initial event pull! %s", response.SubscriptionReference.Address);
|
||||
if ((proxyEvent.PullMessages(response.SubscriptionReference.Address, NULL, &tev__PullMessages, tev__PullMessagesResponse) != SOAP_OK) &&
|
||||
( soap->error != SOAP_EOF)) { //SOAP_EOF could indicate no messages to pull.
|
||||
Error("Couldn't do initial event pull! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
||||
} else {
|
||||
Debug(1, "Good Initial ONVIF Pull");
|
||||
ONVIF_Healthy = TRUE;
|
||||
|
@ -1138,10 +1138,12 @@ bool Monitor::connect() {
|
|||
|
||||
#if HAVE_LIBCURL //janus setup. Depends on libcurl.
|
||||
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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} else if (!shared_data->valid) {
|
||||
|
@ -1812,8 +1814,10 @@ bool Monitor::Poll() {
|
|||
set_credentials(soap);
|
||||
int result = proxyEvent.PullMessages(response.SubscriptionReference.Address, NULL, &tev__PullMessages, tev__PullMessagesResponse);
|
||||
if (result != SOAP_OK) {
|
||||
if (result != -1) //Ignore the timeout error
|
||||
Warning("Failed to get ONVIF messages! %i", result);
|
||||
if (result != SOAP_EOF) { //Ignore the timeout error
|
||||
Error("Failed to get ONVIF messages! %s", soap_fault_string(soap));
|
||||
ONVIF_Healthy = FALSE;
|
||||
}
|
||||
} else {
|
||||
Debug(1, "Got Good Response! %i", result);
|
||||
for (auto msg : tev__PullMessagesResponse.wsnt__NotificationMessage) {
|
||||
|
@ -1832,6 +1836,7 @@ bool Monitor::Poll() {
|
|||
if (!ONVIF_Trigger_State) {
|
||||
Debug(1,"Triggered Event");
|
||||
ONVIF_Trigger_State = TRUE;
|
||||
std::this_thread::sleep_for (std::chrono::seconds(1)); //thread sleep
|
||||
}
|
||||
} else {
|
||||
Debug(1, "Triggered off ONVIF");
|
||||
|
@ -1844,6 +1849,8 @@ bool Monitor::Poll() {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::this_thread::sleep_for (std::chrono::seconds(1)); //thread sleep to avoid the busy loop.
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
|
@ -2065,29 +2072,36 @@ bool Monitor::Analyse() {
|
|||
Debug(1, "Not analysing %d", shared_data->analysing);
|
||||
} // end if active and doing motion detection
|
||||
|
||||
Info("%s: %03d - Closing event %" PRIu64 ", section end forced %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64 ,
|
||||
name.c_str(),
|
||||
image_count,
|
||||
event->Id(),
|
||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(snap->timestamp.time_since_epoch()).count()),
|
||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(event->StartTime().time_since_epoch()).count()),
|
||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(snap->timestamp - event->StartTime()).count()),
|
||||
static_cast<int64>(Seconds(section_length).count()));
|
||||
closeEvent();
|
||||
} // end if section_length
|
||||
} // end if event
|
||||
|
||||
if (shared_data->capturing && !event) {
|
||||
event = openEvent(snap, cause.empty() ? "Continuous" : cause, noteSetMap);
|
||||
if (!event) {
|
||||
event = openEvent(snap, cause, noteSetMap);
|
||||
Info("%s: %03d - Opening new event %" PRIu64 ", alarm start", name.c_str(), analysis_image_count, event->Id());
|
||||
} // end if no event, so start it
|
||||
shared_data->state = state = ALARM;
|
||||
if (alarm_frame_count) {
|
||||
Debug(1, "alarm frame count so SavePreAlarmFrames");
|
||||
event->SavePreAlarmFrames();
|
||||
// If motion detecting, score will be > 0 on motion, but if skipping frames, might not be. So also test snap->score
|
||||
if ((score > 0) or (snap->score > 0)) {
|
||||
if ((state == IDLE) || (state == TAPE) || (state == PREALARM)) {
|
||||
// If we should end then previous continuous event and start a new non-continuous event
|
||||
if (event && event->Frames()
|
||||
&& !event->AlarmFrames()
|
||||
&& (event_close_mode == CLOSE_ALARM)
|
||||
// FIXME since we won't be including this snap in the event if we close it, we should be looking at event->duration() instead
|
||||
&& (event->Duration() >= min_section_length)
|
||||
&& ((!pre_event_count) || (Event::PreAlarmCount() >= alarm_frame_count - 1))) {
|
||||
Info("%s: %03d - Closing event %" PRIu64 ", continuous end, alarm begins",
|
||||
name.c_str(), image_count, event->Id());
|
||||
closeEvent();
|
||||
} else if (event) {
|
||||
// This is so if we need more than 1 alarm frame before going into alarm, so it is basically if we have enough alarm frames
|
||||
Debug(3,
|
||||
"pre_alarm_count in event %d of %d, event frames %d, alarm frames %d event length %" PRIi64 " >=? %" PRIi64 " min close mode is ALARM? %d",
|
||||
Event::PreAlarmCount(), pre_event_count,
|
||||
event->Frames(),
|
||||
event->AlarmFrames(),
|
||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(event->Duration()).count()),
|
||||
static_cast<int64>(Seconds(min_section_length).count()),
|
||||
(event_close_mode == CLOSE_ALARM));
|
||||
}
|
||||
if ((!pre_event_count) || (Event::PreAlarmCount() >= alarm_frame_count-1)) {
|
||||
Info("%s: %03d - Gone into alarm state PreAlarmCount: %u > AlarmFrameCount:%u Cause:%s",
|
||||
name.c_str(), image_count, Event::PreAlarmCount(), alarm_frame_count, cause.c_str());
|
||||
shared_data->state = state = ALARM;
|
||||
|
||||
} else if (state != PREALARM) {
|
||||
Info("%s: %03d - Gone into prealarm state", name.c_str(), analysis_image_count);
|
||||
shared_data->state = state = PREALARM;
|
||||
|
@ -2110,7 +2124,10 @@ bool Monitor::Analyse() {
|
|||
if (state == ALARM) {
|
||||
last_alarm_count = analysis_image_count;
|
||||
} // This is needed so post_event_count counts after last alarmed frames while in ALARM not single alarmed frames while ALERT
|
||||
} else if (!score and (snap->score == 0)) { // snap->score means -1 which means didn't do motion detection so don't do state transition
|
||||
|
||||
// snap->score -1 means didn't do motion detection so don't do state transition
|
||||
// In Nodect, we may still have a triggered event, so need this code to run to end the event.
|
||||
} else if (!score and ((snap->score == 0) or (analysing == ANALYSING_NONE))) {
|
||||
Debug(1, "!score %s", State_Strings[state].c_str());
|
||||
alert_to_alarm_frame_count = alarm_frame_count; // load same value configured for alarm_frame_count
|
||||
|
||||
|
@ -2125,7 +2142,7 @@ bool Monitor::Analyse() {
|
|||
Info("%s: %03d - Left alarm state (%" PRIu64 ") - %d(%d) images",
|
||||
name.c_str(), analysis_image_count, event->Id(), event->Frames(), event->AlarmFrames());
|
||||
if (
|
||||
(recording = RECORDING_ONDEMAND)
|
||||
(recording = RECORDING_ONMOTION)
|
||||
||
|
||||
(event_close_mode == CLOSE_ALARM || event_close_mode==CLOSE_IDLE)
|
||||
) {
|
||||
|
@ -2178,7 +2195,14 @@ bool Monitor::Analyse() {
|
|||
event = openEvent(snap, cause, noteSetMap);
|
||||
}
|
||||
} else {
|
||||
Error("ALARM but no event");
|
||||
if (!event) {
|
||||
event = openEvent(snap, cause, noteSetMap);
|
||||
Info("%s: %03d - Opening new event %" PRIu64 ", alarm start", name.c_str(), analysis_image_count, event->Id());
|
||||
} // end if no event, so start it
|
||||
if (alarm_frame_count) {
|
||||
Debug(1, "alarm frame count so SavePreAlarmFrames");
|
||||
event->SavePreAlarmFrames();
|
||||
}
|
||||
}
|
||||
} else if (state == ALERT) {
|
||||
// Alert means this frame has no motion, but we were alarmed and are still recording.
|
||||
|
@ -2221,7 +2245,7 @@ bool Monitor::Analyse() {
|
|||
} // end if ! event
|
||||
} // end if RECORDING
|
||||
|
||||
if ((analysiing == ANALYSING_ALWAYS) and snap->image) {
|
||||
if ((analysing == ANALYSING_ALWAYS) and snap->image) {
|
||||
if (!ref_image.Buffer()) {
|
||||
Debug(1, "Assigning");
|
||||
ref_image.Assign(*(snap->image));
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
var janus = null;
|
||||
var streaming = [];
|
||||
|
||||
function MonitorStream(monitorData) {
|
||||
this.id = monitorData.id;
|
||||
|
@ -8,6 +10,7 @@ function MonitorStream(monitorData) {
|
|||
this.url_to_zms = monitorData.url_to_zms;
|
||||
this.width = monitorData.width;
|
||||
this.height = monitorData.height;
|
||||
this.janusEnabled = monitorData.janusEnabled;
|
||||
this.scale = 100;
|
||||
this.status = null;
|
||||
this.alarmState = STATE_IDLE;
|
||||
|
@ -80,6 +83,17 @@ function MonitorStream(monitorData) {
|
|||
const stream = this.getElement();
|
||||
if (!stream) return;
|
||||
|
||||
if (this.janusEnabled) {
|
||||
var id = parseInt(this.id);
|
||||
var server = "http://" + window.location.hostname + ":8088/janus";
|
||||
if (janus == null) {
|
||||
Janus.init({debug: "all", callback: function() {
|
||||
janus = new Janus({server: server}); //new Janus
|
||||
}});
|
||||
}
|
||||
attachVideo(id);
|
||||
return;
|
||||
}
|
||||
if (!stream.src) {
|
||||
// Website Monitors won't have an img tag
|
||||
console.log('No src for #liveStream'+this.id);
|
||||
|
@ -287,3 +301,68 @@ function MonitorStream(monitorData) {
|
|||
this.streamCmdReq(this.streamCmdParms);
|
||||
};
|
||||
} // end function MonitorStream
|
||||
|
||||
async function attachVideo(id) {
|
||||
await waitUntil(() => janus.isConnected() );
|
||||
janus.attach({
|
||||
plugin: "janus.plugin.streaming",
|
||||
opaqueId: "streamingtest-"+Janus.randomString(12),
|
||||
success: function(pluginHandle) {
|
||||
streaming[id] = pluginHandle;
|
||||
var body = {"request": "watch", "id": id};
|
||||
streaming[id].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"];
|
||||
Janus.debug(status);
|
||||
}
|
||||
} else if (msg["error"] !== undefined && msg["error"] !== null) {
|
||||
return;
|
||||
}
|
||||
if (jsep !== undefined && jsep !== null) {
|
||||
Janus.debug("Handling SDP as well...");
|
||||
Janus.debug(jsep);
|
||||
// Offer from the plugin, let's answer
|
||||
streaming[id].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"};
|
||||
streaming[id].send({"message": body, "jsep": jsep});
|
||||
},
|
||||
error: function(error) {
|
||||
Janus.error("WebRTC error:", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, //onmessage function
|
||||
onremotestream: function(ourstream) {
|
||||
Janus.debug(" ::: Got a remote track :::");
|
||||
Janus.debug(ourstream);
|
||||
Janus.attachMediaStream(document.getElementById("liveStream" + id), ourstream);
|
||||
}
|
||||
}); // janus.attach
|
||||
} //function attachVideo
|
||||
|
||||
const waitUntil = (condition) => {
|
||||
return new Promise((resolve) => {
|
||||
const interval = setInterval(() => {
|
||||
if (!condition()) {
|
||||
return;
|
||||
}
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
}, 100);
|
||||
});
|
||||
};
|
||||
|
|
3649
web/js/janus.js
3649
web/js/janus.js
File diff suppressed because it is too large
Load Diff
|
@ -193,5 +193,5 @@ xhtmlHeaders(__FILE__, translate('CycleWatch'));
|
|||
</div>
|
||||
</div>
|
||||
<script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script>
|
||||
<script src="<?php echo cache_bust('js/janus.js') ?>"></script>
|
||||
<script src="/javascript/janus/janus.js"></script>
|
||||
<?php xhtmlFooter() ?>
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
var server;
|
||||
var janus = null;
|
||||
var opaqueId;
|
||||
var globalCount = 0;
|
||||
var streamingList = [];
|
||||
var janusMonitors = [];
|
||||
/**
|
||||
* called when the layoutControl select element is changed, or the page
|
||||
* is rendered
|
||||
|
@ -306,30 +300,7 @@ function initPage() {
|
|||
$j("#flipMontageHeader").slideToggle("fast");
|
||||
$j("#hdrbutton").toggleClass('glyphicon-menu-down').toggleClass('glyphicon-menu-up');
|
||||
}
|
||||
var initJanus = false;
|
||||
//var streamingMonitors = [];
|
||||
for ( var i = 0, length = monitorData.length; i < length; i++ ) {
|
||||
if (monitorData[i].janusEnabled) {
|
||||
initJanus = true;
|
||||
janusMonitors.push(monitorData[i]);
|
||||
}
|
||||
}
|
||||
if (initJanus) {
|
||||
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() {
|
||||
for ( var i = 0, length = janusMonitors.length; i < length; i++ ) {
|
||||
attachVideo(janus, i);
|
||||
}
|
||||
}
|
||||
});
|
||||
}});
|
||||
}
|
||||
for ( var i = 0, length = monitorData.length; i < length; i++ ) {
|
||||
if (!monitorData[i].janusEnabled) {
|
||||
monitors[i] = new MonitorStream(monitorData[i]);
|
||||
|
||||
// Start the fps and status updates. give a random delay so that we don't assault the server
|
||||
|
@ -343,7 +314,6 @@ function initPage() {
|
|||
}
|
||||
monitors[i].setup_onclick();
|
||||
}
|
||||
}
|
||||
selectLayout('#zmMontageLayout');
|
||||
}
|
||||
|
||||
|
@ -352,58 +322,5 @@ function watchFullscreen() {
|
|||
openFullscreen(content);
|
||||
}
|
||||
|
||||
function attachVideo(janus, i) {
|
||||
janus.attach({
|
||||
plugin: "janus.plugin.streaming",
|
||||
opaqueId: "streamingtest-"+Janus.randomString(12),
|
||||
success: function(pluginHandle) {
|
||||
janusMonitors[i].streaming = pluginHandle;
|
||||
var body = {"request": "watch", "id": parseInt(janusMonitors[i].id)};
|
||||
janusMonitors[i].streaming.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) {
|
||||
const status = result["status"];
|
||||
console.log(status);
|
||||
}
|
||||
} else if (msg["error"] !== undefined && msg["error"] !== null) {
|
||||
Janus.error(msg["error"]);
|
||||
return;
|
||||
}
|
||||
if (jsep !== undefined && jsep !== null) {
|
||||
Janus.debug("Handling SDP as well...");
|
||||
Janus.debug(jsep);
|
||||
// Offer from the plugin, let's answer
|
||||
janusMonitors[i].streaming.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"};
|
||||
janusMonitors[i].streaming.send({"message": body, "jsep": jsep});
|
||||
},
|
||||
error: function(error) {
|
||||
Janus.error("WebRTC error:", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, //onmessage function
|
||||
onremotestream: function(ourstream) {
|
||||
Janus.debug(" ::: Got a remote track :::");
|
||||
Janus.debug(ourstream);
|
||||
Janus.attachMediaStream(document.getElementById("liveStream" + janusMonitors[i].id), ourstream);
|
||||
document.getElementById("liveStream" + janusMonitors[i].id).play();
|
||||
}
|
||||
});// attach
|
||||
}
|
||||
// Kick everything off
|
||||
$j(document).ready(initPage);
|
||||
|
|
|
@ -326,6 +326,6 @@ foreach (array_reverse($zones) as $zone) {
|
|||
</div>
|
||||
</div>
|
||||
<script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script>
|
||||
<script src="<?php echo cache_bust('js/janus.js') ?>"></script>
|
||||
<script src="/javascript/janus/janus.js"></script>
|
||||
<script src="<?php echo cache_bust('js/MonitorStream.js') ?>"></script>
|
||||
<?php xhtmlFooter() ?>
|
||||
|
|
|
@ -412,5 +412,5 @@ if ( ZM_WEB_SOUND_ON_ALARM ) {
|
|||
</div>
|
||||
</div>
|
||||
<script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script>
|
||||
<script src="<?php echo cache_bust('js/janus.js') ?>"></script>
|
||||
<script src="/javascript/janus/janus.js"></script>
|
||||
<?php xhtmlFooter() ?>
|
||||
|
|
Loading…
Reference in New Issue