Disconnect VoIP on RTCP bye message (#95452)
* Support RTCP BYE message * Make RtcpState optionalpull/95509/head
parent
54255331d5
commit
33c7cdcdb3
|
@ -7,5 +7,5 @@
|
||||||
"documentation": "https://www.home-assistant.io/integrations/voip",
|
"documentation": "https://www.home-assistant.io/integrations/voip",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"quality_scale": "internal",
|
"quality_scale": "internal",
|
||||||
"requirements": ["voip-utils==0.0.7"]
|
"requirements": ["voip-utils==0.1.0"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,13 @@ import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import async_timeout
|
import async_timeout
|
||||||
from voip_utils import CallInfo, RtpDatagramProtocol, SdpInfo, VoipDatagramProtocol
|
from voip_utils import (
|
||||||
|
CallInfo,
|
||||||
|
RtcpState,
|
||||||
|
RtpDatagramProtocol,
|
||||||
|
SdpInfo,
|
||||||
|
VoipDatagramProtocol,
|
||||||
|
)
|
||||||
|
|
||||||
from homeassistant.components import stt, tts
|
from homeassistant.components import stt, tts
|
||||||
from homeassistant.components.assist_pipeline import (
|
from homeassistant.components.assist_pipeline import (
|
||||||
|
@ -46,7 +52,10 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def make_protocol(
|
def make_protocol(
|
||||||
hass: HomeAssistant, devices: VoIPDevices, call_info: CallInfo
|
hass: HomeAssistant,
|
||||||
|
devices: VoIPDevices,
|
||||||
|
call_info: CallInfo,
|
||||||
|
rtcp_state: RtcpState | None = None,
|
||||||
) -> VoipDatagramProtocol:
|
) -> VoipDatagramProtocol:
|
||||||
"""Plays a pre-recorded message if pipeline is misconfigured."""
|
"""Plays a pre-recorded message if pipeline is misconfigured."""
|
||||||
voip_device = devices.async_get_or_create(call_info)
|
voip_device = devices.async_get_or_create(call_info)
|
||||||
|
@ -70,6 +79,7 @@ def make_protocol(
|
||||||
hass,
|
hass,
|
||||||
"problem.pcm",
|
"problem.pcm",
|
||||||
opus_payload_type=call_info.opus_payload_type,
|
opus_payload_type=call_info.opus_payload_type,
|
||||||
|
rtcp_state=rtcp_state,
|
||||||
)
|
)
|
||||||
|
|
||||||
vad_sensitivity = pipeline_select.get_vad_sensitivity(
|
vad_sensitivity = pipeline_select.get_vad_sensitivity(
|
||||||
|
@ -86,6 +96,7 @@ def make_protocol(
|
||||||
Context(user_id=devices.config_entry.data["user"]),
|
Context(user_id=devices.config_entry.data["user"]),
|
||||||
opus_payload_type=call_info.opus_payload_type,
|
opus_payload_type=call_info.opus_payload_type,
|
||||||
silence_seconds=VadSensitivity.to_seconds(vad_sensitivity),
|
silence_seconds=VadSensitivity.to_seconds(vad_sensitivity),
|
||||||
|
rtcp_state=rtcp_state,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,13 +112,14 @@ class HassVoipDatagramProtocol(VoipDatagramProtocol):
|
||||||
session_name="voip_hass",
|
session_name="voip_hass",
|
||||||
version=__version__,
|
version=__version__,
|
||||||
),
|
),
|
||||||
valid_protocol_factory=lambda call_info: make_protocol(
|
valid_protocol_factory=lambda call_info, rtcp_state: make_protocol(
|
||||||
hass, devices, call_info
|
hass, devices, call_info, rtcp_state
|
||||||
),
|
),
|
||||||
invalid_protocol_factory=lambda call_info: PreRecordMessageProtocol(
|
invalid_protocol_factory=lambda call_info, rtcp_state: PreRecordMessageProtocol(
|
||||||
hass,
|
hass,
|
||||||
"not_configured.pcm",
|
"not_configured.pcm",
|
||||||
opus_payload_type=call_info.opus_payload_type,
|
opus_payload_type=call_info.opus_payload_type,
|
||||||
|
rtcp_state=rtcp_state,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
|
@ -147,6 +159,7 @@ class PipelineRtpDatagramProtocol(RtpDatagramProtocol):
|
||||||
tone_delay: float = 0.2,
|
tone_delay: float = 0.2,
|
||||||
tts_extra_timeout: float = 1.0,
|
tts_extra_timeout: float = 1.0,
|
||||||
silence_seconds: float = 1.0,
|
silence_seconds: float = 1.0,
|
||||||
|
rtcp_state: RtcpState | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up pipeline RTP server."""
|
"""Set up pipeline RTP server."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
|
@ -154,6 +167,7 @@ class PipelineRtpDatagramProtocol(RtpDatagramProtocol):
|
||||||
width=WIDTH,
|
width=WIDTH,
|
||||||
channels=CHANNELS,
|
channels=CHANNELS,
|
||||||
opus_payload_type=opus_payload_type,
|
opus_payload_type=opus_payload_type,
|
||||||
|
rtcp_state=rtcp_state,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
|
@ -454,6 +468,7 @@ class PreRecordMessageProtocol(RtpDatagramProtocol):
|
||||||
opus_payload_type: int,
|
opus_payload_type: int,
|
||||||
message_delay: float = 1.0,
|
message_delay: float = 1.0,
|
||||||
loop_delay: float = 2.0,
|
loop_delay: float = 2.0,
|
||||||
|
rtcp_state: RtcpState | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up RTP server."""
|
"""Set up RTP server."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
|
@ -461,6 +476,7 @@ class PreRecordMessageProtocol(RtpDatagramProtocol):
|
||||||
width=WIDTH,
|
width=WIDTH,
|
||||||
channels=CHANNELS,
|
channels=CHANNELS,
|
||||||
opus_payload_type=opus_payload_type,
|
opus_payload_type=opus_payload_type,
|
||||||
|
rtcp_state=rtcp_state,
|
||||||
)
|
)
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
|
|
|
@ -2614,7 +2614,7 @@ venstarcolortouch==0.19
|
||||||
vilfo-api-client==0.4.1
|
vilfo-api-client==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.voip
|
# homeassistant.components.voip
|
||||||
voip-utils==0.0.7
|
voip-utils==0.1.0
|
||||||
|
|
||||||
# homeassistant.components.volkszaehler
|
# homeassistant.components.volkszaehler
|
||||||
volkszaehler==0.4.0
|
volkszaehler==0.4.0
|
||||||
|
|
|
@ -1914,7 +1914,7 @@ venstarcolortouch==0.19
|
||||||
vilfo-api-client==0.4.1
|
vilfo-api-client==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.voip
|
# homeassistant.components.voip
|
||||||
voip-utils==0.0.7
|
voip-utils==0.1.0
|
||||||
|
|
||||||
# homeassistant.components.volvooncall
|
# homeassistant.components.volvooncall
|
||||||
volvooncall==0.10.3
|
volvooncall==0.10.3
|
||||||
|
|
Loading…
Reference in New Issue