From: Calin Crisan <ccrisan@gmail.com>
Date: Sat, 26 Oct 2013 16:13:54 +0000 (+0300)
Subject: remote camera device is now presented using
X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=0b3a842cacadd58ce87e41d5c96ae2b1dd088ba5;p=motioneye-debian

remote camera device is now presented using
http://host:port/config/camera_id
---

diff --git a/doc/todo.txt b/doc/todo.txt
index 32515b7..1d151b8 100644
--- a/doc/todo.txt
+++ b/doc/todo.txt
@@ -1,8 +1,6 @@
 -> add an autoupdate mechanism
--> 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
diff --git a/src/handlers.py b/src/handlers.py
index 5ec4946..4b25dd2 100644
--- a/src/handlers.py
+++ b/src/handlers.py
@@ -149,6 +149,11 @@ class ConfigHandler(BaseHandler):
                     for key, value in camera_config.items():
                         remote_ui_config[key.replace('@', '')] = value
                     
+                    remote_ui_config['device'] = remote.make_remote_camera_url(
+                            camera_config.get('@host'),
+                            camera_config.get('@port'),
+                            camera_config.get('@remote_camera_id'))
+                    
                     self.finish_json(remote_ui_config)
                 
                 remote.get_config(
@@ -351,9 +356,14 @@ class ConfigHandler(BaseHandler):
             def on_response_builder(camera_id, camera_config):
                 def on_response(remote_ui_config):
                     if remote_ui_config is None:
+                        camera_url = remote.make_remote_camera_url(
+                                camera_config.get('@host'),
+                                camera_config.get('@port'),
+                                camera_config.get('@remote_camera_id'))
+                        
                         cameras.append({
                             'id': camera_id,
-                            'name': '&lt;error&gt;', # TODO add the camera url here
+                            'name': '&lt;' + camera_url + '&gt;',
                             'enabled': False,
                             'streaming_framerate': 1,
                             'framerate': 1
diff --git a/src/remote.py b/src/remote.py
index 870accc..3f9b1f7 100644
--- a/src/remote.py
+++ b/src/remote.py
@@ -25,6 +25,14 @@ def _make_request(host, port, username, password, uri, method='GET', data=None,
     return request
 
 
+def make_remote_camera_url(host, port, camera_id):
+    return '%(host)s:%(port)s/config/%(camera_id)s' % {
+        'host': host,
+        'port': port,
+        'camera_id': camera_id
+    }
+
+
 def list_cameras(host, port, username, password, callback):
     logging.debug('listing remote cameras on %(host)s:%(port)s' % {
             'host': host,