]> www.vanbest.org Git - motioneye-debian/commitdiff
added caching mechanism for v4l ctl
authorCalin Crisan <ccrisan@gmail.com>
Sat, 26 Oct 2013 13:45:02 +0000 (16:45 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 26 Oct 2013 13:45:02 +0000 (16:45 +0300)
doc/todo.txt
src/handlers.py
src/v4l2ctl.py

index 399df2de5afce29a76b3393572fcd3f3501eee09..07de28b332401e187073bfb02ede086afdaeb9a6 100644 (file)
@@ -1,15 +1,18 @@
 -> add an autoupdate mechanism
+-> cache jpegs from remote cameras locally
+-> cache prevention query arg should be according to the refresh rate
+-> the camera is not available on page load, it is never shown afterwards - increase the timeout
+-> click to zoom on cameras
+-> make camera frames positions configurable
+-> remote cameras are presented as http:///dev/video0
+-> add a view log functionality
+-> add a previewer for movies
+-> add a previewer for snapshots
 
 -> style scroll bars
 -> hint text next to section titles
 -> clickable hints
 
--> make camera frames positions configurable
--> add a view log functionality
--> click to zoom on cameras
--> add a previewer for movies
--> add a previewer for snapshots
--> add a motioneye.svg icon
 
 -> implement working schedule (add another combo deciding what to do during working schedule)
 -> add other options applicable only to special devices (rpi): wifi settings, notifications
index d3e837124d3a43838b7acdd05d9b373d14d6ee53..5ec4946ec685647ff7056f782da1b0f20fcb38c5 100644 (file)
@@ -353,7 +353,7 @@ class ConfigHandler(BaseHandler):
                     if remote_ui_config is None:
                         cameras.append({
                             'id': camera_id,
-                            'name': '&lt;error&gt;',
+                            'name': '&lt;error&gt;', # TODO add the camera url here
                             'enabled': False,
                             'streaming_framerate': 1,
                             'framerate': 1
index f41e72552ca0af70c29cfc55eafbfe97ccad6a98..7a28bbe9e72674c3cca9f7fbc74514650159e576 100644 (file)
@@ -4,7 +4,14 @@ import re
 import subprocess
 
 
+_resolutions_cache = {}
+_ctrls_cache = {}
+_ctrl_values_cache = {}
+
+
 def list_devices():
+    global _resolutions_cache
+    
     logging.debug('listing v4l devices...')
     
     devices = []
@@ -22,11 +29,21 @@ def list_devices():
             
         else:
             name = line.split('(')[0].strip()
+    
+    # clear the cache
+    _resolutions_cache = {}
+    _ctrls_cache = {}
+    _ctrl_values_cache = {}
 
     return devices
 
 
 def list_resolutions(device):
+    global _resolutions_cache
+    
+    if device in _resolutions_cache:
+        return _resolutions_cache[device]
+    
     logging.debug('listing resolutions of device %(device)s...' % {'device': device})
     
     resolutions = set()
@@ -47,7 +64,10 @@ def list_resolutions(device):
         logging.debug('found resolution %(width)sx%(height)s for device %(device)s' % {
                 'device': device, 'width': width, 'height': height})
     
-    return list(sorted(resolutions, key=lambda r: (r[0], r[1])))
+    resolutions = list(sorted(resolutions, key=lambda r: (r[0], r[1])))
+    _resolutions_cache[device] = resolutions
+    
+    return resolutions
 
 
 def get_brightness(device):
@@ -83,6 +103,11 @@ def set_hue(device, value):
 
 
 def _get_ctrl(device, control):
+    global _ctrl_values_cache
+    
+    if device in _ctrl_values_cache and control in _ctrl_values_cache[device]:
+        return _ctrl_values_cache[device][control]
+    
     controls = _list_ctrls(device)
     properties = controls.get(control)
     if properties is None:
@@ -111,6 +136,8 @@ def _get_ctrl(device, control):
 
 
 def _set_ctrl(device, control, value):
+    global _ctrl_values_cache
+    
     controls = _list_ctrls(device)
     properties = controls.get(control)
     if properties is None:
@@ -119,6 +146,8 @@ def _set_ctrl(device, control, value):
         
         return
     
+    _ctrl_values_cache.setdefault(device, {})[control] = value
+
     # adjust the value range
     if 'min' in properties and 'max' in properties:
         min_value = int(properties['min'])
@@ -138,6 +167,11 @@ def _set_ctrl(device, control, value):
 
 
 def _list_ctrls(device):
+    global _ctrls_cache
+    
+    if device in _ctrls_cache:
+        return _ctrls_cache[device]
+    
     output = subprocess.check_output('v4l2-ctl -d %(device)s --list-ctrls' % {
             'device': device}, shell=True)
 
@@ -154,4 +188,6 @@ def _list_ctrls(device):
         properties = dict([v.split('=') for v in properties.split(' ')])
         controls[control] = properties
     
+    _ctrls_cache[device] = controls
+    
     return controls