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

rtc: added sip publish dtmf feature #273

Merged
merged 2 commits into from
Oct 2, 2024
Merged
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: 33 additions & 0 deletions livekit-rtc/livekit/rtc/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def __init__(self, message: str) -> None:
self.message = message


class PublishDTMFError(Exception):
def __init__(self, message: str) -> None:
self.message = message


class PublishTranscriptionError(Exception):
def __init__(self, message: str) -> None:
self.message = message
Expand Down Expand Up @@ -147,6 +152,34 @@ async def publish_data(
if cb.publish_data.error:
raise PublishDataError(cb.publish_data.error)

async def publish_dtmf(self, *, code: int, digit: str) -> None:
"""
Publish SIP DTMF message.

Args:
code (int): DTMF code.
digit (str): DTMF digit.

Raises:
PublishDTMFError: If there is an error in publishing SIP DTMF message.
"""
req = proto_ffi.FfiRequest()
req.publish_sip_dtmf.local_participant_handle = self._ffi_handle.handle
req.publish_sip_dtmf.code = code
req.publish_sip_dtmf.digit = digit

queue = FfiClient.instance.queue.subscribe()
try:
resp = FfiClient.instance.request(req)
cb = await queue.wait_for(
lambda e: e.publish_sip_dtmf.async_id == resp.publish_sip_dtmf.async_id
)
finally:
FfiClient.instance.queue.unsubscribe(queue)

if cb.publish_sip_dtmf.error:
raise PublishDTMFError(cb.publish_sip_dtmf.error)

async def publish_transcription(self, transcription: Transcription) -> None:
"""
Publish transcription data to the room.
Expand Down
Loading