jitsi / libjitsi

Advanced Java media library for secure real-time audio/video communication.
Apache License 2.0
627 stars 280 forks source link

Incorrect interpretations of DTMF tones #562

Closed batishchev closed 2 years ago

batishchev commented 2 years ago

This change is created to fix incorrect interpretations of DTMF tones.

When I send a single digit DTMF tone with a duration, for example, 1000 sendTones

sendTones(1, 1000)

this tone is caught by DtmfTransformEngine as multiple RawPackets

Every RawPacket is converted to DtmfRawPacket with isEnd boolean flag inside.

The amount of DtmfRawPackets depends on DTMF tone duration, for example amount of 1000 - 5 packets with toEnd == false, and 3 packets with toEnd == true amount of 2000 - 10 packets with toEnd == false, and 3 packets with toEnd == true

Then DtmfRawPackets go to synchronized block in addTonePacket

Processing thread of DTMFDispatcher gets current packet in synchronized block, let's say a packet1. When it leaves synchronized block to process the packet1, another packet2 comes to addTonePacket with for example toEnd = true At the end of processing packet1 we set toEnd to false, but packet2 is not yet processed, so we will process it wrongly, with toEnd = false, instead of toEnd = true.

2022-06-04 00-01-19