Specify rtsp_transport for Onvif Camera (#31918)
* specify rtsp_transport for onvif camera * remove used variable * Update homeassistant/components/stream/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * change options to stream_options Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
1 parent
ac945242dc
commit
e1cc2acdf9
3 files changed
+33
-11
No files matched your search
@@ -136,7 +136,13 @@ async def async_request_stream(hass, entity_id, fmt):
|
||||
f"{camera.entity_id} does not support play stream service"
|
||||
)
|
||||
|
||||
return request_stream(hass, source, fmt=fmt, keepalive=camera_prefs.preload_stream)
|
||||
return request_stream(
|
||||
hass,
|
||||
source,
|
||||
fmt=fmt,
|
||||
keepalive=camera_prefs.preload_stream,
|
||||
options=camera.options,
|
||||
)
|
||||
|
||||
|
||||
@bind_hass
|
||||
@@ -256,7 +262,7 @@ async def async_setup(hass, config):
|
||||
if not source:
|
||||
continue
|
||||
|
||||
request_stream(hass, source, keepalive=True)
|
||||
request_stream(hass, source, keepalive=True, options=camera.stream_options)
|
||||
|
||||
async_when_setup(hass, DOMAIN_STREAM, preload_stream)
|
||||
|
||||
@@ -312,6 +318,7 @@ class Camera(Entity):
|
||||
def __init__(self):
|
||||
"""Initialize a camera."""
|
||||
self.is_streaming = False
|
||||
self.stream_options = {}
|
||||
self.content_type = DEFAULT_CONTENT_TYPE
|
||||
self.access_tokens: collections.deque = collections.deque([], 2)
|
||||
self.async_update_token()
|
||||
@@ -581,7 +588,11 @@ async def ws_camera_stream(hass, connection, msg):
|
||||
|
||||
fmt = msg["format"]
|
||||
url = request_stream(
|
||||
hass, source, fmt=fmt, keepalive=camera_prefs.preload_stream
|
||||
hass,
|
||||
source,
|
||||
fmt=fmt,
|
||||
keepalive=camera_prefs.preload_stream,
|
||||
options=camera.stream_options,
|
||||
)
|
||||
connection.send_result(msg["id"], {"url": url})
|
||||
except HomeAssistantError as ex:
|
||||
@@ -666,7 +677,13 @@ async def async_handle_play_stream_service(camera, service_call):
|
||||
fmt = service_call.data[ATTR_FORMAT]
|
||||
entity_ids = service_call.data[ATTR_MEDIA_PLAYER]
|
||||
|
||||
url = request_stream(hass, source, fmt=fmt, keepalive=camera_prefs.preload_stream)
|
||||
url = request_stream(
|
||||
hass,
|
||||
source,
|
||||
fmt=fmt,
|
||||
keepalive=camera_prefs.preload_stream,
|
||||
options=camera.stream_options,
|
||||
)
|
||||
data = {
|
||||
ATTR_ENTITY_ID: entity_ids,
|
||||
ATTR_MEDIA_CONTENT_ID: f"{hass.config.api.base_url}{url}",
|
||||
|
||||
Reference in new issue
Block a user