Skip to content

Commit

Permalink
#1939 Duplicate call detector enhancements and unit testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Sheirer committed Sep 15, 2024
1 parent e6a8048 commit 596d101
Show file tree
Hide file tree
Showing 8 changed files with 519 additions and 74 deletions.
36 changes: 35 additions & 1 deletion src/main/java/io/github/dsheirer/audio/AudioSegment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2023 Dennis Sheirer
* Copyright (C) 2014-2024 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -27,6 +27,7 @@
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.identifier.IdentifierUpdateNotification;
import io.github.dsheirer.identifier.MutableIdentifierCollection;
import io.github.dsheirer.identifier.encryption.EncryptionKeyIdentifier;
import io.github.dsheirer.sample.Broadcaster;
import io.github.dsheirer.sample.Listener;
import java.util.Collection;
Expand Down Expand Up @@ -68,6 +69,7 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
private final static Logger mLog = LoggerFactory.getLogger(AudioSegment.class);
private BooleanProperty mComplete = new SimpleBooleanProperty(false);
private BooleanProperty mDuplicate = new SimpleBooleanProperty(false);
private BooleanProperty mEncrypted = new SimpleBooleanProperty(false);
private BooleanProperty mRecordAudio = new SimpleBooleanProperty(false);
private IntegerProperty mMonitorPriority = new SimpleIntegerProperty(Priority.DEFAULT_PRIORITY);
private ObservableSet<BroadcastChannel> mBroadcastChannels = FXCollections.observableSet(new HashSet<>());
Expand Down Expand Up @@ -129,6 +131,25 @@ public long getDuration()
return (mSampleCount / 8); //8 kHz audio generates 8 samples per millisecond
}

/**
* Indicates if the audio segment contains encrypted audio.
*
* @return encrypted property
*/
public BooleanProperty encryptedProperty()
{
return mEncrypted;
}

/**
* Indicates if this audio segment is encrypted
* @return true if encrypted.
*/
public boolean isEncrypted()
{
return mEncrypted.get();
}

/**
* The complete property is used by the audio segment producer to signal that the segment is complete and no
* additional audio or identifiers will be added to the segment.
Expand Down Expand Up @@ -386,6 +407,11 @@ public void addAudio(float[] audioBuffer)
throw new IllegalStateException("Can't add audio to an audio segment that is being disposed");
}

if(mAudioBuffers.isEmpty())
{
mStartTimestamp = System.currentTimeMillis() - 20;
}

mAudioBuffers.add(audioBuffer);
mSampleCount += audioBuffer.length;
}
Expand Down Expand Up @@ -415,6 +441,14 @@ public void addIdentifier(Identifier identifier)
{
mIdentifierCollection.update(identifier);

/**
* If we have a late-add encryption key, set the encrypted flag to true.
*/
if(identifier instanceof EncryptionKeyIdentifier eki)
{
mEncrypted.set(eki.isEncrypted());
}

List<Alias> aliases = mAliasList.getAliases(identifier);

for(Alias alias: aliases)
Expand Down
Loading

0 comments on commit 596d101

Please sign in to comment.