Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VOIP Assist Satellite Announce support #25

Merged

Conversation

jaminh
Copy link
Contributor

@jaminh jaminh commented Jan 10, 2025

Updates to make assist satellite announcements work with the VOIP integration. Allow using the existing SIP transport for Home Assistant for both incoming and outgoing calls.

Updates to make assist satellite announcements work with the
VOIP integration. Allow using the existing SIP transport for
Home Assistant for both incoming and outgoing calls.
@jaminh
Copy link
Contributor Author

jaminh commented Jan 10, 2025

The main changes in this PR are moving the INVITE response and BYE message handling from the separate DatagramProtocol class to the original SipDatagramProtocol class. Also added a method for sending an outgoing call to the same SipDatagramProtocol class. Making outgoing calls requires keeping track of the local RTP port that will be used for each call.

@balloob balloob requested a review from synesthesiam January 12, 2025 06:23
voip_utils/sip.py Outdated Show resolved Hide resolved
voip_utils/sip.py Outdated Show resolved Hide resolved
voip_utils/sip.py Outdated Show resolved Hide resolved
voip_utils/sip.py Outdated Show resolved Hide resolved
voip_utils/sip.py Outdated Show resolved Hide resolved
voip_utils/sip.py Outdated Show resolved Hide resolved
f"To: {to_header}",
f"Call-ID: {call_id}",
"CSeq: 50 ACK",
"User-Agent: test-agent 1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow the consumer of this library to pass in a user agent ? Or should we put in voip-utils ?

voip_utils/sip.py Outdated Show resolved Hide resolved
f"To: {to_header}",
f"Call-ID: {callid_header}",
f"CSeq: {cseq_header}",
"User-Agent: test-agent 1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above: let's set it / allow setting it .

voip_utils/sip.py Outdated Show resolved Hide resolved
Copy link
Contributor

@balloob balloob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left some comments. Mark it as ready when addressed 👍

@balloob balloob marked this pull request as draft January 12, 2025 16:39
@jaminh jaminh marked this pull request as ready for review January 12, 2025 19:46
voip_utils/sip.py Outdated Show resolved Hide resolved
local_rtp_port=local_rtp_port,
)
)
elif method == "bye":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this cleanup the call / call an abstract method to indicate the call is over? We would have to update the state in HA

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already calling a method to clean up this class' call dictionary, but I added an abstract on_hangup method as well.

@balloob balloob marked this pull request as draft January 14, 2025 02:47
The on_hangup method will be called when a BYE message is received to
allow any state about the call to be cleaned up after the call has
ended.
@synesthesiam synesthesiam self-assigned this Jan 16, 2025
@synesthesiam
Copy link
Collaborator

I'm able to confirm that the announce action now calls the phone, however it doesn't go into a pipeline for me.
@jaminh Is the plan to call _create_rtp_server in the announce method for VoipAssistSatellite?

@jaminh
Copy link
Contributor Author

jaminh commented Jan 18, 2025

I'm able to confirm that the announce action now calls the phone, however it doesn't go into a pipeline for me. @jaminh Is the plan to call _create_rtp_server in the announce method for VoipAssistSatellite?

When the phone answers and sends the invite response message SipDatagramProtocol should be calling on_call just like when a phone calls in, and that is where _create_rtp_server is called.

https://github.com/jaminh/voip-utils/blob/cff70d0e7d24ce62c70179ce311c04d3e416e035/voip_utils/sip.py#L488

https://github.com/jaminh/voip-utils/blob/cff70d0e7d24ce62c70179ce311c04d3e416e035/voip_utils/voip.py#L102

@jaminh jaminh marked this pull request as ready for review January 18, 2025 20:55

@abstractmethod
def on_call(self, call_info: CallInfo):
"""Handle incoming calls."""

def on_hangup(self, call_info: CallInfo):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this method needs to be required to be implemented in subclasses. That way if we want to release and use the updated voip_utils without updating HA yet things should still work.

@synesthesiam synesthesiam merged commit 5fdfce6 into home-assistant-libs:master Jan 27, 2025
1 check passed
@synesthesiam
Copy link
Collaborator

Thanks @jaminh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants