]> www.vanbest.org Git - motioneye-debian/commitdiff
removed local picture caching mechanism, as it was useless, especially
authorCalin Crisan <ccrisan@gmail.com>
Sun, 5 Jul 2015 14:48:52 +0000 (17:48 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sun, 5 Jul 2015 14:48:52 +0000 (17:48 +0300)
at high framerates

motioneye.py
settings_default.py
src/handlers.py
src/mediafiles.py
src/mjpgclient.py
static/js/frame.js
static/js/main.js

index 0a72083da6152edd6d430a7c57e3d07409069f1c..1beb6ec7948e7b3e15860b451fef178ec0eca716 100755 (executable)
@@ -66,8 +66,6 @@ def _configure_settings():
     set_default_setting('REMOTE_REQUEST_TIMEOUT', 10)
     set_default_setting('MJPG_CLIENT_TIMEOUT', 10)
     set_default_setting('MJPG_CLIENT_IDLE_TIMEOUT', 10)
-    set_default_setting('PICTURE_CACHE_SIZE', 8)
-    set_default_setting('PICTURE_CACHE_LIFETIME', 60)
     set_default_setting('SMB_SHARES', False)
     set_default_setting('SMB_MOUNT_ROOT', '/media')
     set_default_setting('WPA_SUPPLICANT_CONF', None)
index 3dc11d6b83172aa68ba260f930ec79ceb90245b5..d200cc346026fabf5fcf38a35f74ada674b9cca8 100644 (file)
@@ -56,12 +56,6 @@ MJPG_CLIENT_TIMEOUT = 10
 # timeout in seconds after which an idle mjpg client is removed (set to 0 to disable)
 MJPG_CLIENT_IDLE_TIMEOUT = 10
 
-# the maximal number of entries per camera in the current pictures cache
-PICTURE_CACHE_SIZE = 8
-
-# the number of seconds that a cached picture is valid
-PICTURE_CACHE_LIFETIME = 60
-
 # enable SMB shares (requires root) 
 SMB_SHARES = False
 
index e33c635fdbdbad25d084f09ba50186cb9dc949ba..56b99e32dbe2628c6721f6cf9bbbeb10ceb2b0bf 100644 (file)
@@ -741,35 +741,20 @@ class PictureHandler(BaseHandler):
     def current(self, camera_id):
         self.set_header('Content-Type', 'image/jpeg')
         
-        sequence = self.get_argument('seq', None)
-        if sequence:
-            sequence = int(sequence)
-        
         width = self.get_argument('width', None)
         height = self.get_argument('height', None)
         
-        picture = sequence and mediafiles.get_picture_cache(camera_id, sequence, width) or None
-
-        if picture is not None:
-            return self.try_finish(picture)
-
         camera_config = config.get_camera(camera_id)
         if utils.local_motion_camera(camera_config):
             picture = mediafiles.get_current_picture(camera_config,
                     width=width,
                     height=height)
             
-            if sequence and picture:
-                mediafiles.set_picture_cache(camera_id, sequence, width, picture)
-
             self.set_cookie('motion_detected_' + str(camera_id), str(motionctl.is_motion_detected(camera_id)).lower())
             self.try_finish(picture)
                 
         elif utils.remote_camera(camera_config):
             def on_response(motion_detected=False, picture=None, error=None):
-                if sequence and picture:
-                    mediafiles.set_picture_cache(camera_id, sequence, width, picture)
-                
                 self.set_cookie('motion_detected_' + str(camera_id), str(motion_detected).lower())
                 self.try_finish(picture)
             
index f7c5fc1a412f6c4d7466a7d87169d298ccfb8dca..c4f615ecb13af39ea5094c7cd3a71fc46eefd6d6 100644 (file)
@@ -42,10 +42,6 @@ import utils
 _PICTURE_EXTS = ['.jpg']
 _MOVIE_EXTS = ['.avi', '.mp4']
 
-# a dictionary indexed by camera_id containing
-# tuples of (moment, sequence, width, content)
-_current_pictures_cache = {}
-
 # a cache list of paths to movies without preview
 _previewless_movie_files = []
 
@@ -757,7 +753,7 @@ def get_current_picture(camera_config, width, height):
         return None
     
     if width is height is None:
-        return jpg
+        return jpg # no server-side resize needed
 
     sio = StringIO.StringIO(jpg)
     image = Image.open(sio)
@@ -783,33 +779,6 @@ def get_current_picture(camera_config, width, height):
     return sio.getvalue()
 
 
-def set_picture_cache(camera_id, sequence, width, content):
-    if not content:
-        return
-    
-    cache = _current_pictures_cache.setdefault(camera_id, [])
-    
-    if len(cache) >= settings.PICTURE_CACHE_SIZE:
-        cache.pop(0) # drop the first item
-    
-    cache.append((datetime.datetime.utcnow(), sequence, width, content))
-
-
-def get_picture_cache(camera_id, sequence, width):
-    cache = _current_pictures_cache.setdefault(camera_id, [])
-    now = datetime.datetime.utcnow()
-
-    for (moment, seq, w, content) in cache:
-        delta = now - moment
-        if delta.days * 86400 + delta.seconds > settings.PICTURE_CACHE_LIFETIME:
-            continue
-        
-        if (seq >= sequence) and ((width is w is None) or (width >= w)):
-            return content
-        
-    return None
-
-
 def get_prepared_cache(key):
     return _prepared_files.pop(key, None)
 
index d576d81b3341bc423385492902d191c1647fdce1..8c8de0e44d49d166b51988a3761a29fdc66afb95 100644 (file)
@@ -257,9 +257,6 @@ def _garbage_collector():
 
 
 def get_jpg(camera_id):
-    if not motionctl.running():
-        return None
-    
     if camera_id not in MjpgClient.clients:
         # mjpg client not started yet for this camera
         
index 028279d006f0ca6ecfbc4f68155c7ee68b81c104..0a911659e2ef84c9918dfadbf6eb1555bb67162a 100644 (file)
@@ -123,9 +123,8 @@ function refreshCameraFrame() {
                 }
             }
             
-            var timestamp = Math.round(new Date().getTime());
-            
-            var uri = baseUri + 'picture/' + cameraId + '/current/?seq=' + timestamp;
+            var timestamp = new Date().getTime();
+            var uri = baseUri + 'picture/' + cameraId + '/current/?_=' + timestamp;
             if (cameraFrame.serverSideResize) {
                 uri += '&width=' + img.width;
             }
index 6b7a10901e0e783691bced5ec048e853b3098e52..e4dbe785a4edab013e2ccf3f30ddd21b3d780256 100644 (file)
@@ -1589,9 +1589,6 @@ function dict2CameraUi(dict) {
         if (snapshotUrl) {
             snapshotUrl = addAuthParams('GET', snapshotUrl);
         }
-        if (mjpgUrl && dict['proto'] != 'mjpeg') {
-            mjpgUrl = addAuthParams('GET', mjpgUrl);
-        }
     }
     
     $('#streamingSnapshotUrlEntry').val(snapshotUrl); markHideIfNull(!snapshotUrl, 'streamingSnapshotUrlEntry');
@@ -3778,9 +3775,8 @@ function refreshCameraFrames() {
             }
         }
         
-        var timestamp = Math.round(new Date().getTime());
-        
-        var uri = baseUri + 'picture/' + cameraId + '/current/?seq=' + timestamp;
+        var timestamp = new Date().getTime();
+        var uri = baseUri + 'picture/' + cameraId + '/current/?_=' + timestamp;
         if (serverSideResize) {
             uri += '&width=' + img.width;
         }