Commit Graph

146 Commits (b78e22e01240a843b9df638794111ffd21730316)

Author SHA1 Message Date
Franck Nijhof 31f37f3363
Update PyTurboJPEG to 1.6.4 (#63553) 2022-01-06 08:56:39 -08:00
Marc Mueller 04e1933728
Use correct relative imports [n-z] (#63471) 2022-01-05 17:23:49 +01:00
uvjustin 849dc0e53a
Use original PyAv in stream (#63079) 2021-12-30 10:54:25 -08:00
Allen Porter 23384ee1e8
Update stream errors with additional error information (#62900) 2021-12-29 18:57:14 +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
Erik Montnemery cb2c2d98c3
Remove unnecessary checks before calling os.makedirs (#62576) 2021-12-23 09:59:31 +01: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 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 9ea338c121
Remove incomplete segment on stream restart (#59532) 2021-11-12 00:59:13 +08:00
uvjustin 3693b9bd04
Adjust frag_duration setting in stream (#59135) 2021-11-05 18:54:51 -07:00
uvjustin f73c734fb6
Add libav.mpegts to logging filter (#58937) 2021-11-02 06:32:02 -07: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
Marc Mueller 1e98761f30
Use assignment expressions 15 (#57961) 2021-10-18 14:01:23 +02:00
Robert Hillis 488a636aec
Clean up unused loggers (#57662) 2021-10-14 10:03:38 -07:00
uvjustin ce186c5935
Only pass libav logger messages when stream logger is set to debug (#57616) 2021-10-14 23:43:00 +08:00
Marc Mueller d51487f82a
Import Callable from collections.abc (3) (#56777) 2021-09-29 16:19:06 +02:00
Marc Mueller 48bada5a18
Update pylint to 2.11.1 (#56364) 2021-09-18 13:52:59 +02:00
uvjustin 071fcee9a9
Remove byte-range addressed parts in stream (#55396)
Add individually addressed parts
2021-08-30 13:20:19 +08:00
uvjustin 923158cfba
Add ll hls to stream (#49608) 2021-08-29 09:53:41 +08:00
Allen Porter 094f7d38ad
Use buffer at stream start with unsupported audio (#54672)
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 (#53712)
* 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 (#53598) 2021-07-27 22:04:59 -07:00
Allen Porter 022ba31999
Refactor the logic for peeking into the start of the stream (#52699)
* 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 (#52847)
* 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
uvjustin b021e2ee8c
Move recorder.py import to runtime (#52682) 2021-07-08 09:20:27 +02:00
Allen Porter e895b6cd42
Refactor decompression timestamp validation logic in stream component (#52462)
* Refactor dts validation logic into a separate function

Create a decompression timestamp validation function to move the logic out of
the worker into a separate class. This also uses the python itertools.chain
to chain together the initial packets with the remaining packets in the
container iterator, removing additional inline if statements.

* Reset dts validator when container is reset

* Fix typo in a comment

* Reuse existing dts_validator when disabling audio stream
2021-07-07 15:29:15 -07:00
uvjustin e8b5790846
Clean up stream refactor (#51951)
* Clean up target_duration method

* Consolidate Part creation in one place

* Use BytesIO.read instead of memoryview access

* Change flush() signature
2021-06-20 13:38:02 +08:00
uvjustin 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 123e8f01a1
Refactor stream to create partial segments (#51282) 2021-06-14 00:41:21 +08:00
uvjustin 55f158cf78
Fix HLS idle timer in stream (#51372) 2021-06-02 21:31:39 -07:00
uvjustin 3ca7eb9440
Update HLS playlist in stream (#51191)
* Enable gzip encoding for playlist responses
* Add EXT-X-PROGRAM-DATE-TIME to playlist
* Add EXT-X-START to playlist
* Change EXT-X-VERSION from 7 to 6
* Move idle timer call to recv
* Refactor recv to remove cursor and return bool
* Rename STREAM_TIMEOUT to SOURCE_TIMEOUT
2021-05-30 11:41:23 +08:00
uvjustin 6ad29aec2c
Adjust segment duration calculation in stream (#51149)
* Calculate min segment duration internally

* Rename segments to sequences in StreamOutput

* Fix segment duration calculation in test_worker
2021-05-28 13:36:41 +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
uvjustin c6f108f7c3
Refactor stream to use bytes (#51066)
* Refactor stream to use bytes
2021-05-26 16:19:09 +08:00
uvjustin 2eb87b8806
Combine StreamBuffer into SegmentBuffer in stream (#51041)
* Combine StreamBuffer into SegmentBuffer in stream

* Use new style type hint in comment
Remove unused member self._segment

* Change reset_av to static helper function

* Change make_new_av to only return OutputContainer
2021-05-24 22:57:07 -07:00
Maciej Bieniek f212049fc2
Add constructor return type in integrations O-S (#50896) 2021-05-20 15:58:17 +02: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
J. Nick Koston 3fa8ffa731
Enable mccabe complexity checks in flake8 (#49616)
Co-authored-by: Franck Nijhof <git@frenck.dev>
2021-04-25 12:38:40 +02:00
Marc Mueller c07646db5d
Update typing syntax (#49480)
* Update typing syntax

* Replace typing imports with ones from collections where possible

* Changes after review
2021-04-20 17:40:41 +02:00
Paulus Schoutsen 6604614c39
Move top-level av import behind type checking flag (#49281)
* Move top-level av import behind type checking flag

* Lint
2021-04-15 18:18:25 -07:00