mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
WIP - Updated P25 C4FM and LSM decoders to assemble dibits and push
reusable byte buffers out to the processing chain. This enables the processing chain to broadcast these buffers back to the decoder for message assembly and to any running binary recorder. Updated P25Decoder to be a reusable byte buffer listener. The decoder will now pass reusable byte buffers down to the message framer for message processing. This should make the code more efficient since it can process byte arrays versus handling each individual dibit. The P25MessageFramer has been updated to be a listener of reusable byte buffers instead of Dibits, but the actual processing of byte arrays has to be coded. Added max recording size to the binary recorder so that it cycles at 500 kB max file size.
This commit is contained in:
@@ -476,9 +476,6 @@ public class DecoderFactory
|
||||
*/
|
||||
public static EnumSet<DecoderType> getBitstreamDecoders()
|
||||
{
|
||||
// return EnumSet.of(DecoderType.P25_PHASE1);
|
||||
|
||||
//None of the decoders currently support bitstream output.
|
||||
return EnumSet.noneOf(DecoderType.class);
|
||||
return EnumSet.of(DecoderType.P25_PHASE1);
|
||||
}
|
||||
}
|
||||
@@ -16,19 +16,25 @@
|
||||
package io.github.dsheirer.module.decode.p25;
|
||||
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.dsp.symbol.DibitToByteBufferAssembler;
|
||||
import io.github.dsheirer.module.decode.Decoder;
|
||||
import io.github.dsheirer.module.decode.DecoderType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.IReusableByteBufferListener;
|
||||
import io.github.dsheirer.sample.buffer.IReusableByteBufferProvider;
|
||||
import io.github.dsheirer.sample.buffer.IReusableComplexBufferListener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableByteBuffer;
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBuffer;
|
||||
import io.github.dsheirer.source.ISourceEventListener;
|
||||
import io.github.dsheirer.source.ISourceEventProvider;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
|
||||
public abstract class P25Decoder extends Decoder implements ISourceEventListener, ISourceEventProvider,
|
||||
IReusableComplexBufferListener, Listener<ReusableComplexBuffer>
|
||||
public abstract class P25Decoder extends Decoder
|
||||
implements ISourceEventListener, ISourceEventProvider, IReusableComplexBufferListener, Listener<ReusableComplexBuffer>,
|
||||
IReusableByteBufferProvider, IReusableByteBufferListener
|
||||
{
|
||||
private double mSampleRate;
|
||||
private DibitToByteBufferAssembler mByteBufferAssembler = new DibitToByteBufferAssembler(300);
|
||||
private P25MessageProcessor mMessageProcessor;
|
||||
private AliasList mAliasList;
|
||||
private Listener<SourceEvent> mSourceEventListener;
|
||||
@@ -42,6 +48,41 @@ public abstract class P25Decoder extends Decoder implements ISourceEventListener
|
||||
mMessageProcessor.setMessageListener(getMessageListener());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assembler for packaging Dibit stream into reusable byte buffers.
|
||||
*/
|
||||
protected DibitToByteBufferAssembler getByteBufferAssembler()
|
||||
{
|
||||
return mByteBufferAssembler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the IByteBufferProvider interface - delegates to the byte buffer assembler
|
||||
*/
|
||||
@Override
|
||||
public void setBufferListener(Listener<ReusableByteBuffer> listener)
|
||||
{
|
||||
getByteBufferAssembler().setBufferListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the IByteBufferProvider interface - delegates to the byte buffer assembler
|
||||
*/
|
||||
@Override
|
||||
public void removeBufferListener(Listener<ReusableByteBuffer> listener)
|
||||
{
|
||||
getByteBufferAssembler().removeBufferListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the IByteBufferProvider interface - delegates to the byte buffer assembler
|
||||
*/
|
||||
@Override
|
||||
public boolean hasBufferListeners()
|
||||
{
|
||||
return getByteBufferAssembler().hasBufferListeners();
|
||||
}
|
||||
|
||||
protected double getSymbolRate()
|
||||
{
|
||||
return mSymbolRate;
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.github.dsheirer.dsp.psk.DQPSKDecisionDirectedDemodulator;
|
||||
import io.github.dsheirer.dsp.psk.InterpolatingSampleBuffer;
|
||||
import io.github.dsheirer.dsp.psk.pll.AdaptivePLLGainMonitor;
|
||||
import io.github.dsheirer.dsp.psk.pll.CostasLoop;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBuffer;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
import org.slf4j.Logger;
|
||||
@@ -76,7 +77,15 @@ public class P25DecoderC4FM extends P25Decoder
|
||||
mMessageFramer = new P25MessageFramer(getAliasList(), mCostasLoop, mPLLGainMonitor);
|
||||
mMessageFramer.setListener(getMessageProcessor());
|
||||
mMessageFramer.setSampleRate(sampleRate);
|
||||
mQPSKDemodulator.setSymbolListener(mMessageFramer);
|
||||
|
||||
// mQPSKDemodulator.setSymbolListener(mMessageFramer);
|
||||
mQPSKDemodulator.setSymbolListener(getByteBufferAssembler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener getReusableByteBufferListener()
|
||||
{
|
||||
return mMessageFramer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,7 +78,7 @@ public class P25DecoderC4FMInstrumented extends P25DecoderC4FM
|
||||
instrumented.setPLLFrequencyListener(mPLLFrequencyListener);
|
||||
instrumented.setSymbolDecisionDataListener(mSymbolDecisionDataListener);
|
||||
instrumented.setSamplesPerSymbolListener(mSamplesPerSymbolListener);
|
||||
instrumented.setSymbolListener(mMessageFramer);
|
||||
instrumented.setSymbolListener(getByteBufferAssembler());
|
||||
}
|
||||
|
||||
public void setComplexSymbolListener(Listener<Complex> listener)
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.github.dsheirer.dsp.psk.DQPSKGardnerDemodulator;
|
||||
import io.github.dsheirer.dsp.psk.InterpolatingSampleBuffer;
|
||||
import io.github.dsheirer.dsp.psk.pll.AdaptivePLLGainMonitor;
|
||||
import io.github.dsheirer.dsp.psk.pll.CostasLoop;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBuffer;
|
||||
import io.github.dsheirer.source.SourceEvent;
|
||||
|
||||
@@ -78,7 +79,14 @@ public class P25DecoderLSM extends P25Decoder
|
||||
mMessageFramer = new P25MessageFramer(getAliasList(), mCostasLoop, mPLLGainMonitor);
|
||||
mMessageFramer.setListener(getMessageProcessor());
|
||||
mMessageFramer.setSampleRate(sampleRate);
|
||||
mQPSKDemodulator.setSymbolListener(mMessageFramer);
|
||||
// mQPSKDemodulator.setSymbolListener(mMessageFramer);
|
||||
mQPSKDemodulator.setSymbolListener(getByteBufferAssembler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener getReusableByteBufferListener()
|
||||
{
|
||||
return mMessageFramer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,7 +79,7 @@ public class P25DecoderLSMInstrumented extends P25DecoderLSM
|
||||
instrumented.setPLLFrequencyListener(mPLLFrequencyListener);
|
||||
instrumented.setSymbolDecisionDataListener(mSymbolDecisionDataListener);
|
||||
instrumented.setSamplesPerSymbolListener(mSamplesPerSymbolListener);
|
||||
instrumented.setSymbolListener(mMessageFramer);
|
||||
instrumented.setSymbolListener(getByteBufferAssembler());
|
||||
}
|
||||
|
||||
public void setComplexSymbolListener(Listener<Complex> listener)
|
||||
|
||||
@@ -32,13 +32,14 @@ import io.github.dsheirer.module.decode.p25.message.vselp.VSELP1Message;
|
||||
import io.github.dsheirer.module.decode.p25.message.vselp.VSELP2Message;
|
||||
import io.github.dsheirer.module.decode.p25.reference.DataUnitID;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableByteBuffer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class P25MessageFramer implements Listener<Dibit>
|
||||
public class P25MessageFramer implements Listener<ReusableByteBuffer>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(P25MessageFramer.class);
|
||||
|
||||
@@ -199,24 +200,30 @@ public class P25MessageFramer implements Listener<Dibit>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(Dibit symbol)
|
||||
public void receive(ReusableByteBuffer reusableByteBuffer)
|
||||
{
|
||||
for(P25MessageAssembler assembler : mAssemblers)
|
||||
{
|
||||
if(assembler.isActive())
|
||||
{
|
||||
assembler.receive(symbol);
|
||||
|
||||
if(assembler.complete())
|
||||
{
|
||||
assembler.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mMatcher.receive(symbol.getBit1(), symbol.getBit2());
|
||||
//process the buffer received
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void receive(Dibit symbol)
|
||||
// {
|
||||
// for(P25MessageAssembler assembler : mAssemblers)
|
||||
// {
|
||||
// if(assembler.isActive())
|
||||
// {
|
||||
// assembler.receive(symbol);
|
||||
//
|
||||
// if(assembler.complete())
|
||||
// {
|
||||
// assembler.reset();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// mMatcher.receive(symbol.getBit1(), symbol.getBit2());
|
||||
// }
|
||||
|
||||
public void setListener(Listener<Message> listener)
|
||||
{
|
||||
mListener = listener;
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* sdr-trunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program.
|
||||
* If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.decode.p25;
|
||||
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
@@ -13,8 +28,7 @@ import java.util.HashMap;
|
||||
|
||||
public class P25MessageProcessor implements Listener<Message>
|
||||
{
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( P25MessageProcessor.class );
|
||||
private final static Logger mLog = LoggerFactory.getLogger( P25MessageProcessor.class );
|
||||
|
||||
private Listener<Message> mMessageListener;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user