mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 01:27:34 -05:00
Compare commits
63 Commits
v0.3.0-bet
...
v0.3.2-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88580af436 | ||
|
|
64688a3c20 | ||
|
|
8be3399a6b | ||
|
|
28340809ca | ||
|
|
f3d3a8187a | ||
|
|
8484e837b8 | ||
|
|
01b188ea25 | ||
|
|
108691dc3c | ||
|
|
455aa97286 | ||
|
|
d608834214 | ||
|
|
41660e1881 | ||
|
|
110ccb158c | ||
|
|
64ccacf04a | ||
|
|
f00b9555fe | ||
|
|
85442a9648 | ||
|
|
c67a0b329d | ||
|
|
8035d64fcd | ||
|
|
df2a061a08 | ||
|
|
e430319937 | ||
|
|
724f769771 | ||
|
|
c196cfebed | ||
|
|
e80b5866d4 | ||
|
|
c8994d5593 | ||
|
|
99ef57c90f | ||
|
|
be62ae0459 | ||
|
|
b9be6f43e0 | ||
|
|
d5ad3f807d | ||
|
|
d85ebd018d | ||
|
|
ab4e31ae00 | ||
|
|
5efd89632e | ||
|
|
1dc3863489 | ||
|
|
441286ba13 | ||
|
|
e4323df347 | ||
|
|
a872e0d664 | ||
|
|
fbc92cfe31 | ||
|
|
1a432197ac | ||
|
|
fbc6e508bd | ||
|
|
f9b6e67b00 | ||
|
|
a628800a71 | ||
|
|
25f71a76c4 | ||
|
|
5fe8ccd478 | ||
|
|
069f951a86 | ||
|
|
dab6df7836 | ||
|
|
89da46b63c | ||
|
|
5f2ce2a9f2 | ||
|
|
7a0b377971 | ||
|
|
5dbe0ecce3 | ||
|
|
6647c581a6 | ||
|
|
a2ab5bfa95 | ||
|
|
ed486440b8 | ||
|
|
13464e01fc | ||
|
|
ea46a8b0e8 | ||
|
|
d510c34356 | ||
|
|
ae8a44caed | ||
|
|
1aa85a86ca | ||
|
|
17539d4d55 | ||
|
|
1db1d28390 | ||
|
|
37a941e904 | ||
|
|
57f6655824 | ||
|
|
4cd8f8209f | ||
|
|
61bfef5798 | ||
|
|
ef172a04c6 | ||
|
|
a877afcceb |
10
CHANGELOG
10
CHANGELOG
@@ -1,5 +1,13 @@
|
|||||||
|
0.3.2 20171105
|
||||||
|
- Resolves issue with tuner frequency adjustments that was causing channel processing
|
||||||
|
to lockup and show persistent 'overflow' state in each channel status
|
||||||
|
- Resolves issue with broadcastify 'mountpoint-in-use' error handling and updates
|
||||||
|
memory usage logging
|
||||||
|
|
||||||
0.3.0-beta1 20170129
|
0.3.1 20171009
|
||||||
|
- Resolves Java 9 incompatibility issues
|
||||||
|
|
||||||
|
0.3.0 20170922
|
||||||
- REQUIRES: Java 8 (or newer) for compatibility and eventual changeover to JavaFX
|
- REQUIRES: Java 8 (or newer) for compatibility and eventual changeover to JavaFX
|
||||||
- FEATURE: audio streaming - adds capability to stream to multiple remote broadcast
|
- FEATURE: audio streaming - adds capability to stream to multiple remote broadcast
|
||||||
servers (Broadcastify, Icecast v2.3 and v2.4+, and Shoutcast V1 and V2). Each
|
servers (Broadcastify, Icecast v2.3 and v2.4+, and Shoutcast V1 and V2). Each
|
||||||
|
|||||||
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
|
|||||||
state the exclusion of warranty; and each file should have at least
|
state the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
{one line to give the program's name and a brief idea of what it does.}
|
||||||
Copyright (C) <year> <name of author>
|
Copyright (C) {year} {name of author}
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|||||||
If the program does terminal interaction, make it output a short
|
If the program does terminal interaction, make it output a short
|
||||||
notice like this when it starts in an interactive mode:
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
{project} Copyright (C) {year} {fullname}
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
A cross-platform java application for decoding, monitoring, recording and streaming trunked mobile and related radio protocols using Software Defined Radios (SDR).
|
A cross-platform java application for decoding, monitoring, recording and streaming trunked mobile and related radio protocols using Software Defined Radios (SDR).
|
||||||
|
|
||||||
* [Getting Started](https://github.com/DSheirer/sdrtrunk/wiki/GettingStarted)
|
* [Getting Started](https://github.com/DSheirer/sdrtrunk/wiki/GettingStarted)
|
||||||
* [User's Manual Version 0.2.0](https://github.com/DSheirer/sdrtrunk/wiki/UserManual)
|
|
||||||
* [User's Manual Version 0.3.0](https://github.com/DSheirer/sdrtrunk/wiki/UserManual_Version0.3.0)
|
* [User's Manual Version 0.3.0](https://github.com/DSheirer/sdrtrunk/wiki/UserManual_Version0.3.0)
|
||||||
* [Download](https://github.com/DSheirer/sdrtrunk/releases)
|
* [Download](https://github.com/DSheirer/sdrtrunk/releases)
|
||||||
* [Support](https://groups.google.com/forum/#!forum/sdrtrunk)
|
* [Support](https://groups.google.com/forum/#!forum/sdrtrunk)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<!-- version properties -->
|
<!-- version properties -->
|
||||||
<property name="major" value="0"/>
|
<property name="major" value="0"/>
|
||||||
<property name="minor" value="3"/>
|
<property name="minor" value="3"/>
|
||||||
<property name="patch" value="0"/>
|
<property name="patch" value="1"/>
|
||||||
<property name="release" value="-beta7"/>
|
<property name="release" value=""/> <!-- Use dash (-) prefix (e.g. -beta1) -->
|
||||||
<property name="filename" value="sdrtrunk_${major}.${minor}.${patch}${release}"/>
|
<property name="filename" value="sdrtrunk_${major}.${minor}.${patch}${release}"/>
|
||||||
|
|
||||||
<!-- Build properties -->
|
<!-- Build properties -->
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
<property name="source.configs" location="${repo}/config"/>
|
<property name="source.configs" location="${repo}/config"/>
|
||||||
<property name="source.images" location="${repo}/images"/>
|
<property name="source.images" location="${repo}/images"/>
|
||||||
<property name="source.libs" location="${repo}/imports"/>
|
<property name="source.libs" location="${repo}/imports"/>
|
||||||
<property name="source.license" location="${repo}/license"/>
|
|
||||||
<property name="source.scripts" location="${repo}/scripts"/>
|
<property name="source.scripts" location="${repo}/scripts"/>
|
||||||
|
|
||||||
<property name="output" location="${repo}/product"/>
|
<property name="output" location="${repo}/product"/>
|
||||||
@@ -35,13 +34,35 @@
|
|||||||
<mkdir dir="${output.classes}"/>
|
<mkdir dir="${output.classes}"/>
|
||||||
|
|
||||||
<!-- Create version file -->
|
<!-- Create version file -->
|
||||||
<echo message="${major}.${minor}.${patch}-${release}" file="${output.classes}/sdrtrunk-version"/>
|
<echo message="${major}.${minor}.${patch}${release}" file="${output.classes}/sdrtrunk-version"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="compile" depends="clean,init" description="Compile java classes" >
|
<target name="compile" depends="clean,init,compile-java-8,compile-java-9"
|
||||||
|
description="Compile java classes" />
|
||||||
|
|
||||||
|
<target name="compile-java-8" depends="check-java-version" if="java.8" description="Compiles code with Java 8 arguments">
|
||||||
|
<echo message="Compiling with Java 8 Options"/>
|
||||||
<javac srcdir="${source.code}" destdir="${output.classes}" classpathref="classpath" includeantruntime="false"/>
|
<javac srcdir="${source.code}" destdir="${output.classes}" classpathref="classpath" includeantruntime="false"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="compile-java-9" depends="check-java-version" if="java.9" description="Compiles code with Java 9 arguments">
|
||||||
|
<echo message="Compiling with Java 9 Options"/>
|
||||||
|
<javac srcdir="${source.code}" destdir="${output.classes}" classpathref="classpath" includeantruntime="false">
|
||||||
|
<compilerarg value="--add-modules"/>
|
||||||
|
<compilerarg value="java.xml.bind"/>
|
||||||
|
</javac>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="check-java-version" description="Determines if the compiler is Java 8 or 9">
|
||||||
|
<condition property="java.8" value="true">
|
||||||
|
<contains string="${java.version}" substring="1.8"/>
|
||||||
|
</condition>
|
||||||
|
<condition property="java.9" value="true">
|
||||||
|
<equals arg1="${java.version}" arg2="9"/>
|
||||||
|
</condition>
|
||||||
|
<echo message="Java Version: ${java.version}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="SDRTrunk" depends="compile" description="Create SDRTrunk application">
|
<target name="SDRTrunk" depends="compile" description="Create SDRTrunk application">
|
||||||
<!-- Create the distribution directory -->
|
<!-- Create the distribution directory -->
|
||||||
<mkdir dir="${output.folder}"/>
|
<mkdir dir="${output.folder}"/>
|
||||||
@@ -57,8 +78,8 @@
|
|||||||
<exclude name="*.rules"/>
|
<exclude name="*.rules"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
|
|
||||||
<fileset dir="${source.license}">
|
<fileset dir="${repo}">
|
||||||
<include name="license.txt"/>
|
<include name="LICENSE"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</jar>
|
</jar>
|
||||||
|
|
||||||
@@ -85,8 +106,8 @@
|
|||||||
|
|
||||||
<!-- Copy license file -->
|
<!-- Copy license file -->
|
||||||
<copy todir="${output.folder}">
|
<copy todir="${output.folder}">
|
||||||
<fileset dir="${source.license}">
|
<fileset dir="${repo}">
|
||||||
<include name="license.txt"/>
|
<include name="LICENSE"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
|
<conversionRule conversionWord="memory_usage" converterClass="util.MemoryUsageLogger" />
|
||||||
|
|
||||||
<timestamp key="appstart" datePattern="HHmmss"/>
|
<timestamp key="appstart" datePattern="HHmmss"/>
|
||||||
|
|
||||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
@@ -9,7 +11,7 @@
|
|||||||
<maxHistory>10</maxHistory>
|
<maxHistory>10</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%-25(%d{yyyyMMdd HHmmss.SSS} [%thread]) %-5level %logger{30} - %msg%n</pattern>
|
<pattern>%-25(%d{yyyyMMdd HHmmss.SSS} [%thread]) %-5level %logger{30} - %msg %memory_usage%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@
|
|||||||
|
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%-12(%d{HH:mm:ss.SSS}) %-5level %logger{25} - %msg%n</pattern>
|
<pattern>%-12(%d{HH:mm:ss.SSS}) %-5level %logger{25} - %msg %memory_usage%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
java -XX:+UseG1GC -cp "*:libs/*" gui.SDRTrunk
|
|
||||||
|
java -version
|
||||||
|
|
||||||
|
# Test for java version 9
|
||||||
|
JAVA_9=$(java -version 2>&1 | grep -i version | sed 's/.* "\([9]\).*/\1/')
|
||||||
|
|
||||||
|
if [ -z ${JAVA_9+x} ]; then
|
||||||
|
echo Using Java 9 program options
|
||||||
|
# Java 9 uses the G1 garbage collector by default and requires that we specify the
|
||||||
|
# java.xml.bind package since it's been removed from the java se core library
|
||||||
|
java -cp "*:libs/*" --add-modules java.xml.bind gui.SDRTrunk;
|
||||||
|
else
|
||||||
|
echo Using Java 8 program options
|
||||||
|
java -XX:+UseG1GC -cp "*:libs/*" gui.SDRTrunk;
|
||||||
|
fi
|
||||||
|
|||||||
@@ -1 +1,25 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
java -version
|
||||||
|
|
||||||
|
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||||
|
|
||||||
|
for /f "usebackq tokens=3" %%a in (`java -version 2^>^&1 ^| find "version"`) do (
|
||||||
|
rem set b to the unquoted version string parsed from the java version command
|
||||||
|
set b=%%~a
|
||||||
|
|
||||||
|
rem set c to the first character of the unquoted version string
|
||||||
|
set c=!b:~0,1!
|
||||||
|
|
||||||
|
if !c! equ 9 (
|
||||||
|
echo Using Java 9 options
|
||||||
|
java -cp "SDRTrunk.jar;*;libs/*;config/*;images/*" --add-modules java.xml.bind gui.SDRTrunk
|
||||||
|
) else (
|
||||||
|
echo Using Java 8 options
|
||||||
java -XX:+UseG1GC -cp "SDRTrunk.jar;*;libs/*;config/*;images/*" gui.SDRTrunk
|
java -XX:+UseG1GC -cp "SDRTrunk.jar;*;libs/*;config/*;images/*" gui.SDRTrunk
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
ENDLOCAL
|
||||||
|
|
||||||
|
@echo on
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ public class AudioChannelPanel extends JPanel
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("align center center, insets 0 0 0 0", "[][][align right]0[grow,fill]", ""));
|
setLayout(new MigLayout("align center center, insets 0 0 0 0",
|
||||||
|
"[][][align right]0[grow,fill]", ""));
|
||||||
setBackground(mBackgroundColor);
|
setBackground(mBackgroundColor);
|
||||||
|
|
||||||
mMutedLabel.setFont(mFont);
|
mMutedLabel.setFont(mFont);
|
||||||
@@ -109,7 +110,7 @@ public class AudioChannelPanel extends JPanel
|
|||||||
|
|
||||||
mTo.setFont(mFont);
|
mTo.setFont(mFont);
|
||||||
mTo.setForeground(mValueColor);
|
mTo.setForeground(mValueColor);
|
||||||
add(mTo);
|
add(mTo,"wmin 10lp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -159,29 +160,39 @@ public class AudioChannelPanel extends JPanel
|
|||||||
* does not occur on the Swing event thread -- wrap any calls to this
|
* does not occur on the Swing event thread -- wrap any calls to this
|
||||||
* method with an event thread call.
|
* method with an event thread call.
|
||||||
*/
|
*/
|
||||||
private void updateLabel(JLabel valueLabel, String value, JLabel aliasLabel, Alias alias)
|
private void updateLabel(JLabel textLabel, String value, JLabel iconLabel, Alias alias)
|
||||||
{
|
{
|
||||||
if(value != null)
|
if(value != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(alias != null)
|
if(alias != null)
|
||||||
{
|
{
|
||||||
valueLabel.setText(alias.getName());
|
iconLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
|
||||||
aliasLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
valueLabel.setText(value);
|
|
||||||
aliasLabel.setIcon(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
valueLabel.setText("-----");
|
|
||||||
aliasLabel.setIcon(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
String aliasName = alias.getName();
|
||||||
|
|
||||||
|
//Truncate label if length exceeds 33 characters - hack!
|
||||||
|
if(aliasName.length() > 33)
|
||||||
|
{
|
||||||
|
textLabel.setText(aliasName.substring(0,30) + "...");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textLabel.setText(aliasName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iconLabel.setIcon(null);
|
||||||
|
textLabel.setText(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iconLabel.setIcon(null);
|
||||||
|
textLabel.setText("-----");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes audio metadata to update this panel's display values
|
* Processes audio metadata to update this panel's display values
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ public class AudioChannelsPanel extends JPanel
|
|||||||
|
|
||||||
public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
|
public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
|
||||||
{
|
{
|
||||||
// setLayout(new MigLayout("insets 0 0 0 0", "[][grow,fill][][grow,fill]", "[grow,fill]"));
|
setLayout(new MigLayout("insets 0 0 0 0", "[][sg abc,grow,fill][][sg abc,grow,fill]", "[grow,fill]"));
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[][sg,grow,fill][][sg,grow,fill]", "[grow,fill]"));
|
|
||||||
|
|
||||||
setBackground(Color.BLACK);
|
setBackground(Color.BLACK);
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ public class AudioChannelsPanel extends JPanel
|
|||||||
|
|
||||||
for(int x = 0; x < outputs.size(); x++)
|
for(int x = 0; x < outputs.size(); x++)
|
||||||
{
|
{
|
||||||
add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)), "growx");
|
add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)));
|
||||||
|
|
||||||
if(x < outputs.size() - 1)
|
if(x < outputs.size() - 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the saved mixer configuration or a default configuration for audio playback.
|
||||||
|
*/
|
||||||
private void loadSettings()
|
private void loadSettings()
|
||||||
{
|
{
|
||||||
MixerChannelConfiguration configuration = null;
|
MixerChannelConfiguration configuration = null;
|
||||||
@@ -132,6 +135,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a default audio playback configuration with a mono audio playback channel.
|
||||||
|
*/
|
||||||
private MixerChannelConfiguration getDefaultConfiguration()
|
private MixerChannelConfiguration getDefaultConfiguration()
|
||||||
{
|
{
|
||||||
/* Use the system default mixer and mono channel as default startup */
|
/* Use the system default mixer and mono channel as default startup */
|
||||||
@@ -161,6 +167,9 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
mAudioOutputConnections.clear();
|
mAudioOutputConnections.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary ingest point for audio produced by all decoding channels, for distribution to audio playback devices.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void receive(AudioPacket packet)
|
public synchronized void receive(AudioPacket packet)
|
||||||
{
|
{
|
||||||
@@ -176,11 +185,11 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
|
|
||||||
for(AudioOutputConnection connection : mAudioOutputConnections)
|
for(AudioOutputConnection connection : mAudioOutputConnections)
|
||||||
{
|
{
|
||||||
if(connection.isInactive() &&
|
if(connection.isInactive() && mChannelConnectionMap.containsKey(connection.getChannelMetadataID()))
|
||||||
mChannelConnectionMap.containsKey(connection.getChannelMetadataID()))
|
|
||||||
{
|
{
|
||||||
mChannelConnectionMap.remove(connection.getChannelMetadataID());
|
mChannelConnectionMap.remove(connection.getChannelMetadataID());
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
mAvailableConnectionCount++;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +201,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies the lowest priority channel connection
|
* Identifies the lowest priority channel connection where the a higher value indicates a lower priority.
|
||||||
*/
|
*/
|
||||||
private void updateLowestPriorityAssignment()
|
private void updateLowestPriorityAssignment()
|
||||||
{
|
{
|
||||||
@@ -201,19 +210,32 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
for(AudioOutputConnection connection : mAudioOutputConnections)
|
for(AudioOutputConnection connection : mAudioOutputConnections)
|
||||||
{
|
{
|
||||||
if(connection.isConnected() &&
|
if(connection.isConnected() &&
|
||||||
(mLowestPriorityConnection == null || mLowestPriorityConnection.getPriority() > connection.getPriority()))
|
(mLowestPriorityConnection == null || mLowestPriorityConnection.getPriority() < connection.getPriority()))
|
||||||
{
|
{
|
||||||
mLowestPriorityConnection = connection;
|
mLowestPriorityConnection = connection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures audio playback to use the configuration specified in the entry argument.
|
||||||
|
*
|
||||||
|
* @param entry to use in configuring the audio playback setup.
|
||||||
|
* @throws AudioException if there is an error
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setMixerChannelConfiguration(MixerChannelConfiguration entry) throws AudioException
|
public void setMixerChannelConfiguration(MixerChannelConfiguration entry) throws AudioException
|
||||||
{
|
{
|
||||||
setMixerChannelConfiguration(entry, true);
|
setMixerChannelConfiguration(entry, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures audio playback to use the configuration specified in the entry argument.
|
||||||
|
*
|
||||||
|
* @param entry to use in configuring the audio playback setup.
|
||||||
|
* @param saveSettings to save the audio playback configuration settings in the properties file.
|
||||||
|
* @throws AudioException if there is an error
|
||||||
|
*/
|
||||||
public void setMixerChannelConfiguration(MixerChannelConfiguration entry, boolean saveSettings) throws AudioException
|
public void setMixerChannelConfiguration(MixerChannelConfiguration entry, boolean saveSettings) throws AudioException
|
||||||
{
|
{
|
||||||
if(entry != null && (entry.getMixerChannel() == MixerChannel.MONO || entry.getMixerChannel() == MixerChannel.STEREO))
|
if(entry != null && (entry.getMixerChannel() == MixerChannel.MONO || entry.getMixerChannel() == MixerChannel.STEREO))
|
||||||
@@ -266,9 +288,8 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all channel assignments and terminates all audio outputs in
|
* Clears all channel assignments and terminates all audio outputs in preparation for complete shutdown or change
|
||||||
* preparation for complete shutdown or change to another mixer/channel
|
* to another mixer/channel configuration
|
||||||
* configuration
|
|
||||||
*/
|
*/
|
||||||
private void disposeCurrentConfiguration()
|
private void disposeCurrentConfiguration()
|
||||||
{
|
{
|
||||||
@@ -288,12 +309,18 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
mLowestPriorityConnection = null;
|
mLowestPriorityConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current audio playback mixer channel configuration setting.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MixerChannelConfiguration getMixerChannelConfiguration() throws AudioException
|
public MixerChannelConfiguration getMixerChannelConfiguration() throws AudioException
|
||||||
{
|
{
|
||||||
return mMixerChannelConfiguration;
|
return mMixerChannelConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of audio outputs available for the current mixer channel configuration
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AudioOutput> getAudioOutputs()
|
public List<AudioOutput> getAudioOutputs()
|
||||||
{
|
{
|
||||||
@@ -311,12 +338,18 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
return outputs;
|
return outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an audio event listener to receive audio event notifications.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addControllerListener(Listener<AudioEvent> listener)
|
public void addControllerListener(Listener<AudioEvent> listener)
|
||||||
{
|
{
|
||||||
mControllerBroadcaster.addListener(listener);
|
mControllerBroadcaster.addListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an audio event listener from receiving audio event notifications.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeControllerListener(Listener<AudioEvent> listener)
|
public void removeControllerListener(Listener<AudioEvent> listener)
|
||||||
{
|
{
|
||||||
@@ -324,16 +357,15 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an audio output connection for the packet if one is
|
* Returns an audio output connection for the packet if one is available, or overrides an existing lower priority
|
||||||
* available, or overrides an existing lower priority connection.
|
* connection. Returns null if no connection is available for the audio packet.
|
||||||
* Returns null if no connection is available for the audio packet.
|
|
||||||
*
|
*
|
||||||
* @param packet from a source
|
* @param audioPacket from a decoding channel source
|
||||||
* @return an audio output connection or null
|
* @return an audio output connection or null
|
||||||
*/
|
*/
|
||||||
private AudioOutputConnection getConnection(AudioPacket packet)
|
private AudioOutputConnection getConnection(AudioPacket audioPacket)
|
||||||
{
|
{
|
||||||
int channelMetadataID = packet.getMetadata().getMetadataID();
|
int channelMetadataID = audioPacket.getMetadata().getMetadataID();
|
||||||
|
|
||||||
//Use an existing connection
|
//Use an existing connection
|
||||||
if(mChannelConnectionMap.containsKey(channelMetadataID))
|
if(mChannelConnectionMap.containsKey(channelMetadataID))
|
||||||
@@ -341,37 +373,35 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
return mChannelConnectionMap.get(channelMetadataID);
|
return mChannelConnectionMap.get(channelMetadataID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Connect to and use an available connection
|
//Connect to an unused, available connection
|
||||||
if(mAvailableConnectionCount > 0)
|
if(mAvailableConnectionCount > 0)
|
||||||
{
|
{
|
||||||
for(AudioOutputConnection connection : mAudioOutputConnections)
|
for(AudioOutputConnection connection : mAudioOutputConnections)
|
||||||
{
|
{
|
||||||
if(connection.isDisconnected())
|
if(connection.isDisconnected())
|
||||||
{
|
{
|
||||||
connection.connect(channelMetadataID);
|
connection.connect(channelMetadataID, audioPacket.getMetadata().getAudioPriority());
|
||||||
mChannelConnectionMap.put(channelMetadataID, connection);
|
mChannelConnectionMap.put(channelMetadataID, connection);
|
||||||
|
mAvailableConnectionCount--;
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Preempt an existing connection and connect it to this higher priority source
|
//Preempt an existing lower priority connection and connect when this is a higher priority packet
|
||||||
else //Check for a channel priority override
|
else
|
||||||
{
|
{
|
||||||
int priority = packet.getMetadata().getAudioPriority();
|
int priority = audioPacket.getMetadata().getAudioPriority();
|
||||||
|
|
||||||
if(mLowestPriorityConnection != null &&
|
|
||||||
priority < mLowestPriorityConnection.getPriority())
|
|
||||||
{
|
|
||||||
AudioOutputConnection connection = mLowestPriorityConnection;
|
AudioOutputConnection connection = mLowestPriorityConnection;
|
||||||
|
|
||||||
|
if(connection != null && priority < connection.getPriority())
|
||||||
|
{
|
||||||
mChannelConnectionMap.remove(connection.getChannelMetadataID());
|
mChannelConnectionMap.remove(connection.getChannelMetadataID());
|
||||||
|
|
||||||
connection.connect(channelMetadataID);
|
connection.connect(channelMetadataID, priority);
|
||||||
|
|
||||||
mChannelConnectionMap.put(channelMetadataID, connection);
|
mChannelConnectionMap.put(channelMetadataID, connection);
|
||||||
|
|
||||||
updateLowestPriorityAssignment();
|
|
||||||
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,9 +524,11 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
* Connects this assignment to the indicated source so that audio
|
* Connects this assignment to the indicated source so that audio
|
||||||
* packets from this source can be sent to the audio output
|
* packets from this source can be sent to the audio output
|
||||||
*/
|
*/
|
||||||
public void connect(int source)
|
public void connect(int source, int priority)
|
||||||
{
|
{
|
||||||
mChannelMetadataID = source;
|
mChannelMetadataID = source;
|
||||||
|
mPriority = priority;
|
||||||
|
updateLowestPriorityAssignment();
|
||||||
|
|
||||||
mAudioOutput.updateTimestamp();
|
mAudioOutput.updateTimestamp();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public enum BroadcastState
|
|||||||
/**
|
/**
|
||||||
* Specified mount point is already in use
|
* Specified mount point is already in use
|
||||||
*/
|
*/
|
||||||
MOUNT_POINT_IN_USE("Mount Point In Use", true),
|
MOUNT_POINT_IN_USE("Mount Point In Use", false),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server is not known or reachable
|
* Server is not known or reachable
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import util.ThreadPool;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.nio.channels.UnresolvedAddressException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@@ -44,7 +45,8 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
private final static Logger mLog = LoggerFactory.getLogger(IcecastTCPAudioBroadcaster.class);
|
private final static Logger mLog = LoggerFactory.getLogger(IcecastTCPAudioBroadcaster.class);
|
||||||
private final static String TERMINATOR = "\r\n";
|
private final static String TERMINATOR = "\r\n";
|
||||||
private final static String SEPARATOR = ":";
|
private final static String SEPARATOR = ":";
|
||||||
private static final long RECONNECT_INTERVAL_MILLISECONDS = 30000; //30 seconds
|
private static final long RECONNECT_INTERVAL_MILLISECONDS = 3000; //3 seconds
|
||||||
|
private static final long CONNECTION_ATTEMPT_TIMEOUT = 5000; //5 seconds
|
||||||
|
|
||||||
private NioSocketConnector mSocketConnector;
|
private NioSocketConnector mSocketConnector;
|
||||||
private IoSession mStreamingSession = null;
|
private IoSession mStreamingSession = null;
|
||||||
@@ -99,10 +101,11 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
if(mSocketConnector == null)
|
if(mSocketConnector == null)
|
||||||
{
|
{
|
||||||
mSocketConnector = new NioSocketConnector();
|
mSocketConnector = new NioSocketConnector();
|
||||||
mSocketConnector.setConnectTimeoutCheckInterval(10000);
|
mSocketConnector.setConnectTimeoutCheckInterval(CONNECTION_ATTEMPT_TIMEOUT);
|
||||||
|
|
||||||
// mSocketConnector.getFilterChain().addLast("logger",
|
// LoggingFilter loggingFilter = new LoggingFilter(IcecastTCPAudioBroadcaster.class);
|
||||||
// new LoggingFilter(IcecastTCPAudioBroadcaster.class));
|
// loggingFilter.setMessageSentLogLevel(LogLevel.NONE);
|
||||||
|
// mSocketConnector.getFilterChain().addLast("logger", loggingFilter);
|
||||||
|
|
||||||
mSocketConnector.getFilterChain().addLast("codec",
|
mSocketConnector.getFilterChain().addLast("codec",
|
||||||
new ProtocolCodecFilter(new IcecastCodecFactory()));
|
new ProtocolCodecFilter(new IcecastCodecFactory()));
|
||||||
@@ -123,9 +126,20 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
ConnectFuture future = mSocketConnector
|
ConnectFuture future = mSocketConnector
|
||||||
.connect(new InetSocketAddress(getBroadcastConfiguration().getHost(),
|
.connect(new InetSocketAddress(getBroadcastConfiguration().getHost(),
|
||||||
getBroadcastConfiguration().getPort()));
|
getBroadcastConfiguration().getPort()));
|
||||||
future.awaitUninterruptibly();
|
|
||||||
|
boolean connected = future.await(CONNECTION_ATTEMPT_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
mStreamingSession = future.getSession();
|
mStreamingSession = future.getSession();
|
||||||
}
|
}
|
||||||
|
catch(UnresolvedAddressException uae)
|
||||||
|
{
|
||||||
|
//What do you do with this? Nothing.
|
||||||
|
}
|
||||||
|
catch(InterruptedException ie)
|
||||||
|
{
|
||||||
|
//We couldn't connect within the timeout period -- disconnect so that we can try again later
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
catch(RuntimeIoException rie)
|
catch(RuntimeIoException rie)
|
||||||
{
|
{
|
||||||
Throwable throwableCause = rie.getCause();
|
Throwable throwableCause = rie.getCause();
|
||||||
@@ -137,16 +151,20 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
else if(throwableCause != null)
|
else if(throwableCause != null)
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.ERROR);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
mLog.debug("Failed to connect", rie);
|
mLog.debug("[" + getStreamName() + "] failed to connect", rie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.ERROR);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
mLog.debug("Failed to connect - no exception is available");
|
mLog.debug("[" + getStreamName() + "] failed to connect - no exception is available");
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
|
catch(Throwable t)
|
||||||
|
{
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
mConnecting.set(false);
|
mConnecting.set(false);
|
||||||
}
|
}
|
||||||
@@ -164,12 +182,13 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
*/
|
*/
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
{
|
{
|
||||||
if(connected())
|
if(connected() && mStreamingSession != null)
|
||||||
{
|
|
||||||
if(mStreamingSession != null)
|
|
||||||
{
|
{
|
||||||
mStreamingSession.closeNow();
|
mStreamingSession.closeNow();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,17 +245,18 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
@Override
|
@Override
|
||||||
public void sessionClosed(IoSession session) throws Exception
|
public void sessionClosed(IoSession session) throws Exception
|
||||||
{
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
|
|
||||||
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
||||||
if(!getBroadcastState().isErrorState())
|
if(!getBroadcastState().isErrorState())
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.DISCONNECTED);
|
setBroadcastState(BroadcastState.DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSocketConnector.dispose();
|
|
||||||
mStreamingSession = null;
|
mStreamingSession = null;
|
||||||
mSocketConnector = null;
|
|
||||||
|
|
||||||
mConnecting.set(false);
|
mConnecting.set(false);
|
||||||
|
|
||||||
super.sessionClosed(session);
|
super.sessionClosed(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,45 +273,36 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
|
|
||||||
if(connected())
|
if(connected())
|
||||||
{
|
{
|
||||||
mLog.info("Streaming connection error detected - resetting connection - " + reason);
|
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else if(reason.startsWith("Connection reset"))
|
else if(reason.startsWith("Connection reset"))
|
||||||
{
|
{
|
||||||
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else if(reason.startsWith("Operation timed out"))
|
else if(reason.startsWith("Operation timed out"))
|
||||||
{
|
{
|
||||||
mLog.info("Streaming connection timed out - resetting connection");
|
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.ERROR);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
disconnect();
|
disconnect();
|
||||||
mLog.error("Unrecognized IO error: " + reason + ". Streaming halted.", cause);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(ioe instanceof WriteTimeoutException)
|
else if(ioe instanceof WriteTimeoutException)
|
||||||
{
|
{
|
||||||
mLog.info("Network write timeout error - resetting connection");
|
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.ERROR);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
disconnect();
|
disconnect();
|
||||||
mLog.error("Unspecified IO error - streaming halted.", cause);
|
mLog.error("[" + getStreamName() + "] Unspecified IO error - streaming halted.", cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLog.error("Broadcast error", cause);
|
mLog.error("[" + getStreamName() + "] Broadcast error", cause);
|
||||||
setBroadcastState(BroadcastState.ERROR);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
@@ -314,11 +325,19 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.MOUNT_POINT_IN_USE);
|
setBroadcastState(BroadcastState.MOUNT_POINT_IN_USE);
|
||||||
}
|
}
|
||||||
|
else if(message.contains("Content-Type: text/html"))
|
||||||
|
{
|
||||||
|
//Disregard ... this normally follows the mount point in use error
|
||||||
|
}
|
||||||
else if(message.contains("Invalid Password") ||
|
else if(message.contains("Invalid Password") ||
|
||||||
message.contains("Authentication Required"))
|
message.contains("Authentication Required"))
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.INVALID_CREDENTIALS);
|
setBroadcastState(BroadcastState.INVALID_CREDENTIALS);
|
||||||
}
|
}
|
||||||
|
else if(message.contains("HTTP/1.1 501"))
|
||||||
|
{
|
||||||
|
disconnect(); //So that we can reconnect later
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLog.error("Unrecognized server response:" + message);
|
mLog.error("Unrecognized server response:" + message);
|
||||||
@@ -328,7 +347,7 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLog.error("Icecast TCP broadcaster - unrecognized message [ " + object.getClass() +
|
mLog.error("[" + getStreamName() + "]Icecast TCP broadcaster - unrecognized message [ " + object.getClass() +
|
||||||
"] received:" + object.toString());
|
"] received:" + object.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,10 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
|
|||||||
|
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
|
catch(Throwable t)
|
||||||
|
{
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
mConnecting.set(false);
|
mConnecting.set(false);
|
||||||
}
|
}
|
||||||
@@ -185,12 +189,13 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
|
|||||||
*/
|
*/
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
{
|
{
|
||||||
if(connected())
|
if(connected() && mStreamingSession != null)
|
||||||
{
|
|
||||||
if(mStreamingSession != null)
|
|
||||||
{
|
{
|
||||||
mStreamingSession.closeNow();
|
mStreamingSession.closeNow();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,15 +231,15 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
|
|||||||
@Override
|
@Override
|
||||||
public void sessionClosed(IoSession session) throws Exception
|
public void sessionClosed(IoSession session) throws Exception
|
||||||
{
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
|
|
||||||
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
||||||
if(!getBroadcastState().isErrorState())
|
if(!getBroadcastState().isErrorState())
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.DISCONNECTED);
|
setBroadcastState(BroadcastState.DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSocketConnector.dispose();
|
|
||||||
mStreamingSession = null;
|
mStreamingSession = null;
|
||||||
mSocketConnector = null;
|
|
||||||
|
|
||||||
mConnecting.set(false);
|
mConnecting.set(false);
|
||||||
super.sessionClosed(session);
|
super.sessionClosed(session);
|
||||||
@@ -255,13 +260,11 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
|
|||||||
{
|
{
|
||||||
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else if(reason.startsWith("Operation timed out"))
|
else if(reason.startsWith("Operation timed out"))
|
||||||
{
|
{
|
||||||
mLog.info("Streaming connection timed out - resetting connection");
|
mLog.info("Streaming connection timed out - resetting connection");
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -204,6 +204,10 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
|
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
|
catch(Throwable t)
|
||||||
|
{
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
mConnecting.set(false);
|
mConnecting.set(false);
|
||||||
}
|
}
|
||||||
@@ -221,13 +225,13 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
*/
|
*/
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
{
|
{
|
||||||
if(connected())
|
if(connected() && mStreamingSession != null)
|
||||||
{
|
{
|
||||||
if(mStreamingSession != null)
|
|
||||||
{
|
|
||||||
mStreamingSession.write(new TerminateBroadcast());
|
|
||||||
mStreamingSession.closeNow();
|
mStreamingSession.closeNow();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,15 +353,15 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
@Override
|
@Override
|
||||||
public void sessionClosed(IoSession session) throws Exception
|
public void sessionClosed(IoSession session) throws Exception
|
||||||
{
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
|
|
||||||
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
||||||
if(!getBroadcastState().isErrorState())
|
if(!getBroadcastState().isErrorState())
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.DISCONNECTED);
|
setBroadcastState(BroadcastState.DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSocketConnector.dispose();
|
|
||||||
mStreamingSession = null;
|
mStreamingSession = null;
|
||||||
mSocketConnector = null;
|
|
||||||
|
|
||||||
mConnecting.set(false);
|
mConnecting.set(false);
|
||||||
super.sessionClosed(session);
|
super.sessionClosed(session);
|
||||||
@@ -378,13 +382,11 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
{
|
{
|
||||||
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else if(reason.startsWith("Operation timed out"))
|
else if(reason.startsWith("Operation timed out"))
|
||||||
{
|
{
|
||||||
mLog.info("Streaming connection timed out - resetting connection");
|
mLog.info("Streaming connection timed out - resetting connection");
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -137,6 +137,17 @@ public class BinaryMessage extends BitSet
|
|||||||
mCRC = crc;
|
mCRC = crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the number of bit errors that were corrected in this message.
|
||||||
|
*
|
||||||
|
* @see CorrectedBinaryMessage subclass that supports setting this value
|
||||||
|
* @return number of corrected bits in this message
|
||||||
|
*/
|
||||||
|
public int getCorrectedBitCount()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current pointer index
|
* Current pointer index
|
||||||
*/
|
*/
|
||||||
|
|||||||
65
src/bits/CorrectedBinaryMessage.java
Normal file
65
src/bits/CorrectedBinaryMessage.java
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 bits;
|
||||||
|
|
||||||
|
import java.util.BitSet;
|
||||||
|
|
||||||
|
public class CorrectedBinaryMessage extends BinaryMessage
|
||||||
|
{
|
||||||
|
private int mCorrectedBitCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of binary message class to allow capturing a corrected bits metric.
|
||||||
|
* @param size of message to create.
|
||||||
|
*/
|
||||||
|
public CorrectedBinaryMessage(int size)
|
||||||
|
{
|
||||||
|
super(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CorrectedBinaryMessage(int size, boolean[] bitsToPreload)
|
||||||
|
{
|
||||||
|
super(size, bitsToPreload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CorrectedBinaryMessage(BitSet bitset, int size)
|
||||||
|
{
|
||||||
|
super(bitset, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CorrectedBinaryMessage(byte[] data)
|
||||||
|
{
|
||||||
|
super(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCorrectedBitCount()
|
||||||
|
{
|
||||||
|
return mCorrectedBitCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the number of bits that were corrected in this message
|
||||||
|
* @param count of corrected bits
|
||||||
|
*/
|
||||||
|
public void setCorrectedBitCount(int count)
|
||||||
|
{
|
||||||
|
mCorrectedBitCount = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/channel/heartbeat/Heartbeat.java
Normal file
31
src/channel/heartbeat/Heartbeat.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 channel.heartbeat;
|
||||||
|
|
||||||
|
public class Heartbeat
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Periodic pulse that is broadcast to subscribing modules within the demodulating chain so that
|
||||||
|
* monitoring of state and other attributes can occur on the primary demodulation and decoding
|
||||||
|
* thread.
|
||||||
|
*/
|
||||||
|
public Heartbeat()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/channel/heartbeat/IHeartbeatListener.java
Normal file
26
src/channel/heartbeat/IHeartbeatListener.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 channel.heartbeat;
|
||||||
|
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
public interface IHeartbeatListener
|
||||||
|
{
|
||||||
|
public Listener<Heartbeat> getHeartbeatListener();
|
||||||
|
}
|
||||||
28
src/channel/heartbeat/IHeartbeatProvider.java
Normal file
28
src/channel/heartbeat/IHeartbeatProvider.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 channel.heartbeat;
|
||||||
|
|
||||||
|
import sample.Listener;
|
||||||
|
|
||||||
|
public interface IHeartbeatProvider
|
||||||
|
{
|
||||||
|
public void setHeartbeatListener(Listener<Heartbeat> listener);
|
||||||
|
|
||||||
|
public void removeHeartbeatListener();
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ChannelMetadataModel extends AbstractTableModel implements Listener<MutableMetadataChangeEvent>
|
public class ChannelMetadataModel extends AbstractTableModel implements Listener<MutableMetadataChangeEvent>
|
||||||
{
|
{
|
||||||
private final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.0000" );
|
private final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.00000" );
|
||||||
|
|
||||||
public static final int COLUMN_STATE = 0;
|
public static final int COLUMN_STATE = 0;
|
||||||
public static final int COLUMN_DECODER = 1;
|
public static final int COLUMN_DECODER = 1;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ package channel.state;
|
|||||||
|
|
||||||
import audio.squelch.ISquelchStateProvider;
|
import audio.squelch.ISquelchStateProvider;
|
||||||
import audio.squelch.SquelchState;
|
import audio.squelch.SquelchState;
|
||||||
|
import channel.heartbeat.Heartbeat;
|
||||||
|
import channel.heartbeat.IHeartbeatListener;
|
||||||
import channel.metadata.Attribute;
|
import channel.metadata.Attribute;
|
||||||
import channel.metadata.AttributeChangeRequest;
|
import channel.metadata.AttributeChangeRequest;
|
||||||
import channel.metadata.IAttributeChangeRequestListener;
|
import channel.metadata.IAttributeChangeRequestListener;
|
||||||
@@ -36,14 +38,16 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.real.IOverflowListener;
|
import sample.real.IOverflowListener;
|
||||||
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
|
import source.tuner.frequency.IFrequencyChangeListener;
|
||||||
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import static source.tuner.frequency.FrequencyChangeEvent.Event.NOTIFICATION_FREQUENCY_CHANGE;
|
||||||
|
|
||||||
public class ChannelState extends Module implements ICallEventProvider, IDecoderStateEventListener,
|
public class ChannelState extends Module implements ICallEventProvider, IDecoderStateEventListener,
|
||||||
IDecoderStateEventProvider, ISquelchStateProvider, IAttributeChangeRequestListener, IOverflowListener
|
IDecoderStateEventProvider, IFrequencyChangeListener, IHeartbeatListener, ISquelchStateProvider,
|
||||||
|
IAttributeChangeRequestListener, IOverflowListener
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelState.class);
|
private final static Logger mLog = LoggerFactory.getLogger(ChannelState.class);
|
||||||
|
|
||||||
@@ -56,11 +60,11 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
private Listener<DecoderStateEvent> mDecoderStateListener;
|
private Listener<DecoderStateEvent> mDecoderStateListener;
|
||||||
private Listener<SquelchState> mSquelchStateListener;
|
private Listener<SquelchState> mSquelchStateListener;
|
||||||
private DecoderStateEventReceiver mDecoderStateEventReceiver = new DecoderStateEventReceiver();
|
private DecoderStateEventReceiver mDecoderStateEventReceiver = new DecoderStateEventReceiver();
|
||||||
private StateMonitor mStateMonitor = new StateMonitor();
|
private HeartbeatReceiver mHeartbeatReceiver = new HeartbeatReceiver();
|
||||||
private ScheduledFuture<?> mStateMonitorFuture;
|
|
||||||
private ChannelType mChannelType;
|
private ChannelType mChannelType;
|
||||||
private TrafficChannelManager mTrafficChannelEndListener;
|
private TrafficChannelManager mTrafficChannelEndListener;
|
||||||
private CallEvent mTrafficChannelCallEvent;
|
private CallEvent mTrafficChannelCallEvent;
|
||||||
|
private FrequencyChangeListener mFrequencyChangeListener;
|
||||||
|
|
||||||
private boolean mSquelchLocked = false;
|
private boolean mSquelchLocked = false;
|
||||||
private boolean mSelected = false;
|
private boolean mSelected = false;
|
||||||
@@ -73,30 +77,21 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel state tracks the overall state of all processing modules and decoders
|
* Channel state tracks the overall state of all processing modules and decoders configured for the channel and
|
||||||
* configured for the channel and provides squelch control and decoder state
|
* provides squelch control and decoder state reset events.
|
||||||
* reset events.
|
|
||||||
*
|
*
|
||||||
* Uses a state enumeration that defines allowable channel state transitions in
|
* Uses a state enumeration that defines allowable channel state transitions in order to track a call or data decode
|
||||||
* order to track a call or data decode event from start to finish. Uses a
|
* event from start to finish. Uses a timer to monitor for inactivity and to provide a FADE period that indicates
|
||||||
* timer to monitor for inactivity and to provide a FADE period that indicates
|
* to the user that the activity has stopped while continuing to provide details about the call, before the state is
|
||||||
* to the user that the activity has stopped while continuing to provide details
|
* reset to IDLE.
|
||||||
* about the call, before the state is reset to IDLE.
|
|
||||||
*
|
|
||||||
* Since this class is multi-threaded between decoder events and the internal
|
|
||||||
* timer that monitors for inactivity, this class uses the mState object for
|
|
||||||
* thread synchronization.
|
|
||||||
*
|
*
|
||||||
* State Descriptions:
|
* State Descriptions:
|
||||||
* IDLE Normal state. No voice or data call activity
|
* IDLE: Normal state. No voice or data call activity
|
||||||
* CALL/DATA/ENCRYPTED/CONTROL
|
* CALL/DATA/ENCRYPTED/CONTROL: Decoding states.
|
||||||
* Decoding states.
|
* FADE: The phase after a voice or data call when either an explicit call end has been received, or when no new
|
||||||
* FADE The phase after a voice or data call when either an explicit
|
* signalling updates have been received, and the fade timer has expired. This phase allows for gui updates to
|
||||||
* call end has been received, or when no new signalling updates
|
* signal to the user that the call is ended, while continuing to display the call details for the user
|
||||||
* have been received, and the fade timer has expired. This phase
|
* TEARDOWN: Indicates a traffic channel that will be torn down for reuse.
|
||||||
* allows for gui updates to signal to the user that the call is
|
|
||||||
* ended, while continuing to display the call details for the user
|
|
||||||
* TEARDOWN Indicates a traffic channel that will be torn down for reuse.
|
|
||||||
*/
|
*/
|
||||||
public ChannelState(ChannelType channelType)
|
public ChannelState(ChannelType channelType)
|
||||||
{
|
{
|
||||||
@@ -130,8 +125,6 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(ScheduledExecutorService executor)
|
public void start(ScheduledExecutorService executor)
|
||||||
{
|
|
||||||
if(mStateMonitorFuture == null && mStateMonitor != null)
|
|
||||||
{
|
{
|
||||||
mMutableMetadata.receive(new AttributeChangeRequest<State>(Attribute.CHANNEL_STATE, mState));
|
mMutableMetadata.receive(new AttributeChangeRequest<State>(Attribute.CHANNEL_STATE, mState));
|
||||||
|
|
||||||
@@ -139,16 +132,6 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
{
|
{
|
||||||
setState(State.CALL);
|
setState(State.CALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mStateMonitorFuture = executor.scheduleAtFixedRate(mStateMonitor, 0, 20, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
|
||||||
catch(RejectedExecutionException ree)
|
|
||||||
{
|
|
||||||
mLog.error("state monitor scheduled task rejected", ree);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -156,16 +139,6 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
{
|
{
|
||||||
mMutableMetadata.resetAllAttributes();
|
mMutableMetadata.resetAllAttributes();
|
||||||
|
|
||||||
if(mStateMonitorFuture != null)
|
|
||||||
{
|
|
||||||
boolean success = mStateMonitorFuture.cancel(true);
|
|
||||||
|
|
||||||
if(!success)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't stop monitoring scheduled future");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mTrafficChannelEndListener = null;
|
mTrafficChannelEndListener = null;
|
||||||
|
|
||||||
if(mTrafficChannelCallEvent != null)
|
if(mTrafficChannelCallEvent != null)
|
||||||
@@ -176,8 +149,6 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
|
|
||||||
mTrafficChannelCallEvent = null;
|
mTrafficChannelCallEvent = null;
|
||||||
|
|
||||||
mStateMonitorFuture = null;
|
|
||||||
|
|
||||||
mSquelchLocked = false;
|
mSquelchLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +157,17 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
mCallEventListener = null;
|
mCallEventListener = null;
|
||||||
mDecoderStateListener = null;
|
mDecoderStateListener = null;
|
||||||
mSquelchStateListener = null;
|
mSquelchStateListener = null;
|
||||||
mStateMonitor = null;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
if(mFrequencyChangeListener == null)
|
||||||
|
{
|
||||||
|
mFrequencyChangeListener = new FrequencyChangeListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mFrequencyChangeListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStandardChannel()
|
private boolean isStandardChannel()
|
||||||
@@ -295,15 +276,12 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the channel state to the specified state, or updates the timeout
|
* Sets the channel state to the specified state, or updates the timeout values so that the state monitor will not
|
||||||
* values so that the state monitor will not change state. Broadcasts a
|
* change state. Broadcasts a squelch event when the state changes and the audio squelch state should change. Also
|
||||||
* squelch event when the state changes and the audio squelch state should
|
* broadcasts changed attribute and decoder state events so that external processes can maintain sync with this
|
||||||
* change. Also broadcasts changed attribute and decoder state events so
|
* channel state.
|
||||||
* that external processes can maintain sync with this channel state.
|
|
||||||
*/
|
*/
|
||||||
protected void setState(State state)
|
protected void setState(State state)
|
||||||
{
|
|
||||||
synchronized(mState)
|
|
||||||
{
|
{
|
||||||
if(state == mState)
|
if(state == mState)
|
||||||
{
|
{
|
||||||
@@ -312,13 +290,12 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
updateFadeTimeout();
|
updateFadeTimeout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(state != mState && mState.canChangeTo(state))
|
else if(mState.canChangeTo(state))
|
||||||
{
|
{
|
||||||
switch(state)
|
switch(state)
|
||||||
{
|
{
|
||||||
case CONTROL:
|
case CONTROL:
|
||||||
//Don't allow traffic channels to be control channels,
|
//Don't allow traffic channels to be control channels, otherwise they can't transition to teardown
|
||||||
//otherwise they can't transition to call tear down
|
|
||||||
if(isStandardChannel())
|
if(isStandardChannel())
|
||||||
{
|
{
|
||||||
broadcast(SquelchState.SQUELCH);
|
broadcast(SquelchState.SQUELCH);
|
||||||
@@ -357,6 +334,14 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
mSourceOverflow ? State.OVERFLOW : mState));
|
mSourceOverflow ? State.OVERFLOW : mState));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receiver inner class that implements the IHeartbeatListener interface to receive heartbeat messages.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Listener<Heartbeat> getHeartbeatListener()
|
||||||
|
{
|
||||||
|
return mHeartbeatReceiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -532,6 +517,23 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
broadcast(mTrafficChannelCallEvent);
|
broadcast(mTrafficChannelCallEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener to receive frequency change events and rebroadcast them to the decoder states
|
||||||
|
*/
|
||||||
|
public class FrequencyChangeListener implements Listener<FrequencyChangeEvent>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void receive(FrequencyChangeEvent frequencyChangeEvent)
|
||||||
|
{
|
||||||
|
if(frequencyChangeEvent.getEvent() == NOTIFICATION_FREQUENCY_CHANGE)
|
||||||
|
{
|
||||||
|
long frequency = frequencyChangeEvent.getValue().longValue();
|
||||||
|
|
||||||
|
broadcast(new DecoderStateEvent(this, Event.SOURCE_FREQUENCY, getState(), frequency));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DecoderStateEvent receiver wrapper
|
* DecoderStateEvent receiver wrapper
|
||||||
*/
|
*/
|
||||||
@@ -591,30 +593,27 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors decoder state events to automatically transition the channel
|
* Processes periodic heartbeats received from the processing chain to perform state monitoring and cleanup
|
||||||
* state to IDLE (standard channel) or to TEARDOWN (traffic channel) when
|
* functions.
|
||||||
* decoding stops or the monitored channel returns to a no signal state.
|
|
||||||
*
|
*
|
||||||
* Provides a FADE transition state to allow for momentary decoding dropouts
|
* Monitors decoder state events to automatically transition the channel state to IDLE (standard channel) or to
|
||||||
* and to allow the user access to call details for a fade period upon
|
* TEARDOWN (traffic channel) when decoding stops or the monitored channel returns to a no signal state.
|
||||||
* call end.
|
*
|
||||||
|
* Provides a FADE transition state to allow for momentary decoding dropouts and to allow the user access to call
|
||||||
|
* details for a fade period upon call end.
|
||||||
*/
|
*/
|
||||||
public class StateMonitor implements Runnable
|
public class HeartbeatReceiver implements Listener<Heartbeat>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void receive(Heartbeat heartbeat)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
synchronized(mState)
|
if(State.CALL_STATES.contains(mState) && mFadeTimeout <= System.currentTimeMillis())
|
||||||
{
|
|
||||||
if(State.CALL_STATES.contains(mState) &&
|
|
||||||
mFadeTimeout <= System.currentTimeMillis())
|
|
||||||
{
|
{
|
||||||
processFadeState();
|
processFadeState();
|
||||||
}
|
}
|
||||||
else if(mState == State.FADE &&
|
else if(mState == State.FADE && mEndTimeout <= System.currentTimeMillis())
|
||||||
mEndTimeout <= System.currentTimeMillis())
|
|
||||||
{
|
{
|
||||||
if(isTrafficChannel())
|
if(isTrafficChannel())
|
||||||
{
|
{
|
||||||
@@ -626,10 +625,9 @@ public class ChannelState extends Module implements ICallEventProvider, IDecoder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch(Throwable e)
|
||||||
catch(Exception e)
|
|
||||||
{
|
{
|
||||||
mLog.error("Exception thrown while state monitor is running " +
|
mLog.error("An error occurred while state monitor was running " +
|
||||||
"- state [" + getState() +
|
"- state [" + getState() +
|
||||||
"] current [" + System.currentTimeMillis() +
|
"] current [" + System.currentTimeMillis() +
|
||||||
"] mResetTimeout [" + mEndTimeout +
|
"] mResetTimeout [" + mEndTimeout +
|
||||||
|
|||||||
@@ -63,13 +63,11 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
|
|||||||
private Listener<CallEvent> mCallEventListener;
|
private Listener<CallEvent> mCallEventListener;
|
||||||
|
|
||||||
private ChannelModel mChannelModel;
|
private ChannelModel mChannelModel;
|
||||||
private ChannelProcessingManager mChannelProcessingManager;
|
|
||||||
private DecodeConfiguration mDecodeConfiguration;
|
private DecodeConfiguration mDecodeConfiguration;
|
||||||
private RecordConfiguration mRecordConfiguration;
|
private RecordConfiguration mRecordConfiguration;
|
||||||
private String mSystem;
|
private String mSystem;
|
||||||
private String mSite;
|
private String mSite;
|
||||||
private String mAliasListName;
|
private String mAliasListName;
|
||||||
private CallEvent mPreviousDoNotMonitorCallEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors call events and allocates traffic decoder channels in response
|
* Monitors call events and allocates traffic decoder channels in response
|
||||||
@@ -77,7 +75,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
|
|||||||
* traffic channel allocations.
|
* traffic channel allocations.
|
||||||
*
|
*
|
||||||
* @param channelModel containing channels currently in use
|
* @param channelModel containing channels currently in use
|
||||||
* @param channelProcessingManager
|
|
||||||
* @param decodeConfiguration - decoder configuration to use for each
|
* @param decodeConfiguration - decoder configuration to use for each
|
||||||
* traffic channel allocation.
|
* traffic channel allocation.
|
||||||
* @param recordConfiguration - recording options for each traffic channel
|
* @param recordConfiguration - recording options for each traffic channel
|
||||||
@@ -88,7 +85,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
|
|||||||
* in the pool
|
* in the pool
|
||||||
*/
|
*/
|
||||||
public TrafficChannelManager(ChannelModel channelModel,
|
public TrafficChannelManager(ChannelModel channelModel,
|
||||||
ChannelProcessingManager channelProcessingManager,
|
|
||||||
DecodeConfiguration decodeConfiguration,
|
DecodeConfiguration decodeConfiguration,
|
||||||
RecordConfiguration recordConfiguration,
|
RecordConfiguration recordConfiguration,
|
||||||
String system,
|
String system,
|
||||||
@@ -97,7 +93,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
|
|||||||
int trafficChannelPoolSize)
|
int trafficChannelPoolSize)
|
||||||
{
|
{
|
||||||
mChannelModel = channelModel;
|
mChannelModel = channelModel;
|
||||||
mChannelProcessingManager = channelProcessingManager;
|
|
||||||
mDecodeConfiguration = decodeConfiguration;
|
mDecodeConfiguration = decodeConfiguration;
|
||||||
mRecordConfiguration = recordConfiguration;
|
mRecordConfiguration = recordConfiguration;
|
||||||
mSystem = system;
|
mSystem = system;
|
||||||
@@ -120,7 +115,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
|
|||||||
|
|
||||||
mCallEventListener = null;
|
mCallEventListener = null;
|
||||||
mDecodeConfiguration = null;
|
mDecodeConfiguration = null;
|
||||||
mPreviousDoNotMonitorCallEvent = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,21 +191,7 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
|
|||||||
|
|
||||||
long frequency = callEvent.getFrequency();
|
long frequency = callEvent.getFrequency();
|
||||||
|
|
||||||
/* Check the from/to aliases for do not monitor priority */
|
if(frequency > 0)
|
||||||
if(isDoNotMonitor(callEvent))
|
|
||||||
{
|
|
||||||
callEvent.setCallEventType(CallEventType.CALL_DO_NOT_MONITOR);
|
|
||||||
|
|
||||||
if(isSameCallEvent(mPreviousDoNotMonitorCallEvent, callEvent))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mPreviousDoNotMonitorCallEvent = callEvent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(frequency > 0)
|
|
||||||
{
|
{
|
||||||
Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(Type.TRAFFIC,
|
Channel channel = getChannel(callEvent.getChannel(), new TunerChannel(Type.TRAFFIC,
|
||||||
frequency, mDecodeConfiguration.getDecoderType().getChannelBandwidth()));
|
frequency, mDecodeConfiguration.getDecoderType().getChannelBandwidth()));
|
||||||
@@ -330,31 +310,6 @@ public class TrafficChannelManager extends Module implements ICallEventProvider,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks for aliases that contain a do not follow/process priority.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
* @return - true if there is an alias that has a do not process alias id
|
|
||||||
*/
|
|
||||||
private boolean isDoNotMonitor(CallEvent event)
|
|
||||||
{
|
|
||||||
Alias to = event.getToIDAlias();
|
|
||||||
|
|
||||||
if(to != null && to.hasCallPriority() && to.getCallPriority() == Priority.DO_NOT_MONITOR)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Alias from = event.getFromIDAlias();
|
|
||||||
|
|
||||||
if(from != null && from.hasCallPriority() && from.getCallPriority() == Priority.DO_NOT_MONITOR)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<DecoderStateEvent> getDecoderStateListener()
|
public Listener<DecoderStateEvent> getDecoderStateListener()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,15 +14,11 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package controller.channel;
|
package controller.channel;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import controller.config.Configuration;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
|
||||||
import javax.xml.bind.annotation.XmlTransient;
|
|
||||||
|
|
||||||
import module.decode.DecoderFactory;
|
import module.decode.DecoderFactory;
|
||||||
import module.decode.DecoderType;
|
import module.decode.DecoderType;
|
||||||
import module.decode.config.AuxDecodeConfiguration;
|
import module.decode.config.AuxDecodeConfiguration;
|
||||||
@@ -31,6 +27,7 @@ import module.log.EventLogType;
|
|||||||
import module.log.config.EventLogConfiguration;
|
import module.log.config.EventLogConfiguration;
|
||||||
import record.RecorderType;
|
import record.RecorderType;
|
||||||
import record.config.RecordConfiguration;
|
import record.config.RecordConfiguration;
|
||||||
|
import sample.Listener;
|
||||||
import source.SourceType;
|
import source.SourceType;
|
||||||
import source.config.SourceConfigFactory;
|
import source.config.SourceConfigFactory;
|
||||||
import source.config.SourceConfigRecording;
|
import source.config.SourceConfigRecording;
|
||||||
@@ -40,15 +37,24 @@ import source.tuner.TunerChannel;
|
|||||||
import source.tuner.TunerChannel.Type;
|
import source.tuner.TunerChannel.Type;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
|
||||||
import controller.config.Configuration;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
@XmlSeeAlso({Configuration.class})
|
@XmlSeeAlso({Configuration.class})
|
||||||
@XmlRootElement(name = "channel")
|
@XmlRootElement(name = "channel")
|
||||||
public class Channel extends Configuration implements IFrequencyChangeProcessor
|
public class Channel extends Configuration implements Listener<FrequencyChangeEvent>
|
||||||
{
|
{
|
||||||
// Standard channels are persisted and traffic channels are temporary
|
// Standard channels are persisted and traffic channels are temporary
|
||||||
public enum ChannelType { STANDARD, TRAFFIC };
|
public enum ChannelType
|
||||||
|
{
|
||||||
|
STANDARD, TRAFFIC
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
// Static unique channel identifier tracking
|
// Static unique channel identifier tracking
|
||||||
@@ -278,7 +284,7 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
|
|||||||
* Note: this method is package private and is intended to be managed
|
* Note: this method is package private and is intended to be managed
|
||||||
* by a co-package central processing manager
|
* by a co-package central processing manager
|
||||||
*
|
*
|
||||||
* @see controller.ChannelProcessingManager
|
* @see controller.channel.ChannelProcessingManager
|
||||||
*/
|
*/
|
||||||
void setEnabled(boolean enabled)
|
void setEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
@@ -436,8 +442,7 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
|
|||||||
{
|
{
|
||||||
TunerChannel tunerChannel = getTunerChannel();
|
TunerChannel tunerChannel = getTunerChannel();
|
||||||
|
|
||||||
return tunerChannel != null &&
|
return tunerChannel != null && tunerChannel.overlaps(minimum, maximum);
|
||||||
tunerChannel.overlaps( minimum, maximum );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -447,7 +452,7 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
|
|||||||
* be used to visually show in the spectral display.
|
* be used to visually show in the spectral display.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void frequencyChanged( FrequencyChangeEvent event )
|
public void receive(FrequencyChangeEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEvent() == Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE)
|
if(event.getEvent() == Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE)
|
||||||
{
|
{
|
||||||
@@ -455,9 +460,21 @@ public class Channel extends Configuration implements IFrequencyChangeProcessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current channel frequency correction value (when this channel is processing)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@XmlTransient
|
@XmlTransient
|
||||||
public int getChannelFrequencyCorrection()
|
public int getChannelFrequencyCorrection()
|
||||||
{
|
{
|
||||||
return mChannelFrequencyCorrection;
|
return mChannelFrequencyCorrection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets frequency correction value to 0
|
||||||
|
*/
|
||||||
|
public void resetFrequencyCorrection()
|
||||||
|
{
|
||||||
|
mChannelFrequencyCorrection = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
|
|
||||||
if(processingChain == null)
|
if(processingChain == null)
|
||||||
{
|
{
|
||||||
processingChain = new ProcessingChain(channel.getName(), channel.getChannelType());
|
processingChain = new ProcessingChain(channel.getChannelType());
|
||||||
|
|
||||||
/* Register global listeners */
|
/* Register global listeners */
|
||||||
for(Listener<AudioPacket> listener : mAudioPacketListeners)
|
for(Listener<AudioPacket> listener : mAudioPacketListeners)
|
||||||
@@ -244,6 +244,9 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
processingChain.addMessageListener(listener);
|
processingChain.addMessageListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Register channel to receive frequency correction events to show in the spectral display (hack!)
|
||||||
|
processingChain.addFrequencyChangeListener(channel);
|
||||||
|
|
||||||
/* Processing Modules */
|
/* Processing Modules */
|
||||||
List<Module> modules = DecoderFactory.getModules(mChannelModel, mChannelMapModel, this,
|
List<Module> modules = DecoderFactory.getModules(mChannelModel, mChannelMapModel, this,
|
||||||
mAliasModel, channel, processingChain.getChannelState().getMutableMetadata());
|
mAliasModel, channel, processingChain.getChannelState().getMutableMetadata());
|
||||||
@@ -347,6 +350,9 @@ public class ChannelProcessingManager implements ChannelEventListener
|
|||||||
|
|
||||||
processingChain.removeRecordingModules();
|
processingChain.removeRecordingModules();
|
||||||
|
|
||||||
|
//Deregister channel from receive frequency correction events to show in the spectral display (hack!)
|
||||||
|
processingChain.removeFrequencyChangeListener(channel);
|
||||||
|
channel.resetFrequencyCorrection();
|
||||||
|
|
||||||
mChannelModel.broadcast(new ChannelEvent(channel, Event.NOTIFICATION_PROCESSING_STOP));
|
mChannelModel.broadcast(new ChannelEvent(channel, Event.NOTIFICATION_PROCESSING_STOP));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,23 +14,24 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package dsp.filter.cic;
|
package dsp.filter.cic;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import dsp.filter.FilterFactory;
|
||||||
import java.util.List;
|
import dsp.filter.Filters;
|
||||||
|
import dsp.filter.Window.WindowType;
|
||||||
|
import dsp.filter.fir.complex.ComplexFIRFilter_CB_CB;
|
||||||
|
import dsp.filter.halfband.complex.HalfBandFilter_CB_CB;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.complex.ComplexBuffer;
|
import sample.complex.ComplexBuffer;
|
||||||
import sample.complex.ComplexSampleListener;
|
import sample.complex.ComplexSampleListener;
|
||||||
import sample.complex.ComplexToComplexBufferAssembler;
|
import sample.complex.ComplexToComplexBufferAssembler;
|
||||||
import sample.decimator.ComplexDecimator;
|
import sample.decimator.ComplexDecimator;
|
||||||
import dsp.filter.FilterFactory;
|
|
||||||
import dsp.filter.Filters;
|
import java.util.ArrayList;
|
||||||
import dsp.filter.Window.WindowType;
|
import java.util.List;
|
||||||
import dsp.filter.fir.complex.ComplexFIRFilter_CB_CB;
|
|
||||||
import dsp.filter.halfband.complex.HalfBandFilter_CB_CB;
|
|
||||||
|
|
||||||
public class ComplexPrimeCICDecimate implements Listener<ComplexBuffer>
|
public class ComplexPrimeCICDecimate implements Listener<ComplexBuffer>
|
||||||
{
|
{
|
||||||
@@ -367,8 +368,11 @@ public class ComplexPrimeCICDecimate implements Listener<ComplexBuffer>
|
|||||||
attenuation,
|
attenuation,
|
||||||
windowType), 0.4f);
|
windowType), 0.4f);
|
||||||
|
|
||||||
mAssembler.setListener( mCleanupFilter );
|
//Bypassing the CIC cleanup filter for now
|
||||||
mCleanupFilter.setListener( mHalfBandFilter );
|
mAssembler.setListener(mHalfBandFilter);
|
||||||
|
|
||||||
|
// mAssembler.setListener( mCleanupFilter );
|
||||||
|
// mCleanupFilter.setListener( mHalfBandFilter );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
|
|||||||
86
src/edac/trellis/DMRNode.java
Normal file
86
src/edac/trellis/DMRNode.java
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 edac.trellis;
|
||||||
|
|
||||||
|
public class DMRNode extends Node
|
||||||
|
{
|
||||||
|
//Hamming error values indicating the number of bits set in each indexed value, 0-15
|
||||||
|
public static final int[] HAMMING_ERROR_COUNT = new int[]{0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transmitted quad-bit value, derived from ETSI TS 102-361-1, Table B.7 Trellis encoder state transition table
|
||||||
|
*
|
||||||
|
* Note: the B.7 table contains constellation point ID numbers that have to be converted into actual bit values
|
||||||
|
* where the bits represent the dibit pair for the constellation point.
|
||||||
|
*/
|
||||||
|
public static final int[][] DMR_TRANSITION_MATRIX = new int[][]
|
||||||
|
{
|
||||||
|
{2,13,14,1,7,8,11,4},
|
||||||
|
{14,1,7,8,11,4,2,13},
|
||||||
|
{10,5,6,9,15,0,3,12},
|
||||||
|
{6,9,15,0,3,12,10,5},
|
||||||
|
{15,0,3,12,10,5,6,9},
|
||||||
|
{3,12,10,5,6,9,15,0},
|
||||||
|
{7,8,11,4,2,13,14,1},
|
||||||
|
{11,4,2,13,14,1,7,8}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trellis Coded Modulation (TCM) 3/4-rate trellis node for decoding DMR
|
||||||
|
*
|
||||||
|
* @param inputValue for the trellis time instant
|
||||||
|
* @param transmittedOutputValue the actual four-bit output value that was transmitted.
|
||||||
|
*/
|
||||||
|
public DMRNode(int inputValue, int transmittedOutputValue)
|
||||||
|
{
|
||||||
|
super(inputValue, transmittedOutputValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the error between the preceeding node and this node as the Hamming distance between the expected
|
||||||
|
* four-bit output value versus the actual transmitted output value.
|
||||||
|
*
|
||||||
|
* @param precedingNode that precedes this node
|
||||||
|
* @return error value for this node relative to the preceeding node argument
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getError(Node precedingNode)
|
||||||
|
{
|
||||||
|
if(precedingNode != null)
|
||||||
|
{
|
||||||
|
int expectedOutputValue = getOutputValue(precedingNode);
|
||||||
|
int errorMask = expectedOutputValue ^ getTransmittedOutputValue();
|
||||||
|
return HAMMING_ERROR_COUNT[errorMask];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expected output four-bit value when this node is preceeded by the argument node.
|
||||||
|
*
|
||||||
|
* @param precedingNode that precedes this node
|
||||||
|
* @return expected output value
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getOutputValue(Node precedingNode)
|
||||||
|
{
|
||||||
|
return DMR_TRANSITION_MATRIX[precedingNode.getInputValue()][getInputValue()];
|
||||||
|
}
|
||||||
|
}
|
||||||
77
src/edac/trellis/Node.java
Normal file
77
src/edac/trellis/Node.java
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 edac.trellis;
|
||||||
|
|
||||||
|
public abstract class Node
|
||||||
|
{
|
||||||
|
private int mInputValue;
|
||||||
|
private int mTransmittedOutputValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trellis Coded Modulation (TCM) node. A node represents a time instant on the trellis and contains an input
|
||||||
|
* value and the corresponding transmitted output value for the time instant. A node does not maintain the
|
||||||
|
* state at the time instant -- the state is determined by the input value of a preceeding node.
|
||||||
|
*
|
||||||
|
* @param inputValue for this node
|
||||||
|
* @param transmittedOutputValue for this node
|
||||||
|
*/
|
||||||
|
public Node(int inputValue, int transmittedOutputValue)
|
||||||
|
{
|
||||||
|
mInputValue = inputValue;
|
||||||
|
mTransmittedOutputValue = transmittedOutputValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input value for this node.
|
||||||
|
*
|
||||||
|
* @return input value
|
||||||
|
*/
|
||||||
|
public int getInputValue()
|
||||||
|
{
|
||||||
|
return mInputValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transmitted output value for this node
|
||||||
|
* @return transmitted output value
|
||||||
|
*/
|
||||||
|
public int getTransmittedOutputValue()
|
||||||
|
{
|
||||||
|
return mTransmittedOutputValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the error value for this node (time instant) by determining the expected output value that would have
|
||||||
|
* been transmitted using the state from the preceding node argument and this node's input value and comparing that
|
||||||
|
* expected value to the actual transmitted output value. This error is normally represented as the Hamming
|
||||||
|
* distance between the two values.
|
||||||
|
*
|
||||||
|
* @param precedingNode that precedes this node
|
||||||
|
* @return error value for this node relative to the preceeding node
|
||||||
|
*/
|
||||||
|
public abstract int getError(Node precedingNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expected output value when this node is preceeded by the node specified in the argument.
|
||||||
|
*
|
||||||
|
* @param precedingNode that precedes this node
|
||||||
|
* @return expected output value
|
||||||
|
*/
|
||||||
|
public abstract int getOutputValue(Node precedingNode);
|
||||||
|
}
|
||||||
131
src/edac/trellis/Path.java
Normal file
131
src/edac/trellis/Path.java
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 edac.trellis;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Path
|
||||||
|
{
|
||||||
|
private List<Node> mNodes = new ArrayList<>();
|
||||||
|
private int mError = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trellis Coded Modulation (TCM) path. Represents a sequence of nodes that traverse various time instants and
|
||||||
|
* states across a trellis.
|
||||||
|
*
|
||||||
|
* Note: each node can be shared across multiple paths. This class does not assume that any nodes are unique.
|
||||||
|
* @param startingNode to start the path. This node normally contains an input value of zero, but is implementation
|
||||||
|
* specific.
|
||||||
|
*/
|
||||||
|
public Path(Node startingNode)
|
||||||
|
{
|
||||||
|
add(startingNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trellis Coded Modulation (TCM) path. Represents a sequence of nodes that traverse various time instants and
|
||||||
|
* states across a trellis.
|
||||||
|
*
|
||||||
|
* Note: each node can be shared across multiple paths. This class does not assume that any nodes are unique.
|
||||||
|
*
|
||||||
|
* @param original path to create a copy from. Each of the nodes in the original will be added to this path and
|
||||||
|
* after construction both this path and the original will contain the exact same set of nodes.
|
||||||
|
*/
|
||||||
|
private Path(Path original)
|
||||||
|
{
|
||||||
|
for(Node node: original.getNodes())
|
||||||
|
{
|
||||||
|
add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cumulative error across all nodes contained within this path. Error value is updated as each new node is added
|
||||||
|
* to this path.
|
||||||
|
*
|
||||||
|
* @return cumulative error value
|
||||||
|
*/
|
||||||
|
public int getError()
|
||||||
|
{
|
||||||
|
return mError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Length or number of nodes contained within this path. Note: this value includes the starting node and may
|
||||||
|
* also include a flushing node. The values contained in the starting and flushing nodes are normally not used
|
||||||
|
* when decoding a path.
|
||||||
|
*
|
||||||
|
* @return number of nodes in this path
|
||||||
|
*/
|
||||||
|
public int getLength()
|
||||||
|
{
|
||||||
|
return mNodes.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The set of nodes contained in this path.
|
||||||
|
* @return nodes
|
||||||
|
*/
|
||||||
|
public List<Node> getNodes()
|
||||||
|
{
|
||||||
|
return mNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the node to this path and updates the cumulative error value for this path by adding the node's error
|
||||||
|
* value to the running error total.
|
||||||
|
*
|
||||||
|
* @param node to add to this path
|
||||||
|
*/
|
||||||
|
public void add(Node node)
|
||||||
|
{
|
||||||
|
if(!mNodes.isEmpty())
|
||||||
|
{
|
||||||
|
mError += node.getError(getLastNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
mNodes.add(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last node in this path.
|
||||||
|
*
|
||||||
|
* @return last node
|
||||||
|
*/
|
||||||
|
public Node getLastNode()
|
||||||
|
{
|
||||||
|
if(!mNodes.isEmpty())
|
||||||
|
{
|
||||||
|
return mNodes.get(mNodes.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to create an exact copy of this path.
|
||||||
|
*
|
||||||
|
* @return a new copy of this path.
|
||||||
|
*/
|
||||||
|
public Path copyOf()
|
||||||
|
{
|
||||||
|
return new Path(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
226
src/edac/trellis/ViterbiDecoder.java
Normal file
226
src/edac/trellis/ViterbiDecoder.java
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 edac.trellis;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public abstract class ViterbiDecoder
|
||||||
|
{
|
||||||
|
private int mInputBitLength;
|
||||||
|
private int mInputValueCount;
|
||||||
|
private int mOutputBitLength;
|
||||||
|
private int mOutputValueCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Viterbi decoder for trellis coded modulation (TCM) encoded binary sequences.
|
||||||
|
*
|
||||||
|
* @param inputBitLength for coding (e.g. 3/4 rate input bit length is 3)
|
||||||
|
* @param outputBitLength for coding (e.g. 3/4 rate output bit length is 4)
|
||||||
|
*/
|
||||||
|
public ViterbiDecoder(int inputBitLength, int outputBitLength)
|
||||||
|
{
|
||||||
|
mInputBitLength = inputBitLength;
|
||||||
|
mOutputBitLength = outputBitLength;
|
||||||
|
|
||||||
|
mInputValueCount = (int)Math.pow(2.0, mInputBitLength);
|
||||||
|
mOutputValueCount = (int)Math.pow(2.0, mOutputBitLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a node that represents an input value and the actual/transmitted output value.
|
||||||
|
*
|
||||||
|
* Note: this method must be implemented by a sub-class since the node requires a specific state transition
|
||||||
|
* table/matrix implementation.
|
||||||
|
*
|
||||||
|
* @param inputValue for the specific trellis node
|
||||||
|
* @param transmittedOutputValue the actual transmitted output value
|
||||||
|
* @return node for decoding
|
||||||
|
*/
|
||||||
|
protected abstract Node createNode(int inputValue, int transmittedOutputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a flushing or final node that represents an actual/transmitted output value and a flushing input value.
|
||||||
|
*
|
||||||
|
* The final flushing input value is implementation-specific, therefore this will be implemented in any subclass
|
||||||
|
* of this decoder. A normal flushing input value is zero.
|
||||||
|
*
|
||||||
|
* @param transmittedOutputValue the actual transmitted output value
|
||||||
|
* @return flushing node
|
||||||
|
*/
|
||||||
|
protected abstract Node createFlushingNode(int transmittedOutputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a starting node that represents a starting state and notional transmitted output value.
|
||||||
|
*
|
||||||
|
* The starting input value is implementation-specific, therefore this will be implemented in any subclass
|
||||||
|
* of this decoder. A normal starting input value is zero.
|
||||||
|
*
|
||||||
|
* @return starting node
|
||||||
|
*/
|
||||||
|
protected abstract Node createStartingNode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size in bits of the input and state values (e.g. 3/4 rate input size is 3)
|
||||||
|
*
|
||||||
|
* @return input bit size
|
||||||
|
*/
|
||||||
|
public int getInputBitLength()
|
||||||
|
{
|
||||||
|
return mInputBitLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count of input or state values where the set of values is in the range of 0 <> count - 1
|
||||||
|
*
|
||||||
|
* @return input or state values count
|
||||||
|
*/
|
||||||
|
public int getInputValueCount()
|
||||||
|
{
|
||||||
|
return mInputValueCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size in bits of the output constellation or transmitted symbol value (e.g. 3/4 rate output size is 4)
|
||||||
|
*
|
||||||
|
* @return output size in bits
|
||||||
|
*/
|
||||||
|
public int getOutputBitLength()
|
||||||
|
{
|
||||||
|
return mOutputBitLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count of input or state values where the set of values is in the range of 0 <> count - 1
|
||||||
|
*
|
||||||
|
* @return input or state values count
|
||||||
|
*/
|
||||||
|
public int getOutputValueCount()
|
||||||
|
{
|
||||||
|
return mOutputValueCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes the TCM encoded transmitted output values and returns a path the represents the most likely transmitted
|
||||||
|
* sequence of nodes.
|
||||||
|
*
|
||||||
|
* @param transmittedOutputValues from the encoded message
|
||||||
|
* @return most likely path representing the transmitted values
|
||||||
|
*/
|
||||||
|
public Path decode(int[] transmittedOutputValues)
|
||||||
|
{
|
||||||
|
Collection<Path> survivingPaths = new ArrayList<>();
|
||||||
|
|
||||||
|
survivingPaths.add(new Path(createStartingNode()));
|
||||||
|
|
||||||
|
//Add all but the last transmitted value to the starting path, creating a set of survivors at each iteration.
|
||||||
|
for(int x = 0; x < transmittedOutputValues.length - 1; x++)
|
||||||
|
{
|
||||||
|
survivingPaths = add(survivingPaths, transmittedOutputValues[x]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Flush the survivors with the final transmitted value and return the lone surviving path
|
||||||
|
return flush(survivingPaths, transmittedOutputValues[transmittedOutputValues.length - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a set of new nodes representing all possible input values and the transmitted output value argument
|
||||||
|
* and iteratively adds the set of nodes to a copy of each of the surviving paths. A set of surviving paths is
|
||||||
|
* returned that represents each path that terminates at a distinct input/state value that has the least error
|
||||||
|
* value.
|
||||||
|
*
|
||||||
|
* @param survivingPaths from the previous time instant to evaluate for the next time instant in the trellis
|
||||||
|
* using the transmitted output value.
|
||||||
|
*
|
||||||
|
* @param transmittedOutputValue that will be decoded for this time instant.
|
||||||
|
*
|
||||||
|
* @return paths that have survived (ie have the lowest error value) after adding nodes for the transmitted
|
||||||
|
* output value
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Collection<Path> add(Collection<Path> survivingPaths, int transmittedOutputValue)
|
||||||
|
{
|
||||||
|
Map<Integer,Path> survivingPathMap = new HashMap<>();
|
||||||
|
|
||||||
|
for(int x = 0; x < getInputValueCount(); x++)
|
||||||
|
{
|
||||||
|
//Create a single/unique node for each possible input value combined with the transmitted output value
|
||||||
|
Node node = createNode(x, transmittedOutputValue);
|
||||||
|
|
||||||
|
//Evaluate each surviving path by creating a copy and adding the node to it and see if it survives
|
||||||
|
for(Path path: survivingPaths)
|
||||||
|
{
|
||||||
|
Path pathToEvaluate = path.copyOf();
|
||||||
|
|
||||||
|
pathToEvaluate.add(node);
|
||||||
|
|
||||||
|
if(survivingPathMap.containsKey(node.getInputValue()))
|
||||||
|
{
|
||||||
|
Path survivingPath = survivingPathMap.get(node.getInputValue());
|
||||||
|
|
||||||
|
//Replace the current survivor path if this evaluate path has a lower error value
|
||||||
|
if(pathToEvaluate.getError() < survivingPath.getError())
|
||||||
|
{
|
||||||
|
survivingPathMap.put(node.getInputValue(), pathToEvaluate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//No survivor yet -- set this evaluate path as the first survivor
|
||||||
|
survivingPathMap.put(node.getInputValue(), pathToEvaluate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return survivingPathMap.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flushes each of the surviving paths with a final/flushing node using the transmitted symbol. A final flushing
|
||||||
|
* input value or state is implementation-specific, but normally uses a value of zero. Since all paths will be
|
||||||
|
* evaluated against each other as terminating at the same state, only the path with the lowest error value will
|
||||||
|
* be returned from this method.
|
||||||
|
*
|
||||||
|
* @param survivingPaths to flush with the final flushing node
|
||||||
|
* @param transmittedOutputValue to use for the final flushing node
|
||||||
|
*
|
||||||
|
* @return the single survivor path that remains after adding the flushing node to each of the candidate argument
|
||||||
|
* survivor paths.
|
||||||
|
*/
|
||||||
|
public Path flush(Collection<Path> survivingPaths, int transmittedOutputValue)
|
||||||
|
{
|
||||||
|
Node flushingNode = createFlushingNode(transmittedOutputValue);
|
||||||
|
|
||||||
|
Path bestPath = null;
|
||||||
|
|
||||||
|
for(Path survivingPath: survivingPaths)
|
||||||
|
{
|
||||||
|
survivingPath.add(flushingNode);
|
||||||
|
|
||||||
|
if(bestPath == null || (survivingPath.getError() < bestPath.getError()))
|
||||||
|
{
|
||||||
|
bestPath = survivingPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
159
src/edac/trellis/ViterbiDecoder_3_4_DMR.java
Normal file
159
src/edac/trellis/ViterbiDecoder_3_4_DMR.java
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 edac.trellis;
|
||||||
|
|
||||||
|
import bits.BinaryMessage;
|
||||||
|
import bits.CorrectedBinaryMessage;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ViterbiDecoder_3_4_DMR extends ViterbiDecoder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Viterbi decoder for Digital Mobile Radio (DMR) 3/4 rate Trellis Coded Modulation (TCM) encoded messages.
|
||||||
|
*/
|
||||||
|
public ViterbiDecoder_3_4_DMR()
|
||||||
|
{
|
||||||
|
super(3,4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a 3/4 rate trellis coded modulation (TCM) encoded DMR binary message containing 196 bits that have
|
||||||
|
* already been deinterleaved.
|
||||||
|
*
|
||||||
|
* @param encodedMessage to decode that has already been deinterleaved.
|
||||||
|
* @return decoded message
|
||||||
|
*/
|
||||||
|
public BinaryMessage decode(BinaryMessage encodedMessage)
|
||||||
|
{
|
||||||
|
int[] symbols = getSymbols(encodedMessage);
|
||||||
|
|
||||||
|
Path mostLikelyPath = decode(symbols);
|
||||||
|
|
||||||
|
return getMessage(mostLikelyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the decoded/corrected message from the surviving path argument.
|
||||||
|
*
|
||||||
|
* @param path to extract a message from
|
||||||
|
* @return corrected binary message.
|
||||||
|
*/
|
||||||
|
private static CorrectedBinaryMessage getMessage(Path path)
|
||||||
|
{
|
||||||
|
List<Node> mNodes = path.getNodes();
|
||||||
|
|
||||||
|
//Each node contains an input value excluding the starting(0) and final flushing(0) nodes.
|
||||||
|
CorrectedBinaryMessage message = new CorrectedBinaryMessage((mNodes.size() - 2) * 3);
|
||||||
|
|
||||||
|
if(mNodes.size() > 2)
|
||||||
|
{
|
||||||
|
for(int x = 1; x < mNodes.size() - 1; x++)
|
||||||
|
{
|
||||||
|
int inputValue = mNodes.get(x).getInputValue();
|
||||||
|
|
||||||
|
int messageOffset = 3 * (x - 1);
|
||||||
|
|
||||||
|
if((inputValue & 4) == 4)
|
||||||
|
{
|
||||||
|
message.set(messageOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((inputValue & 2) == 2)
|
||||||
|
{
|
||||||
|
message.set(messageOffset + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((inputValue & 1) == 1)
|
||||||
|
{
|
||||||
|
message.set(messageOffset + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Transfer the corrected error count to the message
|
||||||
|
message.setCorrectedBitCount(path.getError());
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts (49) four-bit symbols (196 bits / 4) from the deinterleaved DMR binary message
|
||||||
|
*
|
||||||
|
* @param encodedMessage that deinterleaved and contains 196-bits of 3/4 TCM encoding
|
||||||
|
* @return symbols
|
||||||
|
*/
|
||||||
|
public int[] getSymbols(BinaryMessage encodedMessage)
|
||||||
|
{
|
||||||
|
//Ensure we have an integral number of transmitted symbols (nibbles) in the message
|
||||||
|
if(encodedMessage.size() % getOutputBitLength() != 0)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Encoded message must contain an integral number of 4-bit symbols -" +
|
||||||
|
" message size: " + encodedMessage.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] symbols = new int[encodedMessage.size() / getOutputBitLength()];
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
int pointer = 0;
|
||||||
|
|
||||||
|
while(index < encodedMessage.size())
|
||||||
|
{
|
||||||
|
int symbol = encodedMessage.getInt(index, index + (getOutputBitLength() - 1));
|
||||||
|
symbols[pointer++] = symbol;
|
||||||
|
index += getOutputBitLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
return symbols;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a DMR node
|
||||||
|
* @param inputValue for the specific trellis node
|
||||||
|
* @param transmittedOutputValue the actual transmitted output value
|
||||||
|
* @return created node
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Node createNode(int inputValue, int transmittedOutputValue)
|
||||||
|
{
|
||||||
|
return new DMRNode(inputValue, transmittedOutputValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a DMR flushing node. DMR uses an input value of zero to flush the final output value out of the
|
||||||
|
* encoder.
|
||||||
|
*
|
||||||
|
* @param transmittedOutputValue the actual transmitted output value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Node createFlushingNode(int transmittedOutputValue)
|
||||||
|
{
|
||||||
|
return new DMRNode(0, transmittedOutputValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a DMR starting node. DMR uses a starting input value of zero for the initial node.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Node createStartingNode()
|
||||||
|
{
|
||||||
|
return new DMRNode(0,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -151,41 +151,4 @@ public class RadioReferenceService
|
|||||||
|
|
||||||
return mClient.getUserFeedBroadcasts(mUserAuthorization);
|
return mClient.getUserFeedBroadcasts(mUserAuthorization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
RadioReferenceService service = new RadioReferenceService("dsheirer", "1dodgeram");
|
|
||||||
|
|
||||||
Long expiration = service.getAccountExpirationDate();
|
|
||||||
|
|
||||||
mLog.debug("Expiration Date:" + (expiration != null ? new Date(expiration).toString() : "unknown"));
|
|
||||||
|
|
||||||
mLog.debug("Is Active: " + service.isAccountActive());
|
|
||||||
|
|
||||||
UserFeedBroadcast[] feeds = service.getUserFeedBroadcasts();
|
|
||||||
|
|
||||||
for(UserFeedBroadcast feed: feeds)
|
|
||||||
{
|
|
||||||
mLog.debug("Feed ID: " + feed.getFeedId() + " Desc:" + feed.getDescr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(AxisFault af)
|
|
||||||
{
|
|
||||||
mLog.debug("Hey, I caught an axis fault!");
|
|
||||||
mLog.debug("Reason:" + af.getFaultReason());
|
|
||||||
}
|
|
||||||
catch(RemoteException re)
|
|
||||||
{
|
|
||||||
re.printStackTrace();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
mLog.debug("Finished!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import icon.IconManager;
|
|||||||
import map.MapService;
|
import map.MapService;
|
||||||
import module.log.EventLogManager;
|
import module.log.EventLogManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import playlist.PlaylistManager;
|
import playlist.PlaylistManager;
|
||||||
@@ -80,16 +81,16 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
|
|
||||||
public SDRTrunk()
|
public SDRTrunk()
|
||||||
{
|
{
|
||||||
mLog.info("");
|
|
||||||
mLog.info("*******************************************************************");
|
mLog.info("*******************************************************************");
|
||||||
mLog.info("**** sdrtrunk: a trunked radio and digital decoding application ***");
|
mLog.info("**** sdrtrunk: a trunked radio and digital decoding application ***");
|
||||||
mLog.info("**** website: https://github.com/dsheirer/sdrtrunk ***");
|
mLog.info("**** website: https://github.com/dsheirer/sdrtrunk ***");
|
||||||
mLog.info("*******************************************************************");
|
mLog.info("*******************************************************************");
|
||||||
mLog.info("");
|
mLog.info("Memory Logging Format: [Used/Allocated PercentUsed%]");
|
||||||
mLog.info("Host CPU Cores: " + Runtime.getRuntime().availableProcessors());
|
mLog.info("Host CPU Cores: " + Runtime.getRuntime().availableProcessors());
|
||||||
mLog.info("Host Memory Total: " + Runtime.getRuntime().totalMemory());
|
mLog.info("Host OS Name: " + System.getProperty("os.name"));
|
||||||
mLog.info("Host Memory Max: " + Runtime.getRuntime().maxMemory());
|
mLog.info("Host OS Arch: " + System.getProperty("os.arch"));
|
||||||
mLog.info("Host Memory Free: " + Runtime.getRuntime().freeMemory());
|
mLog.info("Host OS Version: " + System.getProperty("os.version"));
|
||||||
|
mLog.info("Host Max Java Memory: " + FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory()));
|
||||||
|
|
||||||
//Setup the application home directory
|
//Setup the application home directory
|
||||||
Path home = getHomePath();
|
Path home = getHomePath();
|
||||||
|
|||||||
@@ -1,21 +1,38 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 instrument;
|
package instrument;
|
||||||
|
|
||||||
|
import controller.channel.Channel.ChannelType;
|
||||||
import instrument.tap.Tap;
|
import instrument.tap.Tap;
|
||||||
import instrument.tap.TapGroup;
|
import instrument.tap.TapGroup;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import module.Module;
|
import module.Module;
|
||||||
import module.ProcessingChain;
|
import module.ProcessingChain;
|
||||||
import source.Source;
|
import source.Source;
|
||||||
import controller.channel.Channel.ChannelType;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class InstrumentableProcessingChain extends ProcessingChain implements Instrumentable
|
public class InstrumentableProcessingChain extends ProcessingChain implements Instrumentable
|
||||||
{
|
{
|
||||||
public InstrumentableProcessingChain()
|
public InstrumentableProcessingChain()
|
||||||
{
|
{
|
||||||
super( "instrumented", ChannelType.STANDARD );
|
super(ChannelType.STANDARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(Source source) throws IllegalStateException
|
public void setSource(Source source) throws IllegalStateException
|
||||||
|
|||||||
@@ -24,16 +24,17 @@ import audio.IAudioPacketProvider;
|
|||||||
import audio.squelch.ISquelchStateListener;
|
import audio.squelch.ISquelchStateListener;
|
||||||
import audio.squelch.ISquelchStateProvider;
|
import audio.squelch.ISquelchStateProvider;
|
||||||
import audio.squelch.SquelchState;
|
import audio.squelch.SquelchState;
|
||||||
|
import channel.heartbeat.Heartbeat;
|
||||||
|
import channel.heartbeat.IHeartbeatListener;
|
||||||
|
import channel.heartbeat.IHeartbeatProvider;
|
||||||
import channel.metadata.AttributeChangeRequest;
|
import channel.metadata.AttributeChangeRequest;
|
||||||
import channel.metadata.IAttributeChangeRequestListener;
|
import channel.metadata.IAttributeChangeRequestListener;
|
||||||
import channel.metadata.IAttributeChangeRequestProvider;
|
import channel.metadata.IAttributeChangeRequestProvider;
|
||||||
import channel.state.ChannelState;
|
import channel.state.ChannelState;
|
||||||
import channel.state.DecoderState;
|
import channel.state.DecoderState;
|
||||||
import channel.state.DecoderStateEvent;
|
import channel.state.DecoderStateEvent;
|
||||||
import channel.state.DecoderStateEvent.Event;
|
|
||||||
import channel.state.IDecoderStateEventListener;
|
import channel.state.IDecoderStateEventListener;
|
||||||
import channel.state.IDecoderStateEventProvider;
|
import channel.state.IDecoderStateEventProvider;
|
||||||
import channel.state.State;
|
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import controller.channel.ChannelEvent;
|
import controller.channel.ChannelEvent;
|
||||||
import controller.channel.IChannelEventListener;
|
import controller.channel.IChannelEventListener;
|
||||||
@@ -63,8 +64,6 @@ import sample.real.RealBuffer;
|
|||||||
import source.ComplexSource;
|
import source.ComplexSource;
|
||||||
import source.RealSource;
|
import source.RealSource;
|
||||||
import source.Source;
|
import source.Source;
|
||||||
import source.SourceException;
|
|
||||||
import source.tuner.TunerChannelSource;
|
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
import source.tuner.frequency.IFrequencyChangeListener;
|
||||||
import source.tuner.frequency.IFrequencyChangeProvider;
|
import source.tuner.frequency.IFrequencyChangeProvider;
|
||||||
@@ -103,12 +102,12 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
private Broadcaster<ComplexBuffer> mComplexBufferBroadcaster = new Broadcaster<>();
|
private Broadcaster<ComplexBuffer> mComplexBufferBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<DecoderStateEvent> mDecoderStateEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<DecoderStateEvent> mDecoderStateEventBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<FrequencyChangeEvent> mFrequencyChangeEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<FrequencyChangeEvent> mFrequencyChangeEventBroadcaster = new Broadcaster<>();
|
||||||
|
private Broadcaster<Heartbeat> mHeartbeatBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<Message> mMessageBroadcaster = new Broadcaster<>();
|
private Broadcaster<Message> mMessageBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<RealBuffer> mFilteredRealBufferBroadcaster = new Broadcaster<>();
|
private Broadcaster<RealBuffer> mFilteredRealBufferBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<RealBuffer> mUnFilteredRealBufferBroadcaster = new Broadcaster<>();
|
private Broadcaster<RealBuffer> mUnFilteredRealBufferBroadcaster = new Broadcaster<>();
|
||||||
private Broadcaster<SquelchState> mSquelchStateBroadcaster = new Broadcaster<>();
|
private Broadcaster<SquelchState> mSquelchStateBroadcaster = new Broadcaster<>();
|
||||||
|
|
||||||
private String mName;
|
|
||||||
private AtomicBoolean mRunning = new AtomicBoolean();
|
private AtomicBoolean mRunning = new AtomicBoolean();
|
||||||
|
|
||||||
protected Source mSource;
|
protected Source mSource;
|
||||||
@@ -120,13 +119,10 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
/**
|
/**
|
||||||
* Creates a processing chain for managing a set of modules
|
* Creates a processing chain for managing a set of modules
|
||||||
*
|
*
|
||||||
* @param name for thread pool naming each thread
|
|
||||||
* @param channelType
|
* @param channelType
|
||||||
*/
|
*/
|
||||||
public ProcessingChain(String name, ChannelType channelType)
|
public ProcessingChain(ChannelType channelType)
|
||||||
{
|
{
|
||||||
mName = name;
|
|
||||||
|
|
||||||
mChannelState = new ChannelState(channelType);
|
mChannelState = new ChannelState(channelType);
|
||||||
addModule(mChannelState);
|
addModule(mChannelState);
|
||||||
|
|
||||||
@@ -211,6 +207,8 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
mSource = source;
|
mSource = source;
|
||||||
|
|
||||||
|
addModule(mSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -322,7 +320,18 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
|
|
||||||
if(module instanceof IFrequencyChangeListener)
|
if(module instanceof IFrequencyChangeListener)
|
||||||
{
|
{
|
||||||
mFrequencyChangeEventBroadcaster.addListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
Listener<FrequencyChangeEvent> frequencyChangeEventListener =
|
||||||
|
((IFrequencyChangeListener)module).getFrequencyChangeListener();
|
||||||
|
|
||||||
|
if(frequencyChangeEventListener != null)
|
||||||
|
{
|
||||||
|
mFrequencyChangeEventBroadcaster.addListener(frequencyChangeEventListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(module instanceof IHeartbeatListener)
|
||||||
|
{
|
||||||
|
mHeartbeatBroadcaster.addListener(((IHeartbeatListener)module).getHeartbeatListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageListener)
|
if(module instanceof IMessageListener)
|
||||||
@@ -387,6 +396,11 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
mFrequencyChangeEventBroadcaster.removeListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
mFrequencyChangeEventBroadcaster.removeListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(module instanceof IHeartbeatListener)
|
||||||
|
{
|
||||||
|
mHeartbeatBroadcaster.removeListener(((IHeartbeatListener)module).getHeartbeatListener());
|
||||||
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageListener)
|
if(module instanceof IMessageListener)
|
||||||
{
|
{
|
||||||
mMessageBroadcaster.removeListener(((IMessageListener) module).getMessageListener());
|
mMessageBroadcaster.removeListener(((IMessageListener) module).getMessageListener());
|
||||||
@@ -444,6 +458,11 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
((IFrequencyChangeProvider) module).setFrequencyChangeListener(mFrequencyChangeEventBroadcaster);
|
((IFrequencyChangeProvider) module).setFrequencyChangeListener(mFrequencyChangeEventBroadcaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(module instanceof IHeartbeatProvider)
|
||||||
|
{
|
||||||
|
((IHeartbeatProvider)module).setHeartbeatListener(mHeartbeatBroadcaster);
|
||||||
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageProvider)
|
if(module instanceof IMessageProvider)
|
||||||
{
|
{
|
||||||
((IMessageProvider) module).setMessageListener(mMessageBroadcaster);
|
((IMessageProvider) module).setMessageListener(mMessageBroadcaster);
|
||||||
@@ -501,6 +520,11 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
((IFrequencyChangeProvider) module).setFrequencyChangeListener(null);
|
((IFrequencyChangeProvider) module).setFrequencyChangeListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(module instanceof IHeartbeatProvider)
|
||||||
|
{
|
||||||
|
((IHeartbeatProvider)module).removeHeartbeatListener();
|
||||||
|
}
|
||||||
|
|
||||||
if(module instanceof IMessageProvider)
|
if(module instanceof IMessageProvider)
|
||||||
{
|
{
|
||||||
((IMessageProvider) module).setMessageListener(null);
|
((IMessageProvider) module).setMessageListener(null);
|
||||||
@@ -557,25 +581,6 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
+ "sample type - cannot start processing chain");
|
+ "sample type - cannot start processing chain");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this is a tuner source, broadcast the frequency to all
|
|
||||||
* of the decoder state's and start the samples flowing */
|
|
||||||
if(mSource instanceof TunerChannelSource)
|
|
||||||
{
|
|
||||||
TunerChannelSource tcs = (TunerChannelSource) mSource;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
long frequency = tcs.getFrequency();
|
|
||||||
|
|
||||||
mDecoderStateEventBroadcaster.broadcast(
|
|
||||||
new DecoderStateEvent(this, Event.SOURCE_FREQUENCY, State.IDLE, frequency));
|
|
||||||
}
|
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
mLog.error("Error getting frequency from tuner channel source", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Start each of the modules */
|
/* Start each of the modules */
|
||||||
for(Module module : mModules)
|
for(Module module : mModules)
|
||||||
{
|
{
|
||||||
@@ -588,8 +593,6 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
mLog.error("Error starting module", e);
|
mLog.error("Error starting module", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mSource.start(ThreadPool.SCHEDULED);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -606,9 +609,16 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
{
|
{
|
||||||
if(mRunning.compareAndSet(true, false))
|
if(mRunning.compareAndSet(true, false))
|
||||||
{
|
{
|
||||||
|
/* Stop each of the modules */
|
||||||
|
for(Module module : mModules)
|
||||||
|
{
|
||||||
|
module.stop();
|
||||||
|
}
|
||||||
|
|
||||||
if(mSource != null)
|
if(mSource != null)
|
||||||
{
|
{
|
||||||
mSource.stop();
|
removeModule(mSource);
|
||||||
|
|
||||||
mSource.setOverflowListener(null);
|
mSource.setOverflowListener(null);
|
||||||
|
|
||||||
switch(mSource.getSampleType())
|
switch(mSource.getSampleType())
|
||||||
@@ -629,11 +639,6 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
mSource = null;
|
mSource = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop each of the modules */
|
|
||||||
for(Module module : mModules)
|
|
||||||
{
|
|
||||||
module.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,6 +765,24 @@ public class ProcessingChain implements IChannelEventListener
|
|||||||
mMessageBroadcaster.removeListener(listener);
|
mMessageBroadcaster.removeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the listener to receive frequency change events from the processing chain
|
||||||
|
* @param listener to receive events
|
||||||
|
*/
|
||||||
|
public void addFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
||||||
|
{
|
||||||
|
mFrequencyChangeEventBroadcaster.addListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the listener from receiving frequency change events
|
||||||
|
* @param listener to remove
|
||||||
|
*/
|
||||||
|
public void removeFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
||||||
|
{
|
||||||
|
mFrequencyChangeEventBroadcaster.removeListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the listener to receive call events from all modules.
|
* Adds the listener to receive call events from all modules.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ public class DecoderFactory
|
|||||||
|
|
||||||
if(channelType == ChannelType.STANDARD)
|
if(channelType == ChannelType.STANDARD)
|
||||||
{
|
{
|
||||||
modules.add(new TrafficChannelManager(channelModel, channelProcessingManager, decodeConfig,
|
modules.add(new TrafficChannelManager(channelModel, decodeConfig,
|
||||||
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
|
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
|
||||||
(aliasList != null ? aliasList.getName() : null), mptConfig.getTrafficChannelPoolSize()));
|
(aliasList != null ? aliasList.getName() : null), mptConfig.getTrafficChannelPoolSize()));
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,7 @@ public class DecoderFactory
|
|||||||
|
|
||||||
if(channelType == ChannelType.STANDARD)
|
if(channelType == ChannelType.STANDARD)
|
||||||
{
|
{
|
||||||
modules.add(new TrafficChannelManager(channelModel, channelProcessingManager, decodeConfig,
|
modules.add(new TrafficChannelManager(channelModel, decodeConfig,
|
||||||
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
|
channel.getRecordConfiguration(), channel.getSystem(), channel.getSite(),
|
||||||
(aliasList != null ? aliasList.getName() : null), p25Config.getTrafficChannelPoolSize()));
|
(aliasList != null ? aliasList.getName() : null), p25Config.getTrafficChannelPoolSize()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class LJ1200DecoderState extends DecoderState
|
|||||||
super(aliasList);
|
super(aliasList);
|
||||||
|
|
||||||
mAddressAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_TO,
|
mAddressAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_TO,
|
||||||
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.LOJACK);
|
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.SITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,19 +9,19 @@ import instrument.tap.stream.FloatTap;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.real.RealBuffer;
|
import sample.real.RealBuffer;
|
||||||
import sample.real.RealSampleListener;
|
import sample.real.RealSampleListener;
|
||||||
import sample.real.RealSampleProvider;
|
import sample.real.RealSampleProvider;
|
||||||
|
import source.tuner.TunerChannelSource;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
||||||
import source.tuner.frequency.IFrequencyChangeListener;
|
import source.tuner.frequency.IFrequencyChangeListener;
|
||||||
import dsp.gain.DirectGainControl;
|
import dsp.gain.DirectGainControl;
|
||||||
|
|
||||||
public class C4FMSymbolFilter implements Listener<RealBuffer>,
|
public class C4FMSymbolFilter implements Listener<RealBuffer>, IFrequencyChangeListener, RealSampleProvider, Instrumentable
|
||||||
IFrequencyChangeListener,
|
|
||||||
RealSampleProvider,
|
|
||||||
Instrumentable
|
|
||||||
{
|
{
|
||||||
private static final float TAPS[][] =
|
private static final float TAPS[][] =
|
||||||
{
|
{
|
||||||
@@ -198,8 +198,7 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>,
|
|||||||
|
|
||||||
private RealSampleListener mListener;
|
private RealSampleListener mListener;
|
||||||
|
|
||||||
private DirectGainControl mGainController =
|
private DirectGainControl mGainController = new DirectGainControl( 15.0f, 0.1f, 35.0f, 0.3f );
|
||||||
new DirectGainControl( 15.0f, 0.1f, 35.0f, 0.3f );
|
|
||||||
|
|
||||||
private int mFrequencyAdjustmentRequested = 0;
|
private int mFrequencyAdjustmentRequested = 0;
|
||||||
private int mFrequencyCorrection = 0;
|
private int mFrequencyCorrection = 0;
|
||||||
@@ -258,8 +257,7 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>,
|
|||||||
correction = -mFrequencyCorrectionMaximum;
|
correction = -mFrequencyCorrectionMaximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcast( new FrequencyChangeEvent(
|
broadcast( new FrequencyChangeEvent(Event.REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE, correction ) );
|
||||||
Event.REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE, correction ) );
|
|
||||||
|
|
||||||
mFrequencyAdjustmentRequested = 0;
|
mFrequencyAdjustmentRequested = 0;
|
||||||
}
|
}
|
||||||
@@ -452,6 +450,10 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts a frequency change event to the registered listener
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
public void broadcast( FrequencyChangeEvent event )
|
public void broadcast( FrequencyChangeEvent event )
|
||||||
{
|
{
|
||||||
if( mFrequencyChangeListener != null )
|
if( mFrequencyChangeListener != null )
|
||||||
@@ -460,6 +462,10 @@ public class C4FMSymbolFilter implements Listener<RealBuffer>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the listener for frequency change events.
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener )
|
public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener )
|
||||||
{
|
{
|
||||||
mFrequencyChangeListener = listener;
|
mFrequencyChangeListener = listener;
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import alias.AliasList;
|
|||||||
import instrument.Instrumentable;
|
import instrument.Instrumentable;
|
||||||
import module.decode.Decoder;
|
import module.decode.Decoder;
|
||||||
import module.decode.DecoderType;
|
import module.decode.DecoderType;
|
||||||
|
import source.tuner.frequency.IFrequencyChangeListener;
|
||||||
|
import source.tuner.frequency.IFrequencyChangeProvider;
|
||||||
|
|
||||||
public abstract class P25Decoder extends Decoder implements Instrumentable
|
public abstract class P25Decoder extends Decoder implements IFrequencyChangeListener, IFrequencyChangeProvider, Instrumentable
|
||||||
{
|
{
|
||||||
private P25MessageProcessor mMessageProcessor;
|
private P25MessageProcessor mMessageProcessor;
|
||||||
|
|
||||||
|
|||||||
@@ -315,6 +315,8 @@ public class P25DecoderState extends DecoderState
|
|||||||
*/
|
*/
|
||||||
public void registerCallEvent(P25CallEvent event)
|
public void registerCallEvent(P25CallEvent event)
|
||||||
{
|
{
|
||||||
|
String channel = event.getChannel();
|
||||||
|
|
||||||
if(mChannelCallMap.containsKey(event.getChannel()))
|
if(mChannelCallMap.containsKey(event.getChannel()))
|
||||||
{
|
{
|
||||||
P25CallEvent previousEvent = mChannelCallMap.remove(event.getChannel());
|
P25CallEvent previousEvent = mChannelCallMap.remove(event.getChannel());
|
||||||
@@ -419,7 +421,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
mCurrentCallEvent = new P25CallEvent.Builder(CallEventType.CALL)
|
mCurrentCallEvent = new P25CallEvent.Builder(CallEventType.CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(mCurrentChannel)
|
.channel(mCurrentChannel)
|
||||||
.details((hdu.isEncrypted() ? "ENCRYPTED " : ""))
|
.details((hdu.isEncryptedAudio() ? "ENCRYPTED " : ""))
|
||||||
.frequency(mCurrentChannelFrequency)
|
.frequency(mCurrentChannelFrequency)
|
||||||
.to(to)
|
.to(to)
|
||||||
.build();
|
.build();
|
||||||
@@ -1105,7 +1107,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
broadcast(new P25CallEvent.Builder(CallEventType.CALL_DETECT)
|
broadcast(new P25CallEvent.Builder(CallEventType.CALL_DETECT)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(gvcu.getChannelA())
|
.channel(gvcu.getChannelA())
|
||||||
.details((gvcu.isEncrypted() ? "ENCRYPTED" : ""))
|
.details((gvcu.isEncryptedLinkControlWord() ? "ENCRYPTED" : ""))
|
||||||
.frequency(gvcu.getDownlinkFrequencyA())
|
.frequency(gvcu.getDownlinkFrequencyA())
|
||||||
.to(userA)
|
.to(userA)
|
||||||
.build());
|
.build());
|
||||||
@@ -1120,7 +1122,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
broadcast(new P25CallEvent.Builder(CallEventType.CALL_DETECT)
|
broadcast(new P25CallEvent.Builder(CallEventType.CALL_DETECT)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(gvcu.getChannelB())
|
.channel(gvcu.getChannelB())
|
||||||
.details((gvcu.isEncrypted() ? "ENCRYPTED" : ""))
|
.details((gvcu.isEncryptedLinkControlWord() ? "ENCRYPTED" : ""))
|
||||||
.frequency(gvcu.getDownlinkFrequencyB())
|
.frequency(gvcu.getDownlinkFrequencyB())
|
||||||
.to(userB)
|
.to(userB)
|
||||||
.build());
|
.build());
|
||||||
@@ -1149,7 +1151,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
broadcast(new P25CallEvent.Builder(CallEventType.CALL_DETECT)
|
broadcast(new P25CallEvent.Builder(CallEventType.CALL_DETECT)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(gvcue.getTransmitChannel())
|
.channel(gvcue.getTransmitChannel())
|
||||||
.details((gvcue.isEncrypted() ? "ENCRYPTED" : ""))
|
.details((gvcue.isEncryptedLinkControlWord() ? "ENCRYPTED" : ""))
|
||||||
.frequency(gvcue.getDownlinkFrequency())
|
.frequency(gvcue.getDownlinkFrequency())
|
||||||
.to(group)
|
.to(group)
|
||||||
.build());
|
.build());
|
||||||
@@ -1185,7 +1187,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
if(mCurrentCallEvent.getDetails() == null)
|
if(mCurrentCallEvent.getDetails() == null)
|
||||||
{
|
{
|
||||||
mCurrentCallEvent.setDetails(
|
mCurrentCallEvent.setDetails(
|
||||||
(gvcuser.isEncrypted() ? "ENCRYPTED " : "") +
|
(gvcuser.isEncryptedLinkControlWord() ? "ENCRYPTED " : "") +
|
||||||
(gvcuser.isEmergency() ? "EMERGENCY " : ""));
|
(gvcuser.isEmergency() ? "EMERGENCY " : ""));
|
||||||
|
|
||||||
broadcast(mCurrentCallEvent);
|
broadcast(mCurrentCallEvent);
|
||||||
@@ -1397,7 +1399,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
if(mCurrentCallEvent.getDetails() == null)
|
if(mCurrentCallEvent.getDetails() == null)
|
||||||
{
|
{
|
||||||
mCurrentCallEvent.setDetails(
|
mCurrentCallEvent.setDetails(
|
||||||
(tivcu.isEncrypted() ? "ENCRYPTED " : "") +
|
(tivcu.isEncryptedLinkControlWord() ? "ENCRYPTED " : "") +
|
||||||
(tivcu.isEmergency() ? "EMERGENCY " : ""));
|
(tivcu.isEmergency() ? "EMERGENCY " : ""));
|
||||||
|
|
||||||
broadcast(mCurrentCallEvent);
|
broadcast(mCurrentCallEvent);
|
||||||
@@ -1480,7 +1482,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
if(mCurrentCallEvent.getDetails() == null)
|
if(mCurrentCallEvent.getDetails() == null)
|
||||||
{
|
{
|
||||||
mCurrentCallEvent.setDetails(
|
mCurrentCallEvent.setDetails(
|
||||||
(uuvcu.isEncrypted() ? "ENCRYPTED " : "") +
|
(uuvcu.isEncryptedLinkControlWord() ? "ENCRYPTED " : "") +
|
||||||
(uuvcu.isEmergency() ? "EMERGENCY " : ""));
|
(uuvcu.isEmergency() ? "EMERGENCY " : ""));
|
||||||
|
|
||||||
broadcast(mCurrentCallEvent);
|
broadcast(mCurrentCallEvent);
|
||||||
@@ -1557,6 +1559,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
break;
|
break;
|
||||||
case IDENTIFIER_UPDATE_NON_VUHF:
|
case IDENTIFIER_UPDATE_NON_VUHF:
|
||||||
case IDENTIFIER_UPDATE_VHF_UHF_BANDS:
|
case IDENTIFIER_UPDATE_VHF_UHF_BANDS:
|
||||||
|
case IDENTIFIER_UPDATE_TDMA:
|
||||||
IdentifierUpdate iu = (IdentifierUpdate)tsbk;
|
IdentifierUpdate iu = (IdentifierUpdate)tsbk;
|
||||||
|
|
||||||
if(!mBands.containsKey(iu.getIdentifier()))
|
if(!mBands.containsKey(iu.getIdentifier()))
|
||||||
@@ -1710,6 +1713,8 @@ public class P25DecoderState extends DecoderState
|
|||||||
.build());
|
.build());
|
||||||
break;
|
break;
|
||||||
case SNDCP_RF_CONFIRMED_DATA:
|
case SNDCP_RF_CONFIRMED_DATA:
|
||||||
|
if(pduc instanceof SNDCPUserData)
|
||||||
|
{
|
||||||
SNDCPUserData sud = (SNDCPUserData)pduc;
|
SNDCPUserData sud = (SNDCPUserData)pduc;
|
||||||
|
|
||||||
StringBuilder sbFrom = new StringBuilder();
|
StringBuilder sbFrom = new StringBuilder();
|
||||||
@@ -1737,6 +1742,12 @@ public class P25DecoderState extends DecoderState
|
|||||||
.from(sbFrom.toString())
|
.from(sbFrom.toString())
|
||||||
.to(pduc.getLogicalLinkID())
|
.to(pduc.getLogicalLinkID())
|
||||||
.build());
|
.build());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLog.error("Error - expected SNDCPUserData instance but class was: " + pduc.getClass() +
|
||||||
|
" and PDU Type:" + pduc.getPDUType().name());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SNDCP_RF_UNCONFIRMED_DATA:
|
case SNDCP_RF_UNCONFIRMED_DATA:
|
||||||
break;
|
break;
|
||||||
@@ -2735,6 +2746,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(pgvcg.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(pgvcg.isEmergency() ? "EMERGENCY " : "");
|
details.append(pgvcg.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(pgvcg.getPriority());
|
details.append("PRI:").append(pgvcg.getPriority());
|
||||||
details.append(pgvcg.isEncryptedChannel() ? " ENCRYPTED" : "");
|
details.append(pgvcg.isEncryptedChannel() ? " ENCRYPTED" : "");
|
||||||
@@ -2742,7 +2754,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (pgvcg.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(pgvcg.getDownlinkFrequency())
|
.frequency(pgvcg.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -2775,8 +2787,9 @@ public class P25DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (gvcgu.isTDMAChannel1() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details((gvcgu.isEncrypted() ? "ENCRYPTED " : ""))
|
.details((gvcgu.isTDMAChannel1() ? "TDMA " : "") +
|
||||||
|
(gvcgu.isEncrypted() ? "ENCRYPTED " : ""))
|
||||||
.frequency(gvcgu.getDownlinkFrequency1())
|
.frequency(gvcgu.getDownlinkFrequency1())
|
||||||
.to(to)
|
.to(to)
|
||||||
.build();
|
.build();
|
||||||
@@ -2801,8 +2814,9 @@ public class P25DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.PATCH_GROUP_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel2 + (gvcgu.isTDMAChannel2() ? " TDMA" : ""))
|
.channel(channel2)
|
||||||
.details((gvcgu.isEncrypted() ? "ENCRYPTED " : ""))
|
.details((gvcgu.isTDMAChannel2() ? "TDMA " : "") +
|
||||||
|
(gvcgu.isEncrypted() ? "ENCRYPTED " : ""))
|
||||||
.frequency(gvcgu.getDownlinkFrequency2())
|
.frequency(gvcgu.getDownlinkFrequency2())
|
||||||
.to(to2)
|
.to(to2)
|
||||||
.build();
|
.build();
|
||||||
@@ -2866,6 +2880,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(gdcg.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(gdcg.isEmergency() ? "EMERGENCY " : "");
|
details.append(gdcg.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(gdcg.getPriority()).append(" ");
|
details.append("PRI:").append(gdcg.getPriority()).append(" ");
|
||||||
details.append(gdcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(gdcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -2873,7 +2888,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (gdcg.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(gdcg.getDownlinkFrequency())
|
.frequency(gdcg.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -2904,6 +2919,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(gvcg.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(gvcg.isEmergency() ? "EMERGENCY " : "");
|
details.append(gvcg.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(gvcg.getPriority()).append(" ");
|
details.append("PRI:").append(gvcg.getPriority()).append(" ");
|
||||||
details.append(gvcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(gvcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -2911,7 +2927,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (gvcg.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(gvcg.getDownlinkFrequency())
|
.frequency(gvcg.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -2928,8 +2944,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GROUP_VOICE_CHANNEL_GRANT_UPDATE:
|
case GROUP_VOICE_CHANNEL_GRANT_UPDATE:
|
||||||
GroupVoiceChannelGrantUpdate gvcgu =
|
GroupVoiceChannelGrantUpdate gvcgu = (GroupVoiceChannelGrantUpdate)message;
|
||||||
(GroupVoiceChannelGrantUpdate)message;
|
|
||||||
|
|
||||||
channel = gvcgu.getChannel1();
|
channel = gvcgu.getChannel1();
|
||||||
from = null;
|
from = null;
|
||||||
@@ -2942,6 +2957,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(gvcgu.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(gvcgu.isEmergency() ? "EMERGENCY " : "");
|
details.append(gvcgu.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(gvcgu.getPriority()).append(" ");
|
details.append("PRI:").append(gvcgu.getPriority()).append(" ");
|
||||||
details.append(gvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(gvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -2949,7 +2965,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(gvcgu.getChannel1() + (gvcgu.isTDMAChannel1() ? " TDMA" : ""))
|
.channel(gvcgu.getChannel1())
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(gvcgu.getDownlinkFrequency1())
|
.frequency(gvcgu.getDownlinkFrequency1())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -2977,6 +2993,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(gvcgu.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(gvcgu.isEmergency() ? "EMERGENCY " : "");
|
details.append(gvcgu.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(gvcgu.getPriority()).append(" ");
|
details.append("PRI:").append(gvcgu.getPriority()).append(" ");
|
||||||
details.append(gvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(gvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -2984,7 +3001,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
P25CallEvent event2 = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
|
P25CallEvent event2 = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(gvcgu.getChannel2() + (gvcgu.isTDMAChannel2() ? " TDMA" : ""))
|
.channel(gvcgu.getChannel2())
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(gvcgu.getDownlinkFrequency2())
|
.frequency(gvcgu.getDownlinkFrequency2())
|
||||||
.to(gvcgu.getGroupAddress2())
|
.to(gvcgu.getGroupAddress2())
|
||||||
@@ -3016,6 +3033,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(gvcgue.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(gvcgue.isEmergency() ? "EMERGENCY " : "");
|
details.append(gvcgue.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(gvcgue.getPriority()).append(" ");
|
details.append("PRI:").append(gvcgue.getPriority()).append(" ");
|
||||||
details.append(gvcgue.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(gvcgue.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -3023,7 +3041,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.GROUP_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (gvcgue.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(gvcgue.getDownlinkFrequency())
|
.frequency(gvcgue.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -3053,6 +3071,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(idcg.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(idcg.isEmergency() ? "EMERGENCY " : "");
|
details.append(idcg.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(idcg.getPriority()).append(" ");
|
details.append("PRI:").append(idcg.getPriority()).append(" ");
|
||||||
details.append(idcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(idcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -3060,7 +3079,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (idcg.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(idcg.getDownlinkFrequency())
|
.frequency(idcg.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -3090,13 +3109,14 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(sdcg.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(sdcg.isEmergency() ? "EMERGENCY " : "");
|
details.append(sdcg.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append(sdcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(sdcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
details.append(sdcg.getSessionMode().name());
|
details.append(sdcg.getSessionMode().name());
|
||||||
|
|
||||||
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
|
P25CallEvent event = new P25CallEvent.Builder(CallEventType.DATA_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (sdcg.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(sdcg.getDownlinkFrequency())
|
.frequency(sdcg.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -3128,6 +3148,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(tivcg.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(tivcg.isEmergency() ? "EMERGENCY " : "");
|
details.append(tivcg.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(tivcg.getPriority()).append(" ");
|
details.append("PRI:").append(tivcg.getPriority()).append(" ");
|
||||||
details.append(tivcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(tivcg.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -3137,7 +3158,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
P25CallEvent event = new P25CallEvent.Builder(
|
P25CallEvent event = new P25CallEvent.Builder(
|
||||||
CallEventType.TELEPHONE_INTERCONNECT)
|
CallEventType.TELEPHONE_INTERCONNECT)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (tivcg.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(tivcg.getDownlinkFrequency())
|
.frequency(tivcg.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -3170,6 +3191,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(tivcgu.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(tivcgu.isEmergency() ? "EMERGENCY " : "");
|
details.append(tivcgu.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(tivcgu.getPriority()).append(" ");
|
details.append("PRI:").append(tivcgu.getPriority()).append(" ");
|
||||||
details.append(tivcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(tivcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -3179,7 +3201,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
P25CallEvent event = new P25CallEvent.Builder(
|
P25CallEvent event = new P25CallEvent.Builder(
|
||||||
CallEventType.TELEPHONE_INTERCONNECT)
|
CallEventType.TELEPHONE_INTERCONNECT)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (tivcgu.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(tivcgu.getDownlinkFrequency())
|
.frequency(tivcgu.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -3209,6 +3231,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(uuvcg.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(uuvcg.isEmergency() ? "EMERGENCY " : "");
|
details.append(uuvcg.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(uuvcg.getPriority()).append(" ");
|
details.append("PRI:").append(uuvcg.getPriority()).append(" ");
|
||||||
details.append(uuvcg.isEncryptedChannel() ? " ENCRYPTED " : "");
|
details.append(uuvcg.isEncryptedChannel() ? " ENCRYPTED " : "");
|
||||||
@@ -3217,7 +3240,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
P25CallEvent event = new P25CallEvent.Builder(
|
P25CallEvent event = new P25CallEvent.Builder(
|
||||||
CallEventType.UNIT_TO_UNIT_CALL)
|
CallEventType.UNIT_TO_UNIT_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (uuvcg.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(uuvcg.getDownlinkFrequency())
|
.frequency(uuvcg.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
@@ -3247,6 +3270,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
|
details.append(uuvcgu.isTDMAChannel() ? "TDMA " : "");
|
||||||
details.append(uuvcgu.isEmergency() ? "EMERGENCY " : "");
|
details.append(uuvcgu.isEmergency() ? "EMERGENCY " : "");
|
||||||
details.append("PRI:").append(uuvcgu.getPriority()).append(" ");
|
details.append("PRI:").append(uuvcgu.getPriority()).append(" ");
|
||||||
details.append(uuvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
|
details.append(uuvcgu.isEncryptedChannel() ? "ENCRYPTED " : "");
|
||||||
@@ -3255,7 +3279,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
P25CallEvent event = new P25CallEvent.Builder(
|
P25CallEvent event = new P25CallEvent.Builder(
|
||||||
CallEventType.UNIT_TO_UNIT_CALL)
|
CallEventType.UNIT_TO_UNIT_CALL)
|
||||||
.aliasList(getAliasList())
|
.aliasList(getAliasList())
|
||||||
.channel(channel + (uuvcgu.isTDMAChannel() ? " TDMA" : ""))
|
.channel(channel)
|
||||||
.details(details.toString())
|
.details(details.toString())
|
||||||
.frequency(uuvcgu.getDownlinkFrequency())
|
.frequency(uuvcgu.getDownlinkFrequency())
|
||||||
.from(from)
|
.from(from)
|
||||||
|
|||||||
@@ -689,8 +689,7 @@ public class P25MessageFramer implements Listener<Dibit>
|
|||||||
private LSMDemodulator mDemodulator;
|
private LSMDemodulator mDemodulator;
|
||||||
private double mCorrection;
|
private double mCorrection;
|
||||||
|
|
||||||
public CostasPhaseErrorDetector( FrameSync frameSync,
|
public CostasPhaseErrorDetector( FrameSync frameSync, LSMDemodulator demodulator, double correction )
|
||||||
LSMDemodulator demodulator, double correction )
|
|
||||||
{
|
{
|
||||||
super( frameSync.getSync() );
|
super( frameSync.getSync() );
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.p25;
|
package module.decode.p25;
|
||||||
|
|
||||||
@@ -41,8 +42,7 @@ import dsp.filter.FilterFactory;
|
|||||||
import dsp.filter.Window.WindowType;
|
import dsp.filter.Window.WindowType;
|
||||||
import dsp.filter.fir.real.RealFIRFilter_RB_RB;
|
import dsp.filter.fir.real.RealFIRFilter_RB_RB;
|
||||||
|
|
||||||
public class P25_C4FMDecoder extends P25Decoder
|
public class P25_C4FMDecoder extends P25Decoder implements IFilteredRealBufferListener
|
||||||
implements IFrequencyChangeListener, IFrequencyChangeProvider,IFilteredRealBufferListener
|
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger( P25_C4FMDecoder.class );
|
private final static Logger mLog = LoggerFactory.getLogger( P25_C4FMDecoder.class );
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import dsp.filter.fir.complex.ComplexFIRFilter_CB_CB;
|
|||||||
import dsp.gain.ComplexFeedForwardGainControl;
|
import dsp.gain.ComplexFeedForwardGainControl;
|
||||||
import dsp.psk.LSMDemodulator;
|
import dsp.psk.LSMDemodulator;
|
||||||
import dsp.psk.QPSKPolarSlicer;
|
import dsp.psk.QPSKPolarSlicer;
|
||||||
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
|
|
||||||
public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
|
public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
|
||||||
{
|
{
|
||||||
@@ -56,8 +57,7 @@ public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
|
|||||||
private List<TapGroup> mAvailableTaps;
|
private List<TapGroup> mAvailableTaps;
|
||||||
|
|
||||||
private ComplexFIRFilter_CB_CB mBasebandFilter;
|
private ComplexFIRFilter_CB_CB mBasebandFilter;
|
||||||
private ComplexBufferToStreamConverter mStreamConverter =
|
private ComplexBufferToStreamConverter mStreamConverter = new ComplexBufferToStreamConverter();
|
||||||
new ComplexBufferToStreamConverter();
|
|
||||||
private ComplexFeedForwardGainControl mAGC =
|
private ComplexFeedForwardGainControl mAGC =
|
||||||
new ComplexFeedForwardGainControl( 32 );
|
new ComplexFeedForwardGainControl( 32 );
|
||||||
private LSMDemodulator mLSMDemodulator = new LSMDemodulator();
|
private LSMDemodulator mLSMDemodulator = new LSMDemodulator();
|
||||||
@@ -108,6 +108,29 @@ public class P25_LSMDecoder extends P25Decoder implements IComplexBufferListener
|
|||||||
mMessageFramer = null;
|
mMessageFramer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
return new Listener<FrequencyChangeEvent>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void receive(FrequencyChangeEvent frequencyChangeEvent)
|
||||||
|
{
|
||||||
|
//Ignored
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Listener<ComplexBuffer> getComplexBufferListener()
|
public Listener<ComplexBuffer> getComplexBufferListener()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ import jmbe.iface.AudioConverter;
|
|||||||
import message.IMessageListener;
|
import message.IMessageListener;
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
|
import module.decode.p25.message.hdu.HDUMessage;
|
||||||
|
import module.decode.p25.message.ldu.LDU1Message;
|
||||||
|
import module.decode.p25.message.ldu.LDU2Message;
|
||||||
import module.decode.p25.message.ldu.LDUMessage;
|
import module.decode.p25.message.ldu.LDUMessage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -25,14 +28,18 @@ public class P25AudioModule extends Module implements Listener<Message>, IAudioP
|
|||||||
private final static Logger mLog = LoggerFactory.getLogger(P25AudioModule.class);
|
private final static Logger mLog = LoggerFactory.getLogger(P25AudioModule.class);
|
||||||
|
|
||||||
private static final String IMBE_CODEC = "IMBE";
|
private static final String IMBE_CODEC = "IMBE";
|
||||||
|
|
||||||
private static boolean mLibraryLoadStatusLogged = false;
|
private static boolean mLibraryLoadStatusLogged = false;
|
||||||
|
|
||||||
private boolean mCanConvertAudio = false;
|
private boolean mCanConvertAudio = false;
|
||||||
|
private boolean mEncryptedCall = false;
|
||||||
|
private boolean mEncryptedCallStateEstablished = false;
|
||||||
|
|
||||||
private AudioConverter mAudioConverter;
|
private AudioConverter mAudioConverter;
|
||||||
private Listener<AudioPacket> mAudioPacketListener;
|
private Listener<AudioPacket> mAudioPacketListener;
|
||||||
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
||||||
private NonClippingGain mGain = new NonClippingGain(5.0f, 0.95f);
|
private NonClippingGain mGain = new NonClippingGain(5.0f, 0.95f);
|
||||||
private Metadata mMetadata;
|
private Metadata mMetadata;
|
||||||
|
private LDU1Message mCachedLDU1Message = null;
|
||||||
|
|
||||||
public P25AudioModule(Metadata metadata)
|
public P25AudioModule(Metadata metadata)
|
||||||
{
|
{
|
||||||
@@ -76,21 +83,60 @@ public class P25AudioModule extends Module implements Listener<Message>, IAudioP
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary processing method for p25 imbe audio frame messages. Each LDU
|
* Processes call header (HDU) and voice frame (LDU1/LDU2) messages to decode audio and to determine the
|
||||||
* audio message contains 9 imbe voice frames. Each frame is converted to
|
* encrypted audio status of a call event. Only the HDU and LDU2 messages convey encrypted call status. If an
|
||||||
* audio when the JMBE library is loaded, processed by auto-gain, and
|
* LDU1 message is received without a preceding HDU message, then the LDU1 message is cached until the first
|
||||||
* broadcast to the audio packet listener.
|
* LDU2 message is received and the encryption state can be determined. Both the LDU1 and the LDU2 message are
|
||||||
|
* then processed for audio if the call is unencrypted.
|
||||||
*/
|
*/
|
||||||
public void receive(Message message)
|
public void receive(Message message)
|
||||||
{
|
{
|
||||||
if(mCanConvertAudio && mAudioPacketListener != null)
|
if(mCanConvertAudio && mAudioPacketListener != null)
|
||||||
|
{
|
||||||
|
if(mEncryptedCallStateEstablished)
|
||||||
{
|
{
|
||||||
if(message instanceof LDUMessage)
|
if(message instanceof LDUMessage)
|
||||||
{
|
{
|
||||||
LDUMessage ldu = (LDUMessage) message;
|
processAudio((LDUMessage)message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(message instanceof HDUMessage)
|
||||||
|
{
|
||||||
|
mEncryptedCallStateEstablished = true;
|
||||||
|
mEncryptedCall = ((HDUMessage)message).isEncryptedAudio();
|
||||||
|
}
|
||||||
|
else if(message instanceof LDU1Message)
|
||||||
|
{
|
||||||
|
//When we receive an LDU1 message with first receiving the HDU message, cache the LDU1 Message
|
||||||
|
//until we can determine the encrypted call state from the next LDU2 message
|
||||||
|
mCachedLDU1Message = (LDU1Message)message;
|
||||||
|
}
|
||||||
|
else if(message instanceof LDU2Message)
|
||||||
|
{
|
||||||
|
mEncryptedCallStateEstablished = true;
|
||||||
|
LDU2Message ldu2 = (LDU2Message)message;
|
||||||
|
mEncryptedCall = ldu2.isEncryptedAudio();
|
||||||
|
|
||||||
/* Only process unencrypted audio frames */
|
if(mCachedLDU1Message != null)
|
||||||
if (!(ldu.isValid() && ldu.isEncrypted()))
|
{
|
||||||
|
processAudio(mCachedLDU1Message);
|
||||||
|
mCachedLDU1Message = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
processAudio(ldu2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes an audio packet by decoding the IMBE audio frames and rebroadcasting them as PCM audio packets.
|
||||||
|
*/
|
||||||
|
private void processAudio(LDUMessage ldu)
|
||||||
|
{
|
||||||
|
if(!mEncryptedCall)
|
||||||
{
|
{
|
||||||
for(byte[] frame : ldu.getIMBEFrames())
|
for(byte[] frame : ldu.getIMBEFrames())
|
||||||
{
|
{
|
||||||
@@ -101,7 +147,9 @@ public class P25AudioModule extends Module implements Listener<Message>, IAudioP
|
|||||||
mAudioPacketListener.receive(new AudioPacket(audio, mMetadata.copyOf()));
|
mAudioPacketListener.receive(new AudioPacket(audio, mMetadata.copyOf()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
//Encrypted audio processing not implemented
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,20 +244,26 @@ public class P25AudioModule extends Module implements Listener<Message>, IAudioP
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for squelch state listener. Internally, the P25 audio module
|
* Wrapper for squelch state to process end of call actions. At call end the encrypted call state established
|
||||||
* doesn't have a squelch state. If there are IMBE audio frames, we have
|
* flag is reset so that the encrypted audio state for the next call can be properly detected and we send an
|
||||||
* audio. We use this listener to signal to the recorder manager that the
|
* END audio packet so that downstream processors like the audio recorder can properly close out a call sequence.
|
||||||
* channel state is resetting and it should end the recording.
|
|
||||||
*/
|
*/
|
||||||
public class SquelchStateListener implements Listener<SquelchState>
|
public class SquelchStateListener implements Listener<SquelchState>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void receive(SquelchState state)
|
public void receive(SquelchState state)
|
||||||
{
|
{
|
||||||
if (state == SquelchState.SQUELCH && mAudioPacketListener != null)
|
if(state == SquelchState.SQUELCH)
|
||||||
|
{
|
||||||
|
if(mAudioPacketListener != null)
|
||||||
{
|
{
|
||||||
mAudioPacketListener.receive(new AudioPacket(AudioPacket.Type.END, mMetadata.copyOf()));
|
mAudioPacketListener.receive(new AudioPacket(AudioPacket.Type.END, mMetadata.copyOf()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mEncryptedCallStateEstablished = false;
|
||||||
|
mEncryptedCall = false;
|
||||||
|
mCachedLDU1Message = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ public class HDUMessage extends P25Message
|
|||||||
return Encryption.fromValue( mMessage.getInt( ALGORITHM_ID ) );
|
return Encryption.fromValue( mMessage.getInt( ALGORITHM_ID ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEncrypted()
|
public boolean isEncryptedAudio()
|
||||||
{
|
{
|
||||||
return getEncryption() != Encryption.UNENCRYPTED;
|
return getEncryption() != Encryption.UNENCRYPTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
package module.decode.p25.message.ldu;
|
package module.decode.p25.message.ldu;
|
||||||
|
|
||||||
import module.decode.p25.reference.DataUnitID;
|
|
||||||
import module.decode.p25.reference.LinkControlOpcode;
|
|
||||||
import module.decode.p25.reference.Vendor;
|
|
||||||
import module.decode.p25.reference.VendorLinkControlOpcode;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import alias.AliasList;
|
import alias.AliasList;
|
||||||
import bits.BinaryMessage;
|
import bits.BinaryMessage;
|
||||||
import edac.CRC;
|
import edac.CRC;
|
||||||
import edac.Hamming10;
|
import edac.Hamming10;
|
||||||
import edac.ReedSolomon_63_47_17;
|
import edac.ReedSolomon_63_47_17;
|
||||||
|
import module.decode.p25.reference.DataUnitID;
|
||||||
|
import module.decode.p25.reference.LinkControlOpcode;
|
||||||
|
import module.decode.p25.reference.Vendor;
|
||||||
|
import module.decode.p25.reference.VendorLinkControlOpcode;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class LDU1Message extends LDUMessage
|
public class LDU1Message extends LDUMessage
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(LDU1Message.class);
|
private final static Logger mLog = LoggerFactory.getLogger(LDU1Message.class);
|
||||||
|
|
||||||
public static final int ENCRYPTION_FLAG = 352;
|
public static final int ENCRYPTED_LINK_CONTROL_WORD_FLAG = 352;
|
||||||
public static final int IMPLICIT_VENDOR_FLAG = 353;
|
public static final int IMPLICIT_VENDOR_FLAG = 353;
|
||||||
public static final int[] OPCODE = {354, 355, 356, 357, 362, 363};
|
public static final int[] OPCODE = {354, 355, 356, 357, 362, 363};
|
||||||
public static final int[] VENDOR = {364, 365, 366, 367, 372, 373, 374, 375};
|
public static final int[] VENDOR = {364, 365, 366, 367, 372, 373, 374, 375};
|
||||||
@@ -81,10 +79,14 @@ public class LDU1Message extends LDUMessage
|
|||||||
mCRC = message.mCRC;
|
mCRC = message.mCRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean isEncrypted()
|
* Indicates if the contents of the Link Control Word are encrypted.
|
||||||
|
*
|
||||||
|
* @return true if the contents of the LCW are encrypted.
|
||||||
|
*/
|
||||||
|
public boolean isEncryptedLinkControlWord()
|
||||||
{
|
{
|
||||||
return mMessage.get( ENCRYPTION_FLAG );
|
return mMessage.get(ENCRYPTED_LINK_CONTROL_WORD_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCRC()
|
private void checkCRC()
|
||||||
@@ -197,7 +199,7 @@ public class LDU1Message extends LDUMessage
|
|||||||
|
|
||||||
sb.append(super.getMessageStub());
|
sb.append(super.getMessageStub());
|
||||||
|
|
||||||
if( isEncrypted() )
|
if(isEncryptedLinkControlWord())
|
||||||
{
|
{
|
||||||
sb.append("ENCRYPTED");
|
sb.append("ENCRYPTED");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,10 @@ public class LDU2Message extends LDUMessage
|
|||||||
checkCRC();
|
checkCRC();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean isEncrypted()
|
* Indicates if the audio stream is encrypted
|
||||||
|
*/
|
||||||
|
public boolean isEncryptedAudio()
|
||||||
{
|
{
|
||||||
Encryption encryption = getEncryption();
|
Encryption encryption = getEncryption();
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ public abstract class LDUMessage extends P25Message
|
|||||||
super( message, duid, aliasList );
|
super( message, duid, aliasList );
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean isEncrypted();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage()
|
public String getMessage()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class IdentifierUpdateTDMA extends IdentifierUpdate
|
|||||||
|
|
||||||
sb.append( " ID:" + getIdentifier() );
|
sb.append( " ID:" + getIdentifier() );
|
||||||
sb.append( " BASE:" + getBaseFrequency() );
|
sb.append( " BASE:" + getBaseFrequency() );
|
||||||
sb.append( " BW:" + getBandwidth() );
|
sb.append( " BANDWIDTH:" + getBandwidth() );
|
||||||
sb.append( " SPACING:" + getChannelSpacing() );
|
sb.append( " SPACING:" + getChannelSpacing() );
|
||||||
sb.append( " OFFSET:" + getTransmitOffset() );
|
sb.append( " OFFSET:" + getTransmitOffset() );
|
||||||
sb.append( " TYPE:" + getChannelType().toString() );
|
sb.append( " TYPE:" + getChannelType().toString() );
|
||||||
@@ -137,7 +137,7 @@ public class IdentifierUpdateTDMA extends IdentifierUpdate
|
|||||||
|
|
||||||
sb.append( mAccessType.name() );
|
sb.append( mAccessType.name() );
|
||||||
sb.append( " BANDWIDTH:" + mBandwidth );
|
sb.append( " BANDWIDTH:" + mBandwidth );
|
||||||
sb.append( " SLOT/CARRIER:" + mSlotsPerCarrier );
|
sb.append( " TIMESLOTS PER CARRIER:" + mSlotsPerCarrier );
|
||||||
sb.append( " VOCODER:" + mVocoder.name() );
|
sb.append( " VOCODER:" + mVocoder.name() );
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|||||||
@@ -25,11 +25,15 @@ import properties.SystemProperties;
|
|||||||
import record.wave.ComplexBufferWaveRecorder;
|
import record.wave.ComplexBufferWaveRecorder;
|
||||||
import record.wave.RealBufferWaveRecorder;
|
import record.wave.RealBufferWaveRecorder;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
|
import sample.OverflowableTransferQueue;
|
||||||
|
import sample.real.IOverflowListener;
|
||||||
import util.ThreadPool;
|
import util.ThreadPool;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -42,7 +46,8 @@ public class RecorderManager implements Listener<AudioPacket>
|
|||||||
public static final long IDLE_RECORDER_REMOVAL_THRESHOLD = 6000; //6 seconds
|
public static final long IDLE_RECORDER_REMOVAL_THRESHOLD = 6000; //6 seconds
|
||||||
|
|
||||||
private Map<String,RealBufferWaveRecorder> mRecorders = new HashMap<>();
|
private Map<String,RealBufferWaveRecorder> mRecorders = new HashMap<>();
|
||||||
private ScheduledFuture<?> mRecorderMonitorFuture;
|
private OverflowableTransferQueue<AudioPacket> mAudioPacketQueue = new OverflowableTransferQueue<>(1000, 100);
|
||||||
|
private ScheduledFuture<?> mBufferProcessorFuture;
|
||||||
|
|
||||||
private boolean mCanStartNewRecorders = true;
|
private boolean mCanStartNewRecorders = true;
|
||||||
|
|
||||||
@@ -55,8 +60,24 @@ public class RecorderManager implements Listener<AudioPacket>
|
|||||||
*/
|
*/
|
||||||
public RecorderManager()
|
public RecorderManager()
|
||||||
{
|
{
|
||||||
mRecorderMonitorFuture = ThreadPool.SCHEDULED.scheduleAtFixedRate(new RecorderMonitor(), 2,
|
mAudioPacketQueue.setOverflowListener(new IOverflowListener()
|
||||||
2, TimeUnit.SECONDS);
|
{
|
||||||
|
@Override
|
||||||
|
public void sourceOverflow(boolean overflow)
|
||||||
|
{
|
||||||
|
if(overflow)
|
||||||
|
{
|
||||||
|
mLog.warn("overflow - audio packets will be dropped until recording catches up");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLog.info("audio recorder packet processing has returned to normal");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mBufferProcessorFuture = ThreadPool.SCHEDULED.scheduleAtFixedRate(new BufferProcessor(), 0,
|
||||||
|
1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,9 +85,9 @@ public class RecorderManager implements Listener<AudioPacket>
|
|||||||
*/
|
*/
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
if(mRecorderMonitorFuture != null)
|
if(mBufferProcessorFuture != null)
|
||||||
{
|
{
|
||||||
mRecorderMonitorFuture.cancel(true);
|
mBufferProcessorFuture.cancel(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,11 +99,26 @@ public class RecorderManager implements Listener<AudioPacket>
|
|||||||
public void receive(AudioPacket audioPacket)
|
public void receive(AudioPacket audioPacket)
|
||||||
{
|
{
|
||||||
if(audioPacket.hasMetadata() && audioPacket.getMetadata().isRecordable())
|
if(audioPacket.hasMetadata() && audioPacket.getMetadata().isRecordable())
|
||||||
|
{
|
||||||
|
mAudioPacketQueue.offer(audioPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process any queued audio buffers and dispatch them to the audio recorders
|
||||||
|
*/
|
||||||
|
private void processBuffers()
|
||||||
|
{
|
||||||
|
List<AudioPacket> audioPackets = new ArrayList<>();
|
||||||
|
|
||||||
|
mAudioPacketQueue.drainTo(audioPackets, 50);
|
||||||
|
|
||||||
|
while(!audioPackets.isEmpty())
|
||||||
|
{
|
||||||
|
for(AudioPacket audioPacket: audioPackets)
|
||||||
{
|
{
|
||||||
String identifier = audioPacket.getMetadata().getUniqueIdentifier();
|
String identifier = audioPacket.getMetadata().getUniqueIdentifier();
|
||||||
|
|
||||||
synchronized(mRecorders)
|
|
||||||
{
|
|
||||||
if(mRecorders.containsKey(identifier))
|
if(mRecorders.containsKey(identifier))
|
||||||
{
|
{
|
||||||
RealBufferWaveRecorder recorder = mRecorders.get(identifier);
|
RealBufferWaveRecorder recorder = mRecorders.get(identifier);
|
||||||
@@ -129,6 +165,29 @@ public class RecorderManager implements Listener<AudioPacket>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audioPackets.clear();
|
||||||
|
mAudioPacketQueue.drainTo(audioPackets, 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes recorders that have not received any new audio buffers in the last 6 seconds.
|
||||||
|
*/
|
||||||
|
private void removeIdleRecorders()
|
||||||
|
{
|
||||||
|
Iterator<Map.Entry<String,RealBufferWaveRecorder>> it = mRecorders.entrySet().iterator();
|
||||||
|
|
||||||
|
while(it.hasNext())
|
||||||
|
{
|
||||||
|
Map.Entry<String,RealBufferWaveRecorder> entry = it.next();
|
||||||
|
|
||||||
|
if(entry.getValue().getLastBufferReceived() + IDLE_RECORDER_REMOVAL_THRESHOLD < System.currentTimeMillis())
|
||||||
|
{
|
||||||
|
mLog.info("Removing idle recorder [" + entry.getKey() + "]");
|
||||||
|
it.remove();
|
||||||
|
entry.getValue().stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,29 +234,16 @@ public class RecorderManager implements Listener<AudioPacket>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors currently running recorders and removes/closes any recorders that are idle more than 6 seconds
|
* Processes queued audio packets and distributes to each of the audio recorders. Removes any idle recorders
|
||||||
|
* that have not been updated according to an idle threshold period
|
||||||
*/
|
*/
|
||||||
public class RecorderMonitor implements Runnable
|
public class BufferProcessor implements Runnable
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
synchronized(mRecorders)
|
processBuffers();
|
||||||
{
|
removeIdleRecorders();
|
||||||
Iterator<Map.Entry<String,RealBufferWaveRecorder>> it = mRecorders.entrySet().iterator();
|
|
||||||
|
|
||||||
while(it.hasNext())
|
|
||||||
{
|
|
||||||
Map.Entry<String,RealBufferWaveRecorder> entry = it.next();
|
|
||||||
|
|
||||||
if(entry.getValue().getLastBufferReceived() + IDLE_RECORDER_REMOVAL_THRESHOLD < System.currentTimeMillis())
|
|
||||||
{
|
|
||||||
mLog.info("Removing idle recorder [" + entry.getKey() + "]");
|
|
||||||
it.remove();
|
|
||||||
entry.getValue().stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ public class Broadcaster<T> implements Listener<T>
|
|||||||
|
|
||||||
public void addListener( Listener<T> listener )
|
public void addListener( Listener<T> listener )
|
||||||
{
|
{
|
||||||
|
if(listener == null)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Listener cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
mListeners.add( listener );
|
mListeners.add( listener );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,10 +124,6 @@ public class OverflowableTransferQueue<E>
|
|||||||
mQueue.clear();
|
mQueue.clear();
|
||||||
mCounter.set(0);
|
mCounter.set(0);
|
||||||
mOverflow.set(false);
|
mOverflow.set(false);
|
||||||
if(mOverflowListener != null)
|
|
||||||
{
|
|
||||||
mOverflowListener.sourceOverflow(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,18 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source;
|
package source;
|
||||||
|
|
||||||
|
import channel.heartbeat.IHeartbeatProvider;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
import sample.SampleType;
|
import sample.SampleType;
|
||||||
import sample.real.IOverflowListener;
|
import sample.real.IOverflowListener;
|
||||||
|
import source.tuner.frequency.IFrequencyChangeListener;
|
||||||
|
import source.tuner.frequency.IFrequencyChangeProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class to define the minimum functionality of a sample data provider.
|
* Abstract class to define the minimum functionality of a sample data provider.
|
||||||
*/
|
*/
|
||||||
public abstract class Source extends Module
|
public abstract class Source extends Module implements IFrequencyChangeListener, IFrequencyChangeProvider,
|
||||||
|
IHeartbeatProvider
|
||||||
{
|
{
|
||||||
protected SampleType mSampleType;
|
protected SampleType mSampleType;
|
||||||
protected IOverflowListener mOverflowListener;
|
protected IOverflowListener mOverflowListener;
|
||||||
|
|||||||
@@ -17,30 +17,29 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.mixer;
|
package source.mixer;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import channel.heartbeat.Heartbeat;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import dsp.gain.AutomaticGainControl;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import javax.sound.sampled.AudioFormat;
|
|
||||||
import javax.sound.sampled.AudioSystem;
|
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
|
||||||
import javax.sound.sampled.TargetDataLine;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.adapter.ISampleAdapter;
|
import sample.adapter.ISampleAdapter;
|
||||||
import sample.real.RealBuffer;
|
import sample.real.RealBuffer;
|
||||||
import source.RealSource;
|
import source.RealSource;
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import dsp.gain.AutomaticGainControl;
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
|
|
||||||
|
import javax.sound.sampled.AudioFormat;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
|
import javax.sound.sampled.TargetDataLine;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class RealMixerSource extends RealSource
|
public class RealMixerSource extends RealSource
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger(RealMixerSource.class);
|
||||||
LoggerFactory.getLogger( RealMixerSource.class );
|
|
||||||
|
|
||||||
private long mFrequency = 0;
|
private long mFrequency = 0;
|
||||||
private int mBufferSize = 16384;
|
private int mBufferSize = 16384;
|
||||||
@@ -48,13 +47,13 @@ public class RealMixerSource extends RealSource
|
|||||||
private BufferReader mBufferReader = new BufferReader();
|
private BufferReader mBufferReader = new BufferReader();
|
||||||
private TargetDataLine mTargetDataLine;
|
private TargetDataLine mTargetDataLine;
|
||||||
private AudioFormat mAudioFormat;
|
private AudioFormat mAudioFormat;
|
||||||
private String mDisplayName;
|
|
||||||
private int mBytesPerFrame = 0;
|
private int mBytesPerFrame = 0;
|
||||||
private ISampleAdapter mSampleAdapter;
|
private ISampleAdapter mSampleAdapter;
|
||||||
private AutomaticGainControl mAGC = new AutomaticGainControl();
|
private AutomaticGainControl mAGC = new AutomaticGainControl();
|
||||||
|
private Listener<Heartbeat> mHeartbeatListener;
|
||||||
|
private static final Heartbeat HEARTBEAT = new Heartbeat();
|
||||||
|
|
||||||
CopyOnWriteArrayList<Listener<RealBuffer>> mSampleListeners =
|
private CopyOnWriteArrayList<Listener<RealBuffer>> mSampleListeners = new CopyOnWriteArrayList<Listener<RealBuffer>>();
|
||||||
new CopyOnWriteArrayList<Listener<RealBuffer>>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Real Mixer Source - constructs a reader on the mixer/sound card target
|
* Real Mixer Source - constructs a reader on the mixer/sound card target
|
||||||
@@ -63,11 +62,7 @@ public class RealMixerSource extends RealSource
|
|||||||
* Reads buffers sized to 10% of the sample rate specified in audio format.
|
* Reads buffers sized to 10% of the sample rate specified in audio format.
|
||||||
*
|
*
|
||||||
* @param targetDataLine - mixer or sound card to be used
|
* @param targetDataLine - mixer or sound card to be used
|
||||||
*
|
|
||||||
* @param format - audio format
|
* @param format - audio format
|
||||||
*
|
|
||||||
* @param name - token name to use for this source
|
|
||||||
*
|
|
||||||
* @param sampleAdapter - adapter to convert byte array data read from the
|
* @param sampleAdapter - adapter to convert byte array data read from the
|
||||||
* mixer into float array data. Can optionally invert the channel data if
|
* mixer into float array data. Can optionally invert the channel data if
|
||||||
* the left/right stereo channels are inverted.
|
* the left/right stereo channels are inverted.
|
||||||
@@ -81,6 +76,45 @@ public class RealMixerSource extends RealSource
|
|||||||
mSampleAdapter = sampleAdapter;
|
mSampleAdapter = sampleAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the listener to receive heartbeats from this source.
|
||||||
|
*
|
||||||
|
* @param listener to receive heartbeats
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setHeartbeatListener(Listener<Heartbeat> listener)
|
||||||
|
{
|
||||||
|
mHeartbeatListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the currently registered heartbeat listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeHeartbeatListener()
|
||||||
|
{
|
||||||
|
mHeartbeatListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
@@ -133,23 +167,15 @@ public class RealMixerSource extends RealSource
|
|||||||
* buffer, otherwise send him a copy of the buffer */
|
* buffer, otherwise send him a copy of the buffer */
|
||||||
if(it.hasNext())
|
if(it.hasNext())
|
||||||
{
|
{
|
||||||
// next.receive( mAGC.process( samples.copyOf() ) );
|
|
||||||
next.receive(samples.copyOf());
|
next.receive(samples.copyOf());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// next.receive( mAGC.process( samples ) );
|
|
||||||
next.receive(samples);
|
next.receive(samples);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return mDisplayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSampleRate()
|
public int getSampleRate()
|
||||||
{
|
{
|
||||||
if(mTargetDataLine != null)
|
if(mTargetDataLine != null)
|
||||||
@@ -194,6 +220,12 @@ public class RealMixerSource extends RealSource
|
|||||||
{
|
{
|
||||||
if(mRunning.compareAndSet(false, true))
|
if(mRunning.compareAndSet(false, true))
|
||||||
{
|
{
|
||||||
|
//Send a heartbeat every time we run
|
||||||
|
if(mHeartbeatListener != null)
|
||||||
|
{
|
||||||
|
mHeartbeatListener.receive(HEARTBEAT);
|
||||||
|
}
|
||||||
|
|
||||||
if(mTargetDataLine == null)
|
if(mTargetDataLine == null)
|
||||||
{
|
{
|
||||||
mRunning.set(false);
|
mRunning.set(false);
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.tuner;
|
package source.tuner;
|
||||||
|
|
||||||
|
import channel.heartbeat.Heartbeat;
|
||||||
|
import channel.heartbeat.IHeartbeatProvider;
|
||||||
import dsp.filter.FilterFactory;
|
import dsp.filter.FilterFactory;
|
||||||
import dsp.filter.Window.WindowType;
|
import dsp.filter.Window.WindowType;
|
||||||
import dsp.filter.cic.ComplexPrimeCICDecimate;
|
import dsp.filter.cic.ComplexPrimeCICDecimate;
|
||||||
@@ -34,7 +36,9 @@ import source.ComplexSource;
|
|||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
||||||
|
import source.tuner.frequency.IFrequencyChangeListener;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||||
|
import source.tuner.frequency.IFrequencyChangeProvider;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -56,6 +60,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
|
|
||||||
private static int CHANNEL_RATE = 48000;
|
private static int CHANNEL_RATE = 48000;
|
||||||
private static int CHANNEL_PASS_FREQUENCY = 12000;
|
private static int CHANNEL_PASS_FREQUENCY = 12000;
|
||||||
|
private static final Heartbeat HEARTBEAT = new Heartbeat();
|
||||||
|
|
||||||
private OverflowableTransferQueue<ComplexBuffer> mBuffer;
|
private OverflowableTransferQueue<ComplexBuffer> mBuffer;
|
||||||
|
|
||||||
@@ -64,7 +69,9 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
private Oscillator mMixer;
|
private Oscillator mMixer;
|
||||||
private ComplexPrimeCICDecimate mDecimationFilter;
|
private ComplexPrimeCICDecimate mDecimationFilter;
|
||||||
private Listener<ComplexBuffer> mListener;
|
private Listener<ComplexBuffer> mListener;
|
||||||
|
private Listener<Heartbeat> mHeartbeatListener;
|
||||||
private IFrequencyChangeProcessor mFrequencyChangeProcessor;
|
private IFrequencyChangeProcessor mFrequencyChangeProcessor;
|
||||||
|
private DownstreamProcessor mDownstreamFrequencyEventProcessor = new DownstreamProcessor();
|
||||||
private ScheduledFuture<?> mTaskHandle;
|
private ScheduledFuture<?> mTaskHandle;
|
||||||
|
|
||||||
private long mTunerFrequency = 0;
|
private long mTunerFrequency = 0;
|
||||||
@@ -75,7 +82,6 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
|
|
||||||
private AtomicBoolean mRunning = new AtomicBoolean();
|
private AtomicBoolean mRunning = new AtomicBoolean();
|
||||||
private boolean mExpended = false;
|
private boolean mExpended = false;
|
||||||
private int mCount;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a Digital Drop Channel (DDC) to decimate the IQ output from a
|
* Provides a Digital Drop Channel (DDC) to decimate the IQ output from a
|
||||||
@@ -109,7 +115,8 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
mMixer = new Oscillator(frequencyOffset, mTuner.getTunerController().getSampleRate());
|
mMixer = new Oscillator(frequencyOffset, mTuner.getTunerController().getSampleRate());
|
||||||
|
|
||||||
/* Fire a sample rate change event to setup the decimation chain */
|
/* Fire a sample rate change event to setup the decimation chain */
|
||||||
frequencyChanged(new FrequencyChangeEvent(Event.NOTIFICATION_SAMPLE_RATE_CHANGE, mTuner.getTunerController().getSampleRate()));
|
frequencyChanged(new FrequencyChangeEvent(Event.NOTIFICATION_SAMPLE_RATE_CHANGE,
|
||||||
|
mTuner.getTunerController().getSampleRate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,6 +138,10 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
|
|
||||||
if(mRunning.compareAndSet(false, true))
|
if(mRunning.compareAndSet(false, true))
|
||||||
{
|
{
|
||||||
|
//Broadcast current frequency and sample rate settings so all downstream components are aware
|
||||||
|
mDownstreamFrequencyEventProcessor.broadcastCurrentFrequency();
|
||||||
|
mDownstreamFrequencyEventProcessor.broadcastCurrentSampleRate();
|
||||||
|
|
||||||
//Schedule the decimation task to run every 9 ms (111 iterations/second), an odd periodicity relative
|
//Schedule the decimation task to run every 9 ms (111 iterations/second), an odd periodicity relative
|
||||||
//to the inbound periodicity of 20 ms, to attempt to avoid thread queue contention
|
//to the inbound periodicity of 20 ms, to attempt to avoid thread queue contention
|
||||||
mTaskHandle = executor.scheduleAtFixedRate(mDecimationProcessor, 0, 9, TimeUnit.MILLISECONDS);
|
mTaskHandle = executor.scheduleAtFixedRate(mDecimationProcessor, 0, 9, TimeUnit.MILLISECONDS);
|
||||||
@@ -184,6 +195,20 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the frequency correction value and broadcasts the change to the registered downstream listener.
|
||||||
|
* @param correction current frequency correction value.
|
||||||
|
*/
|
||||||
|
private void setFrequencyCorrection(int correction)
|
||||||
|
{
|
||||||
|
mChannelFrequencyCorrection = correction;
|
||||||
|
|
||||||
|
updateMixerFrequencyOffset();
|
||||||
|
|
||||||
|
mDownstreamFrequencyEventProcessor.broadcast(
|
||||||
|
new FrequencyChangeEvent( Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE, mChannelFrequencyCorrection));
|
||||||
|
}
|
||||||
|
|
||||||
public Tuner getTuner()
|
public Tuner getTuner()
|
||||||
{
|
{
|
||||||
return mTuner;
|
return mTuner;
|
||||||
@@ -242,21 +267,25 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
case NOTIFICATION_FREQUENCY_CHANGE:
|
case NOTIFICATION_FREQUENCY_CHANGE:
|
||||||
mTunerFrequency = event.getValue().longValue();
|
mTunerFrequency = event.getValue().longValue();
|
||||||
updateMixerFrequencyOffset();
|
updateMixerFrequencyOffset();
|
||||||
break;
|
|
||||||
case REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE:
|
|
||||||
mChannelFrequencyCorrection = event.getValue().intValue();
|
|
||||||
|
|
||||||
updateMixerFrequencyOffset();
|
//Reset frequency correction so that downstream components can recalculate the value
|
||||||
|
setFrequencyCorrection(0);
|
||||||
if(mFrequencyChangeProcessor != null)
|
|
||||||
{
|
|
||||||
mFrequencyChangeProcessor.frequencyChanged(new FrequencyChangeEvent(
|
|
||||||
Event.NOTIFICATION_CHANNEL_FREQUENCY_CORRECTION_CHANGE, mChannelFrequencyCorrection));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NOTIFICATION_SAMPLE_RATE_CHANGE:
|
case NOTIFICATION_SAMPLE_RATE_CHANGE:
|
||||||
int sampleRate = event.getValue().intValue();
|
int sampleRate = event.getValue().intValue();
|
||||||
|
setSampleRate(sampleRate);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the sample rate to the requested value and notifies any downstream components of the change
|
||||||
|
* @param sampleRate to set
|
||||||
|
*/
|
||||||
|
private void setSampleRate(int sampleRate)
|
||||||
|
{
|
||||||
if(mTunerSampleRate != sampleRate)
|
if(mTunerSampleRate != sampleRate)
|
||||||
{
|
{
|
||||||
mMixer.setSampleRate(sampleRate);
|
mMixer.setSampleRate(sampleRate);
|
||||||
@@ -269,10 +298,8 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
mDecimationFilter.setListener(mListener);
|
mDecimationFilter.setListener(mListener);
|
||||||
|
|
||||||
mTunerSampleRate = sampleRate;
|
mTunerSampleRate = sampleRate;
|
||||||
}
|
|
||||||
break;
|
mDownstreamFrequencyEventProcessor.broadcastCurrentSampleRate();
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,10 +309,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
*/
|
*/
|
||||||
private void updateMixerFrequencyOffset()
|
private void updateMixerFrequencyOffset()
|
||||||
{
|
{
|
||||||
long offset = mTunerFrequency -
|
long offset = mTunerFrequency - mTunerChannel.getFrequency() - mChannelFrequencyCorrection;
|
||||||
mTunerChannel.getFrequency() -
|
|
||||||
mChannelFrequencyCorrection;
|
|
||||||
|
|
||||||
mMixer.setFrequency(offset);
|
mMixer.setFrequency(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,6 +323,159 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
return mTunerChannel.getFrequency();
|
return mTunerChannel.getFrequency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements IFrequencyChangeProvider to enable this source to broadcast frequency change events to downstream
|
||||||
|
* listeners.
|
||||||
|
*
|
||||||
|
* @param listener to receive downstream events
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
||||||
|
{
|
||||||
|
mDownstreamFrequencyEventProcessor.setFrequencyChangeListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements IFrequencyChangeProvider to remove the frequency change listener from receiving down-stream frequency
|
||||||
|
* change events.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
mDownstreamFrequencyEventProcessor.removeFrequencyChangeListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements IFrequencyChangeListener to receive frequency change events containing requests from downstream
|
||||||
|
* listeners to change frequency values.
|
||||||
|
* @return listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
return mDownstreamFrequencyEventProcessor.getFrequencyChangeListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the listener to receive heartbeats from this source.
|
||||||
|
* @param listener to receive heartbeats
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setHeartbeatListener(Listener<Heartbeat> listener)
|
||||||
|
{
|
||||||
|
mHeartbeatListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the currently registered heartbeat listener
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeHeartbeatListener()
|
||||||
|
{
|
||||||
|
mHeartbeatListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Managers frequency change requests and notifications from/to any downstream component. Downstream
|
||||||
|
* components are those that receive samples from this tuner channel source. These downstream components will be
|
||||||
|
* notified of any frequency or sample rate change events and will also be able to request frequency correction
|
||||||
|
* updates.
|
||||||
|
*/
|
||||||
|
public class DownstreamProcessor implements IFrequencyChangeListener, IFrequencyChangeProvider,
|
||||||
|
Listener<FrequencyChangeEvent>
|
||||||
|
{
|
||||||
|
//Listener to receive downstream events
|
||||||
|
private Listener<FrequencyChangeEvent> mListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts the frequency change event to the downstream frequency change listener
|
||||||
|
* @param event to broadcast
|
||||||
|
*/
|
||||||
|
public void broadcast(FrequencyChangeEvent event)
|
||||||
|
{
|
||||||
|
if(mListener != null)
|
||||||
|
{
|
||||||
|
mListener.receive(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts the current frequency of this tuner channel source to the downstream listener
|
||||||
|
*/
|
||||||
|
public void broadcastCurrentFrequency()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long frequency = getFrequency();
|
||||||
|
broadcast(new FrequencyChangeEvent(Event.NOTIFICATION_FREQUENCY_CHANGE, frequency));
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
mLog.error("Error obtaining frequency from tuner to broadcast downstream");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Broadcasts the current decimated sample rate of this tuner channel source
|
||||||
|
*/
|
||||||
|
public void broadcastCurrentSampleRate()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Note: downstream sample rate is currently a fixed value -- it will change in the future
|
||||||
|
broadcast(new FrequencyChangeEvent(Event.NOTIFICATION_SAMPLE_RATE_CHANGE, getSampleRate()));
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
mLog.error("Error obtaining sample rate from tuner to broadcast downstream");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the downstream listener to receive frequency change events from this tuner channel source
|
||||||
|
* @param listener to receive events
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
||||||
|
{
|
||||||
|
mListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the downstream listener from receiving frequency change events.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
mListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for receiving frequency change events from downstream components
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes frequency change events from downstream components.
|
||||||
|
* @param event to process
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void receive(FrequencyChangeEvent event)
|
||||||
|
{
|
||||||
|
switch(event.getEvent())
|
||||||
|
{
|
||||||
|
//Frequency correction requests are the only change requests supported from downstream components
|
||||||
|
case REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE:
|
||||||
|
setFrequencyCorrection(event.getValue().intValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decimates an inbound buffer of I/Q samples from the source down to the
|
* Decimates an inbound buffer of I/Q samples from the source down to the
|
||||||
* standard 48000 channel sample rate
|
* standard 48000 channel sample rate
|
||||||
@@ -323,6 +500,13 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
{
|
{
|
||||||
if(mProcessing)
|
if(mProcessing)
|
||||||
{
|
{
|
||||||
|
//Send a heartbeat every time this runs to allow downstream components to perform periodic
|
||||||
|
//state monitoring functions on this thread
|
||||||
|
if(mHeartbeatListener != null)
|
||||||
|
{
|
||||||
|
mHeartbeatListener.receive(HEARTBEAT);
|
||||||
|
}
|
||||||
|
|
||||||
mBuffer.drainTo(mSampleBuffers, 20);
|
mBuffer.drainTo(mSampleBuffers, 20);
|
||||||
|
|
||||||
for(Buffer buffer : mSampleBuffers)
|
for(Buffer buffer : mSampleBuffers)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,13 +17,8 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.tuner;
|
package source.tuner;
|
||||||
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.concurrent.ConcurrentSkipListSet;
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.configuration.TunerConfiguration;
|
import source.tuner.configuration.TunerConfiguration;
|
||||||
import source.tuner.frequency.FrequencyChangeEvent;
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
@@ -32,10 +27,13 @@ import source.tuner.frequency.FrequencyController;
|
|||||||
import source.tuner.frequency.FrequencyController.Tunable;
|
import source.tuner.frequency.FrequencyController.Tunable;
|
||||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
public abstract class TunerController implements Tunable, IFrequencyChangeProcessor
|
public abstract class TunerController implements Tunable, IFrequencyChangeProcessor
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger(TunerController.class);
|
||||||
LoggerFactory.getLogger( TunerController.class );
|
|
||||||
|
|
||||||
/* List of currently tuned channels being served to demod channels */
|
/* List of currently tuned channels being served to demod channels */
|
||||||
private SortedSet<TunerChannel> mTunedChannels = new ConcurrentSkipListSet<>();
|
private SortedSet<TunerChannel> mTunedChannels = new ConcurrentSkipListSet<>();
|
||||||
@@ -44,36 +42,27 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
private double mUsableBandwidthPercentage;
|
private double mUsableBandwidthPercentage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract tuner controller class. The tuner controller manages frequency
|
* Abstract tuner controller class. The tuner controller manages frequency bandwidth and currently tuned channels
|
||||||
* bandwidth and currently tuned channels that are being fed samples from
|
* that are being fed samples from the tuner.
|
||||||
* the tuner.
|
|
||||||
*
|
*
|
||||||
* @param minimumFrequency minimum uncorrected tunable frequency
|
* @param minimumFrequency minimum uncorrected tunable frequency
|
||||||
* @param maximumFrequency maximum uncorrected tunable frequency
|
* @param maximumFrequency maximum uncorrected tunable frequency
|
||||||
* @param middleUnusable is the +/- value center DC spike to avoid for channels
|
* @param middleUnusable is the +/- value center DC spike to avoid for channels
|
||||||
* @param usableBandwidthPercentage is the unusable space at the extreme ends of the spectrum
|
* @param usableBandwidth percentage of usable bandwidth relative to space at the extreme ends of the spectrum
|
||||||
*
|
|
||||||
* @throws SourceException - for any issues related to constructing the
|
* @throws SourceException - for any issues related to constructing the
|
||||||
* class, tuning a frequency, or setting the bandwidth
|
* class, tuning a frequency, or setting the bandwidth
|
||||||
*/
|
*/
|
||||||
public TunerController( long minimumFrequency,
|
public TunerController(long minimumFrequency, long maximumFrequency, int middleUnusable, double usableBandwidth)
|
||||||
long maximumFrequency,
|
|
||||||
int middleUnusable,
|
|
||||||
double usableBandwidthPercentage )
|
|
||||||
{
|
{
|
||||||
mFrequencyController = new FrequencyController( this,
|
mFrequencyController = new FrequencyController(this, minimumFrequency, maximumFrequency, 0.0d);
|
||||||
minimumFrequency,
|
|
||||||
maximumFrequency,
|
|
||||||
0.0d );
|
|
||||||
mMiddleUnusable = middleUnusable;
|
mMiddleUnusable = middleUnusable;
|
||||||
mUsableBandwidthPercentage = usableBandwidthPercentage;
|
mUsableBandwidthPercentage = usableBandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the settings in the tuner configuration
|
* Applies the settings in the tuner configuration
|
||||||
*/
|
*/
|
||||||
public abstract void apply( TunerConfiguration config )
|
public abstract void apply(TunerConfiguration config) throws SourceException;
|
||||||
throws SourceException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responds to requests to set the frequency
|
* Responds to requests to set the frequency
|
||||||
@@ -155,8 +144,7 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
private boolean canTune(TunerChannel channel)
|
private boolean canTune(TunerChannel channel)
|
||||||
{
|
{
|
||||||
//Make sure we're within the tunable frequency range of this tuner
|
//Make sure we're within the tunable frequency range of this tuner
|
||||||
if( getMinFrequency() < channel.getMinFrequency() &&
|
if(getMinFrequency() < channel.getMinFrequency() && getMaxFrequency() > channel.getMaxFrequency())
|
||||||
getMaxFrequency() > channel.getMaxFrequency() )
|
|
||||||
{
|
{
|
||||||
//If this is the first lock, then we're good
|
//If this is the first lock, then we're good
|
||||||
if(mTunedChannels.isEmpty())
|
if(mTunedChannels.isEmpty())
|
||||||
@@ -170,8 +158,7 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
long maxLockedFrequency = mTunedChannels.last().getMaxFrequency();
|
long maxLockedFrequency = mTunedChannels.last().getMaxFrequency();
|
||||||
|
|
||||||
//Requested channel is within current locked channel frequency range
|
//Requested channel is within current locked channel frequency range
|
||||||
if( minLockedFrequency <= channel.getMinFrequency() &&
|
if(minLockedFrequency <= channel.getMinFrequency() && channel.getMaxFrequency() <= maxLockedFrequency)
|
||||||
channel.getMaxFrequency() <= maxLockedFrequency )
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -182,6 +169,7 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Requested channel is lower than the max locked frequency
|
//Requested channel is lower than the max locked frequency
|
||||||
if(channel.getMinFrequency() <= maxLockedFrequency &&
|
if(channel.getMinFrequency() <= maxLockedFrequency &&
|
||||||
maxLockedFrequency - channel.getMinFrequency() <= usableBandwidth)
|
maxLockedFrequency - channel.getMinFrequency() <= usableBandwidth)
|
||||||
@@ -195,25 +183,19 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a digital drop channel (DDC) as a tuner channel from from
|
* Constructs a digital drop channel (DDC) as a tuner channel from from the tuner, or returns null if the channel
|
||||||
* the tuner, or returns null if the channel cannot be sourced from the
|
* cannot be sourced from the tuner.
|
||||||
* tuner.
|
|
||||||
*
|
*
|
||||||
* This controller can't provide a channel if the channel, along with the
|
* This controller can't provide a channel if the channel, along with the current set of sourced channels, can't be
|
||||||
* current set of sourced channels, can't be accomodated within the current
|
* accomodated within the current tuner bandwidth, or if a center frequency cannot be calculated that will ensure
|
||||||
* tuner bandwidth, or if a center frequency cannot be calculated that will
|
* all of the channels can be accomodated and any defined central DC spike avoided.
|
||||||
* ensure all of the channels can be accomodated and any defined central DC
|
|
||||||
* spike avoided.
|
|
||||||
*
|
*
|
||||||
* @param tuner to source the channel from
|
* @param tuner to source the channel from
|
||||||
* @param channel with defined center frequency and bandwidth
|
* @param channel with defined center frequency and bandwidth
|
||||||
*
|
|
||||||
* @return fully constructed tuner channel or null
|
* @return fully constructed tuner channel or null
|
||||||
*
|
|
||||||
* @throws RejectedExecutionException if the decimation processor has an error
|
* @throws RejectedExecutionException if the decimation processor has an error
|
||||||
*/
|
*/
|
||||||
public TunerChannelSource getChannel( Tuner tuner, TunerChannel channel )
|
public TunerChannelSource getChannel(Tuner tuner, TunerChannel channel) throws RejectedExecutionException
|
||||||
throws RejectedExecutionException
|
|
||||||
{
|
{
|
||||||
TunerChannelSource source = null;
|
TunerChannelSource source = null;
|
||||||
|
|
||||||
@@ -246,21 +228,20 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the tuner's LO frequency must be updated in order to
|
* Indicates if the tuner's LO frequency must be updated in order to accommodate the tuner channel
|
||||||
* accomodate the tuner channel
|
|
||||||
*/
|
*/
|
||||||
private boolean requiresLOUpdate(TunerChannel channel) throws SourceException
|
private boolean requiresLOUpdate(TunerChannel channel) throws SourceException
|
||||||
{
|
{
|
||||||
return !( getMinTunedFrequency() <= channel.getMinFrequency() &&
|
boolean isBelow = channel.getMinFrequency() < getMinTunedFrequency();
|
||||||
channel.getMaxFrequency() <= getMaxTunedFrequency() &&
|
boolean isAbove = channel.getMaxFrequency() > getMaxTunedFrequency();
|
||||||
( ( mMiddleUnusable == 0 ) ||
|
boolean overlapsCenter = mMiddleUnusable > 0 &&
|
||||||
( !channel.overlaps( getTunedFrequency() - mMiddleUnusable,
|
channel.overlaps(getFrequency() - mMiddleUnusable, getFrequency() + mMiddleUnusable);
|
||||||
getTunedFrequency() + mMiddleUnusable ) ) ) );
|
|
||||||
|
return isAbove || isBelow || overlapsCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases the currently sourced tuner channel from this tuner and shuts
|
* Releases the currently sourced tuner channel from this tuner and shuts down the tuner if no other sources exist.
|
||||||
* down the tuner if no other sources exist.
|
|
||||||
*/
|
*/
|
||||||
public void releaseChannel(TunerChannelSource tunerChannelSource)
|
public void releaseChannel(TunerChannelSource tunerChannelSource)
|
||||||
{
|
{
|
||||||
@@ -271,82 +252,79 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Local Oscillator frequency accomodate the current set of tuned
|
* Sets the Local Oscillator frequency to accomodate the current set of tuned channels.
|
||||||
* channels.
|
|
||||||
*
|
*
|
||||||
* If there is only a single tuned channel, it is placed immediately to the
|
* If there is only a single tuned channel, it is placed immediately to the right of the usable bandwidth right
|
||||||
* right of the usable bandwidth right of the central DC spike.
|
* of the central DC spike.
|
||||||
*
|
*
|
||||||
* Otherwise, it places the highest channel frequency at the upper end of
|
* Otherwise, it places the highest channel frequency at the upper end of the tuner bandwidth, and then iteratively
|
||||||
* the tuner bandwidth, and then iteratively moves the center frequency
|
* moves the center frequency higher until all channels fit within the bandwidth and none of the channels overlap
|
||||||
* higher until all channels fit within the bandwidth and none of the
|
* any defined central DC spike unusable region. If a center tune frequency cannot be calculated, throw an
|
||||||
* channels overlap any defined central DC spike unusable region. If a
|
* exception so that the most recently added channel can be removed.
|
||||||
* center tune frequency cannot be calculated, throw an exception so that
|
|
||||||
* the most recently added channel can be removed.
|
|
||||||
*
|
*
|
||||||
* Note: the tuned frequency is not changed until a legitimate new frequency
|
* Note: the tuned frequency is not changed until a legitimate new frequency can be calculated. If an exception
|
||||||
* can be calculated. If an exception is thrown, the current frequency is
|
* is thrown, the current frequency is retained, so that the recently added channel can be removed and all other
|
||||||
* retained, so that the recently added channel can be removed and all other
|
|
||||||
* channels can continue as previously arranged.
|
* channels can continue as previously arranged.
|
||||||
*
|
*
|
||||||
* @throws SourceException if the set of tuner channels, including a recently
|
* @throws SourceException if the set of tuner channels, including a recently added channel, cannot be tuned
|
||||||
* added channel, cannot be tuned within the current tuner bandwidth and any
|
* within the current tuner bandwidth and any central DC spike unusable region.
|
||||||
* central DC spike unusable region.
|
|
||||||
*/
|
*/
|
||||||
private void updateLOFrequency() throws SourceException
|
private void updateLOFrequency() throws SourceException
|
||||||
{
|
{
|
||||||
long frequency = getFrequency();
|
long candidateFrequency;
|
||||||
|
|
||||||
boolean frequencyValid = true;
|
boolean isValidCandidateFrequency = true;
|
||||||
|
|
||||||
//If there is only 1 channel, position it to the right of center
|
//If there is only 1 channel set the center frequency so that the channel is positioned to the right of center
|
||||||
if(mTunedChannels.size() == 1)
|
if(mTunedChannels.size() == 1)
|
||||||
{
|
{
|
||||||
frequency = mTunedChannels.first().getMinFrequency() - mMiddleUnusable;
|
candidateFrequency = mTunedChannels.first().getMinFrequency() - mMiddleUnusable + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long minLockedFrequency = mTunedChannels.first().getMinFrequency();
|
long minLockedFrequency = mTunedChannels.first().getMinFrequency();
|
||||||
long maxLockedFrequency = mTunedChannels.last().getMaxFrequency();
|
long maxLockedFrequency = mTunedChannels.last().getMaxFrequency();
|
||||||
|
|
||||||
//Start by placing the highest frequency channel at the high end of
|
//Start by placing the highest frequency channel at the high end of the spectrum
|
||||||
//the spectrum
|
candidateFrequency = maxLockedFrequency - (getUsableBandwidth() / 2);
|
||||||
frequency = maxLockedFrequency - ( getUsableBandwidth() / 2 );
|
|
||||||
|
|
||||||
//Iterate the channels and make sure that none of them overlap the
|
//Iterate the channels and make sure that none of them overlap the center DC spike buffer, if one exists
|
||||||
//center DC spike buffer, if one exists
|
|
||||||
if(mMiddleUnusable > 0)
|
if(mMiddleUnusable > 0)
|
||||||
{
|
{
|
||||||
boolean processingRequired = true;
|
boolean processingRequired = true;
|
||||||
|
|
||||||
while( frequencyValid && processingRequired )
|
while(isValidCandidateFrequency && processingRequired)
|
||||||
{
|
{
|
||||||
processingRequired = false;
|
processingRequired = false;
|
||||||
|
|
||||||
long minAvoid = frequency - mMiddleUnusable;
|
long minAvoid = candidateFrequency - mMiddleUnusable;
|
||||||
long maxAvoid = frequency + mMiddleUnusable;
|
long maxAvoid = candidateFrequency + mMiddleUnusable;
|
||||||
|
|
||||||
|
//If any of the center channel(s) overlap the central DC spike avoid area, we'll iteratively
|
||||||
|
//increase the tuned frequency causing the set of channels to move left in the tuned bandwidth until
|
||||||
|
//we either find a good center tune frequency, or we walk the lowest frequency channel out of the
|
||||||
|
//minimum tuned range, in which case we'll throw an exception indicating we don't have a solution.
|
||||||
for(TunerChannel channel : mTunedChannels)
|
for(TunerChannel channel : mTunedChannels)
|
||||||
{
|
{
|
||||||
if(channel.overlaps(minAvoid, maxAvoid))
|
if(channel.overlaps(minAvoid, maxAvoid))
|
||||||
{
|
{
|
||||||
//Can we move the frequency lower so that the
|
//Calculate a tuned frequency adjustment that places this overlapping channel just to the
|
||||||
//channel sits to the right of center?
|
//left of the central DC spike avoid zone
|
||||||
long adjustment = channel.getMaxFrequency() - minAvoid;
|
long adjustment = channel.getMaxFrequency() - minAvoid + 1;
|
||||||
|
|
||||||
if( frequency + adjustment -
|
//If the candidate frequency doesn't push the lowest channel out of bounds, make adjustment
|
||||||
( getUsableBandwidth() / 2 ) <= minLockedFrequency )
|
if(candidateFrequency + adjustment - (getUsableBandwidth() / 2) <= minLockedFrequency)
|
||||||
{
|
{
|
||||||
frequency += adjustment;
|
candidateFrequency += adjustment;
|
||||||
processingRequired = true;
|
processingRequired = true;
|
||||||
}
|
}
|
||||||
|
//Otherwise, punt and indicate that we can't find a center frequency or add the channel
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
frequencyValid = false;
|
isValidCandidateFrequency = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//break out of the for/each loop, so that we can
|
//break out of the for/each loop, so that we can start over again with all of the channels
|
||||||
//start over again with all of the channels
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,20 +332,18 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( frequencyValid )
|
if(isValidCandidateFrequency)
|
||||||
{
|
{
|
||||||
mFrequencyController.setFrequency( frequency );
|
mFrequencyController.setFrequency(candidateFrequency);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new SourceException( "Couldn't calculate viable center "
|
throw new SourceException("Couldn't calculate viable center frequency from set of tuner channels");
|
||||||
+ "frequency from set of tuner channels" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usable bandwidth - total bandwidth minus the unusable space at either end
|
* Usable bandwidth - total bandwidth minus the unusable space at either end of the spectrum.
|
||||||
* of the spectrum.
|
|
||||||
*/
|
*/
|
||||||
private int getUsableBandwidth()
|
private int getUsableBandwidth()
|
||||||
{
|
{
|
||||||
@@ -375,11 +351,9 @@ public abstract class TunerController implements Tunable, IFrequencyChangeProces
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the listener to be notified any time that the tuner changes frequency
|
* Sets the listener to be notified any time that the tuner changes frequency or bandwidth/sample rate.
|
||||||
* or bandwidth/sample rate.
|
|
||||||
*
|
*
|
||||||
* Note: this is normally used by the Tuner. Any additional listeners can
|
* Note: this is normally used by the Tuner. Any additional listeners can be registered on the tuner.
|
||||||
* be registered on the tuner.
|
|
||||||
*/
|
*/
|
||||||
public void addListener(IFrequencyChangeProcessor processor)
|
public void addListener(IFrequencyChangeProcessor processor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,30 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 source.tuner.frequency;
|
package source.tuner.frequency;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provider of Frequency Change Events
|
||||||
|
*/
|
||||||
public interface IFrequencyChangeProvider
|
public interface IFrequencyChangeProvider
|
||||||
{
|
{
|
||||||
public void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener );
|
void setFrequencyChangeListener( Listener<FrequencyChangeEvent> listener );
|
||||||
public void removeFrequencyChangeListener();
|
void removeFrequencyChangeListener();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class USBTransferProcessor implements TransferCallback
|
|||||||
private static final int TRANSFER_BUFFER_POOL_SIZE = 16;
|
private static final int TRANSFER_BUFFER_POOL_SIZE = 16;
|
||||||
|
|
||||||
//Maximum number of filled buffers for the blocking queue
|
//Maximum number of filled buffers for the blocking queue
|
||||||
private static final int FILLED_BUFFER_MAX_CAPACITY = 300;
|
private static final int FILLED_BUFFER_MAX_CAPACITY = 500;
|
||||||
|
|
||||||
//Threshold for resetting buffer overflow condition
|
//Threshold for resetting buffer overflow condition
|
||||||
private static final int FILLED_BUFFER_OVERFLOW_RESET_THRESHOLD = 100;
|
private static final int FILLED_BUFFER_OVERFLOW_RESET_THRESHOLD = 100;
|
||||||
@@ -200,7 +200,7 @@ public class USBTransferProcessor implements TransferCallback
|
|||||||
|
|
||||||
|
|
||||||
//Unregister from LibUSB processor so that it auto-stops LibUSB processing
|
//Unregister from LibUSB processor so that it auto-stops LibUSB processing
|
||||||
TunerManager.LIBUSB_TRANSFER_PROCESSOR.registerTransferProcessor(this);
|
TunerManager.LIBUSB_TRANSFER_PROCESSOR.unregisterTransferProcessor(this);
|
||||||
|
|
||||||
//Directly invoke the timeout handler to ensure that our cancelled transfer buffers are flushed.
|
//Directly invoke the timeout handler to ensure that our cancelled transfer buffers are flushed.
|
||||||
int result = LibUsb.handleEventsTimeoutCompleted(null, USB_TIMEOUT_MS,
|
int result = LibUsb.handleEventsTimeoutCompleted(null, USB_TIMEOUT_MS,
|
||||||
@@ -414,11 +414,13 @@ public class USBTransferProcessor implements TransferCallback
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
|
{
|
||||||
|
mFilledBuffers.drainTo(mBuffersToDispatch, 50);
|
||||||
|
|
||||||
|
while(!mBuffersToDispatch.isEmpty())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mFilledBuffers.drainTo(mBuffersToDispatch, 15);
|
|
||||||
|
|
||||||
for(byte[] buffer : mBuffersToDispatch)
|
for(byte[] buffer : mBuffersToDispatch)
|
||||||
{
|
{
|
||||||
float[] complexSamples = mSampleAdapter.convert(buffer);
|
float[] complexSamples = mSampleAdapter.convert(buffer);
|
||||||
@@ -432,6 +434,8 @@ public class USBTransferProcessor implements TransferCallback
|
|||||||
}
|
}
|
||||||
|
|
||||||
mBuffersToDispatch.clear();
|
mBuffersToDispatch.clear();
|
||||||
|
mFilledBuffers.drainTo(mBuffersToDispatch, 50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,28 +14,29 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.wave;
|
package source.wave;
|
||||||
|
|
||||||
import java.io.File;
|
import channel.heartbeat.Heartbeat;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
|
|
||||||
import javax.sound.sampled.AudioFormat;
|
|
||||||
import javax.sound.sampled.AudioInputStream;
|
|
||||||
import javax.sound.sampled.AudioSystem;
|
|
||||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sample.ConversionUtils;
|
import sample.ConversionUtils;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.complex.ComplexBuffer;
|
import sample.complex.ComplexBuffer;
|
||||||
import source.ComplexSource;
|
import source.ComplexSource;
|
||||||
import source.IControllableFileSource;
|
import source.IControllableFileSource;
|
||||||
import source.IFrameLocationListener;
|
import source.IFrameLocationListener;
|
||||||
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
|
|
||||||
|
import javax.sound.sampled.AudioFormat;
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
public class ComplexWaveSource extends ComplexSource implements IControllableFileSource
|
public class ComplexWaveSource extends ComplexSource implements IControllableFileSource
|
||||||
{
|
{
|
||||||
@@ -55,6 +56,41 @@ public class ComplexWaveSource extends ComplexSource implements IControllableFil
|
|||||||
mFile = file;
|
mFile = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Not implemented
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setHeartbeatListener(Listener<Heartbeat> listener)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Not implemented
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeHeartbeatListener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,31 +17,29 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.wave;
|
package source.wave;
|
||||||
|
|
||||||
import java.io.File;
|
import channel.heartbeat.Heartbeat;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
|
|
||||||
import javax.sound.sampled.AudioFormat;
|
|
||||||
import javax.sound.sampled.AudioInputStream;
|
|
||||||
import javax.sound.sampled.AudioSystem;
|
|
||||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sample.ConversionUtils;
|
import sample.ConversionUtils;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.real.RealBuffer;
|
import sample.real.RealBuffer;
|
||||||
import source.IControllableFileSource;
|
import source.IControllableFileSource;
|
||||||
import source.IFrameLocationListener;
|
import source.IFrameLocationListener;
|
||||||
import source.RealSource;
|
import source.RealSource;
|
||||||
|
import source.tuner.frequency.FrequencyChangeEvent;
|
||||||
|
|
||||||
public class RealWaveSource extends RealSource
|
import javax.sound.sampled.AudioFormat;
|
||||||
implements IControllableFileSource, AutoCloseable
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
|
public class RealWaveSource extends RealSource implements IControllableFileSource, AutoCloseable
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger(RealWaveSource.class);
|
||||||
LoggerFactory.getLogger( RealWaveSource.class );
|
|
||||||
|
|
||||||
private IFrameLocationListener mFrameLocationListener;
|
private IFrameLocationListener mFrameLocationListener;
|
||||||
private int mBytesPerFrame;
|
private int mBytesPerFrame;
|
||||||
@@ -56,6 +54,41 @@ public class RealWaveSource extends RealSource
|
|||||||
mFile = file;
|
mFile = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFrequencyChangeListener(Listener<FrequencyChangeEvent> listener)
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Listener<FrequencyChangeEvent> getFrequencyChangeListener()
|
||||||
|
{
|
||||||
|
//Not implemented
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Not implemented
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setHeartbeatListener(Listener<Heartbeat> listener)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Not implemented
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void removeHeartbeatListener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class OverlayPanel extends JPanel implements ChannelEventListener, IFrequ
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(OverlayPanel.class);
|
private final static Logger mLog = LoggerFactory.getLogger(OverlayPanel.class);
|
||||||
|
private final DecimalFormat PPM_FORMATTER = new DecimalFormat( "#.0" );
|
||||||
|
|
||||||
private final static RenderingHints RENDERING_HINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
|
private final static RenderingHints RENDERING_HINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
@@ -187,7 +188,6 @@ public class OverlayPanel extends JPanel implements ChannelEventListener, IFrequ
|
|||||||
* 6 64x Zoom
|
* 6 64x Zoom
|
||||||
*
|
*
|
||||||
* @param zoom level, 0 - 6.
|
* @param zoom level, 0 - 6.
|
||||||
* @param offset into the FFT bins for start zoom window
|
|
||||||
*/
|
*/
|
||||||
public void setZoom(int zoom)
|
public void setZoom(int zoom)
|
||||||
{
|
{
|
||||||
@@ -412,20 +412,41 @@ public class OverlayPanel extends JPanel implements ChannelEventListener, IFrequ
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a vertical line at the xaxis
|
* Draws the Automatic Frequency Control (AFC) channel center offset
|
||||||
*/
|
*/
|
||||||
private void drawAFC(Graphics2D graphics, double frequencyAxis, double errorAxis)
|
private void drawAFC(Graphics2D graphics, double frequencyAxis, double errorAxis, double bandwidth,
|
||||||
|
int correction, long frequency)
|
||||||
{
|
{
|
||||||
double height = getSize().getHeight() - mSpectrumInset;
|
double height = getSize().getHeight() - mSpectrumInset;
|
||||||
double lineHeight = height * 0.75d;
|
double verticalAxisTop = height * 0.88d;
|
||||||
|
double verticalAxisBottom = height * 0.98d;
|
||||||
|
|
||||||
|
double halfBandwidth = bandwidth / 2.0;
|
||||||
|
double errorEdgeStart = errorAxis - halfBandwidth;
|
||||||
|
double errorEdgeStop = errorAxis + halfBandwidth;
|
||||||
|
|
||||||
graphics.setColor(Color.YELLOW);
|
graphics.setColor(Color.YELLOW);
|
||||||
|
|
||||||
//Vertical frequency error line
|
//Horizontal line connecting frequency and error line
|
||||||
graphics.draw(new Line2D.Double(errorAxis, lineHeight, errorAxis, height - 1.0d));
|
graphics.draw(new Line2D.Double(errorEdgeStart, verticalAxisBottom, errorEdgeStop, verticalAxisBottom));
|
||||||
|
|
||||||
//Horizontal line connecting frequency and error lines
|
//Vertical band edge lines
|
||||||
graphics.draw(new Line2D.Double(frequencyAxis, lineHeight, errorAxis, lineHeight));
|
graphics.draw(new Line2D.Double(errorEdgeStart, verticalAxisTop, errorEdgeStart, verticalAxisBottom));
|
||||||
|
graphics.draw(new Line2D.Double(errorEdgeStop, verticalAxisTop, errorEdgeStop, verticalAxisBottom));
|
||||||
|
|
||||||
|
double ppm = (double)correction / ((double)frequency / 1E6d);
|
||||||
|
|
||||||
|
String label = "PPM " + PPM_FORMATTER.format(ppm) ;
|
||||||
|
|
||||||
|
FontMetrics fontMetrics = graphics.getFontMetrics(this.getFont());
|
||||||
|
|
||||||
|
Rectangle2D rect = fontMetrics.getStringBounds(label, graphics);
|
||||||
|
|
||||||
|
//Only render the correction value label if the spacing is large enough
|
||||||
|
if(rect.getWidth() <= bandwidth && rect.getHeight() * 5 <= height)
|
||||||
|
{
|
||||||
|
graphics.drawString(label, (float)(errorEdgeStart + 1.0), (float)(verticalAxisBottom - 2.0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -564,7 +585,8 @@ public class OverlayPanel extends JPanel implements ChannelEventListener, IFrequ
|
|||||||
{
|
{
|
||||||
long error = frequency + correction;
|
long error = frequency + correction;
|
||||||
|
|
||||||
drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error));
|
drawAFC(graphics, frequencyAxis, getAxisFromFrequency(error), width, correction,
|
||||||
|
tunerChannel.getFrequency());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,56 +14,43 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package spectrum;
|
package spectrum;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.GradientPaint;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.geom.GeneralPath;
|
|
||||||
import java.awt.geom.Line2D;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import settings.ColorSetting;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import settings.Setting;
|
|
||||||
import settings.SettingChangeListener;
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import dsp.filter.smoothing.GaussianSmoothingFilter;
|
import dsp.filter.smoothing.GaussianSmoothingFilter;
|
||||||
import dsp.filter.smoothing.NoSmoothingFilter;
|
import dsp.filter.smoothing.NoSmoothingFilter;
|
||||||
import dsp.filter.smoothing.RectangularSmoothingFilter;
|
import dsp.filter.smoothing.RectangularSmoothingFilter;
|
||||||
import dsp.filter.smoothing.SmoothingFilter;
|
import dsp.filter.smoothing.SmoothingFilter;
|
||||||
import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
|
import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
|
||||||
import dsp.filter.smoothing.TriangularSmoothingFilter;
|
import dsp.filter.smoothing.TriangularSmoothingFilter;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import settings.ColorSetting;
|
||||||
|
import settings.ColorSetting.ColorSettingName;
|
||||||
|
import settings.Setting;
|
||||||
|
import settings.SettingChangeListener;
|
||||||
|
import settings.SettingsManager;
|
||||||
|
|
||||||
public class SpectrumPanel extends JPanel
|
import javax.swing.*;
|
||||||
implements DFTResultsListener,
|
import java.awt.*;
|
||||||
SettingChangeListener,
|
import java.awt.geom.GeneralPath;
|
||||||
SpectralDisplayAdjuster
|
import java.awt.geom.Line2D;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class SpectrumPanel extends JPanel implements DFTResultsListener, SettingChangeListener, SpectralDisplayAdjuster
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger(SpectrumPanel.class);
|
||||||
LoggerFactory.getLogger( SpectrumPanel.class );
|
|
||||||
|
|
||||||
private static final RenderingHints RENDERING_HINTS =
|
private static final RenderingHints RENDERING_HINTS =
|
||||||
new RenderingHints( RenderingHints.KEY_ANTIALIASING,
|
new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON );
|
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
RENDERING_HINTS.put( RenderingHints.KEY_RENDERING,
|
RENDERING_HINTS.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||||
RenderingHints.VALUE_RENDER_QUALITY );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color mColorSpectrumBackground;
|
private Color mColorSpectrumBackground;
|
||||||
@@ -87,7 +74,8 @@ public class SpectrumPanel extends JPanel
|
|||||||
private float mDBScale;
|
private float mDBScale;
|
||||||
|
|
||||||
private int mZoom = 0;
|
private int mZoom = 0;
|
||||||
private int mZoomWindowOffset = 0;;
|
private int mZoomWindowOffset = 0;
|
||||||
|
;
|
||||||
|
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
|
|
||||||
@@ -278,12 +266,13 @@ public class SpectrumPanel extends JPanel
|
|||||||
* 3 8x Zoom
|
* 3 8x Zoom
|
||||||
* 4 16x Zoom
|
* 4 16x Zoom
|
||||||
* 5 32x Zoom
|
* 5 32x Zoom
|
||||||
|
* 6 64x Zoom
|
||||||
*
|
*
|
||||||
* @param zoom level, 0 - 5.
|
* @param zoom level, 0 - 6.
|
||||||
*/
|
*/
|
||||||
public void setZoom(int zoom)
|
public void setZoom(int zoom)
|
||||||
{
|
{
|
||||||
Validate.isTrue( 0 <= zoom && zoom <= 5 );
|
Validate.isTrue(0 <= zoom && zoom <= 6, "Unrecognized Zoom Level: " + zoom);
|
||||||
|
|
||||||
mZoom = zoom;
|
mZoom = zoom;
|
||||||
}
|
}
|
||||||
@@ -427,7 +416,8 @@ public class SpectrumPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void settingDeleted( Setting setting ) { /* not implemented */ }
|
public void settingDeleted(Setting setting)
|
||||||
|
{ /* not implemented */ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current inter-bin smoothing setting
|
* Returns the current inter-bin smoothing setting
|
||||||
|
|||||||
54
src/util/MemoryUsageLogger.java
Normal file
54
src/util/MemoryUsageLogger.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* sdrtrunk
|
||||||
|
* Copyright (C) 2014-2017 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 util;
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.pattern.ClassicConverter;
|
||||||
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom logging plugin for logging memory usage with logback
|
||||||
|
*
|
||||||
|
* Add the following to the logback.xml configuration file to use this custom converter:
|
||||||
|
*
|
||||||
|
* <conversionRule conversionWord="memory_usage" converterClass="util.MemoryUsageLogger" />
|
||||||
|
*
|
||||||
|
* Update the encoder pattern to include %memory_usage within the pattern
|
||||||
|
*/
|
||||||
|
public class MemoryUsageLogger extends ClassicConverter
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public String convert(ILoggingEvent iLoggingEvent)
|
||||||
|
{
|
||||||
|
//Method argument is ignored - we simply return memory usage statistics
|
||||||
|
long allocated = Runtime.getRuntime().totalMemory();
|
||||||
|
long free = Runtime.getRuntime().freeMemory();
|
||||||
|
long used = allocated - free;
|
||||||
|
|
||||||
|
int usedPercentage = (int)((double)(used) / (double)allocated * 100.0);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append("[").append(FileUtils.byteCountToDisplaySize(used).replace(" ", ""));
|
||||||
|
sb.append("/").append(FileUtils.byteCountToDisplaySize(allocated).replace(" ", ""));
|
||||||
|
sb.append(" ").append(usedPercentage).append("%]");
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user