Commit graph

163 commits

Author SHA1 Message Date
uvjustin
06c80e454b
Use av instead of ha-av () 2022-04-27 16:08:05 +02:00
uvjustin
9281f46bcd
Skip invalid segments in stream recorder ()
* Skip segment if duration is None

* Copy segments deque before passing to thread
2022-04-27 15:36:09 +02:00
uvjustin
44e9146463
Use ha-av instead of av and bump to v9.1.1-3 () 2022-04-14 13:36:25 +10:00
J. Nick Koston
32a10648a5
Downgrade av to 8.1.0 to fix memory leak () 2022-04-10 22:58:30 -07:00
Allen Porter
5027e1bcff
Mark stream available on idle timeout ()
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 
2022-03-19 10:24:32 -07:00
Allen Porter
41a032e3e3
Add diagnostics to stream's Stream objects ()
* 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>
2022-03-18 07:40:09 -07:00
uvjustin
accc4fda28
Bump PyAV to v9.0.0 () 2022-03-08 07:53:17 -08:00
Franck Nijhof
63957787c4
Update PyTurboJPEG to 1.6.6 () 2022-03-07 23:26:30 +01:00
Marc Mueller
ec980a574b
Improve typing [util.decorator] () 2022-02-23 20:58:42 +01:00
uvjustin
4efada7db0
Allow stream log level to change at runtime () 2022-02-21 17:58:15 +01:00
Allen Porter
b016259206
Reset the stream backoff timeout when the url updates ()
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.
2022-02-13 07:09:37 -08:00
Allen Porter
0a128d006f
Improve stream robustness by always retrying worker ()
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.
2022-02-12 20:59:11 -08:00
Allen Porter
2e54daa61f
Redact stream url credentials in debug logging () 2022-02-12 14:03:26 -08:00
Allen Porter
24418417fd
Fix nest streams that get stuck broken () 2022-02-11 13:17:19 -08:00
J. Nick Koston
5b755b74fb
Add loggers to integration manifest.json () 2022-01-28 13:37:53 -08:00
Allen Porter
e74fe0e390
Enable Low Latency HLS (LL-HLS) by default to lower stream latency () 2022-01-23 15:38:29 +01:00
Franck Nijhof
c339233421
Update PyTurboJPEG to 1.6.5 () 2022-01-10 13:28:04 +01:00
Franck Nijhof
31f37f3363
Update PyTurboJPEG to 1.6.4 () 2022-01-06 08:56:39 -08:00
Marc Mueller
04e1933728
Use correct relative imports [n-z] () 2022-01-05 17:23:49 +01:00
uvjustin
849dc0e53a
Use original PyAv in stream () 2021-12-30 10:54:25 -08:00
Allen Porter
23384ee1e8
Update stream errors with additional error information () 2021-12-29 18:57:14 +01:00
uvjustin
08a3140e6c
Allow generic camera conf without still_image_url ()
* Allow generic config with no CONF_STILL_IMAGE_URL
* Use Stream.async_get_image when no CONF_STILL_IMAGE_URL
* Remove GenericCamera.camera_image
2021-12-26 15:53:14 +08:00
uvjustin
9dbba6b7f2
Use lock in Camera.create_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
2021-12-25 04:14:43 +08:00
Erik Montnemery
cb2c2d98c3
Remove unnecessary checks before calling os.makedirs () 2021-12-23 09:59:31 +01:00
uvjustin
6e13605cad
Add get_image method to Stream ()
* Add get_image method to Stream

* Add KeyFrameConverter class
2021-12-23 00:24:53 +08:00
Allen Porter
6ae7b928ea
Add a camera specific logger to help diagnose stream errors ()
* 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 

* Apply code review feedback

* Update package name based on manual testing
2021-12-19 19:42:37 -08:00
Allen Porter
647febd7d8
Mark camera unavailable when keepalive stream fails ()
* 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 

