Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.stream Namespace Reference

Namespaces

 const
 
 core
 
 diagnostics
 
 fmp4utils
 
 hls
 
 recorder
 
 worker
 

Classes

class  Stream
 

Functions

bool _should_retry ()
 
bool async_setup (HomeAssistant hass, ConfigType config)
 
Stream create_stream (HomeAssistant hass, str stream_source, Mapping[str, str|bool|float] options, DynamicStreamSettings dynamic_stream_settings, str|None stream_label=None)
 
str redact_credentials (str url)
 
None set_pyav_logging (bool enable)
 

Variables

list __all__
 
 _LOGGER = logging.getLogger(__name__)
 
 CONFIG_SCHEMA
 
 DOMAIN_SCHEMA
 

Detailed Description

Provide functionality to stream video source.

Components use create_stream with a stream source (e.g. an rtsp url) to create
a new Stream object. Stream manages:
  - Background work to fetch and decode a stream
  - Desired output formats
  - Home Assistant URLs for viewing a stream
  - Access tokens for URLs for viewing a stream

A Stream consists of a background worker, and one or more output formats each
with their own idle timeout managed by the stream component. When an output
format is no longer in use, the stream component will expire it. When there
are no active output formats, the background worker is shut down and access
tokens are expired. Alternatively, a Stream can be configured with keepalive
to always keep workers active.

Function Documentation

◆ _should_retry()

bool homeassistant.components.stream._should_retry ( )
private
Return true if worker failures should be retried, for disabling during tests.

Definition at line 576 of file __init__.py.

◆ async_setup()

bool homeassistant.components.stream.async_setup ( HomeAssistant  hass,
ConfigType  config 
)
Set up stream.

Definition at line 201 of file __init__.py.

◆ create_stream()

Stream homeassistant.components.stream.create_stream ( HomeAssistant  hass,
str  stream_source,
Mapping[str, str | bool | float]  options,
DynamicStreamSettings  dynamic_stream_settings,
str | None   stream_label = None 
)
Create a stream with the specified identifier based on the source url.

The stream_source is typically an rtsp url (though any url accepted by ffmpeg is fine) and
options (see STREAM_OPTIONS_SCHEMA) are converted and passed into pyav / ffmpeg.

The stream_label is a string used as an additional message in logging.

Definition at line 111 of file __init__.py.

◆ redact_credentials()

str homeassistant.components.stream.redact_credentials ( str  url)
Redact credentials from string data.

Definition at line 98 of file __init__.py.

◆ set_pyav_logging()

None homeassistant.components.stream.set_pyav_logging ( bool  enable)
Turn PyAV logging on or off.

Definition at line 194 of file __init__.py.

Variable Documentation

◆ __all__

list homeassistant.components.stream.__all__
private
Initial value:
1 = [
2  "ATTR_SETTINGS",
3  "CONF_EXTRA_PART_WAIT_TIME",
4  "CONF_RTSP_TRANSPORT",
5  "CONF_USE_WALLCLOCK_AS_TIMESTAMPS",
6  "DOMAIN",
7  "FORMAT_CONTENT_TYPE",
8  "HLS_PROVIDER",
9  "OUTPUT_FORMATS",
10  "RTSP_TRANSPORTS",
11  "SOURCE_TIMEOUT",
12  "Stream",
13  "create_stream",
14  "Orientation",
15 ]

Definition at line 79 of file __init__.py.

◆ _LOGGER

homeassistant.components.stream._LOGGER = logging.getLogger(__name__)
private

Definition at line 95 of file __init__.py.

◆ CONFIG_SCHEMA

homeassistant.components.stream.CONFIG_SCHEMA
Initial value:
1 = vol.Schema(
2  {
3  DOMAIN: DOMAIN_SCHEMA,
4  },
5  extra=vol.ALLOW_EXTRA,
6 )

Definition at line 186 of file __init__.py.

◆ DOMAIN_SCHEMA

homeassistant.components.stream.DOMAIN_SCHEMA
Initial value:
1 = vol.Schema(
2  {
3  vol.Optional(CONF_LL_HLS, default=True): cv.boolean,
4  vol.Optional(CONF_SEGMENT_DURATION, default=6): vol.All(
5  cv.positive_float, vol.Range(min=2, max=10)
6  ),
7  vol.Optional(CONF_PART_DURATION, default=1): vol.All(
8  cv.positive_float, vol.Range(min=0.2, max=1.5)
9  ),
10  }
11 )

Definition at line 174 of file __init__.py.