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>
正在显示
2 个修改的文件
包含
33 行增加
和
0 行删除
.changeset/hungry-peas-bow.md
0 → 100644
| @@ -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 |
-
请 注册 或 登录 后发表评论