85 Commits
Author SHA1 Message Date
Franck Nijhof ca1a12898c Enable Ruff D212 (#87347) 2023-02-03 23:08:48 +01:00
Franck Nijhof 79b52a2b41 Stricter pylint message control (#86154) 2023-01-20 13:47:55 +01:00
Marc Mueller 63d519c1a8 Spelling updates (#82867) 2022-11-28 16:51:43 +01:00
uvjustinandAllen Porter 6bab63fb0a Redact more credentials in stream URL query params (#82089)
Co-authored-by: Allen Porter <allen.porter@gmail.com>
2022-11-15 12:42:40 +08:00
uvjustin ee910bd0e4 Refactor camera stream settings (#81663) 2022-11-13 01:22:59 +08:00
uvjustin 84725f15a6 Use IntEnum for stream orientation (#81835)
* Use IntEnum for stream orientation

* Rename enum values

* Add comments

* Fix import
2022-11-09 07:28:28 -08:00
uvjustin 852b0caf5b Add orientation transforms to stream (#77439) 2022-09-06 13:31:36 +08:00
uvjustin a612d7a0f3 Round up for stream record lookback (#75580) 2022-07-22 11:46:00 +08:00
uvjustin 2f92c47fe3 Apply filter to libav.hls logging namespace (#75330) 2022-07-16 14:07:47 -07:00
uvjustin 75892385bb Fix playback of hls cameras in stream (#75166) 2022-07-14 12:24:24 -07:00
uvjustin 7a3f632c1d Make stream recorder work concurrently (#73478) 2022-06-18 05:13:07 +10:00
uvjustin f276523ef3 Ignore in progress segment when adding stream recorder lookback (#73604) 2022-06-17 11:07:08 +10:00
uvjustin 01a4a83bab Improve stream playback on high latency cameras (#72547)
* Disable LL-HLS for HLS sources
* Add extra wait for Nest cameras
2022-06-17 01:48:52 +10:00
uvjustin 73f2bca377 Make Stream.stop() async (#73107)
* Make Stream.start() async
* Stop streams concurrently on shutdown
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-06-08 00:10:53 +08:00
uvjustin 32b3ce5727 Clean up use_wallclock_as_timestamps in generic (#71940) 2022-05-16 09:06:54 -07:00
uvjustin 221b77297e Declare exports from stream explicitly (#71898) 2022-05-15 17:58:57 +02:00
uvjustinandAllen Porter 617b0d04dc Decouple stream options from PyAV options (#71247)
Co-authored-by: Allen Porter <allen.porter@gmail.com>
2022-05-14 23:31:18 -07:00
Allen Porter 5027e1bcff Mark stream available on idle timeout (#68380)
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
2022-03-19 10:24:32 -07:00
41a032e3e3 Add diagnostics to stream's Stream objects (#68020)
* 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
Marc Mueller ec980a574b Improve typing [util.decorator] (#67087) 2022-02-23 20:58:42 +01:00
uvjustin 4efada7db0 Allow stream log level to change at runtime (#66153) 2022-02-21 17:58:15 +01:00
Allen Porter b016259206 Reset the stream backoff timeout when the url updates (#66426)
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 (#66417)
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 (#66407) 2022-02-12 14:03:26 -08:00
Allen Porter 24418417fd Fix nest streams that get stuck broken (#66334) 2022-02-11 13:17:19 -08:00
Allen Porter e74fe0e390 Enable Low Latency HLS (LL-HLS) by default to lower stream latency (#64643) 2022-01-23 15:38:29 +01:00
uvjustin 08a3140e6c Allow generic camera conf without still_image_url (#62611)
* 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 (#62757)
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
uvjustin 6e13605cad Add get_image method to Stream (#61918)
* 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 (#61647)
* 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
2021-12-19 19:42:37 -08:00
Allen PorterandPaulus Schoutsen 647febd7d8 Mark camera unavailable when keepalive stream fails (#62294)
* 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>
2021-12-19 09:09:59 -08:00
Allen Porter 8ca89b10eb Split StreamState class out of SegmentBuffer (#60423)
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 (#60429) 2021-11-29 21:23:58 -08:00
Allen Porter 5e86c78c46 Redact ?auth= url parameters in stream sources when logged (#60438) 2021-11-29 09:59:01 +01:00
uvjustin f73c734fb6 Add libav.mpegts to logging filter (#58937) 2021-11-02 06:32:02 -07:00
Marc Mueller 1e98761f30 Use assignment expressions 15 (#57961) 2021-10-18 14:01:23 +02:00
uvjustin ce186c5935 Only pass libav logger messages when stream logger is set to debug (#57616) 2021-10-14 23:43:00 +08:00
uvjustin 923158cfba Add ll hls to stream (#49608) 2021-08-29 09:53:41 +08:00
uvjustin b021e2ee8c Move recorder.py import to runtime (#52682) 2021-07-08 09:20:27 +02:00
uvjustinandRuslan Sayfutdinov 97e77ab229 Improve type hints in stream (#51837)
* Improve type hints in stream

* Fix import locations

* Add stream to .strict-typing

Co-authored-by: Ruslan Sayfutdinov <ruslan@sayfutdinov.com>
2021-06-14 23:59:25 +08:00
uvjustin 38e0cbe964 Change stream sequence number to start from 0 (#51101)
* Use constants for provider strings

* Add last_sequence property
2021-05-27 11:22:31 +08:00
Ruslan Sayfutdinov 35f304450c Enable type checks for stream component (#50527)
* Enable type checks for stream component

* Fix pylint
2021-05-13 23:26:11 +02:00
Ruslan Sayfutdinov 8e2b3aab44 Enable strict type checks for camera platform (#50395) 2021-05-10 15:12:15 +02:00
Erik Montnemery b0aa64d59c Replace redacted stream recorder credentials with '****' (#48832) 2021-04-08 12:44:17 -07:00
uvjustinandErik Montnemery cd455e296e Remove login details before logging stream source (#45398)
* Remove login details before logging stream source

* Convert to str before re

* Use compiled RE

* Add tests and filter log message in worker

* Update import

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* isort

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-03-23 07:30:45 +01:00
Marc Mueller 16dcbf1467 Update pylint (#47205) 2021-02-28 22:09:01 -10:00
Allen Porteranduvjustin 97b59023d1 Improve handling for recording start of nest cam stream (#47144)
* Improve handling for start of nest cam stream

Add negative_cts_offsets to segment container options in order to better handle recording at the start of a stream. Nest streams start off with a negative offset, and if the segment container does not support it, then it adjusts the timestamps making it out of order with the next segment as described in issue #46968

* Update homeassistant/components/stream/__init__.py

Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com>

Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com>
2021-02-27 11:20:58 -08:00
uvjustin f005c68630 Restore stream recorder functionality and add discontinuity support (#46772)
* Add discontinuity support to stream recorder

* Use same container options for both StreamOutputs

* Fix pts adjuster

* Remove redundant/incorrect duplicate hls segment check

* Use same StreamBuffer across outputs

* Remove keepalive check for recorder

* Set output video timescale explicitly

* Disable avoid_negative_ts
2021-02-23 10:37:19 +08:00
Allen Porter 4aa4f7e285 Rollback stream StreamOutput refactoring in PR#46610 (#46684)
* Rollback PR#46610

* Update stream tests post-merge
2021-02-20 06:49:39 -08:00
Allen Porteranduvjustin 88d143a644 Add discontinuity support to HLS streams and fix nest expiring stream urls (#46683)
* Support HLS stream discontinuity.

* Clarify discontinuity comments

* Signal a stream discontinuity on restart due to stream error

* Apply suggestions from code review

Co-authored-by: uvjustin <46082645+uvjustin@users.noreply.github.com>

* Simplify stream discontinuity logic
2021-02-18 20:26:02 +08:00