mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#438 Adds feature for duplicate call audio detection and suppression for playback, recording and streaming. (#835)
Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -26,6 +26,7 @@ public enum PreferenceType
|
||||
{
|
||||
DECODE_EVENT,
|
||||
DIRECTORY,
|
||||
DUPLICATE_CALL_DETECTION,
|
||||
JMBE_LIBRARY,
|
||||
MULTI_FREQUENCY,
|
||||
PLAYLIST,
|
||||
|
||||
@@ -22,6 +22,7 @@ package io.github.dsheirer.preference;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.preference.decoder.JmbeLibraryPreference;
|
||||
import io.github.dsheirer.preference.directory.DirectoryPreference;
|
||||
import io.github.dsheirer.preference.duplicate.DuplicateCallDetectionPreference;
|
||||
import io.github.dsheirer.preference.event.DecodeEventPreference;
|
||||
import io.github.dsheirer.preference.identifier.TalkgroupFormatPreference;
|
||||
import io.github.dsheirer.preference.javafx.JavaFxPreferences;
|
||||
@@ -52,16 +53,18 @@ import io.github.dsheirer.sample.Listener;
|
||||
*/
|
||||
public class UserPreferences implements Listener<PreferenceType>
|
||||
{
|
||||
private JmbeLibraryPreference mJmbeLibraryPreference;
|
||||
private ChannelMultiFrequencyPreference mChannelMultiFrequencyPreference;
|
||||
private DecodeEventPreference mDecodeEventPreference;
|
||||
private DirectoryPreference mDirectoryPreference;
|
||||
private ChannelMultiFrequencyPreference mChannelMultiFrequencyPreference;
|
||||
private DuplicateCallDetectionPreference mDuplicateCallDetectionPreference;
|
||||
private JmbeLibraryPreference mJmbeLibraryPreference;
|
||||
private PlaybackPreference mPlaybackPreference;
|
||||
private PlaylistPreference mPlaylistPreference;
|
||||
private RadioReferencePreference mRadioReferencePreference;
|
||||
private RecordPreference mRecordPreference;
|
||||
private TalkgroupFormatPreference mTalkgroupFormatPreference;
|
||||
private TunerPreference mTunerPreference;
|
||||
|
||||
private SwingPreference mSwingPreference = new SwingPreference();
|
||||
private JavaFxPreferences mJavaFxPreferences = new JavaFxPreferences();
|
||||
|
||||
@@ -170,15 +173,24 @@ public class UserPreferences implements Listener<PreferenceType>
|
||||
return mSwingPreference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate call detection preferences
|
||||
*/
|
||||
public DuplicateCallDetectionPreference getDuplicateCallDetectionPreference()
|
||||
{
|
||||
return mDuplicateCallDetectionPreference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the managed preferences
|
||||
*/
|
||||
private void loadPreferenceTypes()
|
||||
{
|
||||
mDecodeEventPreference = new DecodeEventPreference(this::receive);
|
||||
mJmbeLibraryPreference = new JmbeLibraryPreference(this::receive);
|
||||
mDirectoryPreference = new DirectoryPreference(this::receive);
|
||||
mChannelMultiFrequencyPreference = new ChannelMultiFrequencyPreference(this::receive);
|
||||
mDecodeEventPreference = new DecodeEventPreference(this::receive);
|
||||
mDirectoryPreference = new DirectoryPreference(this::receive);
|
||||
mDuplicateCallDetectionPreference = new DuplicateCallDetectionPreference(this::receive);
|
||||
mJmbeLibraryPreference = new JmbeLibraryPreference(this::receive);
|
||||
mPlaybackPreference = new PlaybackPreference(this::receive);
|
||||
mPlaylistPreference = new PlaylistPreference(this::receive, mDirectoryPreference);
|
||||
mRadioReferencePreference = new RadioReferencePreference(this::receive);
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.preference.duplicate;
|
||||
|
||||
import io.github.dsheirer.preference.Preference;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* User preferences for duplicate call detection
|
||||
*/
|
||||
public class DuplicateCallDetectionPreference extends Preference
|
||||
{
|
||||
private static final String PREFERENCE_KEY_DETECT_DUPLICATE_TALKGROUP = "duplicate.call.detect.talkgroup";
|
||||
private static final String PREFERENCE_KEY_DETECT_DUPLICATE_RADIO = "duplicate.call.detect.radio";
|
||||
private static final String PREFERENCE_KEY_SUPPRESS_DUPLICATE_PLAYBACK = "suppress.duplicate.audio.playback";
|
||||
private static final String PREFERENCE_KEY_SUPPRESS_DUPLICATE_RECORDING = "suppress.duplicate.audio.recording";
|
||||
private static final String PREFERENCE_KEY_SUPPRESS_DUPLICATE_STREAMING = "suppress.duplicate.audio.streaming";
|
||||
|
||||
private final static Logger mLog = LoggerFactory.getLogger(DuplicateCallDetectionPreference.class);
|
||||
private Preferences mPreferences = Preferences.userNodeForPackage(DuplicateCallDetectionPreference.class);
|
||||
private Boolean mDuplicateCallDetectionByTalkgroupEnabled;
|
||||
private Boolean mDuplicateCallDetectionByRadioEnabled;
|
||||
private Boolean mDuplicatePlaybackSuppressionEnabled;
|
||||
private Boolean mDuplicateRecordingSuppressionEnabled;
|
||||
private Boolean mDuplicateStreamingSuppressionEnabled;
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param updateListener to receive notifications that a preference has been updated
|
||||
*/
|
||||
public DuplicateCallDetectionPreference(Listener<PreferenceType> updateListener)
|
||||
{
|
||||
super(updateListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreferenceType getPreferenceType()
|
||||
{
|
||||
return PreferenceType.DUPLICATE_CALL_DETECTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if duplicate call detection is enabled for either talkgroups or radio identifiers.
|
||||
*/
|
||||
public boolean isDuplicateCallDetectionEnabled()
|
||||
{
|
||||
return isDuplicateCallDetectionByTalkgroupEnabled() || isDuplicateCallDetectionByRadioEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preference for detecting duplicate calls by talkgroup or patchgroup
|
||||
*/
|
||||
public boolean isDuplicateCallDetectionByTalkgroupEnabled()
|
||||
{
|
||||
if(mDuplicateCallDetectionByTalkgroupEnabled == null)
|
||||
{
|
||||
mDuplicateCallDetectionByTalkgroupEnabled =
|
||||
mPreferences.getBoolean(PREFERENCE_KEY_DETECT_DUPLICATE_TALKGROUP, true);
|
||||
}
|
||||
|
||||
return mDuplicateCallDetectionByTalkgroupEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preference for detecting duplicate calls by talkgroup
|
||||
*/
|
||||
public void setDuplicateCallDetectionByTalkgroupEnabled(boolean enabled)
|
||||
{
|
||||
mPreferences.putBoolean(PREFERENCE_KEY_DETECT_DUPLICATE_TALKGROUP, enabled);
|
||||
mDuplicateCallDetectionByTalkgroupEnabled = enabled;
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preference for detecting duplicate calls by radio identifier
|
||||
*/
|
||||
public boolean isDuplicateCallDetectionByRadioEnabled()
|
||||
{
|
||||
if(mDuplicateCallDetectionByRadioEnabled == null)
|
||||
{
|
||||
mDuplicateCallDetectionByRadioEnabled = mPreferences.getBoolean(PREFERENCE_KEY_DETECT_DUPLICATE_RADIO, false);
|
||||
}
|
||||
|
||||
return mDuplicateCallDetectionByRadioEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preference for detecting duplicate calls by radio identifier
|
||||
*/
|
||||
public void setDuplicateCallDetectionByRadioEnabled(boolean enabled)
|
||||
{
|
||||
mPreferences.putBoolean(PREFERENCE_KEY_DETECT_DUPLICATE_RADIO, enabled);
|
||||
mDuplicateCallDetectionByRadioEnabled = enabled;
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preference for suppressig playback of duplicate calls.
|
||||
*/
|
||||
public boolean isDuplicatePlaybackSuppressionEnabled()
|
||||
{
|
||||
if(mDuplicatePlaybackSuppressionEnabled == null)
|
||||
{
|
||||
mDuplicatePlaybackSuppressionEnabled = mPreferences.getBoolean(PREFERENCE_KEY_SUPPRESS_DUPLICATE_PLAYBACK, true);
|
||||
}
|
||||
|
||||
return mDuplicatePlaybackSuppressionEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preference for suppressing playback of duplicate calls.
|
||||
*/
|
||||
public void setDuplicatePlaybackSuppressionEnabled(boolean enabled)
|
||||
{
|
||||
mPreferences.putBoolean(PREFERENCE_KEY_SUPPRESS_DUPLICATE_PLAYBACK, enabled);
|
||||
mDuplicatePlaybackSuppressionEnabled = enabled;
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preference for suppressing recording of duplicate calls.
|
||||
*/
|
||||
public boolean isDuplicateRecordingSuppressionEnabled()
|
||||
{
|
||||
if(mDuplicateRecordingSuppressionEnabled == null)
|
||||
{
|
||||
mDuplicateRecordingSuppressionEnabled = mPreferences.getBoolean(PREFERENCE_KEY_SUPPRESS_DUPLICATE_RECORDING, true);
|
||||
}
|
||||
|
||||
return mDuplicateRecordingSuppressionEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preference for suppressing recording of duplicate calls.
|
||||
*/
|
||||
public void setDuplicateRecordingSuppressionEnabled(boolean enabled)
|
||||
{
|
||||
mPreferences.putBoolean(PREFERENCE_KEY_SUPPRESS_DUPLICATE_RECORDING, enabled);
|
||||
mDuplicateRecordingSuppressionEnabled = enabled;
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preference for suppressing streaming of duplicate calls
|
||||
*/
|
||||
public boolean isDuplicateStreamingSuppressionEnabled()
|
||||
{
|
||||
if(mDuplicateStreamingSuppressionEnabled == null)
|
||||
{
|
||||
mDuplicateStreamingSuppressionEnabled = mPreferences.getBoolean(PREFERENCE_KEY_SUPPRESS_DUPLICATE_STREAMING, true);
|
||||
}
|
||||
|
||||
return mDuplicateStreamingSuppressionEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preference for suppressing streaming of duplicate calls
|
||||
*/
|
||||
public void setDuplicateStreamingSuppressionEnabled(boolean enabled)
|
||||
{
|
||||
mPreferences.putBoolean(PREFERENCE_KEY_SUPPRESS_DUPLICATE_STREAMING, enabled);
|
||||
mDuplicateStreamingSuppressionEnabled = enabled;
|
||||
notifyPreferenceUpdated();;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user