From 5837af45231f472810a013779c8b4d89bf96dfdb Mon Sep 17 00:00:00 2001 From: Yossi Date: Tue, 1 May 2018 15:32:06 +0300 Subject: [PATCH] fix(impulseButton): fix support for new raspivid file --- config.json | 2 +- daemons/bluetooth/videoReady.js | 10 ++++++---- dride-ws/server/api/getClips/getClips.controller.js | 2 +- .../server/api/getEMRClips/getEMRClips.controller.js | 1 + state/config.backup.json | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/config.json b/config.json index 91cb967..0d8f237 100644 --- a/config.json +++ b/config.json @@ -1 +1 @@ -{"name":"drideOS","version":"0.13.0","settings":{"debug":false,"videoRecord":true,"flipVideo":false,"gps":false,"speaker":false,"mic":false,"indicator":true,"resolution":"720","fps":30,"clipLength":1,"gSensorSensitivity":"medium","netwrok":{"ssid":"dride","password":"ilovedride"}}} \ No newline at end of file +{"name":"drideOS","version":"1.0.0-rc.0","settings":{"debug":false,"videoRecord":true,"flipVideo":false,"gps":false,"speaker":false,"mic":false,"indicator":true,"resolution":"720","fps":30,"clipLength":1,"gSensorSensitivity":"medium","netwrok":{"ssid":"dride","password":"ilovedride"}}} \ No newline at end of file diff --git a/daemons/bluetooth/videoReady.js b/daemons/bluetooth/videoReady.js index 23dbcdb..ea6e10f 100644 --- a/daemons/bluetooth/videoReady.js +++ b/daemons/bluetooth/videoReady.js @@ -36,12 +36,13 @@ videoReady.startListner = clickTimeStamp => { /** * We might get unwated encoded video clips during the watch period, So we filter them so we will get the clip we need. */ - if (filename < clickTimeStamp || filename - clickTimeStamp > 60) { - return; - } filename = filename.replace('.jpg', ''); + if (clickTimeStamp - filename * 1000 < 0 || clickTimeStamp - filename * 1000 > 60000) { + return; + } + // save currentTimestamp in the db var emrVideos = JSON.parse(fs.readFileSync('/home/core/modules/video/savedVideos.json', 'utf8')); if (!emrVideos) { @@ -50,8 +51,9 @@ videoReady.startListner = clickTimeStamp => { //make sure this was not published before found = false; + for (var i = 0; i < emrVideos.length; i++) { - if (emrVideos[i].key == filename || Math.abs(parseInt(emrVideos[i].key) - parseInt(filename)) < 5000) { + if (emrVideos[i].key == filename) { found = true; break; } diff --git a/dride-ws/server/api/getClips/getClips.controller.js b/dride-ws/server/api/getClips/getClips.controller.js index ca1705c..327c5b3 100644 --- a/dride-ws/server/api/getClips/getClips.controller.js +++ b/dride-ws/server/api/getClips/getClips.controller.js @@ -20,7 +20,7 @@ exports.index = function(req, res) { key: files[i], clip: '/clip/' + files[i] + '.mp4', thumb: '/thumb/' + files[i] + '.jpg', - timestamp: files[i] + timestamp: files[i] * 1000 }); } diff --git a/dride-ws/server/api/getEMRClips/getEMRClips.controller.js b/dride-ws/server/api/getEMRClips/getEMRClips.controller.js index 00c1289..e33bab0 100644 --- a/dride-ws/server/api/getEMRClips/getEMRClips.controller.js +++ b/dride-ws/server/api/getEMRClips/getEMRClips.controller.js @@ -21,6 +21,7 @@ exports.index = function(req, res) { EMRvideos[i].timestamp = EMRvideos[i].key; EMRvideos[i].clip = '/clip/' + EMRvideos[i].key + '.mp4'; EMRvideos[i].thumb = '/thumb/' + EMRvideos[i].key + '.jpg'; + EMRvideos[i].timestamp = EMRvideos[i].timestamp * 1000; } res.json({ diff --git a/state/config.backup.json b/state/config.backup.json index 91cb967..0d8f237 100644 --- a/state/config.backup.json +++ b/state/config.backup.json @@ -1 +1 @@ -{"name":"drideOS","version":"0.13.0","settings":{"debug":false,"videoRecord":true,"flipVideo":false,"gps":false,"speaker":false,"mic":false,"indicator":true,"resolution":"720","fps":30,"clipLength":1,"gSensorSensitivity":"medium","netwrok":{"ssid":"dride","password":"ilovedride"}}} \ No newline at end of file +{"name":"drideOS","version":"1.0.0-rc.0","settings":{"debug":false,"videoRecord":true,"flipVideo":false,"gps":false,"speaker":false,"mic":false,"indicator":true,"resolution":"720","fps":30,"clipLength":1,"gSensorSensitivity":"medium","netwrok":{"ssid":"dride","password":"ilovedride"}}} \ No newline at end of file