* 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>
2021-12-19 09:09:59 -08:00
Allen Porter
8ca89b10eb
Split StreamState class out of SegmentBuffer ()
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.
2021-11-29 22:25:28 -08:00
Allen Porter
df90fdf641
Add an available property on Stream () 2021-11-29 21:23:58 -08:00
Allen Porter
5e86c78c46
Redact ?auth= url parameters in stream sources when logged () 2021-11-29 09:59:01 +01:00
uvjustin
9ea338c121
Remove incomplete segment on stream restart () 2021-11-12 00:59:13 +08:00
uvjustin
3693b9bd04
Adjust frag_duration setting in stream () 2021-11-05 18:54:51 -07:00
uvjustin
f73c734fb6
Add libav.mpegts to logging filter () 2021-11-02 06:32:02 -07:00
uvjustin
9aaa92f366
Improve part metadata in stream () 2021-10-31 20:23:01 -07:00
uvjustin
35acca1063
Use PyAV fork and set hvc1 codec tag for H.265 () 2021-10-27 11:04:46 +02:00
uvjustin
7024a5d7d9
Minor cleanup on stream ()
* Allow for rounding errors in playlist validation

* Allow EXT-X-TARGETDURATION to change

* Reuse original source in test_record_stream_audio
2021-10-26 13:11:33 -07:00
uvjustin
06008bc343
Fix EXT-X-PROGRAM-DATE-TIME in stream ()
* 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
2021-10-25 11:33:41 +08:00
Ville Skyttä
50e0c58310
Use http.HTTPStatus in components/s* () 2021-10-23 20:49:04 +02:00
Marc Mueller
1e98761f30
Use assignment expressions 15 () 2021-10-18 14:01:23 +02:00
Robert Hillis
488a636aec
Clean up unused loggers () 2021-10-14 10:03:38 -07:00
uvjustin
ce186c5935
Only pass libav logger messages when stream logger is set to debug () 2021-10-14 23:43:00 +08:00
Marc Mueller
d51487f82a
Import Callable from collections.abc (3) () 2021-09-29 16:19:06 +02:00
Marc Mueller
48bada5a18
Update pylint to 2.11.1 () 2021-09-18 13:52:59 +02:00
uvjustin
071fcee9a9
Remove byte-range addressed parts in stream ()
Add individually addressed parts
2021-08-30 13:20:19 +08:00
uvjustin
923158cfba
Add ll hls to stream () 2021-08-29 09:53:41 +08:00
Allen Porter
094f7d38ad
Use buffer at stream start with unsupported audio ()
Add a test that reproduces the issue where resetting the iterator
drops the already read packets. Fix a bug in replace_underlying_iterator
because checking the self._next function turns out not to work since
it points to a bound method so the "is not" check fails.
2021-08-15 21:02:37 -07:00
uvjustin
7a200a5d3b
Fix non monotonic dts error in stream ()
* Use defaultdict for TimestampValidator._last_dts

* Combine filters

* Allow PeekIterator to be updated while preserving buffer

* Fix peek edge case

* Readd is_valid filter to video only iterator
2021-07-30 08:02:33 -07:00
Allen Porter
b3b5ee10b1
Fix mypy type for timestamp validator () 2021-07-27 22:04:59 -07:00
Allen Porter
022ba31999
Refactor the logic for peeking into the start of the stream ()
* Reset dts validator when container is reset

* Reuse existing dts_validator when disabling audio stream

* Refactor peek logic at the start of a stream

Add a PeekingIterator to support rewinding an iterator so that the code
for adjusting audio streams and start pts can be inlined in the worker.

* Simplification and readability improvements

* Remove unnecessary verbiage from comments and pydoc

* Address pylint errors

* Remove rewind function and just mux the first packet separately

* More cleanup after removing rewind()

* Skip check to self._buffer on every iteration
2021-07-27 08:53:42 -07:00
Marc Mueller
b5cec353cc
Fix pylint issue with stream component c-extension ()
* Rename 'extension-pkg-whitelist' setting to 'extension-pkg-allow-list'
* Add 'av.stream' and 'av.audio.stream'
* Replace 'Any' type hint
2021-07-10 22:58:37 +02:00