mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Rename stream_type
to frontend_stream_type
(#57923)
Camera devices may support multiple stream sources so we want to clarify that this is meant to decide which stream source is used in the frontend only. Will set stream_type temporarily to allow rollout without breaking nightly, and this will be removed after frontend is updated.
This commit is contained in:
parent
a1176cc79a
commit
dafea00f41
@ -422,7 +422,7 @@ class Camera(Entity):
|
|||||||
return MIN_STREAM_INTERVAL
|
return MIN_STREAM_INTERVAL
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stream_type(self) -> str | None:
|
def frontend_stream_type(self) -> str | None:
|
||||||
"""Return the type of stream supported by this camera.
|
"""Return the type of stream supported by this camera.
|
||||||
|
|
||||||
A camera may have a single stream type which is used to inform the
|
A camera may have a single stream type which is used to inform the
|
||||||
@ -570,8 +570,10 @@ class Camera(Entity):
|
|||||||
if self.motion_detection_enabled:
|
if self.motion_detection_enabled:
|
||||||
attrs["motion_detection"] = self.motion_detection_enabled
|
attrs["motion_detection"] = self.motion_detection_enabled
|
||||||
|
|
||||||
if self.stream_type:
|
if self.frontend_stream_type:
|
||||||
attrs["stream_type"] = self.stream_type
|
attrs["frontend_stream_type"] = self.frontend_stream_type
|
||||||
|
# Remove after home-assistant/frontend#10298 is merged into nightly
|
||||||
|
attrs["stream_type"] = self.frontend_stream_type
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
@ -746,11 +748,11 @@ async def ws_camera_web_rtc_offer(
|
|||||||
entity_id = msg["entity_id"]
|
entity_id = msg["entity_id"]
|
||||||
offer = msg["offer"]
|
offer = msg["offer"]
|
||||||
camera = _get_camera_from_entity_id(hass, entity_id)
|
camera = _get_camera_from_entity_id(hass, entity_id)
|
||||||
if camera.stream_type != STREAM_TYPE_WEB_RTC:
|
if camera.frontend_stream_type != STREAM_TYPE_WEB_RTC:
|
||||||
connection.send_error(
|
connection.send_error(
|
||||||
msg["id"],
|
msg["id"],
|
||||||
"web_rtc_offer_failed",
|
"web_rtc_offer_failed",
|
||||||
f"Camera does not support WebRTC, stream_type={camera.stream_type}",
|
f"Camera does not support WebRTC, frontend_stream_type={camera.frontend_stream_type}",
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
@ -118,7 +118,7 @@ class NestCamera(Camera):
|
|||||||
return supported_features
|
return supported_features
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stream_type(self) -> str | None:
|
def frontend_stream_type(self) -> str | None:
|
||||||
"""Return the type of stream supported by this camera."""
|
"""Return the type of stream supported by this camera."""
|
||||||
if CameraLiveStreamTrait.NAME not in self._device.traits:
|
if CameraLiveStreamTrait.NAME not in self._device.traits:
|
||||||
return None
|
return None
|
||||||
@ -131,9 +131,11 @@ class NestCamera(Camera):
|
|||||||
"""Return the source of the stream."""
|
"""Return the source of the stream."""
|
||||||
if not self.supported_features & SUPPORT_STREAM:
|
if not self.supported_features & SUPPORT_STREAM:
|
||||||
return None
|
return None
|
||||||
if self.stream_type != STREAM_TYPE_HLS:
|
if CameraLiveStreamTrait.NAME not in self._device.traits:
|
||||||
return None
|
return None
|
||||||
trait = self._device.traits[CameraLiveStreamTrait.NAME]
|
trait = self._device.traits[CameraLiveStreamTrait.NAME]
|
||||||
|
if StreamingProtocol.RTSP not in trait.supported_protocols:
|
||||||
|
return None
|
||||||
if not self._stream:
|
if not self._stream:
|
||||||
_LOGGER.debug("Fetching stream url")
|
_LOGGER.debug("Fetching stream url")
|
||||||
try:
|
try:
|
||||||
|
@ -53,7 +53,7 @@ async def mock_camera_web_rtc_fixture(hass):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.camera.Camera.stream_type",
|
"homeassistant.components.camera.Camera.frontend_stream_type",
|
||||||
new_callable=PropertyMock(return_value=STREAM_TYPE_WEB_RTC),
|
new_callable=PropertyMock(return_value=STREAM_TYPE_WEB_RTC),
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.camera.Camera.async_handle_web_rtc_offer",
|
"homeassistant.components.camera.Camera.async_handle_web_rtc_offer",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user