Initial commit of redesigned internal processing and audio management.

Note: Several of the decoders are currently non-functioning in this
commit.  If you want the latest functioning codebase, please checkout
the commit prior to this one.  All decoders will eventually be updated
with this new architecture.

Currently broken:
- Logging and recording
- Aux decoders (Fleetsync/MDC/LoJack/Tait)
- LTR/Passport decoders

Changes in this commit:
- Module architecture for decoders and components with central
provisioning by the DecoderFactory
- Transition from Complex sample stream processing to float buffer
processing for improved memory management
- Redesigned filter structures - to support buffers and streams
- Resolved several memory leak issues
- Universal sharing of the thread pool manager
- Added centralized audio management with call/user prioritization and
new gui with mute/volume controls
- Embedded audio metadata for eventual streaming support
- Redesigned ProcessingChain to support independent re-use
- Added new TrafficChannelManager to handle traffic channel allocations
- Traffic Channel pool size and Call timeout available in P25 and
MPT1327 configs
- Redesigned channel and decoder gui components
This commit is contained in:
denny
2015-09-01 07:10:26 -04:00
parent 538a299246
commit f4d8ea281d
570 changed files with 21578 additions and 17012 deletions

View File

@@ -0,0 +1,120 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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 controller.channel.map;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
@XmlSeeAlso( { ChannelRange.class } )
public class ChannelMap
{
private String mName;
private ArrayList<ChannelRange> mRanges = new ArrayList<ChannelRange>();
public ChannelMap()
{
this( "New Channel Map" );
}
public ChannelMap( String name )
{
mName = name;
}
public String toString()
{
return mName;
}
/**
* Creates a copy of this channel map
*/
public ChannelMap copyOf()
{
ChannelMap map = new ChannelMap( mName );
for( ChannelRange range: mRanges )
{
map.addRange( range.copyOf() );
}
return map;
}
public int getInvalidRange()
{
for( int x = 0; x < mRanges.size(); x++ )
{
if( !mRanges.get( x ).isValid() )
{
return x;
}
}
return -1;
}
public ArrayList<ChannelRange> getRanges()
{
return mRanges;
}
@XmlElement( name = "range" )
public void setRanges( ArrayList<ChannelRange> ranges )
{
mRanges = ranges;
}
@XmlAttribute
public String getName()
{
return mName;
}
public void setName( String name )
{
mName = name;
}
public long getFrequency( int channelNumber )
{
for( ChannelRange range: mRanges )
{
if( range.hasChannel( channelNumber ) )
{
return range.getFrequency( channelNumber );
}
}
return 0;
}
public void addRange( ChannelRange range )
{
mRanges.add( range );
}
public void deleteRange( ChannelRange range )
{
mRanges.remove( range );
}
}

View File

