Skip to content

Commit

Permalink
feat: add support for fetching the rtsp url without srtp
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Nov 4, 2024
1 parent cd46006 commit 3da3f8f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/uiprotect/data/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ class CameraChannel(ProtectBaseObject):

_rtsp_url: str | None = PrivateAttr(None)
_rtsps_url: str | None = PrivateAttr(None)
_rtsps_no_srtp_url: str | None = PrivateAttr(None)

@property
def rtsp_url(self) -> str | None:
Expand All @@ -294,6 +295,16 @@ def rtsps_url(self) -> str | None:
self._rtsps_url = f"rtsps://{self._api.connection_host}:{self._api.bootstrap.nvr.ports.rtsps}/{self.rtsp_alias}?enableSrtp"
return self._rtsps_url

@property
def rtsps_no_srtp_url(self) -> str | None:
if not self.is_rtsp_enabled or self.rtsp_alias is None:
return None

Check warning on line 301 in src/uiprotect/data/devices.py

View check run for this annotation

Codecov / codecov/patch

src/uiprotect/data/devices.py#L301

Added line #L301 was not covered by tests

if self._rtsps_no_srtp_url is not None:
return self._rtsps_no_srtp_url
self._rtsps_no_srtp_url = f"rtsps://{self._api.connection_host}:{self._api.bootstrap.nvr.ports.rtsps}/{self.rtsp_alias}"
return self._rtsps_no_srtp_url

@property
def is_package(self) -> bool:
return self.fps <= 2
Expand Down
21 changes: 13 additions & 8 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@ async def check_camera(camera: Camera):

for channel in camera.channels:
if channel.is_rtsp_enabled:
assert (
channel.rtsp_url
== f"rtsp://{camera.api.connection_host}:7447/{channel.rtsp_alias}"
)
assert (
channel.rtsps_url
== f"rtsps://{camera.api.connection_host}:7441/{channel.rtsp_alias}?enableSrtp"
)
for _ in range(2):
assert (
channel.rtsp_url
== f"rtsp://{camera.api.connection_host}:7447/{channel.rtsp_alias}"
)
assert (
channel.rtsps_url
== f"rtsps://{camera.api.connection_host}:7441/{channel.rtsp_alias}?enableSrtp"
)
assert (
channel.rtsps_no_srtp_url
== f"rtsps://{camera.api.connection_host}:7441/{channel.rtsp_alias}"
)

if VideoMode.HIGH_FPS in camera.feature_flags.video_modes:
assert camera.feature_flags.has_highfps
Expand Down

0 comments on commit 3da3f8f

Please sign in to comment.