DTMF API on Android

506 views
Skip to first unread message

Raman Budny

unread,
Jun 29, 2017, 6:39:23 AM6/29/17
to discuss-webrtc
Hi all,
could you please describe, how DTMF tones could be sent on Android?

I see that there is a #createSender method in PeerConnection class which takes two undocumented parameters and returns a RtpSender instance, which provides access to a DtmfSender instance via #dtmf.
Could you please describe the meaning of #createSender's parameters (kind and stream_id) and their possible values?

One more question: do you plan to implement some kind of Observer to track tone changes?

Taylor Brandstetter

unread,
Jun 29, 2017, 7:25:57 AM6/29/17
to discuss-webrtc
Sorry that things aren't documented very well; the RtpSender/RtpReceiver stuff is still in development. Anyway, createSender was intended to be used if you want to negotiate sending something, but don't yet have a MediaStreamTrack to send. If you do have a MediaStream, you can call addStream, and one sender will be created implicitly for each track, returned by the getSenders() accessor.

If you need to use createSender, the kind argument may be "audio" or "video", and stream_id is an ID of a MediaStream that the remote audio track created on the other side will be added to. It's similar to addTransceiver in the spec. So if you call:

pc.createSender("audio", "my_stream");
pc.createSender("video", "my_stream");

This is essentially equivalent to calling:

MediaStream stream = pcFactory.createLocalMediaStream("my_stream");
stream.addTrack(audioTrack);
stream.addTrack(videoTrack);
pc.addStream(stream);

Except that in the former case, you won't actually be sending media until you attach a track to the sender via setTrack (equivalent to replaceTrack in the spec).

Hopefully that makes sense... I'll add a note to myself to document these things in the code.

One more question: do you plan to implement some kind of Observer to track tone changes?

No immediate plans, but the interface exists in C++, so it's just a matter of no one needing it in Java so far.


--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/d9beec01-d6bf-43b9-810a-0c0a375ddd8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raman Budny

unread,
Jun 29, 2017, 7:45:46 AM6/29/17
to discuss...@googlegroups.com
Thank you very much for detailed explanation.
If I have to write java binding for DTMF observer, I'll send it to upstream.

--

---
You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/9W-gsv4pARU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/CAK35n0YXy-8Ackm3djq715%3D46T%2BFtP-OnLEJT32662Kz-jH6KQ%40mail.gmail.com.

kwd...@gmail.com

unread,
Sep 22, 2020, 5:41:11 AM9/22/20
to discuss-webrtc

@Raman have you used any type of DTMF observer after all?
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.

--

---
You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/9W-gsv4pARU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.

Gnanaoly Annamalai

unread,
Oct 13, 2020, 2:28:46 AM10/13/20
to discuss-webrtc
InBand DTMF Android code

public void sendDTMF(String tone) {



if (peerConnection == null) return;

RtpSender audioSender = null;

for (RtpSender sender : peerConnection.getSenders()) {

if (sender.track().kind().equals("audio")) {

audioSender = sender;


}
}

if (audioSender == null) {
Logger.println(TAG + "  audioSender not found ");

return;
} else {

AppLogger.println(TAG + " " + audioSender);
}
//
// Create a DTMF sender.
DtmfSender dtmfSender = audioSender.dtmf();


if (dtmfSender != null) {

AppLogger.println(TAG + "  dtmfSender.canInsertDtmf() " + dtmfSender.canInsertDtmf() + " : " + tone);

if (dtmfSender.canInsertDtmf())

dtmfSender.insertDtmf(tone, 400, 50);
}

}


Gnanaoly Annamalai

unread,
Oct 13, 2020, 2:29:08 AM10/13/20
to discuss-webrtc
sendDTMF("1");
sendDTMF("#");
Reply all
Reply to author
Forward
0 new messages