From 04f0f3e980d30730b933629c005268e569b06110 Mon Sep 17 00:00:00 2001 From: Dipak Sisodiya Date: Sun, 5 Jan 2025 00:18:23 +0530 Subject: [PATCH 1/4] Update LocalParticipant.kt Add publishDTMF command. --- .../room/participant/LocalParticipant.kt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt b/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt index d82dcfe62..c0d7a4be6 100644 --- a/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt +++ b/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt @@ -735,6 +735,43 @@ internal constructor( engine.sendData(dataPacket) } + /** + * This suspend function allows you to publish DTMF (Dual-Tone Multi-Frequency) + * signals within a LiveKit room. The `publishDTMF` function constructs a + * SipDTMF message using the provided code and digit, then encapsulates it + * in a DataPacket before sending it via the engine. + * + * Parameters: + * - code: an integer representing the DTMF signal code + * - digit: the string representing the DTMF digit (e.g., "1", "#", "*") + * - reliability: determines how the data is transmitted + * (RELIABLE by default, meaning guaranteed delivery) + * + * Note: If the resulting data packet exceeds RTCEngine.MAX_DATA_PACKET_SIZE, + * an IllegalArgumentException is thrown. + */ + + @Suppress("unused") + suspend fun publishDTMF( + code: Int, + digit: String, + reliability: DataPublishReliability = DataPublishReliability.RELIABLE, + ) { + if (data.size > RTCEngine.MAX_DATA_PACKET_SIZE) { + throw IllegalArgumentException("cannot publish data larger than " + RTCEngine.MAX_DATA_PACKET_SIZE) + } + + val sipDTMF = SipDTMF.newBuilder().setCode(code) + .setDigit(digit) + .build() + + val dataPacket = DataPacket.newBuilder() + .setSipDtmf(sipDTMF) + .build() + + engine.sendData(dataPacket) + } + /** * @suppress */ From 49e344bd66e078e2a4edd929314d5ffc16fdacf6 Mon Sep 17 00:00:00 2001 From: Dipak Sisodiya Date: Sun, 5 Jan 2025 00:50:22 +0530 Subject: [PATCH 2/4] Update LocalParticipant.kt --- .../room/participant/LocalParticipant.kt | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt b/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt index c0d7a4be6..33828a499 100644 --- a/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt +++ b/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt @@ -737,35 +737,26 @@ internal constructor( /** * This suspend function allows you to publish DTMF (Dual-Tone Multi-Frequency) - * signals within a LiveKit room. The `publishDTMF` function constructs a - * SipDTMF message using the provided code and digit, then encapsulates it - * in a DataPacket before sending it via the engine. - * + * signals within a LiveKit room. The `publishDTMF` function constructs a + * SipDTMF message using the provided code and digit, then encapsulates it + * in a DataPacket before sending it via the engine. + * * Parameters: - * - code: an integer representing the DTMF signal code + * - code: an integer representing the DTMF signal code * - digit: the string representing the DTMF digit (e.g., "1", "#", "*") - * - reliability: determines how the data is transmitted - * (RELIABLE by default, meaning guaranteed delivery) - * - * Note: If the resulting data packet exceeds RTCEngine.MAX_DATA_PACKET_SIZE, - * an IllegalArgumentException is thrown. */ @Suppress("unused") - suspend fun publishDTMF( + suspend fun publishDtmf( code: Int, digit: String, - reliability: DataPublishReliability = DataPublishReliability.RELIABLE, ) { - if (data.size > RTCEngine.MAX_DATA_PACKET_SIZE) { - throw IllegalArgumentException("cannot publish data larger than " + RTCEngine.MAX_DATA_PACKET_SIZE) - } - - val sipDTMF = SipDTMF.newBuilder().setCode(code) + + val sipDTMF = LivekitModels.SipDTMF.newBuilder().setCode(code) .setDigit(digit) .build() - val dataPacket = DataPacket.newBuilder() + val dataPacket = LivekitModels.DataPacket.newBuilder() .setSipDtmf(sipDTMF) .build() From abb736b7838ed52e0ddbef97b3585c5e295004b0 Mon Sep 17 00:00:00 2001 From: dipak140 Date: Sun, 5 Jan 2025 17:15:25 +0530 Subject: [PATCH 3/4] spotless apply and setKind --- .../room/participant/LocalParticipant.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt b/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt index 33828a499..43b5c9dad 100644 --- a/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt +++ b/livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt @@ -736,28 +736,28 @@ internal constructor( } /** - * This suspend function allows you to publish DTMF (Dual-Tone Multi-Frequency) - * signals within a LiveKit room. The `publishDTMF` function constructs a - * SipDTMF message using the provided code and digit, then encapsulates it - * in a DataPacket before sending it via the engine. - * - * Parameters: - * - code: an integer representing the DTMF signal code - * - digit: the string representing the DTMF digit (e.g., "1", "#", "*") - */ - + * This suspend function allows you to publish DTMF (Dual-Tone Multi-Frequency) + * signals within a LiveKit room. The `publishDtmf` function constructs a + * SipDTMF message using the provided code and digit, then encapsulates it + * in a DataPacket before sending it via the engine. + * + * Parameters: + * - code: an integer representing the DTMF signal code + * - digit: the string representing the DTMF digit (e.g., "1", "#", "*") + */ + @Suppress("unused") suspend fun publishDtmf( code: Int, digit: String, ) { - val sipDTMF = LivekitModels.SipDTMF.newBuilder().setCode(code) .setDigit(digit) .build() val dataPacket = LivekitModels.DataPacket.newBuilder() .setSipDtmf(sipDTMF) + .setKind(LivekitModels.DataPacket.Kind.RELIABLE) .build() engine.sendData(dataPacket) From 4000772dd544e717196665abab9e8fb75c0c1bb6 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Sun, 5 Jan 2025 18:18:36 -0600 Subject: [PATCH 4/4] Create hungry-peas-bow.md --- .changeset/hungry-peas-bow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/hungry-peas-bow.md diff --git a/.changeset/hungry-peas-bow.md b/.changeset/hungry-peas-bow.md new file mode 100644 index 000000000..74208f8dd --- /dev/null +++ b/.changeset/hungry-peas-bow.md @@ -0,0 +1,5 @@ +--- +"client-sdk-android": patch +--- + +Add publishDTMF method for Sending DTMF signals to SIP Participant