async def test_stream_ended(hass, stream_worker_sync):
    'Test hls stream packets ended.'
    (await async_setup_component(hass, 'stream', {'stream': {}}))
    stream_worker_sync.pause()
    source = generate_h264_video()
    stream = preload_stream(hass, source)
    track = stream.add_provider('hls')
    request_stream(hass, source)
    while True:
        segment = (await track.recv())
        if (segment is None):
            break
        segments = segment.sequence
        if (segments > 1):
            stream_worker_sync.resume()
    assert (segments > 1)
    assert (not track.get_segment())
    stream.stop()
Test hls stream packets ended.
async def test_stream_ended(hass, stream_worker_sync):
    
    (await async_setup_component(hass, 'stream', {'stream': {}}))
    stream_worker_sync.pause()
    source = generate_h264_video()
    stream = preload_stream(hass, source)
    track = stream.add_provider('hls')
    request_stream(hass, source)
    while True:
        segment = (await track.recv())
        if (segment is None):
            break
        segments = segment.sequence
        if (segments > 1):
            stream_worker_sync.resume()
    assert (segments > 1)
    assert (not track.get_segment())
    stream.stop()