Resolves #707 separate DTMF tones of the same value get merged together (#712)

Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
Denny Sheirer
2020-03-28 16:03:47 +00:00
committed by GitHub
parent 277a84702a
commit df25675d3f

View File

@@ -190,8 +190,9 @@ public class P25P2AudioModule extends AmbeAudioModule implements IdentifierUpdat
*/ */
private void processMetadata(IAudioWithMetadata audioWithMetadata) private void processMetadata(IAudioWithMetadata audioWithMetadata)
{ {
if(audioWithMetadata.hasMetadata() && mIdentifierUpdateNotificationListener != null) if(audioWithMetadata.hasMetadata())
{ {
//JMBE only places 1 entry in the map, but for consistency we'll process the map entry set
for(Map.Entry<String,String> entry: audioWithMetadata.getMetadata().entrySet()) for(Map.Entry<String,String> entry: audioWithMetadata.getMetadata().entrySet())
{ {
//Each metadata map entry contains a tone-type (key) and tone (value) //Each metadata map entry contains a tone-type (key) and tone (value)
@@ -203,6 +204,10 @@ public class P25P2AudioModule extends AmbeAudioModule implements IdentifierUpdat
} }
} }
} }
else
{
mToneMetadataProcessor.closeMetadata();
}
} }
/** /**
@@ -243,6 +248,7 @@ public class P25P2AudioModule extends AmbeAudioModule implements IdentifierUpdat
public class ToneMetadataProcessor public class ToneMetadataProcessor
{ {
private List<ToneMetadata> mToneMetadata = new ArrayList<>(); private List<ToneMetadata> mToneMetadata = new ArrayList<>();
private ToneMetadata mCurrentToneMetadata;
/** /**
* Resets or clears any accumulated call tone metadata to prepare for the next call. * Resets or clears any accumulated call tone metadata to prepare for the next call.
@@ -265,18 +271,27 @@ public class P25P2AudioModule extends AmbeAudioModule implements IdentifierUpdat
return null; return null;
} }
ToneMetadata toneMetadata = (mToneMetadata.size() > 0 ? mToneMetadata.get(mToneMetadata.size() - 1) : null); if(mCurrentToneMetadata != null && mCurrentToneMetadata.matches(type, value))
if(toneMetadata == null || !toneMetadata.matches(type, value))
{ {
toneMetadata = new ToneMetadata(type, value); mCurrentToneMetadata.incrementCount();
mToneMetadata.add(toneMetadata); }
else
{
mCurrentToneMetadata = new ToneMetadata(type, value);
mToneMetadata.add(mCurrentToneMetadata);
mCurrentToneMetadata.incrementCount();
} }
toneMetadata.incrementCount();
return P25ToneIdentifier.create(Joiner.on(",").join(mToneMetadata)); return P25ToneIdentifier.create(Joiner.on(",").join(mToneMetadata));
} }
/**
* Closes current tone metadata when there is no metadata for the current audio frame.
*/
public void closeMetadata()
{
mCurrentToneMetadata = null;
}
} }
/** /**