简体   繁体   English

Android WebRTC 无法发送 DTMF

[英]Android WebRTC cant send DTMF

In my Android WebRTC client to send DTFM tones I use code like this在我的 Android WebRTC 客户端发送 DTFM 音我使用这样的代码

val audioSource = peerConnectionFactory.createAudioSource(MediaConstraints())
val localAudioTrack = peerConnectionFactory.createAudioTrack("audio", audioSource)
peerConnection.addTrack(localAudioTrack)
peerConnection?.senders?.firstOrNull()?.let {
    it.dtmf()?.insertDtmf(code, 400, 50)
}

But it seems tone does not reach a peer, and there is erro message in logcat但似乎音调没有到达对等点,并且 logcat 中有错误消息
dtmf_sender.cc E (line 126): InsertDtmf is called on DtmfSender that can't send DTMF. dtmf_sender.cc E(第 126 行):在无法发送 DTMF 的 DtmfSender 上调用 InsertDtmf。

No matter what device I use.不管我用什么设备。
Why could it happen?为什么会发生?

Sample code block over here

Testing strong text测试强文本

Emphasis重点

A quote here!在这里引用!

#Heading# #标题#

There are multiple reasons why this could happen, one of them being that the other party in the WebRTC connection does not support the RTP telephone-event发生这种情况的原因有多种,其中之一是 WebRTC 连接中的另一方不支持 RTP电话事件

Also, check this example: https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Using_DTMF (haven't tried it myself though)另外,检查这个例子: https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Using_DTMF (虽然我自己没试过)

Pay attention to this:注意这一点:

" Note, however, that although it's possible to send DTMF using WebRTC, there is currently no way to detect or receive incoming DTMF. WebRTC currently ignores these payloads; this is because WebRTC's DTMF support is primarily intended for use with legacy telephone services " 但是请注意,虽然可以使用 WebRTC 发送 DTMF,但目前无法检测或接收传入的 DTMF。WebRTC 目前忽略这些有效负载;这是因为 WebRTC 的 DTMF 支持主要用于传统电话服务

I have found, problem is that peers are not connected via RTP.我发现,问题是对等点不是通过 RTP 连接的。 I mean WebRTC did not found yet suitable route, basing on ICE candidates gathered, to pass audio traffic.我的意思是 WebRTC 还没有找到合适的路线,基于 ICE 候选人聚集,通过音频流量。
As only route is constructed, traffic goes on, and sender comes ready to send DTMF tones.由于只构建了路由,流量继续进行,发送方准备好发送 DTMF 音调。
To be ensured that peers are ready to trancieve media, you may look on connection state in PeerConnection.Observer.onIceConnectionChange() , and get sender when state comes to "CONNECTED".为确保对等点准备好传输媒体,您可以在PeerConnection.Observer.onIceConnectionChange()中查看连接 state,并在 state 变为“CONNECTED”时获取发送方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM