Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for fetching the rtsp url without srtp #261

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

_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 @@
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