mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Separate HLS logic out of core StreamOutput to prepare for discontinuity (#46610)
Separate the HLS stream view logic out of StreamOutput since the hls stream view is about to get more complex to track discontinuities. This makes the idle timeout, shutdown, and coupling between hls and record more explicit.
This commit is contained in:
@@ -31,7 +31,6 @@ from homeassistant.components.stream.worker import stream_worker
|
||||
|
||||
STREAM_SOURCE = "some-stream-source"
|
||||
# Formats here are arbitrary, not exercised by tests
|
||||
STREAM_OUTPUT_FORMAT = "hls"
|
||||
AUDIO_STREAM_FORMAT = "mp3"
|
||||
VIDEO_STREAM_FORMAT = "h264"
|
||||
VIDEO_FRAME_RATE = 12
|
||||
@@ -188,7 +187,7 @@ class MockPyAv:
|
||||
async def async_decode_stream(hass, packets, py_av=None):
|
||||
"""Start a stream worker that decodes incoming stream packets into output segments."""
|
||||
stream = Stream(hass, STREAM_SOURCE)
|
||||
stream.add_provider(STREAM_OUTPUT_FORMAT)
|
||||
stream.hls_output()
|
||||
|
||||
if not py_av:
|
||||
py_av = MockPyAv()
|
||||
@@ -207,7 +206,7 @@ async def async_decode_stream(hass, packets, py_av=None):
|
||||
async def test_stream_open_fails(hass):
|
||||
"""Test failure on stream open."""
|
||||
stream = Stream(hass, STREAM_SOURCE)
|
||||
stream.add_provider(STREAM_OUTPUT_FORMAT)
|
||||
stream.hls_output()
|
||||
with patch("av.open") as av_open:
|
||||
av_open.side_effect = av.error.InvalidDataError(-2, "error")
|
||||
stream_worker(STREAM_SOURCE, {}, stream.outputs, threading.Event())
|
||||
@@ -483,7 +482,7 @@ async def test_stream_stopped_while_decoding(hass):
|
||||
worker_wake = threading.Event()
|
||||
|
||||
stream = Stream(hass, STREAM_SOURCE)
|
||||
stream.add_provider(STREAM_OUTPUT_FORMAT)
|
||||
stream.hls_output()
|
||||
|
||||
py_av = MockPyAv()
|
||||
py_av.container.packets = PacketSequence(TEST_SEQUENCE_LENGTH)
|
||||
@@ -510,7 +509,7 @@ async def test_update_stream_source(hass):
|
||||
worker_wake = threading.Event()
|
||||
|
||||
stream = Stream(hass, STREAM_SOURCE)
|
||||
stream.add_provider(STREAM_OUTPUT_FORMAT)
|
||||
stream.hls_output()
|
||||
# Note that keepalive is not set here. The stream is "restarted" even though
|
||||
# it is not stopping due to failure.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user