Allow playback of h265 encoded Reolink video (#138667)
This commit is contained in:
parent
800cdee409
commit
f5e1fa6a21
|
@ -222,7 +222,7 @@ class ReolinkVODMediaSource(MediaSource):
|
|||
if main_enc == "h265":
|
||||
_LOGGER.debug(
|
||||
"Reolink camera %s uses h265 encoding for main stream,"
|
||||
"playback only possible using sub stream",
|
||||
"playback at high resolution may not work in all browsers/apps",
|
||||
host.api.camera_name(channel),
|
||||
)
|
||||
|
||||
|
@ -236,34 +236,29 @@ class ReolinkVODMediaSource(MediaSource):
|
|||
can_play=False,
|
||||
can_expand=True,
|
||||
),
|
||||
BrowseMediaSource(
|
||||
domain=DOMAIN,
|
||||
identifier=f"RES|{config_entry_id}|{channel}|main",
|
||||
media_class=MediaClass.CHANNEL,
|
||||
media_content_type=MediaType.PLAYLIST,
|
||||
title="High resolution",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
),
|
||||
]
|
||||
if main_enc != "h265":
|
||||
children.append(
|
||||
BrowseMediaSource(
|
||||
domain=DOMAIN,
|
||||
identifier=f"RES|{config_entry_id}|{channel}|main",
|
||||
media_class=MediaClass.CHANNEL,
|
||||
media_content_type=MediaType.PLAYLIST,
|
||||
title="High resolution",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
),
|
||||
)
|
||||
|
||||
if host.api.supported(channel, "autotrack_stream"):
|
||||
children.append(
|
||||
BrowseMediaSource(
|
||||
domain=DOMAIN,
|
||||
identifier=f"RES|{config_entry_id}|{channel}|autotrack_sub",
|
||||
media_class=MediaClass.CHANNEL,
|
||||
media_content_type=MediaType.PLAYLIST,
|
||||
title="Autotrack low resolution",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
),
|
||||
)
|
||||
if main_enc != "h265":
|
||||
children.append(
|
||||
children.extend(
|
||||
[
|
||||
BrowseMediaSource(
|
||||
domain=DOMAIN,
|
||||
identifier=f"RES|{config_entry_id}|{channel}|autotrack_sub",
|
||||
media_class=MediaClass.CHANNEL,
|
||||
media_content_type=MediaType.PLAYLIST,
|
||||
title="Autotrack low resolution",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
),
|
||||
BrowseMediaSource(
|
||||
domain=DOMAIN,
|
||||
identifier=f"RES|{config_entry_id}|{channel}|autotrack_main",
|
||||
|
@ -273,11 +268,7 @@ class ReolinkVODMediaSource(MediaSource):
|
|||
can_play=False,
|
||||
can_expand=True,
|
||||
),
|
||||
)
|
||||
|
||||
if len(children) == 1:
|
||||
return await self._async_generate_camera_days(
|
||||
config_entry_id, channel, "sub"
|
||||
]
|
||||
)
|
||||
|
||||
title = host.api.camera_name(channel)
|
||||
|
|
|
@ -235,12 +235,12 @@ async def test_browsing(
|
|||
reolink_connect.model = TEST_HOST_MODEL
|
||||
|
||||
|
||||
async def test_browsing_unsupported_encoding(
|
||||
async def test_browsing_h265_encoding(
|
||||
hass: HomeAssistant,
|
||||
reolink_connect: MagicMock,
|
||||
config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test browsing a Reolink camera with unsupported stream encoding."""
|
||||
"""Test browsing a Reolink camera with h265 stream encoding."""
|
||||
entry_id = config_entry.entry_id
|
||||
|
||||
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]):
|
||||
|
@ -249,7 +249,6 @@ async def test_browsing_unsupported_encoding(
|
|||
|
||||
browse_root_id = f"CAM|{entry_id}|{TEST_CHANNEL}"
|
||||
|
||||
# browse resolution select/camera recording days when main encoding unsupported
|
||||
mock_status = MagicMock()
|
||||
mock_status.year = TEST_YEAR
|
||||
mock_status.month = TEST_MONTH
|
||||
|
@ -261,6 +260,18 @@ async def test_browsing_unsupported_encoding(
|
|||
|
||||
browse = await async_browse_media(hass, f"{URI_SCHEME}{DOMAIN}/{browse_root_id}")
|
||||
|
||||
browse_resolution_id = f"RESs|{entry_id}|{TEST_CHANNEL}"
|
||||
browse_res_sub_id = f"RES|{entry_id}|{TEST_CHANNEL}|sub"
|
||||
browse_res_main_id = f"RES|{entry_id}|{TEST_CHANNEL}|main"
|
||||
|
||||
assert browse.domain == DOMAIN
|
||||
assert browse.title == f"{TEST_NVR_NAME}"
|
||||
assert browse.identifier == browse_resolution_id
|
||||
assert browse.children[0].identifier == browse_res_sub_id
|
||||
assert browse.children[1].identifier == browse_res_main_id
|
||||
|
||||
browse = await async_browse_media(hass, f"{URI_SCHEME}{DOMAIN}/{browse_res_sub_id}")
|
||||
|
||||
browse_days_id = f"DAYS|{entry_id}|{TEST_CHANNEL}|sub"
|
||||
browse_day_0_id = (
|
||||
f"DAY|{entry_id}|{TEST_CHANNEL}|sub|{TEST_YEAR}|{TEST_MONTH}|{TEST_DAY}"
|
||||
|
|
Loading…
Reference in New Issue