mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#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:
@@ -1,31 +1,36 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2015-2016 Dennis Sheirer
|
||||
* 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 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.
|
||||
* 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/>
|
||||
*
|
||||
* 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 module;
|
||||
|
||||
import audio.AudioPacket;
|
||||
import audio.IAudioPacketListener;
|
||||
import audio.IAudioPacketProvider;
|
||||
import audio.metadata.IMetadataListener;
|
||||
import audio.metadata.IMetadataProvider;
|
||||
import audio.metadata.Metadata;
|
||||
import audio.squelch.ISquelchStateListener;
|
||||
import audio.squelch.ISquelchStateProvider;
|
||||
import audio.squelch.SquelchState;
|
||||
import channel.state.ChannelState;
|
||||
import channel.state.DecoderState;
|
||||
import channel.state.DecoderStateEvent;
|
||||
import channel.state.DecoderStateEvent.Event;
|
||||
import channel.state.IDecoderStateEventListener;
|
||||
import channel.state.IDecoderStateEventProvider;
|
||||
import channel.state.State;
|
||||
import controller.NamingThreadFactory;
|
||||
import controller.channel.Channel.ChannelType;
|
||||
import controller.channel.ChannelEvent;
|
||||
@@ -39,13 +44,6 @@ import module.decode.event.CallEventModel;
|
||||
import module.decode.event.ICallEventListener;
|
||||
import module.decode.event.ICallEventProvider;
|
||||
import module.decode.event.MessageActivityModel;
|
||||
import channel.state.ChannelState;
|
||||
import channel.state.DecoderState;
|
||||
import channel.state.DecoderStateEvent;
|
||||
import channel.state.DecoderStateEvent.Event;
|
||||
import channel.state.IDecoderStateEventListener;
|
||||
import channel.state.IDecoderStateEventProvider;
|
||||
import channel.state.State;
|
||||
import module.log.EventLogger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -98,7 +96,6 @@ public class ProcessingChain implements IChannelEventListener
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ProcessingChain.class);
|
||||
|
||||
private Broadcaster<AudioPacket> mAudioPacketBroadcaster = new Broadcaster<>();
|
||||
private Broadcaster<Metadata> mMetadataBroadcaster = new Broadcaster<>();
|
||||
private Broadcaster<CallEvent> mCallEventBroadcaster = new Broadcaster<>();
|
||||
private Broadcaster<ChannelEvent> mChannelEventBroadcaster = new Broadcaster<>();
|
||||
private Broadcaster<ComplexBuffer> mComplexBufferBroadcaster = new Broadcaster<>();
|
||||
@@ -186,17 +183,6 @@ public class ProcessingChain implements IChannelEventListener
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts the metadata to any registered listeners
|
||||
*/
|
||||
public void broadcast(Metadata metadata)
|
||||
{
|
||||
if(mMetadataBroadcaster != null)
|
||||
{
|
||||
mMetadataBroadcaster.broadcast(metadata);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this processing chain is currently receiving samples from
|
||||
* a source and sending those samples to the decoders.
|
||||
@@ -227,9 +213,8 @@ public class ProcessingChain implements IChannelEventListener
|
||||
{
|
||||
if(isProcessing())
|
||||
{
|
||||
throw new IllegalStateException("Processing chain is currently "
|
||||
+ "processing. Invoke stop() on the processing chain before "
|
||||
+ "applying a new sample source");
|
||||
throw new IllegalStateException("Processing chain is currently processing. Invoke stop() on the " +
|
||||
"processing chain before applying a new sample source");
|
||||
}
|
||||
|
||||
mSource = source;
|
||||
@@ -314,68 +299,52 @@ public class ProcessingChain implements IChannelEventListener
|
||||
{
|
||||
if(module instanceof IAudioPacketListener)
|
||||
{
|
||||
mAudioPacketBroadcaster.addListener(
|
||||
((IAudioPacketListener) module).getAudioPacketListener());
|
||||
mAudioPacketBroadcaster.addListener(((IAudioPacketListener) module).getAudioPacketListener());
|
||||
}
|
||||
|
||||
if(module instanceof ICallEventListener)
|
||||
{
|
||||
mCallEventBroadcaster.addListener(
|
||||
((ICallEventListener) module).getCallEventListener());
|
||||
mCallEventBroadcaster.addListener(((ICallEventListener) module).getCallEventListener());
|
||||
}
|
||||
|
||||
if(module instanceof IChannelEventListener)
|
||||
{
|
||||
mChannelEventBroadcaster.addListener(
|
||||
((IChannelEventListener) module).getChannelEventListener());
|
||||
mChannelEventBroadcaster.addListener(((IChannelEventListener) module).getChannelEventListener());
|
||||
}
|
||||
|
||||
if(module instanceof IComplexBufferListener)
|
||||
{
|
||||
mComplexBufferBroadcaster.addListener(
|
||||
((IComplexBufferListener) module).getComplexBufferListener());
|
||||
mComplexBufferBroadcaster.addListener(((IComplexBufferListener) module).getComplexBufferListener());
|
||||
}
|
||||
|
||||
if(module instanceof IDecoderStateEventListener)
|
||||
{
|
||||
mDecoderStateEventBroadcaster.addListener(
|
||||
((IDecoderStateEventListener) module).getDecoderStateListener());
|
||||
mDecoderStateEventBroadcaster.addListener(((IDecoderStateEventListener) module).getDecoderStateListener());
|
||||
}
|
||||
|
||||
if(module instanceof IFrequencyChangeListener)
|
||||
{
|
||||
mFrequencyChangeEventBroadcaster.addListener(
|
||||
((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
||||
mFrequencyChangeEventBroadcaster.addListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
||||
}
|
||||
|
||||
if(module instanceof IMessageListener)
|
||||
{
|
||||
mMessageBroadcaster.addListener(
|
||||
((IMessageListener) module).getMessageListener());
|
||||
}
|
||||
|
||||
if(module instanceof IMetadataListener)
|
||||
{
|
||||
mMetadataBroadcaster.addListener(
|
||||
((IMetadataListener) module).getMetadataListener());
|
||||
mMessageBroadcaster.addListener(((IMessageListener) module).getMessageListener());
|
||||
}
|
||||
|
||||
if(module instanceof IFilteredRealBufferListener)
|
||||
{
|
||||
mFilteredRealBufferBroadcaster.addListener(
|
||||
((IFilteredRealBufferListener) module).getFilteredRealBufferListener());
|
||||
mFilteredRealBufferBroadcaster.addListener(((IFilteredRealBufferListener) module).getFilteredRealBufferListener());
|
||||
}
|
||||
|
||||
if(module instanceof ISquelchStateListener)
|
||||
{
|
||||
mSquelchStateBroadcaster.addListener(
|
||||
((ISquelchStateListener) module).getSquelchStateListener());
|
||||
mSquelchStateBroadcaster.addListener(((ISquelchStateListener) module).getSquelchStateListener());
|
||||
}
|
||||
|
||||
if(module instanceof IUnFilteredRealBufferListener)
|
||||
{
|
||||
mUnFilteredRealBufferBroadcaster.addListener(
|
||||
((IUnFilteredRealBufferListener) module).getUnFilteredRealBufferListener());
|
||||
mUnFilteredRealBufferBroadcaster.addListener(((IUnFilteredRealBufferListener) module).getUnFilteredRealBufferListener());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,38 +356,32 @@ public class ProcessingChain implements IChannelEventListener
|
||||
{
|
||||
if(module instanceof IAudioPacketListener)
|
||||
{
|
||||
mAudioPacketBroadcaster.removeListener(
|
||||
((IAudioPacketListener) module).getAudioPacketListener());
|
||||
mAudioPacketBroadcaster.removeListener(((IAudioPacketListener) module).getAudioPacketListener());
|
||||
}
|
||||
|
||||
if(module instanceof ICallEventListener)
|
||||
{
|
||||
mCallEventBroadcaster.removeListener(
|
||||
((ICallEventListener) module).getCallEventListener());
|
||||
mCallEventBroadcaster.removeListener(((ICallEventListener) module).getCallEventListener());
|
||||
}
|
||||
|
||||
if(module instanceof IChannelEventListener)
|
||||
{
|
||||
mChannelEventBroadcaster.removeListener(
|
||||
((IChannelEventListener) module).getChannelEventListener());
|
||||
mChannelEventBroadcaster.removeListener(((IChannelEventListener) module).getChannelEventListener());
|
||||
}
|
||||
|
||||
if(module instanceof IComplexBufferListener)
|
||||
{
|
||||
mComplexBufferBroadcaster.removeListener(
|
||||
((IComplexBufferListener) module).getComplexBufferListener());
|
||||
mComplexBufferBroadcaster.removeListener(((IComplexBufferListener) module).getComplexBufferListener());
|
||||
}
|
||||
|
||||
if(module instanceof IDecoderStateEventListener)
|
||||
{
|
||||
mDecoderStateEventBroadcaster.removeListener(
|
||||
((IDecoderStateEventListener) module).getDecoderStateListener());
|
||||
mDecoderStateEventBroadcaster.removeListener(((IDecoderStateEventListener) module).getDecoderStateListener());
|
||||
}
|
||||
|
||||
if(module instanceof IFrequencyChangeListener)
|
||||
{
|
||||
mFrequencyChangeEventBroadcaster.removeListener(
|
||||
((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
||||
mFrequencyChangeEventBroadcaster.removeListener(((IFrequencyChangeListener) module).getFrequencyChangeListener());
|
||||
}
|
||||
|
||||
if(module instanceof IMessageListener)
|
||||
@@ -426,27 +389,19 @@ public class ProcessingChain implements IChannelEventListener
|
||||
mMessageBroadcaster.removeListener(((IMessageListener) module).getMessageListener());
|
||||
}
|
||||
|
||||
if(module instanceof IMetadataListener)
|
||||
{
|
||||
mMetadataBroadcaster.removeListener(((IMetadataListener) module).getMetadataListener());
|
||||
}
|
||||
|
||||
if(module instanceof IFilteredRealBufferListener)
|
||||
{
|
||||
mFilteredRealBufferBroadcaster.removeListener(
|
||||
((IFilteredRealBufferListener) module).getFilteredRealBufferListener());
|
||||
mFilteredRealBufferBroadcaster.removeListener(((IFilteredRealBufferListener) module).getFilteredRealBufferListener());
|
||||
}
|
||||
|
||||
if(module instanceof ISquelchStateListener)
|
||||
{
|
||||
mSquelchStateBroadcaster.removeListener(
|
||||
((ISquelchStateListener) module).getSquelchStateListener());
|
||||
mSquelchStateBroadcaster.removeListener(((ISquelchStateListener) module).getSquelchStateListener());
|
||||
}
|
||||
|
||||
if(module instanceof IUnFilteredRealBufferListener)
|
||||
{
|
||||
mUnFilteredRealBufferBroadcaster.removeListener(
|
||||
((IUnFilteredRealBufferListener) module).getUnFilteredRealBufferListener());
|
||||
mUnFilteredRealBufferBroadcaster.removeListener(((IUnFilteredRealBufferListener) module).getUnFilteredRealBufferListener());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,8 +413,7 @@ public class ProcessingChain implements IChannelEventListener
|
||||
{
|
||||
if(module instanceof IAudioPacketProvider)
|
||||
{
|
||||
((IAudioPacketProvider) module).setAudioPacketListener(
|
||||
mAudioPacketBroadcaster);
|
||||
((IAudioPacketProvider) module).setAudioPacketListener(mAudioPacketBroadcaster);
|
||||
}
|
||||
|
||||
if(module instanceof ICallEventProvider)
|
||||
@@ -469,20 +423,17 @@ public class ProcessingChain implements IChannelEventListener
|
||||
|
||||
if(module instanceof IChannelEventProvider)
|
||||
{
|
||||
((IChannelEventProvider) module).setChannelEventListener(
|
||||
mChannelEventBroadcaster);
|
||||
((IChannelEventProvider) module).setChannelEventListener(mChannelEventBroadcaster);
|
||||
}
|
||||
|
||||
if(module instanceof IDecoderStateEventProvider)
|
||||
{
|
||||
((IDecoderStateEventProvider) module).setDecoderStateListener(
|
||||
mDecoderStateEventBroadcaster);
|
||||
((IDecoderStateEventProvider) module).setDecoderStateListener(mDecoderStateEventBroadcaster);
|
||||
}
|
||||
|
||||
if(module instanceof IFrequencyChangeProvider)
|
||||
{
|
||||
((IFrequencyChangeProvider) module).setFrequencyChangeListener(
|
||||
mFrequencyChangeEventBroadcaster);
|
||||
((IFrequencyChangeProvider) module).setFrequencyChangeListener(mFrequencyChangeEventBroadcaster);
|
||||
}
|
||||
|
||||
if(module instanceof IMessageProvider)
|
||||
@@ -490,28 +441,19 @@ public class ProcessingChain implements IChannelEventListener
|
||||
((IMessageProvider) module).setMessageListener(mMessageBroadcaster);
|
||||
}
|
||||
|
||||
if(module instanceof IMetadataProvider)
|
||||
{
|
||||
((IMetadataProvider) module).setMetadataListener(
|
||||
mMetadataBroadcaster);
|
||||
}
|
||||
|
||||
if(module instanceof IFilteredRealBufferProvider)
|
||||
{
|
||||
((IFilteredRealBufferProvider) module)
|
||||
.setFilteredRealBufferListener(mFilteredRealBufferBroadcaster);
|
||||
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(mFilteredRealBufferBroadcaster);
|
||||
}
|
||||
|
||||
if(module instanceof ISquelchStateProvider)
|
||||
{
|
||||
((ISquelchStateProvider) module).setSquelchStateListener(
|
||||
mSquelchStateBroadcaster);
|
||||
((ISquelchStateProvider) module).setSquelchStateListener(mSquelchStateBroadcaster);
|
||||
}
|
||||
|
||||
if(module instanceof IUnFilteredRealBufferProvider)
|
||||
{
|
||||
((IUnFilteredRealBufferProvider) module)
|
||||
.setUnFilteredRealBufferListener(mUnFilteredRealBufferBroadcaster);
|
||||
((IUnFilteredRealBufferProvider) module).setUnFilteredRealBufferListener(mUnFilteredRealBufferBroadcaster);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,11 +493,6 @@ public class ProcessingChain implements IChannelEventListener
|
||||
((IMessageProvider) module).setMessageListener(null);
|
||||
}
|
||||
|
||||
if(module instanceof IMetadataProvider)
|
||||
{
|
||||
((IMetadataProvider) module).setMetadataListener(null);
|
||||
}
|
||||
|
||||
if(module instanceof IFilteredRealBufferProvider)
|
||||
{
|
||||
((IFilteredRealBufferProvider) module).setFilteredRealBufferListener(null);
|
||||
@@ -587,7 +524,7 @@ public class ProcessingChain implements IChannelEventListener
|
||||
{
|
||||
module.reset();
|
||||
}
|
||||
|
||||
|
||||
/* Register with the source to receive sample data. Setup a
|
||||
* timer task to process the buffer queues 50 times a second
|
||||
* (every 20 ms) */
|
||||
@@ -615,8 +552,7 @@ public class ProcessingChain implements IChannelEventListener
|
||||
long frequency = tcs.getFrequency();
|
||||
|
||||
mDecoderStateEventBroadcaster.broadcast(
|
||||
new DecoderStateEvent(this, Event.SOURCE_FREQUENCY,
|
||||
State.IDLE, frequency));
|
||||
new DecoderStateEvent(this, Event.SOURCE_FREQUENCY, State.IDLE, frequency));
|
||||
}
|
||||
catch(SourceException e)
|
||||
{
|
||||
@@ -697,7 +633,7 @@ public class ProcessingChain implements IChannelEventListener
|
||||
{
|
||||
List<Module> eventLoggingModules = new ArrayList<>();
|
||||
|
||||
for(Module module: mModules)
|
||||
for(Module module : mModules)
|
||||
{
|
||||
if(module instanceof EventLogger)
|
||||
{
|
||||
@@ -705,7 +641,7 @@ public class ProcessingChain implements IChannelEventListener
|
||||
}
|
||||
}
|
||||
|
||||
for(Module eventLoggingModule: eventLoggingModules)
|
||||
for(Module eventLoggingModule : eventLoggingModules)
|
||||
{
|
||||
removeModule(eventLoggingModule);
|
||||
}
|
||||
@@ -718,7 +654,7 @@ public class ProcessingChain implements IChannelEventListener
|
||||
{
|
||||
List<Module> recordingModules = new ArrayList<>();
|
||||
|
||||
for(Module module: mModules)
|
||||
for(Module module : mModules)
|
||||
{
|
||||
if(module instanceof RealBufferWaveRecorder || module instanceof ComplexBufferWaveRecorder)
|
||||
{
|
||||
@@ -726,7 +662,7 @@ public class ProcessingChain implements IChannelEventListener
|
||||
}
|
||||
}
|
||||
|
||||
for(Module recordingModule: recordingModules)
|
||||
for(Module recordingModule : recordingModules)
|
||||
{
|
||||
removeModule(recordingModule);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user