Dipak Sisodiya
Committed by GitHub

Add publishDTMF method for Sending DTMF signals to SIP Participant (#576)

* Update LocalParticipant.kt

Add publishDTMF command.

* Update LocalParticipant.kt

* spotless apply and setKind

* Create hungry-peas-bow.md

---------

Co-authored-by: David Zhao <dz@livekit.io>
  1 +---
  2 +"client-sdk-android": patch
  3 +---
  4 +
  5 +Add publishDTMF method for Sending DTMF signals to SIP Participant
@@ -736,6 +736,34 @@ internal constructor( @@ -736,6 +736,34 @@ internal constructor(
736 } 736 }
737 737
738 /** 738 /**
  739 + * This suspend function allows you to publish DTMF (Dual-Tone Multi-Frequency)
  740 + * signals within a LiveKit room. The `publishDtmf` function constructs a
  741 + * SipDTMF message using the provided code and digit, then encapsulates it
  742 + * in a DataPacket before sending it via the engine.
  743 + *
  744 + * Parameters:
  745 + * - code: an integer representing the DTMF signal code
  746 + * - digit: the string representing the DTMF digit (e.g., "1", "#", "*")
  747 + */
  748 +
  749 + @Suppress("unused")
  750 + suspend fun publishDtmf(
  751 + code: Int,
  752 + digit: String,
  753 + ) {
  754 + val sipDTMF = LivekitModels.SipDTMF.newBuilder().setCode(code)
  755 + .setDigit(digit)
  756 + .build()
  757 +
  758 + val dataPacket = LivekitModels.DataPacket.newBuilder()
  759 + .setSipDtmf(sipDTMF)
  760 + .setKind(LivekitModels.DataPacket.Kind.RELIABLE)
  761 + .build()
  762 +
  763 + engine.sendData(dataPacket)
  764 + }
  765 +
  766 + /**
739 * @suppress 767 * @suppress
740 */ 768 */
741 @VisibleForTesting 769 @VisibleForTesting