mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Compare uvc rtsp stream uri to host config (#31107)
This commit is contained in:
parent
751529feca
commit
dd22200a69
@ -1,5 +1,6 @@
|
||||
"""Support for Ubiquiti's UVC cameras."""
|
||||
import logging
|
||||
import re
|
||||
|
||||
import requests
|
||||
from uvcclient import camera as uvc_camera, nvr
|
||||
@ -213,7 +214,16 @@ class UnifiVideoCamera(Camera):
|
||||
"""Return the source of the stream."""
|
||||
for channel in self._caminfo["channels"]:
|
||||
if channel["isRtspEnabled"]:
|
||||
return channel["rtspUris"][0]
|
||||
uri = next(
|
||||
(
|
||||
uri
|
||||
for i, uri in enumerate(channel["rtspUris"])
|
||||
# pylint: disable=protected-access
|
||||
if re.search(self._nvr._host, uri)
|
||||
# pylint: enable=protected-access
|
||||
)
|
||||
)
|
||||
return uri
|
||||
|
||||
return None
|
||||
|
||||
|
@ -199,7 +199,10 @@ class TestUVC(unittest.TestCase):
|
||||
"fps": 25,
|
||||
"bitrate": 6000000,
|
||||
"isRtspEnabled": True,
|
||||
"rtspUris": ["rtsp://host-a:7447/uuid_rtspchannel_0"],
|
||||
"rtspUris": [
|
||||
"rtsp://host-a:7447/uuid_rtspchannel_0",
|
||||
"rtsp://foo:7447/uuid_rtspchannel_0",
|
||||
],
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
@ -208,7 +211,10 @@ class TestUVC(unittest.TestCase):
|
||||
"fps": 15,
|
||||
"bitrate": 1200000,
|
||||
"isRtspEnabled": False,
|
||||
"rtspUris": ["rtsp://host-a:7447/uuid_rtspchannel_1"],
|
||||
"rtspUris": [
|
||||
"rtsp://host-a:7447/uuid_rtspchannel_1",
|
||||
"rtsp://foo:7447/uuid_rtspchannel_1",
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
@ -226,7 +232,7 @@ class TestUVC(unittest.TestCase):
|
||||
def test_stream(self):
|
||||
"""Test the RTSP stream URI."""
|
||||
stream_source = yield from self.uvc.stream_source()
|
||||
assert stream_source == "rtsp://host-a:7447/uuid_rtspchannel_0"
|
||||
assert stream_source == "rtsp://foo:7447/uuid_rtspchannel_0"
|
||||
|
||||
@mock.patch("uvcclient.store.get_info_store")
|
||||
@mock.patch("uvcclient.camera.UVCCameraClientV320")
|
||||
|
Loading…
x
Reference in New Issue
Block a user