Add zoom commands
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from api.recording import RecordingAPIMixin
|
||||
from .recording import RecordingAPIMixin
|
||||
from .zoom import ZoomAPIMixin
|
||||
from .device import DeviceAPIMixin
|
||||
from .display import DisplayAPIMixin
|
||||
from .network import NetworkAPIMixin
|
||||
@@ -12,7 +13,8 @@ class APIHandler(SystemAPIMixin,
|
||||
UserAPIMixin,
|
||||
DeviceAPIMixin,
|
||||
DisplayAPIMixin,
|
||||
RecordingAPIMixin):
|
||||
RecordingAPIMixin,
|
||||
ZoomAPIMixin):
|
||||
"""
|
||||
The APIHandler class is the backend part of the API, the actual API calls
|
||||
are implemented in Mixins.
|
||||
|
||||
32
api/zoom.py
Normal file
32
api/zoom.py
Normal file
@@ -0,0 +1,32 @@
|
||||
class ZoomAPIMixin:
|
||||
"""
|
||||
API for zooming and changing focus.
|
||||
Note that the API does not allow zooming/focusing by absolute
|
||||
values rather that changing focus/zoom for a given time.
|
||||
"""
|
||||
def _start_zoom(self, direction, speed=60):
|
||||
op = 'ZoomInc' if direction == 'in' else 'ZoomDec'
|
||||
data = [{"cmd": "PtzCtrl", "action": 0, "param": {"channel": 0, "op": op, "speed": speed}}]
|
||||
return self._execute_command('PtzCtrl', data)
|
||||
|
||||
def start_zoom_in(self, speed=60):
|
||||
"""
|
||||
The camera zooms in until self.stop_zoom() is called.
|
||||
:return: response json
|
||||
"""
|
||||
return self._start_zoom('in', speed=speed)
|
||||
|
||||
def start_zoom_out(self, speed=60):
|
||||
"""
|
||||
The camera zooms out until self.stop_zoom() is called.
|
||||
:return: response json
|
||||
"""
|
||||
return self._start_zoom('out', speed=speed)
|
||||
|
||||
def stop_zoom(self):
|
||||
"""
|
||||
Stop zooming.
|
||||
:return: response json
|
||||
"""
|
||||
data = [{"cmd": "PtzCtrl", "action": 0, "param": {"channel": 0, "op": "Stop"}}]
|
||||
return self._execute_command('PtzCtrl', data)
|
||||
Reference in New Issue
Block a user