mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +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."""
|
"""Support for Ubiquiti's UVC cameras."""
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from uvcclient import camera as uvc_camera, nvr
|
from uvcclient import camera as uvc_camera, nvr
|
||||||
@ -213,7 +214,16 @@ class UnifiVideoCamera(Camera):
|
|||||||
"""Return the source of the stream."""
|
"""Return the source of the stream."""
|
||||||
for channel in self._caminfo["channels"]:
|
for channel in self._caminfo["channels"]:
|
||||||
if channel["isRtspEnabled"]:
|
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
|
return None
|
||||||
|
|
||||||
|
@ -199,7 +199,10 @@ class TestUVC(unittest.TestCase):
|
|||||||
"fps": 25,
|
"fps": 25,
|
||||||
"bitrate": 6000000,
|
"bitrate": 6000000,
|
||||||
"isRtspEnabled": True,
|
"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",
|
"id": "1",
|
||||||
@ -208,7 +211,10 @@ class TestUVC(unittest.TestCase):
|
|||||||
"fps": 15,
|
"fps": 15,
|
||||||
"bitrate": 1200000,
|
"bitrate": 1200000,
|
||||||
"isRtspEnabled": False,
|
"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):
|
def test_stream(self):
|
||||||
"""Test the RTSP stream URI."""
|
"""Test the RTSP stream URI."""
|
||||||
stream_source = yield from self.uvc.stream_source()
|
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.store.get_info_store")
|
||||||
@mock.patch("uvcclient.camera.UVCCameraClientV320")
|
@mock.patch("uvcclient.camera.UVCCameraClientV320")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user