@@ -0,0 +1,224 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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 controller.channel.map;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.AbstractCellEditor;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableCellEditor;
import javax.swing.text.InternationalFormatter;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ChannelMapEditor extends JPanel implements ActionListener
{
private static final long serialVersionUID = 1L;
private final static Logger mLog =
LoggerFactory.getLogger( ChannelMapEditor.class );
private ChannelMapNode mChannelMapNode;
private JLabel mNameLabel;
private JTextField mNameText;
private ChannelMapModel mRangeModel;
private JTable mRangeTable;
private JButton mDelete;
private ChannelMap mChannelMapCopy;
public ChannelMapEditor( ChannelMapNode ChannelMap )
{
mChannelMapNode = ChannelMap;
mChannelMapCopy = mChannelMapNode.getChannelMap().copyOf();
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "fill,wrap 2", "[right][grow]", "[][][grow][][]" ) );
add( new JLabel( "Channel Map" ), "span, align center" );
mNameLabel = new JLabel( "Name:" );
add( mNameLabel );
mNameText = new JTextField( mChannelMapCopy.getName() );
mNameText.addFocusListener( new FocusListener()
{
@Override public void focusGained( FocusEvent arg0 ) {}
@Override
public void focusLost( FocusEvent arg0 )
{
mChannelMapCopy.setName( mNameText.getText() );
}
} );
add( mNameText, "growx, push" );
mRangeModel = new ChannelMapModel( mChannelMapCopy );
mRangeTable = new JTable( mRangeModel );
mRangeTable.setPreferredScrollableViewportSize( new Dimension( 300, 150 ) );
mRangeTable.setFillsViewportHeight( true );
mRangeTable.setAutoCreateRowSorter( true );
for( int x = 0; x < mRangeTable.getColumnCount(); x++ )
{
mRangeTable.getColumnModel().getColumn( x )
.setCellEditor( new RangeTableEditor() );
}
JScrollPane scrollPane = new JScrollPane( mRangeTable );
add( scrollPane, "span,grow,push");
JButton btnNew = new JButton( "New Range" );
btnNew.addActionListener( ChannelMapEditor.this );
add( btnNew );
mDelete = new JButton( "Delete" );
mDelete.addActionListener( ChannelMapEditor.this );
add( mDelete, "wrap" );
JButton btnSave = new JButton( "Save" );
btnSave.addActionListener( ChannelMapEditor.this );
add( btnSave, "growx" );
JButton btnReset = new JButton( "Reset " );
btnReset.addActionListener( ChannelMapEditor.this );
add( btnReset, "wrap" );
}
private boolean checkForValidRanges()
{
int invalidRow = mChannelMapCopy.getInvalidRange();
if( invalidRow != -1 && invalidRow <= mRangeTable.getRowCount() )
{
mRangeTable.setRowSelectionInterval( invalidRow, invalidRow );
JOptionPane.showMessageDialog( this,
"Starting channel number must be less than ending channel number",
"Channel number range error",
JOptionPane.WARNING_MESSAGE );
return false;
}
return true;
}
@Override
public void actionPerformed( ActionEvent e )
{
String command = e.getActionCommand();
switch( command )
{
case "New Range":
mRangeModel.addRange( new ChannelRange() );
break;
case "Save":
if( checkForValidRanges() )
{
mChannelMapNode.getChannelMap()
.setName( mChannelMapCopy.getName() );
mChannelMapNode.getChannelMap()
.setRanges( mChannelMapCopy.getRanges() );
mChannelMapNode.save();
mChannelMapNode.refresh();
mChannelMapNode.show();
}
case "Reset":
mChannelMapCopy = mChannelMapNode.getChannelMap();
mRangeModel.setChannelMap( mChannelMapCopy );
mNameText.setText( mChannelMapCopy.getName() );
break;
case "Delete":
int row = mRangeTable.getSelectedRow();
if( row < 0 )
{
JOptionPane.showMessageDialog( this,
"Please select a channel range to delete",
"Select a range",
JOptionPane.WARNING_MESSAGE );
}
else
{
mRangeModel.removeRange(
mRangeTable.convertRowIndexToModel( row ) );
}
break;
}
}
public class RangeTableEditor extends AbstractCellEditor
implements TableCellEditor, ActionListener
{
JFormattedTextField mEditor;
public RangeTableEditor()
{
InternationalFormatter nf = new InternationalFormatter();
nf.setMinimum( 1 );
nf.setAllowsInvalid( false );
mEditor = new JFormattedTextField( nf );
}
@Override
public Object getCellEditorValue()
{
return mEditor.getText();
}
@Override
public void actionPerformed( ActionEvent e )
{
}
@Override
public Component getTableCellEditorComponent( JTable table,
Object value,
boolean isSelected,
int row,
int column )
{
mEditor.setValue( value );
return mEditor;
}
}
}

View File

