Identifier Framework and Message/Event Processing Overhaul (#455)

* WIP on new P25 message framer.

* WIP on new P25 message framer.

* Adds new 1/2 and 3/4 rate trellis decoders.  Still trying to chase
down why there is a sync pattern mismatch in the NID buffer queue.

* WIP - new p25 message framer works correctly now.  PDU's are dectected
and decoded using the 1/2 and 3/4 rate trellis decoders.  Packet
Sequences are assembled.  Need to add a new packet sequence message
factory that can detect Motorola Auto Registration Service (ARS)
formatted UDP/ID packets and SNDCP command packets.

* WIP - removes nullify on channel results queue.

* WIP - updates message framer for TSBK 1/2/3 processing.

* WIP removing P25 sync pattern and nid bits from all message parsers.

* WIP - merges identifier framework branch changes into this branch.

* WIP on updating link control words to new format and identifier framework.

* WIP - implements rest of link control words for extended formats

* WIP - initial work on ISP/OSP TSBK message restructuring.

* WIP - adds more TSBK ISP and OSP messages

* WIP - finished updating most of the TSBK ISP and OSP messages.  Converted
all messages to no longer include the NID (nac + dataunitID) so that
each message can simply hold the parsed values.  Removed AliasList as
an argument to each message and updated all messges to use the new
IIdentifer and IAPCO25Channel interfaces.

Removed legacy TDU and LDU link control messages and replaced with a
single LinkControlWord class hierarchy.

P25 decoder state is not yet updated for the new message structure.

PDU message parsing is not fully implemented.

* WIP - adds some Multi-Block trunking control messages with Alternate
and Unconfirmed formats.

* WIP - Fully implements AMBTC and UMBTC PDU message parsers.

Some package restructuring.

* WIP - Resolves Link control parsing in LDU1 and 2 messages.

* WIP - finishes updating TSBK and Link Control messages.  Adds support
for moto link control messages for patch groups.

* WIP - finishes updating TSBK and Link Control messages.  Adds support
for moto link control messages for patch groups.  Adds support for moto
ARS service, IPV4 decoding, and UDP/IP packets.

* WIP - finishes SNDCP packet data with header parsing.  Compressed IP or
UDP headers are not yet supported, but are logged as such.

* WIP - converts all talkgroup identifiers to integers and updates
alias list to create a per-protocol map of talkgroup id's to alias.

Inserts a legacy talkgroup (ltr, p25, passport, mpt1327, mdc, etc.)
conversion utility to convert existing legacy (string) talkgroups to
new integer talkgroup format.

Creates an audio packet manager to insert metadata into audio packets
before streaming packets for playback, recording, and/or streaming.

Creates identifier collection to manage current identifiers in each of
the channel and decoder states.

Creates simplified channel metadata to maintain the now playing display.

Moves channel attributes (alias list, system, site, name) as configuration
identifiers in the channel state.

Many other refactoring and updates.

* WIP - numerous updates to push use of identifier collection throughout
the system.  Updates the channel metadata and audio packet processing
logic.  Implements a large portion of the P25 decode state processing.
Updates traffic channel management.  Adds user preferences for timestamp
and identifier formatting, however doesn't add a user interface yet.

* WIP - initial implementation of user preferences editor window.

* WIP - updates preferences editor window to close and dispose window but
retain javafx event thread running.

* WIP - fully updates p25 decoder state and traffic channel processing to
use the new identifier framework.

Cleans up channel event processing and removes channel model as the sole
broadcaster of channel events.  Channel processing manager now listens
for all start/stop events and requestors dispatch event directly to the
channel processing manager.

Resolves issue in airspy that was causing user interface to lock-up.  The
issue appears to occur when the dongle is plugged into a usb port that
can't fully support the data rate.  sdrtrunk now recognizes these errors
and warns the user that they should use another usb port.

* WIP - updates alias action manager and adds new talkgroup range alias identifier.

Updates playlist to incorporate a version number so that the playlist
updater only runs when needed, to update a playlist to the correct
version format.

Updates user preferences to use the google event bus to broadcast
preference update notifications to remove the need for listeners to
register directly on the user preferences instance.

* WIP - updates alias id editors to flag invalid values and moves legacy
alias ids to legacy package.

Updates event logging configuration to add traffic channel decode events
and decoded message logging.  Removes binary message logging since that
is now replaced with demodulated bitstream recording.

* Removes system properties from user preferences.  Preferences are stored
in the OS-dependent settings store (windows - registry)

* Updates MapService to use new PlottableDecodeEvent instead of monitoring
all of the decoded messages.

Updates Fleetsync decoder and related messages to identifier framework.

* Updates LTR-Net, Fleetsync and LJ1200 decoders to new identifier
framework and adds support for user preferences for formatting of
LTR-Net and fleetsync talkgroup identifiers.

Breaks LTR-Net messages into various message types and uses a new
message factory.

Removes alias list from message processing for ltr-net, fleetsync and
lj1200.

* Updates LTR-Standard messages to Identifier framework.

* Removes Plottable and IPlottable from codebase.

* wip

* WIP on MPT-1327 messages.

* Updates MPT1327 decoder to identifier framework and new traffic channel
manager.  This decoder still needs to be updated with a new message
parser factory and a sync detector like what is now used for P25.

* Updates MDC1200 decoder and message to identifier framework.

* Updates Tait1200 and Passport decoders to identifier framework.

* Merges changes from master branch.

* Removes legacy alias support classes.  Updates passport message processor
to only pass valid messages.  Adds support to playlist updater for
converting passport mobile ids to become passport talkgroup values.

* Updates P25 decoder state and channel state to better track allocated
traffic channels.  Resolves issue in timestamp manager for trackig
message timestamps. Resolves issue in airspy tuner that was causing
the tuner to stop sending samples to the application.

* Update P25 Decoder state to process SNDCP management messages and
PDU messages.

Updates P25 activity summary to display network and site details.

Resolves issue with overlay panel that prevented enabled channels from
rendering correctly when zoomed in.

* Creates a new FilePreferences as part of the user preferences to begin
the transition of SystemProperties over to user preferences and consolidate
file preferences in one location.

Updates playlist manager to use the new file preferences and to use
default.xml as the new default playlist name, following conversion of
a playlist_v2.xml format to the new format.

In the near future, the user will be able to edit file locations and to
create/use other playlists.

Resolved an issue with all decoder states where not all identifiers were
being included in decode events.
This commit is contained in:
Denny Sheirer
2018-12-24 09:08:34 -05:00
committed by GitHub
parent 735fca16d6
commit b67d4d92dc
869 changed files with 64776 additions and 45233 deletions

View File

@@ -19,7 +19,7 @@
package io.github.dsheirer.audio.broadcast;
import io.github.dsheirer.audio.convert.ISilenceGenerator;
import io.github.dsheirer.channel.metadata.Metadata;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.util.ThreadPool;
import org.slf4j.Logger;
@@ -99,15 +99,15 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
/**
* Broadcasts the next song's audio metadata prior to streaming the next song.
*
* @param metadata for the next recording that will be streamed
* @param identifierCollection for the next recording that will be streamed
*/
protected void broadcastMetadata(Metadata metadata)
protected void broadcastMetadata(IdentifierCollection identifierCollection)
{
IBroadcastMetadataUpdater metadataUpdater = getMetadataUpdater();
if(metadataUpdater != null)
{
metadataUpdater.update(metadata);
metadataUpdater.update(identifierCollection);
}
}
@@ -442,7 +442,7 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
if(connected())
{
broadcastMetadata(nextRecording.getMetadata());
broadcastMetadata(nextRecording.getIdentifierCollection());
}
metadataUpdateRequired = false;

View File

@@ -18,7 +18,7 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast;
import io.github.dsheirer.channel.metadata.Metadata;
import io.github.dsheirer.identifier.IdentifierCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,20 +33,20 @@ public class AudioRecording implements Comparable<AudioRecording>
private long mStartTime;
private long mRecordingLength;
private AtomicInteger mPendingReplayCount = new AtomicInteger();
private Metadata mMetadata;
private IdentifierCollection mIdentifierCollection;
/**
* Audio recording that is ready to be streamed
*
* @param path to the audio recording file
* @param metadata associated with the recording
* @param identifierCollection associated with the recording
* @param start time of recording in milliseconds since epoch
* @param recordingLength in milliseconds
*/
public AudioRecording(Path path, Metadata metadata, long start, long recordingLength)
public AudioRecording(Path path, IdentifierCollection identifierCollection, long start, long recordingLength)
{
mPath = path;
mMetadata = metadata;
mIdentifierCollection = identifierCollection;
mStartTime = start;
mRecordingLength = recordingLength;
}
@@ -60,11 +60,19 @@ public class AudioRecording implements Comparable<AudioRecording>
}
/**
* Optional audio metadata for the recording.
* Optional audio metadata/identifiers for the recording.
*/
public Metadata getMetadata()
public IdentifierCollection getIdentifierCollection()
{
return mMetadata;
return mIdentifierCollection;
}
/**
* Indicates if this recording contains an optional identifier collection.
*/
public boolean hasIdentifierCollection()
{
return mIdentifierCollection != null;
}
/**

View File

@@ -60,7 +60,7 @@ public class BroadcastFactory
* @param configuration describing the server and audio types
* @return configured broadcaster or null
*/
public static AudioBroadcaster getBroadcaster(BroadcastConfiguration configuration)
public static AudioBroadcaster getBroadcaster(BroadcastConfiguration configuration, AliasModel aliasModel)
{
if(configuration != null)
{
@@ -71,15 +71,15 @@ public class BroadcastFactory
switch(configuration.getBroadcastServerType())
{
case BROADCASTIFY:
return new IcecastTCPAudioBroadcaster((BroadcastifyConfiguration) configuration);
return new IcecastTCPAudioBroadcaster((BroadcastifyConfiguration) configuration, aliasModel);
case ICECAST_TCP:
return new IcecastTCPAudioBroadcaster((IcecastTCPConfiguration) configuration);
return new IcecastTCPAudioBroadcaster((IcecastTCPConfiguration) configuration, aliasModel);
case ICECAST_HTTP:
return new IcecastHTTPAudioBroadcaster((IcecastHTTPConfiguration) configuration);
return new IcecastHTTPAudioBroadcaster((IcecastHTTPConfiguration) configuration, aliasModel);
case SHOUTCAST_V1:
return new ShoutcastV1AudioBroadcaster((ShoutcastV1Configuration) configuration);
return new ShoutcastV1AudioBroadcaster((ShoutcastV1Configuration) configuration, aliasModel);
case SHOUTCAST_V2:
return new ShoutcastV2AudioBroadcaster((ShoutcastV2Configuration) configuration);
return new ShoutcastV2AudioBroadcaster((ShoutcastV2Configuration) configuration, aliasModel);
case UNKNOWN:
default:
mLog.info("Unrecognized broadcastAudio configuration: " + configuration.getBroadcastFormat().name());

View File

@@ -18,8 +18,9 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.alias.id.broadcast.BroadcastChannel;
import io.github.dsheirer.channel.metadata.Metadata;
import io.github.dsheirer.icon.IconManager;
import io.github.dsheirer.properties.SystemProperties;
import io.github.dsheirer.sample.Broadcaster;
@@ -72,13 +73,15 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Reusa
private Map<String,AudioBroadcaster> mBroadcasterMap = new HashMap<>();
private IconManager mIconManager;
private StreamManager mStreamManager;
private AliasModel mAliasModel;
private Broadcaster<BroadcastEvent> mBroadcastEventBroadcaster = new Broadcaster<>();
/**
* Model for managing Broadcast configurations and any associated broadcaster instances.
*/
public BroadcastModel(IconManager iconManager)
public BroadcastModel(AliasModel aliasModel, IconManager iconManager)
{
mAliasModel = aliasModel;
mIconManager = iconManager;
mStreamManager = new StreamManager(new CompletedRecordingListener(), BroadcastFormat.MP3,
SystemProperties.getInstance().getApplicationFolder(TEMPORARY_STREAM_DIRECTORY));
@@ -278,9 +281,9 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Reusa
@Override
public void receive(ReusableAudioPacket audioPacket)
{
if(audioPacket.hasMetadata() && audioPacket.getMetadata().isStreamable())
if(audioPacket.isStreamable())
{
for(BroadcastChannel channel: audioPacket.getMetadata().getBroadcastChannels())
for(BroadcastChannel channel: audioPacket.getBroadcastChannels())
{
if(mBroadcasterMap.containsKey(channel.getChannelName()))
{
@@ -302,7 +305,7 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Reusa
if(broadcastConfiguration != null && broadcastConfiguration.isEnabled() && broadcastConfiguration.isValid() &&
!mBroadcasterMap.containsKey(broadcastConfiguration.getName()))
{
AudioBroadcaster audioBroadcaster = BroadcastFactory.getBroadcaster(broadcastConfiguration);
AudioBroadcaster audioBroadcaster = BroadcastFactory.getBroadcaster(broadcastConfiguration, mAliasModel);
if(audioBroadcaster != null)
{
@@ -706,22 +709,25 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Reusa
@Override
public void receive(AudioRecording audioRecording)
{
Metadata metadata = audioRecording.getMetadata();
if(metadata != null && metadata.isStreamable())
if(audioRecording != null && audioRecording.hasIdentifierCollection())
{
for(BroadcastChannel broadcastChannel : metadata.getBroadcastChannels())
AliasList aliasList = mAliasModel.getAliasList(audioRecording.getIdentifierCollection());
if(aliasList != null)
{
String channelName = broadcastChannel.getChannelName();
if(channelName != null)
for(BroadcastChannel broadcastChannel : aliasList.getBroadcastChannels(audioRecording.getIdentifierCollection()))
{
AudioBroadcaster audioBroadcaster = getBroadcaster(channelName);
String channelName = broadcastChannel.getChannelName();
if(audioBroadcaster != null)
if(channelName != null)
{
audioRecording.addPendingReplay();
audioBroadcaster.receive(audioRecording);
AudioBroadcaster audioBroadcaster = getBroadcaster(channelName);
if(audioBroadcaster != null)
{
audioRecording.addPendingReplay();
audioBroadcaster.receive(audioRecording);
}
}
}
}

View File

@@ -18,14 +18,14 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast;
import io.github.dsheirer.channel.metadata.Metadata;
import io.github.dsheirer.identifier.IdentifierCollection;
public interface IBroadcastMetadataUpdater
{
/**
* Updates broadcast audio metadata
*
* @param metadata containing metadata attributes
* @param identifierCollection containing metadata attributes
*/
void update(Metadata metadata);
void update(IdentifierCollection identifierCollection);
}

View File

@@ -117,11 +117,11 @@ public class StreamManager implements Listener<ReusableAudioPacket>
@Override
public void receive(ReusableAudioPacket audioPacket)
{
if(mRunning.get() && audioPacket.hasMetadata())
if(mRunning.get() && audioPacket.hasIdentifierCollection())
{
synchronized(mStreamRecorders)
{
int channelMetadataID = audioPacket.getMetadata().getMetadataID();
int channelMetadataID = audioPacket.getAudioChannelId();
ReusableAudioPacket.Type type = audioPacket.getType();
@@ -139,8 +139,7 @@ public class StreamManager implements Listener<ReusableAudioPacket>
}
else
{
AudioRecorder recorder = BroadcastFactory.getAudioRecorder(getTemporaryRecordingPath(),
mBroadcastFormat);
AudioRecorder recorder = BroadcastFactory.getAudioRecorder(getTemporaryRecordingPath(), mBroadcastFormat);
recorder.start();
audioPacket.incrementUserCount();
recorder.receive(audioPacket);
@@ -181,7 +180,7 @@ public class StreamManager implements Listener<ReusableAudioPacket>
public void receive(AudioRecorder audioRecorder)
{
AudioRecording audioRecording =
new AudioRecording(audioRecorder.getPath(), audioRecorder.getMetadata(),
new AudioRecording(audioRecorder.getPath(), audioRecorder.getIdentifierCollection(),
audioRecorder.getTimeRecordingStart(), audioRecorder.getRecordingLength());
if(mAudioRecordingListener != null)

View File

@@ -18,6 +18,7 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast.icecast;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.audio.broadcast.AudioBroadcaster;
import io.github.dsheirer.audio.broadcast.BroadcastConfiguration;
import io.github.dsheirer.audio.broadcast.IBroadcastMetadataUpdater;
@@ -25,10 +26,12 @@ import io.github.dsheirer.audio.broadcast.IBroadcastMetadataUpdater;
public abstract class IcecastAudioBroadcaster extends AudioBroadcaster
{
private IBroadcastMetadataUpdater mMetadataUpdater;
private AliasModel mAliasModel;
public IcecastAudioBroadcaster(BroadcastConfiguration broadcastConfiguration)
public IcecastAudioBroadcaster(BroadcastConfiguration broadcastConfiguration, AliasModel aliasModel)
{
super(broadcastConfiguration);
mAliasModel = aliasModel;
}
/**
@@ -44,7 +47,7 @@ public abstract class IcecastAudioBroadcaster extends AudioBroadcaster
{
if(mMetadataUpdater == null)
{
mMetadataUpdater = new IcecastBroadcastMetadataUpdater(getConfiguration());
mMetadataUpdater = new IcecastBroadcastMetadataUpdater(getConfiguration(), mAliasModel);
}
return mMetadataUpdater;

View File

@@ -18,8 +18,15 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast.icecast;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.audio.broadcast.IBroadcastMetadataUpdater;
import io.github.dsheirer.channel.metadata.Metadata;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.properties.SystemProperties;
import io.github.dsheirer.util.ThreadPool;
import org.apache.mina.core.RuntimeIoException;
@@ -52,7 +59,7 @@ public class IcecastBroadcastMetadataUpdater implements IBroadcastMetadataUpdate
private final static String UTF8 = "UTF-8";
private IcecastConfiguration mIcecastConfiguration;
private AliasModel mAliasModel;
private NioSocketConnector mSocketConnector;
private AtomicBoolean mUpdating = new AtomicBoolean();
private Queue<String> mMetadataQueue = new LinkedTransferQueue<>();
@@ -65,9 +72,10 @@ public class IcecastBroadcastMetadataUpdater implements IBroadcastMetadataUpdate
* broadcaster. When multiple metadata updates are received prior to completion of the current ongoing update
* sequence, those updates will be queued and processed in the order received.
*/
public IcecastBroadcastMetadataUpdater(IcecastConfiguration icecastConfiguration)
public IcecastBroadcastMetadataUpdater(IcecastConfiguration icecastConfiguration, AliasModel aliasModel)
{
mIcecastConfiguration = icecastConfiguration;
mAliasModel = aliasModel;
}
/**
@@ -113,9 +121,9 @@ public class IcecastBroadcastMetadataUpdater implements IBroadcastMetadataUpdate
* and will remain in the update queue until the next metadata update is requested. However, this is a design
* trade-off to avoid having a scheduled runnable repeatedly processing the update queue.
*/
public void update(Metadata metadata)
public void update(IdentifierCollection identifierCollection)
{
mMetadataQueue.offer(getSong(metadata));
mMetadataQueue.offer(getSong(identifierCollection));
if(!mUpdating.get() && !mMetadataQueue.isEmpty())
{
@@ -181,45 +189,54 @@ public class IcecastBroadcastMetadataUpdater implements IBroadcastMetadataUpdate
/**
* Creates the song information for a metadata update
*/
private static String getSong(Metadata metadata)
private String getSong(IdentifierCollection identifierCollection)
{
StringBuilder sb = new StringBuilder();
if(metadata != null)
if(identifierCollection != null)
{
String to = metadata.getPrimaryAddressTo().getIdentifier();
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
sb.append("TO:");
Identifier to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.PATCH_GROUP, Role.TO);
if(metadata.getPrimaryAddressTo().hasAlias())
if(to == null)
{
sb.append(metadata.getPrimaryAddressTo().getAlias().getName());
to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.TO);
}
else if(metadata.getPrimaryAddressTo().hasIdentifier())
if(to != null)
{
sb.append(metadata.getPrimaryAddressTo().getIdentifier());
sb.append("TO:").append(to);
Alias toAlias = aliasList != null ? aliasList.getAlias(to) : null;
if(toAlias != null)
{
sb.append(" ").append(toAlias.getName());
}
}
else
{
sb.append("UNKNOWN");
sb.append("TO:UNKNOWN");
}
Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.FROM);
sb.append(" FROM:");
if(from != null)
{
sb.append(" FROM:").append(from);
if(metadata.getPrimaryAddressFrom().hasAlias())
{
sb.append(metadata.getPrimaryAddressFrom().getAlias().getName());
}
else if(metadata.getPrimaryAddressFrom().hasIdentifier())
{
sb.append(metadata.getPrimaryAddressFrom().getIdentifier());
Alias fromAlias = aliasList != null ? aliasList.getAlias(from) : null;
if(fromAlias != null)
{
sb.append(" ").append(fromAlias.getName());
}
}
else
{
sb.append("UNKNOWN");
sb.append(" FROM:UNKNOWN");
}
}
else
{

View File

@@ -18,6 +18,7 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast.icecast;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.audio.broadcast.BroadcastState;
import io.github.dsheirer.audio.convert.MP3AudioConverter;
import io.github.dsheirer.properties.SystemProperties;
@@ -69,9 +70,9 @@ public class IcecastHTTPAudioBroadcaster extends IcecastAudioBroadcaster
*
* @param configuration for the Icecast stream
*/
public IcecastHTTPAudioBroadcaster(IcecastHTTPConfiguration configuration)
public IcecastHTTPAudioBroadcaster(IcecastHTTPConfiguration configuration, AliasModel aliasModel)
{
super(configuration);
super(configuration, aliasModel);
}
/**

View File

@@ -18,6 +18,7 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast.icecast;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.audio.broadcast.BroadcastState;
import io.github.dsheirer.audio.broadcast.icecast.codec.IcecastCodecFactory;
import io.github.dsheirer.audio.convert.MP3AudioConverter;
@@ -65,9 +66,9 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
*
* @param configuration for the Icecast stream
*/
public IcecastTCPAudioBroadcaster(IcecastTCPConfiguration configuration)
public IcecastTCPAudioBroadcaster(IcecastTCPConfiguration configuration, AliasModel aliasModel)
{
super(configuration);
super(configuration, aliasModel);
}
/**

View File

@@ -18,6 +18,7 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast.shoutcast.v1;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.audio.broadcast.AudioBroadcaster;
import io.github.dsheirer.audio.broadcast.BroadcastState;
import io.github.dsheirer.audio.broadcast.IBroadcastMetadataUpdater;
@@ -47,7 +48,7 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
private NioSocketConnector mSocketConnector;
private IoSession mStreamingSession = null;
private IBroadcastMetadataUpdater mMetadataUpdater;
private AliasModel mAliasModel;
private long mLastConnectionAttempt = 0;
private AtomicBoolean mConnecting = new AtomicBoolean();
@@ -61,9 +62,10 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
*
* @param configuration for the Shoutcast stream
*/
public ShoutcastV1AudioBroadcaster(ShoutcastV1Configuration configuration)
public ShoutcastV1AudioBroadcaster(ShoutcastV1Configuration configuration, AliasModel aliasModel)
{
super(configuration);
mAliasModel = aliasModel;
}
/**
@@ -79,7 +81,7 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
{
if(mMetadataUpdater == null)
{
mMetadataUpdater = new ShoutcastV1BroadcastMetadataUpdater(getConfiguration());
mMetadataUpdater = new ShoutcastV1BroadcastMetadataUpdater(getConfiguration(), mAliasModel);
}
return mMetadataUpdater;

View File

@@ -18,8 +18,15 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast.shoutcast.v1;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.audio.broadcast.IBroadcastMetadataUpdater;
import io.github.dsheirer.channel.metadata.Metadata;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.util.ThreadPool;
import org.apache.mina.core.future.ConnectFuture;
import org.apache.mina.core.service.IoHandlerAdapter;
@@ -50,7 +57,7 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp
private final static String UTF8 = "UTF-8";
private ShoutcastV1Configuration mShoutcastV1Configuration;
private AliasModel mAliasModel;
private NioSocketConnector mSocketConnector;
private AtomicBoolean mUpdating = new AtomicBoolean();
private Queue<String> mMetadataQueue = new LinkedTransferQueue<>();
@@ -62,9 +69,10 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp
* broadcaster. When multiple metadata updates are received prior to completion of the current ongoing update
* sequence, those updates will be queued and processed in the order received.
*/
public ShoutcastV1BroadcastMetadataUpdater(ShoutcastV1Configuration shoutcastV1Configuration)
public ShoutcastV1BroadcastMetadataUpdater(ShoutcastV1Configuration shoutcastV1Configuration, AliasModel aliasModel)
{
mShoutcastV1Configuration = shoutcastV1Configuration;
mAliasModel = aliasModel;
}
/**
@@ -111,9 +119,9 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp
* and will remain in the update queue until the next metadata update is requested. However, this is a design
* trade-off to avoid having a scheduled runnable repeatedly processing the update queue.
*/
public void update(Metadata metadata)
public void update(IdentifierCollection identifierCollection)
{
mMetadataQueue.offer(getSong(metadata));
mMetadataQueue.offer(getSong(identifierCollection));
if(mUpdating.compareAndSet(false, true))
{
@@ -177,45 +185,52 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp
/**
* Creates the song information for a metadata update
*/
private static String getSong(Metadata metadata)
private String getSong(IdentifierCollection identifierCollection)
{
StringBuilder sb = new StringBuilder();
if(metadata != null)
if(identifierCollection != null)
{
String to = metadata.getPrimaryAddressTo().getIdentifier();
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
sb.append("TO:");
Identifier to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.PATCH_GROUP, Role.TO);
if(metadata.getPrimaryAddressTo().hasAlias())
if(to == null)
{
sb.append(metadata.getPrimaryAddressTo().getAlias().getName());
to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.TO);
}
else if(metadata.getPrimaryAddressTo().hasIdentifier())
Alias toAlias = aliasList != null ? aliasList.getAlias(to) : null;
if(toAlias != null)
{
sb.append(metadata.getPrimaryAddressTo().getIdentifier());
sb.append("TO:").append(toAlias.getName());
}
else if(to != null)
{
sb.append("TO:").append(to.toString());
}
else
{
sb.append("UNKNOWN");
sb.append("TO:UNKNOWN");
}
Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.FROM);
sb.append(" FROM:");
Alias fromAlias = aliasList != null ? aliasList.getAlias(from) : null;
if(metadata.getPrimaryAddressFrom().hasAlias())
if(fromAlias != null)
{
sb.append(metadata.getPrimaryAddressFrom().getAlias().getName());
sb.append(" FROM:").append(fromAlias.getName());
}
else if(metadata.getPrimaryAddressFrom().hasIdentifier())
else if(from != null)
{
sb.append(metadata.getPrimaryAddressFrom().getIdentifier());
sb.append(" FROM:").append(from.toString());
}
else
{
sb.append("UNKNOWN");
sb.append(" FROM:UNKNOWN");
}
}
else
{

View File

@@ -18,6 +18,9 @@
******************************************************************************/
package io.github.dsheirer.audio.broadcast.shoutcast.v2;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.audio.broadcast.AudioBroadcaster;
import io.github.dsheirer.audio.broadcast.BroadcastState;
import io.github.dsheirer.audio.broadcast.IBroadcastMetadataUpdater;
@@ -36,7 +39,11 @@ import io.github.dsheirer.audio.broadcast.shoutcast.v2.ultravox.UltravoxMessageF
import io.github.dsheirer.audio.broadcast.shoutcast.v2.ultravox.UltravoxMessageType;
import io.github.dsheirer.audio.broadcast.shoutcast.v2.ultravox.UltravoxMetadata;
import io.github.dsheirer.audio.broadcast.shoutcast.v2.ultravox.UltravoxProtocolFactory;
import io.github.dsheirer.channel.metadata.Metadata;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.properties.SystemProperties;
import io.github.dsheirer.util.ThreadPool;
import org.apache.mina.core.RuntimeIoException;
@@ -66,7 +73,7 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
private NioSocketConnector mSocketConnector;
private IoSession mStreamingSession = null;
private AliasModel mAliasModel;
private long mLastConnectionAttempt = 0;
private AtomicBoolean mConnecting = new AtomicBoolean();
private LinkedTransferQueue<UltravoxMessage> mMetadataMessageQueue = new LinkedTransferQueue<>();
@@ -83,9 +90,10 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
*
* @param configuration for the Shoutcast V2 stream
*/
public ShoutcastV2AudioBroadcaster(ShoutcastV2Configuration configuration)
public ShoutcastV2AudioBroadcaster(ShoutcastV2Configuration configuration, AliasModel aliasModel)
{
super(configuration);
mAliasModel = aliasModel;
}
public ShoutcastV2Configuration getConfiguration()
@@ -119,9 +127,9 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
}
@Override
public void update(Metadata metadata)
public void update(IdentifierCollection identifierCollection)
{
List<UltravoxMessage> metadataMessages = getMetadataMessages(metadata);
List<UltravoxMessage> metadataMessages = getMetadataMessages(identifierCollection);
if(!metadataMessages.isEmpty())
{
@@ -241,10 +249,10 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
*
* See UltravoxMetadata.TAG.asXML(String value)
*
* @param metadata containing audio metadata tags and attributes
* @param identifierCollection containing audio metadata tags and attributes
* @return a sequence of CacheableXMLMetadata messages sufficient to carry the complete set of metadata
*/
private List<UltravoxMessage> getMetadataMessages(Metadata metadata)
private List<UltravoxMessage> getMetadataMessages(IdentifierCollection identifierCollection)
{
StringBuilder sb = new StringBuilder();
@@ -266,24 +274,37 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
sb.append(UltravoxMetadata.URL.asXML(getConfiguration().getURL()));
}
if(metadata != null)
if(identifierCollection != null)
{
if(metadata.getPrimaryAddressTo().hasAlias())
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
Identifier to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.PATCH_GROUP, Role.TO);
if(to == null)
{
sb.append(UltravoxMetadata.TITLE_2.asXML(metadata.getPrimaryAddressTo().getAlias().getName()));
}
else if(metadata.getPrimaryAddressTo().hasIdentifier())
{
sb.append(UltravoxMetadata.TITLE_2.asXML(metadata.getPrimaryAddressTo().getIdentifier()));
to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.TO);
}
if(metadata.getPrimaryAddressFrom().hasAlias())
Alias toAlias = aliasList != null ? aliasList.getAlias(to) : null;
if(toAlias != null)
{
sb.append(UltravoxMetadata.TITLE_3.asXML("From:" + metadata.getPrimaryAddressFrom().getAlias().getName()));
sb.append(UltravoxMetadata.TITLE_2.asXML(toAlias.getName()));
}
else if(metadata.getPrimaryAddressFrom().hasIdentifier())
else if(to != null)
{
sb.append(UltravoxMetadata.TITLE_3.asXML("From:" + metadata.getPrimaryAddressFrom().getIdentifier()));
sb.append(UltravoxMetadata.TITLE_2.asXML(to.toString()));
}
Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.FROM);
Alias fromAlias = aliasList != null ? aliasList.getAlias(from) : null;
if(fromAlias != null)
{
sb.append(UltravoxMetadata.TITLE_3.asXML("From:" + fromAlias.getName()));
}
else if(from != null)
{
sb.append(UltravoxMetadata.TITLE_3.asXML("From:" + from.toString()));
}
}
else