Updated project structure and some file names.
Restored `requirements.txt` Updated `setup.py` to include new repository url and contact details. Moved the rtsp code from `record` to `stream`. Updated project structure to make it more readable and developer friendly - moved mixins to the `mixins` package, moved handlers to the `handlers` package. Moved files not belonging to anything in particular to the `util` package. Updated `camera` class to also defer login call. Deleted unused files like `config_handler`.
This commit is contained in:
59
reolinkapi/mixins/zoom.py
Normal file
59
reolinkapi/mixins/zoom.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from typing import Dict
|
||||
|
||||
|
||||
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_operation(self, operation: str, speed: float) -> Dict:
|
||||
data = [{"cmd": "PtzCtrl", "action": 0, "param": {"channel": 0, "op": operation, "speed": speed}}]
|
||||
return self._execute_command('PtzCtrl', data)
|
||||
|
||||
def _stop_zooming_or_focusing(self) -> Dict:
|
||||
"""This command stops any ongoing zooming or focusing actions."""
|
||||
data = [{"cmd": "PtzCtrl", "action": 0, "param": {"channel": 0, "op": "Stop"}}]
|
||||
return self._execute_command('PtzCtrl', data)
|
||||
|
||||
def start_zooming_in(self, speed: float = 60) -> Dict:
|
||||
"""
|
||||
The camera zooms in until self.stop_zooming() is called.
|
||||
:return: response json
|
||||
"""
|
||||
return self._start_operation('ZoomInc', speed=speed)
|
||||
|
||||
def start_zooming_out(self, speed: float = 60) -> Dict:
|
||||
"""
|
||||
The camera zooms out until self.stop_zooming() is called.
|
||||
:return: response json
|
||||
"""
|
||||
return self._start_operation('ZoomDec', speed=speed)
|
||||
|
||||
def stop_zooming(self) -> Dict:
|
||||
"""
|
||||
Stop zooming.
|
||||
:return: response json
|
||||
"""
|
||||
return self._stop_zooming_or_focusing()
|
||||
|
||||
def start_focusing_in(self, speed: float = 32) -> Dict:
|
||||
"""
|
||||
The camera focuses in until self.stop_focusing() is called.
|
||||
:return: response json
|
||||
"""
|
||||
return self._start_operation('FocusInc', speed=speed)
|
||||
|
||||
def start_focusing_out(self, speed: float = 32) -> Dict:
|
||||
"""
|
||||
The camera focuses out until self.stop_focusing() is called.
|
||||
:return: response json
|
||||
"""
|
||||
return self._start_operation('FocusDec', speed=speed)
|
||||
|
||||
def stop_focusing(self) -> Dict:
|
||||
"""
|
||||
Stop focusing.
|
||||
:return: response json
|
||||
"""
|
||||
return self._stop_zooming_or_focusing()
|
||||
Reference in New Issue
Block a user