Commit Graph

102 Commits

Author SHA1 Message Date
uvjustin
d40a08958d Use dataclasses instead of attrs in stream (#101148) 2023-09-30 09:46:30 +02:00
Raman Gupta
067b94899f Move EVENT_LOGGING_CHANGED to constants (#100974)
* Move EVENT_LOGGING_CHANGED to constants

* fix test

* remove logger as dependency for bluetooth and fix test
2023-09-27 01:06:14 -04:00
uvjustin
5021c69886 Update Stream logging on EVENT_LOGGING_CHANGED (#99256) 2023-09-12 19:38:11 +02:00
uvjustin
407aa31adc Generate Stream snapshots using next keyframe (#96991)
* Add wait_for_next_keyframe option to stream images
Add STREAM_SNAPSHOT to CameraEntityFeature
Use wait_for_next_keyframe option for snapshots using stream

* Update stream test comments

* Add generic camera snapshot test

* Get stream still images directly in camera
Remove getting stream images from generic, nest, and ONVIF
Refactor camera preferences
Add use_stream_for_stills setting to camera
Update tests

* Only attempt to get stream image if integration supports stream

* Use property instead of entity registry setting

* Split out getting stream prerequisites from stream_source in nest

* Use cached_property for rtsp live stream trait

* Make rtsp live stream trait NestCamera attribute

* Update homeassistant/components/nest/camera.py

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* Change usage of async_timeout

* Change import formatting in generic/test_camera

* Simplify Nest camera property initialization

---------

Co-authored-by: Allen Porter <allen.porter@gmail.com>
2023-08-26 10:39:40 -07:00
Marc Mueller
089f76099d Fix stream test aiohttp DeprecationWarning (#98962) 2023-08-24 19:50:25 +02:00
Ville Skyttä
9da192c752 Avoid use of datetime.utc* methods deprecated in Python 3.12 (#93684)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2023-08-24 16:38:22 +02:00
uvjustin
3e58e1987c Avoid infinite loop on corrupt stream recording (#96881)
* Avoid infinite loop on corrupt stream recording

* Update tests
2023-07-19 09:06:04 +02:00
epenet
e277bbb513 Use tmp_path in tests (#91203)
* Use tmp_path in tests

* Use joinpath

* Prefer / operator

* Cleanup
2023-04-12 08:19:01 +02:00
epenet
dab8557951 Add type hints to integration tests (part 21) (#88233) 2023-02-16 11:15:26 +01:00
Franck Nijhof
ed79265843 Enable Ruff PT006 (#88165)
* Enable Ruff PT006

* Adjust existing cases

* Fix tests

* Remove unneeded parentheses
2023-02-15 14:09:50 +01:00
epenet
ba85fdcd61 Add type hints to integration tests (q-s) (#87706) 2023-02-08 08:12:54 -08:00
Franck Nijhof
ca1a12898c Enable Ruff D212 (#87347) 2023-02-03 23:08:48 +01:00
Franck Nijhof
62dcbe5258 Enable Ruff PT001 (#86730) 2023-01-26 18:05:05 +01:00
uvjustin
d0153f5031 Detect timestamp discontinuity in stream (#86430)
fixes undefined
2023-01-23 10:09:46 +01:00
uvjustin
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
eb141a532c Bump ha-av to v10.0.0 (#80514) 2022-10-20 00:06:49 +03:00
uvjustin
d38d21ab3a Fix stream recorder with orientation transforms (#80370)
Find moov instead of using fixed location
2022-10-17 21:12:45 -04:00
epenet
e9f55f4e54 Apply hass-relative-import to tests (s-z) (#78733) 2022-09-19 09:51:31 +02:00
uvjustin
852b0caf5b Add orientation transforms to stream (#77439) 2022-09-06 13:31:36 +08:00
uvjustin
75892385bb Fix playback of hls cameras in stream (#75166) 2022-07-14 12:24:24 -07:00
Franck Nijhof
af2feb3d40 Update pyupgrade to v2.37.1 (#74989) 2022-07-11 16:54:01 +02:00
Franck Nijhof
68ccb96089 Refactor CI (#74014) 2022-07-07 18:53:24 +02:00
uvjustin
f45afe7379 Use bitstream filter to allow ADTS AAC audio in stream (#74151) 2022-06-29 10:15:22 +02:00
uvjustin
7a3f632c1d Make stream recorder work concurrently (#73478) 2022-06-18 05:13:07 +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
c2612d1ade Remove cache control headers from stream (#71996) 2022-05-23 13:56:26 +08:00
Allen Porter
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
uvjustin
4efada7db0 Allow stream log level to change at runtime (#66153) 2022-02-21 17:58:15 +01: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
e74fe0e390 Enable Low Latency HLS (LL-HLS) by default to lower stream latency (#64643) 2022-01-23 15:38:29 +01:00
Simone Chemelli
969930b9c9 Remove debug print (#63460) 2022-01-05 15:34:33 +01:00
Allen Porter
23384ee1e8 Update stream errors with additional error information (#62900) 2021-12-29 18:57:14 +01: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 Porter
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
832184bacd Speed up stream tests by 40-50% with shared data (#62300) 2021-12-18 23:14:21 -08:00
J. Nick Koston
a0cd29bbcf Fix threading error in stream tests (#62221) 2021-12-17 09:26:30 -08:00
Allen Porter
200a5c7e05 Fix flaky tests with unsynchronized stream available assertions (#61167)
Remove assertions that are not guaratuneed to be safe depending
on the state of the background worker. This leaves in the state
check for the keepalive case which does have some synchronization
already.
2021-12-07 07:40:36 -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
uvjustin
9ea338c121 Remove incomplete segment on stream restart (#59532) 2021-11-12 00:59:13 +08:00
J. Nick Koston
10d6247fee Bump to aiohttp 3.8.0 (#58974) 2021-11-04 10:07:50 -05:00
uvjustin
9aaa92f366 Improve part metadata in stream (#58822) 2021-10-31 20:23:01 -07:00
uvjustin
35acca1063 Use PyAV fork and set hvc1 codec tag for H.265 (#58309) 2021-10-27 11:04:46 +02:00
uvjustin
7024a5d7d9 Minor cleanup on stream (#58486)
* 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 (#58036)
* 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* (#58291) 2021-10-23 20:49:04 +02:00