@@ -0,0 +1,76 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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 controller.channel.map;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
@XmlSeeAlso( ChannelMap.class )
public class ChannelMapList
{
private ArrayList<ChannelMap> mChannelMap = new ArrayList<ChannelMap>();
public ChannelMapList()
{
/* Empty constructor for JAXB */
}
@XmlElement( name = "channel_map" )
public ArrayList<ChannelMap> getChannelMap()
{
return mChannelMap;
}
public void setChannelMap( ArrayList<ChannelMap> ChannelMaps )
{
mChannelMap = ChannelMaps;
}
public void addChannelMap( ChannelMap ChannelMap )
{
mChannelMap.add( ChannelMap );
}
public void removeChannelMap( ChannelMap ChannelMap )
{
mChannelMap.remove( ChannelMap );
}
public void clearChannelMaps()
{
mChannelMap.clear();
}
/**
* Gets the named channel map, or returns an empty map
*/
public ChannelMap getChannelMap( String name )
{
for( ChannelMap map: mChannelMap )
{
if( map.getName().equalsIgnoreCase( name ) )
{
return map;
}
}
return new ChannelMap();
}
}

View File

@@ -0,0 +1,87 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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 controller.channel.map;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import controller.ConfigurableNode;
public class ChannelMapListNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public ChannelMapListNode( ChannelMapList list )
{
super( list );
}
public ChannelMapList getChannelMapList()
{
return (ChannelMapList)getUserObject();
}
public void init()
{
for( ChannelMap channelMap: getChannelMapList().getChannelMap() )
{
ChannelMapNode node = new ChannelMapNode( channelMap );
getModel().addNode( node, ChannelMapListNode.this, getChildCount() );
node.init();
}
sort();
}
public String toString()
{
return "Channel Maps [" + this.getChildCount() + "]";
}
public JPopupMenu getContextMenu()
{
JPopupMenu retVal = new JPopupMenu();
JMenuItem addSystemItem = new JMenuItem( "Add Channel Map" );
addSystemItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
ChannelMap channelMap = new ChannelMap();
getChannelMapList().addChannelMap( channelMap );
getModel().addNode( new ChannelMapNode( channelMap ),
ChannelMapListNode.this,
ChannelMapListNode.this.getChildCount() );
save();
}
} );
retVal.add( addSystemItem );
return retVal;
}
}

View File

@@ -0,0 +1,171 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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 controller.channel.map;
import javax.swing.table.AbstractTableModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ChannelMapModel extends AbstractTableModel
{
private static final long serialVersionUID = 1L;
private final static Logger mLog =
LoggerFactory.getLogger( ChannelMapModel.class );
private static final int sSTART = 0;
private static final int sSTOP = 1;
private static final int sBASE = 2;
private static final int sSIZE = 3;
protected int[] mColumnWidths = { 110, 110, 110, -1 };
protected String[] mHeaders = new String[] { "Begin",
"End",
"Base",
"Size" };
private ChannelMap mChannelMap;
public ChannelMapModel( ChannelMap map )
{
mChannelMap = map;
}
public ChannelMap getChannelMap()
{
return mChannelMap;
}
public void setChannelMap( ChannelMap map )
{
mChannelMap = map;
fireTableDataChanged();
}
public void addRange( ChannelRange range )
{
mChannelMap.addRange( range );
int index = mChannelMap.getRanges().size() - 1;
fireTableRowsInserted( index, index );
}
public void removeRange( int rangeIndex )
{
if( rangeIndex < mChannelMap.getRanges().size() )
{
mChannelMap.getRanges().remove( rangeIndex );
}
fireTableRowsDeleted( rangeIndex, rangeIndex );
}
public int[] getColumnWidths()
{
return mColumnWidths;
}
public void setColumnWidths( int[] widths )
{
if( widths.length != 4 )
{
throw new IllegalArgumentException( "ChannelMapRangeModel - "
+ "column widths array should have 5 elements" );
}
else
{
mColumnWidths = widths;
}
}
@Override
public int getRowCount()
{
return mChannelMap.getRanges().size();
}
@Override
public int getColumnCount()
{
return mHeaders.length;
}
public String getColumnName( int column )
{
return mHeaders[ column ];
}
@Override
public Object getValueAt( int rowIndex, int columnIndex )
{
ChannelRange range = mChannelMap.getRanges().get( rowIndex );
switch( columnIndex )
{
case sSTART:
return range.getFirstChannelNumber();
case sSTOP:
return range.getLastChannelNumber();
case sBASE:
return range.getBase();
case sSIZE:
return range.getSize();
}
return null;
}
public boolean isCellEditable( int row, int column )
{
return true;
}
public void setValueAt( Object value, int row, int column )
{
try
{
int parsedValue = Integer.parseInt( (String)value );
ChannelRange range = mChannelMap.getRanges().get( row );
switch( column )
{
case sSTART:
range.setFirstChannelNumber( parsedValue );
break;
case sSTOP:
range.setLastChannelNumber( parsedValue );
break;
case sBASE:
range.setBase( parsedValue );
break;
case sSIZE:
range.setSize( parsedValue );
break;
}
}
catch( Exception e )
{
mLog.error( "ChannelMapModel - couldn't parse integer value "
+ "for [" + value + "]", e );
}
}
}

