Replace Camera STREAM_ constants with StreamType enum (#69871)

This commit is contained in:
Franck Nijhof 2022-04-12 01:27:27 +02:00 committed by GitHub
parent 75fce1f036
commit c93c7e8eff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 36 deletions

View file

@ -1,6 +1,8 @@
"""Constants for Camera component."""
from typing import Final
from homeassistant.backports.enum import StrEnum
DOMAIN: Final = "camera"
DATA_CAMERA_PREFS: Final = "camera_prefs"
@ -16,11 +18,23 @@ CONF_DURATION: Final = "duration"
CAMERA_STREAM_SOURCE_TIMEOUT: Final = 10
CAMERA_IMAGE_TIMEOUT: Final = 10
# A camera that supports CAMERA_SUPPORT_STREAM may have a single stream
# type which is used to inform the frontend which player to use.
# Streams with RTSP sources typically use the stream component which uses
# HLS for display. WebRTC streams use the home assistant core for a signal
# path to initiate a stream, but the stream itself is between the client and
# device.
class StreamType(StrEnum):
"""Camera stream type.
A camera that supports CAMERA_SUPPORT_STREAM may have a single stream
type which is used to inform the frontend which player to use.
Streams with RTSP sources typically use the stream component which uses
HLS for display. WebRTC streams use the home assistant core for a signal
path to initiate a stream, but the stream itself is between the client and
device.
"""
HLS = "hls"
WEB_RTC = "web_rtc"
# These constants are deprecated as of Home Assistant 2022.5
# Please use the StreamType enum instead.
STREAM_TYPE_HLS = "hls"
STREAM_TYPE_WEB_RTC = "web_rtc"