From 0b3a842cacadd58ce87e41d5c96ae2b1dd088ba5 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 26 Oct 2013 19:13:54 +0300 Subject: [PATCH] remote camera device is now presented using http://host:port/config/camera_id --- doc/todo.txt | 2 -- src/handlers.py | 12 +++++++++++- src/remote.py | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) 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': '<error>', # TODO add the camera url here + 'name': '<' + camera_url + '>', '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, -- 2.39.5