Home Assistant Unofficial Reference 2024.12.1
const.py
Go to the documentation of this file.
1 """Constants for Stream component."""
2 
3 from __future__ import annotations
4 
5 from typing import Final
6 
7 DOMAIN = "stream"
8 
9 ATTR_ENDPOINTS = "endpoints"
10 ATTR_SETTINGS = "settings"
11 ATTR_STREAMS = "streams"
12 
13 HLS_PROVIDER = "hls"
14 RECORDER_PROVIDER = "recorder"
15 
16 OUTPUT_FORMATS = [HLS_PROVIDER]
17 
18 SEGMENT_CONTAINER_FORMAT: Final = "mp4" # format for segments
19 RECORDER_CONTAINER_FORMAT: Final = "mp4" # format for recorder output
20 AUDIO_CODECS = {"aac", "mp3"}
21 
22 FORMAT_CONTENT_TYPE = {HLS_PROVIDER: "application/vnd.apple.mpegurl"}
23 
24 OUTPUT_IDLE_TIMEOUT = 300 # Idle timeout due to inactivity
25 
26 NUM_PLAYLIST_SEGMENTS = 3 # Number of segments to use in HLS playlist
27 MAX_SEGMENTS = 5 # Max number of segments to keep around
28 TARGET_SEGMENT_DURATION_NON_LL_HLS = 2.0 # Each segment is about this many seconds
29 SEGMENT_DURATION_ADJUSTER = 0.1 # Used to avoid missing keyframe boundaries
30 # Number of target durations to start before the end of the playlist.
31 # 1.5 should put us in the middle of the second to last segment even with
32 # variable keyframe intervals.
33 EXT_X_START_NON_LL_HLS = 1.5
34 # Number of part durations to start before the end of the playlist with LL-HLS
35 EXT_X_START_LL_HLS = 2
36 
37 
38 PACKETS_TO_WAIT_FOR_AUDIO = 20 # Some streams have an audio stream with no audio
39 MAX_TIMESTAMP_GAP = 30 # seconds - anything from 10 to 50000 is probably reasonable
40 
41 MAX_MISSING_DTS = 6 # Number of packets missing DTS to allow
42 SOURCE_TIMEOUT = 30 # Timeout for reading stream source
43 
44 STREAM_RESTART_INCREMENT = 10 # Increase wait_timeout by this amount each retry
45 STREAM_RESTART_RESET_TIME = 300 # Reset wait_timeout after this many seconds
46 
47 CONF_LL_HLS = "ll_hls"
48 CONF_PART_DURATION = "part_duration"
49 CONF_SEGMENT_DURATION = "segment_duration"
50 
51 CONF_PREFER_TCP = "prefer_tcp"
52 CONF_RTSP_TRANSPORT = "rtsp_transport"
53 # The first dict entry below may be used as the default when populating options
54 RTSP_TRANSPORTS = {
55  "tcp": "TCP",
56  "udp": "UDP",
57  "udp_multicast": "UDP Multicast",
58  "http": "HTTP",
59 }
60 CONF_USE_WALLCLOCK_AS_TIMESTAMPS = "use_wallclock_as_timestamps"
61 CONF_EXTRA_PART_WAIT_TIME = "extra_part_wait_time"