Mark stream as available on idle timeout so that the frontend can
still interact with it. In particular, the Frontend won't interact
with camera objects that are not available e.g. from picture glance
card.
Issue #67922
* Add diagnostics to stream's Stream objects
Add diagnostics key/value pair to the Stream object. Diagnostics support
in camera integration will be added in a follow up and will access the
diagnostics on the Stream object, similar to the examples in the unit
test.
* Rename to audio/video codec
* Fix test codec names
* Update tests/components/stream/test_worker.py
Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com>
Reset the stream backoff timeout when the url updates, meant to improve the retry behavior
for nest cameras. The problem is the nest url updates faster than the stream reset time
so the wait timeout never resets if there is a temporarily problem with the new url. In particular
this *may* help with the flaky cloud nest urls, but seems more correct otherwise.
Improve stream robustness by always retrying in the worker on failure, rather than only when
keepalive is enabled.
This will make cloud cameras like nest more robust, since they have a tendency to be flaky. This
is also needed to improve client side retry behavior because when the client attempts to retry,
the stream token is already revoked because the worker stopped.
The worker will still idle timeout if no streams are present, so it won't go on forever if no
frontend is viewing the stream.
Rename create_stream to async_create_stream in Camera
Rename get_image to async_get_image in Stream
Rename get_image to async_get_image in KeyFrameConverter
* Add a camera specific logger to help diagnose stream errors
Add a camera specific logger to help users associate stream errors with a particular camera.
Issue #54659
* Apply code review feedback
* Update package name based on manual testing
* Mark camera unavailable when keepalive stream fails
Add a listener in stream that notifies camera when the stream state has changed, and
use that to inform the camera `available` property. Update the property to be set
only from the main loop where it is read to reduce thread safety races.
Issue #54659
* Fix pylint import related errors
* Address lint naming errors
* Apply suggestions from code review
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This refactoring was pulled out of https://github.com/home-assistant/core/pull/53676 as an
initial step towards reverting the addition of the SegmentBuffer class, which will be
unrolled back into a for loop.
The StreamState class holds the persistent state in stream that is used across stream worker
instantiations, e.g. state across a retry or url expiration, which primarily handles
discontinuities. By itself, this PR is not a large win until follow up PRs further simplify
the SegmentBuffer class.
* Fix EXT-X-PROGRAM-DATE-TIME in stream
* Update fragment duration comments in worker
* Update duration test in worker
* Augment test on low latency playlists
* Reset start_time on discontinuity