mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
Add streaming support w/ audio to Android IP Webcam integration (#126009)
* Add streaming support w/ audio to Android IP Webcam integration * ruff reformat * Fix ruff * Break long comments and strings * Add camera test * Fix docstring * Remove dead code * Call library function to get URL * Simplify --------- Co-authored-by: Shay Levy <levyshay1@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.camera import CameraEntityFeature
|
||||
from homeassistant.components.mjpeg import MjpegCamera, filter_urllib3_logging
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
@@ -31,6 +32,7 @@ class IPWebcamCamera(MjpegCamera):
|
||||
"""Representation of a IP Webcam camera."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_supported_features = CameraEntityFeature.STREAM
|
||||
|
||||
def __init__(self, coordinator: AndroidIPCamDataUpdateCoordinator) -> None:
|
||||
"""Initialize the camera."""
|
||||
@@ -46,3 +48,17 @@ class IPWebcamCamera(MjpegCamera):
|
||||
identifiers={(DOMAIN, coordinator.config_entry.entry_id)},
|
||||
name=coordinator.config_entry.data[CONF_HOST],
|
||||
)
|
||||
self._coordinator = coordinator
|
||||
|
||||
async def stream_source(self) -> str:
|
||||
"""Get the stream source for the Android IP camera."""
|
||||
return self._coordinator.cam.get_rtsp_url(
|
||||
video_codec="h264", # most compatible & recommended
|
||||
# while "opus" is compatible with more devices,
|
||||
# HA's stream integration requires AAC or MP3,
|
||||
# and IP webcam doesn't provide MP3 audio.
|
||||
# aac is supported on select devices >= android 4.1.
|
||||
# The stream will be quiet on devices that don't support aac,
|
||||
# but it won't fail.
|
||||
audio_codec="aac",
|
||||
)
|
||||
|
Reference in New Issue
Block a user