If it would do incoming calls, this would be neat.

This commit is contained in:
Martyn 2026-08-02 19:30:19 +02:00
parent fae106eeba
commit 9621017702
3 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# dialin
If this ever works for inbound calling, it will connect the pipewire input and output of the machine to the call, so you can join an ongoing video call in discord, zoom or whatever.

43
main.py Normal file
View file

@ -0,0 +1,43 @@
from PySIP.sip_account import SipAccount
from PySIP.sip_call import SipCall
import os
import asyncio
from dotenv import load_dotenv
import logging
# Load SIP credentials from .env file
load_dotenv()
try:
if len(os.environ["SIP_CONN_TYPE"]) < 1:
os.environ["SIP_CONN_TYPE"] = "AUTO"
except:
os.environ["SIP_CONN_TYPE"] = "AUTO"
account = SipAccount(
os.environ["SIP_USERNAME"],
os.environ["SIP_PASSWORD"],
os.environ["SIP_SERVER"],
connection_type = os.environ["SIP_CONN_TYPE"]
)
async def main():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
await account.register()
@account.on_incoming_call
async def handle_incoming_call(call: SipCall):
print("incoming call!")
await call.accept() # or call.reject() or call.busy()
await call.call_handler.say("Thank you for calling us!")
await call.call_handler.hangup()
loop = 0
while True:
await asyncio.sleep(60)
loop = loop + 1
logger.log(logging.INFO, f"Hey, we've been running for {loop} minutes...just so you know.")
if __name__ == "__main__":
asyncio.run(main())

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
PySIPio
scipy