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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions call_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

from dotenv import load_dotenv

from voip_utils.call_phone import VoipCallDatagramProtocol
from voip_utils.voip import VoipDatagramProtocol, CallProtocolFactory
from voip_utils.sip import (
CallInfo,
CallPhoneDatagramProtocol,
SdpInfo,
SipEndpoint,
get_sip_endpoint,
Expand Down Expand Up @@ -52,6 +51,22 @@ def get_env_int(env_var: str, default_val: int) -> int:
"sleep_ratio": 0.99,
}

class ExampleVoipDatagramProtocol(VoipDatagramProtocol):

def __init__(
self,
sdp_info: SdpInfo,
valid_protocol_factory: CallProtocolFactory,
invalid_protocol_factory: Optional[CallProtocolFactory] = None,
) -> None:
"""Set up VoIP call handler."""
super().__init__(sdp_info, valid_protocol_factory, invalid_protocol_factory)
self.call_end = asyncio.Event()


def on_hangup(self, call_info: CallInfo):
"""Example implementation of on hangup. """
self.call_end.set()

class PreRecordMessageProtocol(RtpDatagramProtocol):
"""Plays a pre-recorded message on a loop."""
Expand Down Expand Up @@ -153,11 +168,13 @@ async def main() -> None:
pass

_, protocol = await loop.create_datagram_endpoint(
lambda: VoipCallDatagramProtocol(
lambda: ExampleVoipDatagramProtocol(
None,
source,
destination,
rtp_port,
lambda call_info, rtcp_state: PreRecordMessageProtocol(
"problem.pcm",
call_info.opus_payload_type,
rtcp_state=rtcp_state,
),
lambda call_info, rtcp_state: PreRecordMessageProtocol(
"problem.pcm",
call_info.opus_payload_type,
Expand All @@ -167,7 +184,9 @@ async def main() -> None:
local_addr=(CALL_SRC_IP, CALL_SRC_PORT),
)

await protocol.wait_closed()
protocol.outgoing_call(source, destination, rtp_port)

await protocol.call_end.wait()


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ black==23.3.0
flake8==7.1.0
isort==5.12.0
mypy==1.1.1
opuslib==3.0.1
pylint==3.2.5
pytest==7.2.2
python-dotenv==1.0.1
101 changes: 0 additions & 101 deletions voip_utils/call_phone.py

This file was deleted.

Loading
Loading