View File

@@ -0,0 +1,102 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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 controller.channel.map;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import controller.ConfigurableNode;
public class ChannelMapNode extends ConfigurableNode
{
private static final long serialVersionUID = 1L;
public ChannelMapNode( ChannelMap ChannelMap )
{
super( ChannelMap );
}
public void init()
{
//For consistency, but not used
}
@Override
public String getIconPath()
{
return "images/ChannelMap.png";
}
@Override
public JPanel getEditor()
{
return new ChannelMapEditor( this );
}
public ChannelMap getChannelMap()
{
return (ChannelMap)getUserObject();
}
public String toString()
{
return getChannelMap().getName();
}
public void delete()
{
ChannelMapListNode parent = (ChannelMapListNode)getParent();
parent.getChannelMapList().removeChannelMap( getChannelMap() );
save();
getModel().removeNodeFromParent( ChannelMapNode.this );
/* Show the first child, if one exists so that we don't have a
* collapsed list */
if( parent.getChildCount() > 0 )
{
((ConfigurableNode)parent.getFirstChild()).show();
}
}
public JPopupMenu getContextMenu()
{
JPopupMenu retVal = new JPopupMenu();
JMenuItem deleteItem = new JMenuItem( "Delete" );
deleteItem.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
delete();
}
} );
retVal.add( deleteItem );
return retVal;
}
}

View File

@@ -0,0 +1,122 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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 controller.channel.map;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement
@XmlType( name = "range" )
public class ChannelRange
{
private int mFirst = 1;
private int mLast = 1023;
private int mBase = 450000000;
private int mSize = 12500;
/* JAXB requirement - do not remove */
public ChannelRange() {}
public ChannelRange( int first, int last, int base, int size )
{
mFirst = first;
mLast = last;
mBase = base;
mSize = size;
}
public ChannelRange copyOf()
{
return new ChannelRange( mFirst, mLast, mBase, mSize );
}
public boolean isValid()
{
return mFirst < mLast;
}
public boolean hasChannel( int channel )
{
return mFirst <= channel && channel <= mLast;
}
public long getFrequency( int channel )
{
if( hasChannel( channel ) )
{
return mBase + ( ( channel - mFirst ) * mSize );
}
else
{
return 0;
}
}
@XmlAttribute( name = "first" )
public int getFirstChannelNumber()
{
return mFirst;
}
public void setFirstChannelNumber( int first )
{
mFirst = first;
}
@XmlAttribute( name = "last" )
public void setLastChannelNumber( int last )
{
mLast = last;
}
public int getLastChannelNumber()
{
return mLast;
}
/**
* Sets the base frequency
* @param base frequency in hertz
*/
@XmlAttribute( name = "base" )
public void setBase( int base )
{
mBase = base;
}
public int getBase()
{
return mBase;
}
/**
* Sets the channel size
* @param size in hertz
*/
@XmlAttribute( name = "size" )
public void setSize( int size )
{
mSize = size;
}
public int getSize()
{
return mSize;
}
}