#90 [WIP] merged metadata management for channel state, decoder states and audio metadata into a new metadata class. The new metadata class is maintained for each decoding audio channel, or in the future, a decoding TDMA channel. Audio playback, recording and streaming all use the same metadata object for the channel. The list of channel processing gui panels have been deleted and channel processing status will now reside in a table where each table row is a metadata instance from the processing channel. The channel processing manager is responsible for adding/removing the channel's metadata instance to/from the metadata table. This allows the channel processing table to be the controller for the messages, events and channel spectrum views, keyed to the selected table row metadata.

I still have to clean up the gui components and wire in the table selection listeners.
This commit is contained in:
Denny
2017-01-17 19:24:54 -05:00
parent 16b69d4aef
commit bc8873de01
67 changed files with 6207 additions and 10127 deletions

View File

@@ -20,7 +20,7 @@ package record;
import audio.AudioPacket;
import audio.IAudioPacketListener;
import audio.metadata.AudioMetadata;
import channel.metadata.Metadata;
import module.Module;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,7 +49,7 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
private AtomicBoolean mRunning = new AtomicBoolean();
protected Path mPath;
protected AudioMetadata mAudioMetadata;
protected Metadata mMetadata;
protected long mTimeRecordingStart;
protected long mTimeLastPacketReceived;
private BufferProcessor mBufferProcessor;
@@ -79,9 +79,9 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
/**
* Latest audio metadata received for this recording
*/
public AudioMetadata getMetadata()
public Metadata getMetadata()
{
return mAudioMetadata;
return mMetadata;
}
/**
@@ -119,7 +119,7 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
}
/**
* Processes the audio packet and captures the latest AudioMetadata for the recording for easy access.
* Processes the audio packet and captures the latest Metadata for the recording for easy access.
*/
@Override
public void receive(AudioPacket audioPacket)
@@ -129,14 +129,14 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
mTimeRecordingStart = System.currentTimeMillis();
mTimeLastPacketReceived = mTimeRecordingStart;
if(audioPacket.hasAudioMetadata())
if(audioPacket.hasMetadata())
{
mAudioMetadata = audioPacket.getAudioMetadata();
mMetadata = audioPacket.getMetadata();
}
boolean success = mAudioPacketQueue.offer(audioPacket);
if (!success)
if(!success)
{
mLog.error("recorder buffer overflow - stopping recorder [" + getPath().toString() + "]");
stop();
@@ -189,11 +189,11 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
*/
public void start(ScheduledExecutorService executor)
{
if (mRunning.compareAndSet(false, true))
if(mRunning.compareAndSet(false, true))
{
mTimeLastPacketReceived = System.currentTimeMillis();
if (mBufferProcessor == null)
if(mBufferProcessor == null)
{
mBufferProcessor = new BufferProcessor();
}
@@ -205,7 +205,7 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
/* Schedule the handler to run every half second */
mProcessorHandle = executor.scheduleAtFixedRate(mBufferProcessor, 0, 500, TimeUnit.MILLISECONDS);
}
catch (IOException io)
catch(IOException io)
{
mLog.error("Error starting audio recorder [" + getPath().toString() + "]", io);
@@ -221,13 +221,13 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
{
mAudioPacketQueue.drainTo(mPacketsToProcess);
if (!mPacketsToProcess.isEmpty())
if(!mPacketsToProcess.isEmpty())
{
try
{
record(mPacketsToProcess);
for(AudioPacket packet: mPacketsToProcess)
for(AudioPacket packet : mPacketsToProcess)
{
if(packet.getType() == AudioPacket.Type.AUDIO)
{
@@ -279,7 +279,7 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
public void run()
{
if (mProcessing.compareAndSet(false, true))
if(mProcessing.compareAndSet(false, true))
{
processAudioPacketQueue();
@@ -290,14 +290,14 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
//Allow sub-classes to flush remaining audio frame data to disk.
flush();
if (mFileOutputStream != null)
if(mFileOutputStream != null)
{
try
{
mFileOutputStream.flush();
mFileOutputStream.close();
}
catch (IOException e)
catch(IOException e)
{
mLog.error("Error closing output stream", e);
}
@@ -308,7 +308,7 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
mRecordingClosedListener.receive(AudioRecorder.this);
}
if (mProcessorHandle != null)
if(mProcessorHandle != null)
{
mProcessorHandle.cancel(false);
mProcessorHandle = null;

View File

@@ -18,8 +18,7 @@
package record;
import audio.AudioPacket;
import audio.metadata.Metadata;
import audio.metadata.MetadataType;
import channel.metadata.Metadata;
import controller.ThreadPoolManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,7 +37,7 @@ public class RecorderManager implements Listener<AudioPacket>
public static final int AUDIO_SAMPLE_RATE = 8000;
private Map<String, RealBufferWaveRecorder> mRecorders = new HashMap<>();
private Map<String,RealBufferWaveRecorder> mRecorders = new HashMap<>();
private ThreadPoolManager mThreadPoolManager;
@@ -61,10 +60,10 @@ public class RecorderManager implements Listener<AudioPacket>
@Override
public void receive(AudioPacket audioPacket)
{
if(audioPacket.hasAudioMetadata() &&
audioPacket.getAudioMetadata().isRecordable())
if(audioPacket.hasMetadata() &&
audioPacket.getMetadata().isRecordable())
{
String identifier = audioPacket.getAudioMetadata().getIdentifier();
String identifier = audioPacket.getMetadata().getUniqueIdentifier();
if(mRecorders.containsKey(identifier))
{
@@ -125,37 +124,18 @@ public class RecorderManager implements Listener<AudioPacket>
sb.append(File.separator);
Metadata systemMetadata = packet.getAudioMetadata().getMetadata(MetadataType.SYSTEM);
Metadata metadata = packet.getMetadata();
sb.append(systemMetadata != null ? systemMetadata.getValue() : "UNKNOWN_SYSTEM");
sb.append(metadata.getNetworkID1().hasIdentifier() ? metadata.getNetworkID1().getIdentifier() + "_" : "SYSTEM-SITE");
sb.append(metadata.getNetworkID1().hasIdentifier() ? metadata.getNetworkID1().getIdentifier() : "CHANNEL");
Metadata toMetadata = packet.getAudioMetadata().getMetadata(MetadataType.TO);
if(toMetadata != null)
if(metadata.getPrimaryAddressTo().hasIdentifier())
{
sb.append("_TO_").append(toMetadata.getValue());
sb.append("_TO_").append(metadata.getPrimaryAddressTo().getIdentifier());
Metadata fromMetadata = packet.getAudioMetadata().getMetadata(MetadataType.FROM);
if(fromMetadata != null)
if(metadata.getPrimaryAddressFrom().hasIdentifier())
{
sb.append("_FROM_").append(fromMetadata.getValue());
}
}
else
{
Metadata siteMetadata = packet.getAudioMetadata().getMetadata(MetadataType.SITE_ID);
if(siteMetadata != null)
{
sb.append("_").append(siteMetadata.getValue());
}
Metadata channelMetadata = packet.getAudioMetadata().getMetadata(MetadataType.CHANNEL_NAME);
if(channelMetadata != null)
{
sb.append("_").append(channelMetadata.getValue());
sb.append("_FROM_").append(metadata.getPrimaryAddressFrom().getIdentifier());
}
}

View File

@@ -1,6 +1,6 @@
/*******************************************************************************
* 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
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@ package record.wave;
import audio.AudioPacket;
import audio.IAudioPacketListener;
import audio.metadata.AudioMetadata;
import channel.metadata.Metadata;
import sample.Listener;
import sample.real.RealBuffer;
@@ -29,7 +29,7 @@ import java.nio.file.Path;
public class AudioPacketMonoWaveReader extends MonoWaveReader implements Listener<RealBuffer>
{
private AudioMetadata mMetadata = new AudioMetadata(0, false);
private Metadata mMetadata = new Metadata();
private IAudioPacketListener mListener;
@@ -40,7 +40,6 @@ public class AudioPacketMonoWaveReader extends MonoWaveReader implements Listene
* @param realTime causes the read() method to read and dispatch audio packets in real time. Note: when using
* real time playback, the thread calling the read() method will sleep as needed to effect real-time playback,
* therefore you should invoke read() on a separate thread if this will impact the calling thread.
*
* @throws IOException on any file IO errors
*/
public AudioPacketMonoWaveReader(Path path, boolean realTime) throws IOException
@@ -49,7 +48,7 @@ public class AudioPacketMonoWaveReader extends MonoWaveReader implements Listene
setListener(this);
}
public void setMetadata(AudioMetadata metadata)
public void setMetadata(Metadata metadata)
{
mMetadata = metadata;
}