From 11a47350822abfd4627ce51206038c0851f0517b Mon Sep 17 00:00:00 2001 From: VikingGer <90556180+VikingGer@users.noreply.github.com> Date: Sat, 17 Sep 2022 10:08:07 +0200 Subject: [PATCH 1/7] Update MonitorLinkExpression.js Trailing spaces lead to eslint error. Removed them --- web/js/MonitorLinkExpression.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/js/MonitorLinkExpression.js b/web/js/MonitorLinkExpression.js index 5f94dbf2f..34ebfac9d 100644 --- a/web/js/MonitorLinkExpression.js +++ b/web/js/MonitorLinkExpression.js @@ -158,7 +158,7 @@ function expr_to_ui(expr, container) { select.append(''); for (monitor_id in monitors) { const monitor = monitors[monitor_id]; - //if (!array_search(monitor.Id, used_monitorlinks)) + //if (!array_search(monitor.Id, used_monitorlinks)) select.append(''); for ( zone_id in zones ) { const zone = zones[zone_id]; From 851ddb7f0633fe184210f77cdbe51e9ac51ff14d Mon Sep 17 00:00:00 2001 From: VikingGer <90556180+VikingGer@users.noreply.github.com> Date: Sat, 17 Sep 2022 10:14:00 +0200 Subject: [PATCH 2/7] Update event.js Again Eslint errors --- web/skins/classic/views/js/event.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/skins/classic/views/js/event.js b/web/skins/classic/views/js/event.js index 490920989..295d115ed 100644 --- a/web/skins/classic/views/js/event.js +++ b/web/skins/classic/views/js/event.js @@ -132,11 +132,11 @@ function renderAlarmCues(containerEl) { */ cues_div = document.getElementById('alarmCues'); const event_length = (eventData.Length > cueFrames[cueFrames.length - 1].Delta) ? eventData.Length : cueFrames[cueFrames.length - 1].Delta; - let span_count = 10; - let span_seconds = parseInt(event_length / span_count); - let span_width = parseInt(containerEl.width() / span_count); + const span_count = 10; + const span_seconds = parseInt(event_length / span_count); + const span_width = parseInt(containerEl.width() / span_count); console.log(span_width, containerEl.width(), span_count); - //let span_width = + //let span_width = const date = new Date(eventData.StartDateTime); for (let i=0; i < span_count; i += 1) { html += ''+date.toLocaleTimeString()+''; @@ -848,7 +848,7 @@ function progressBarNav() { if (x<0) x=0; if (x > bar.width()) x = bar.width(); - let seekTime = (x / bar.width()) * parseFloat(eventData.Length); + const seekTime = (x / bar.width()) * parseFloat(eventData.Length); const indicator = document.getElementById('indicator'); From a099a4e3aeab638ecddb6eaf66f1d0b0fb54dd96 Mon Sep 17 00:00:00 2001 From: VikingGer <90556180+VikingGer@users.noreply.github.com> Date: Sat, 17 Sep 2022 10:19:42 +0200 Subject: [PATCH 3/7] Update report.php Again Eslint errors --- web/skins/classic/views/report.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/views/report.php b/web/skins/classic/views/report.php index 0b9b61772..b1f056f4c 100644 --- a/web/skins/classic/views/report.php +++ b/web/skins/classic/views/report.php @@ -110,7 +110,7 @@ dataset_indexes = {}; // Associative array from a date String like July 20 to an for (i=0; i < 24; i++) { time_labels[time_labels.length] = `${i}:00`; } -months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]; +months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; for (event_index=0; event_index < events.length; event_index++) { const event = events[event_index]; @@ -128,7 +128,7 @@ for (event_index=0; event_index < events.length; event_index++) { fill: false, borderColor: 'rgb('+parseInt(255*Math.random())+', '+parseInt(255*Math.random())+', '+parseInt(255*Math.random())+')', tension: 0.1, - data: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] + data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }; } From ac55a9e0f2c58cbaf7afa9a515b23955a5508292 Mon Sep 17 00:00:00 2001 From: VikingGer <90556180+VikingGer@users.noreply.github.com> Date: Sat, 17 Sep 2022 10:28:10 +0200 Subject: [PATCH 4/7] Update reports.js Function name missing? Assumed to be correct according to the rest. --- web/skins/classic/views/js/reports.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/reports.js b/web/skins/classic/views/js/reports.js index e7a1adc19..b758cd4dc 100644 --- a/web/skins/classic/views/js/reports.js +++ b/web/skins/classic/views/js/reports.js @@ -162,7 +162,7 @@ function initPage() { window.location.reload(true); }); - document.getElementById("newBtn").addEventListener('click', function (evt) { + document.getElementById("newBtn").addEventListener('click', function onNewClick(evt) { evt.preventDefault(); window.location = '?view=report'; }); From 67a7c0721a026bd850e0df1704d53e0f752f691e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 17 Sep 2022 18:58:50 -0400 Subject: [PATCH 5/7] Fix bad merge reverts. Put back code that take username and password from fields in monitor instead of parsing from rtsp path --- src/zm_monitor_janus.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/zm_monitor_janus.cpp b/src/zm_monitor_janus.cpp index 816dd99a2..ba25cdd51 100644 --- a/src/zm_monitor_janus.cpp +++ b/src/zm_monitor_janus.cpp @@ -27,8 +27,6 @@ Monitor::JanusManager::JanusManager(Monitor *parent_) : parent(parent_), Janus_Healthy(false) { - //constructor takes care of init and calls add_to - //parent = parent_; Use_RTSP_Restream = parent->janus_use_rtsp_restream; profile_override = parent->janus_profile_override; if ((config.janus_path != nullptr) && (config.janus_path[0] != '\0')) { @@ -38,29 +36,16 @@ Monitor::JanusManager::JanusManager(Monitor *parent_) : } else { janus_endpoint = "127.0.0.1:8088/janus"; } + // std:: strings default to "", don't need to set them ="" if (Use_RTSP_Restream) { int restream_port = config.min_rtsp_port; - rtsp_username = ""; - rtsp_password = ""; rtsp_path = "rtsp://127.0.0.1:" + std::to_string(restream_port) + "/" + parent->rtsp_streamname; } else { - std::size_t at_pos = parent->path.find("@", 7); - if (at_pos != std::string::npos) { - //If we find an @ symbol, we have a username/password. Otherwise, passwordless login. - std::size_t colon_pos = parent->path.find(":", 7); //Search for the colon, but only after the rtsp:// text. - if (colon_pos == std::string::npos) { - //Looks like an invalid url - throw std::runtime_error("Cannot Parse URL for Janus."); - } - rtsp_username = parent->path.substr(7, colon_pos-7); - rtsp_password = parent->path.substr(colon_pos+1, at_pos - colon_pos - 1); - rtsp_path = "rtsp://"; - rtsp_path += parent->path.substr(at_pos + 1); - } else { - rtsp_username = ""; - rtsp_password = ""; - rtsp_path = parent->path; + if (parent->user.length() > 0) { + rtsp_username = escape_json_string(parent->user); + rtsp_password = escape_json_string(parent->pass); } + rtsp_path = parent->path; } parent->janus_pin = generateKey(16); Debug(1, "Monitor %u assigned secret %s", parent->id, parent->janus_pin.c_str()); From dd82a0129132abab6b601652a97ddc2d63dffa65 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 18 Sep 2022 12:35:04 -0400 Subject: [PATCH 6/7] Don't encode the user/pass. If they were properly entered in the web ui then we will double encode them. --- src/zm_ffmpeg_camera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 5e63eee90..5cdc38636 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -116,8 +116,8 @@ FfmpegCamera::FfmpegCamera( ), mPath(p_path), mSecondPath(p_second_path), - mUser(UriEncode(p_user)), - mPass(UriEncode(p_pass)), + mUser(p_user), + mPass(p_pass), mMethod(p_method), mOptions(p_options), hwaccel_name(p_hwaccel_name), From bdf5b5d20233eac34738148108773bdc09b10e37 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sun, 18 Sep 2022 12:36:29 -0400 Subject: [PATCH 7/7] Use empty() instead of length() which is faster. Add rtsp path to debug --- src/zm_monitor_janus.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/zm_monitor_janus.cpp b/src/zm_monitor_janus.cpp index ba25cdd51..12e928b74 100644 --- a/src/zm_monitor_janus.cpp +++ b/src/zm_monitor_janus.cpp @@ -38,17 +38,16 @@ Monitor::JanusManager::JanusManager(Monitor *parent_) : } // std:: strings default to "", don't need to set them ="" if (Use_RTSP_Restream) { - int restream_port = config.min_rtsp_port; - rtsp_path = "rtsp://127.0.0.1:" + std::to_string(restream_port) + "/" + parent->rtsp_streamname; + rtsp_path = "rtsp://127.0.0.1:" + std::to_string(config.min_rtsp_port) + "/" + parent->rtsp_streamname; } else { - if (parent->user.length() > 0) { + if (!parent->user.empty()) { rtsp_username = escape_json_string(parent->user); rtsp_password = escape_json_string(parent->pass); } rtsp_path = parent->path; } parent->janus_pin = generateKey(16); - Debug(1, "Monitor %u assigned secret %s", parent->id, parent->janus_pin.c_str()); + Debug(1, "Monitor %u assigned secret %s, rtsp url is %s", parent->id, parent->janus_pin.c_str(), rtsp_path.c_str()); strncpy(parent->shared_data->janus_pin, parent->janus_pin.c_str(), 17); //copy the null termination, as we're in C land } @@ -163,7 +162,7 @@ int Monitor::JanusManager::add_to_janus() { postData += "\", \"videofmtp\" : \""; postData += profile_override; } - if (rtsp_username.length() > 0) { + if (!rtsp_username.empty()) { postData += "\", \"rtsp_user\" : \""; postData += rtsp_username; postData += "\", \"rtsp_pwd\" : \""; @@ -173,7 +172,7 @@ int Monitor::JanusManager::add_to_janus() { postData += std::to_string(parent->id); if (parent->janus_audio_enabled) postData += ", \"audio\" : true"; postData += ", \"video\" : true}}"; - Warning("Sending %s to %s", postData.c_str(), endpoint.c_str()); + Debug(1, "Sending %s to %s", postData.c_str(), endpoint.c_str()); CURLcode res; std::string response;