mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
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:
111
src/main/java/io/github/dsheirer/audio/AbstractAudioModule.java
Normal file
111
src/main/java/io/github/dsheirer/audio/AbstractAudioModule.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* 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.audio;
|
||||
|
||||
import io.github.dsheirer.audio.squelch.ISquelchStateListener;
|
||||
import io.github.dsheirer.identifier.IdentifierUpdateListener;
|
||||
import io.github.dsheirer.identifier.IdentifierUpdateNotification;
|
||||
import io.github.dsheirer.identifier.MutableIdentifierCollection;
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableAudioPacket;
|
||||
|
||||
/**
|
||||
* Base audio module implementation.
|
||||
*/
|
||||
public abstract class AbstractAudioModule extends Module implements IAudioPacketProvider, IdentifierUpdateListener,
|
||||
ISquelchStateListener
|
||||
{
|
||||
//Static unique audio channel identifier.
|
||||
private static int AUDIO_CHANNEL_ID_GENERATOR = 1;
|
||||
|
||||
private int mAudioChannelId = AUDIO_CHANNEL_ID_GENERATOR++;
|
||||
private Listener<ReusableAudioPacket> mAudioPacketListener;
|
||||
private MutableIdentifierCollection mIdentifierCollection = new MutableIdentifierCollection();
|
||||
|
||||
/**
|
||||
* Constructs an abstract audio module
|
||||
*/
|
||||
public AbstractAudioModule()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique channel identifier for use in tagging audio packets with an audio channel ID so that they can
|
||||
* be identified within a combined audio packet stream
|
||||
*/
|
||||
public int getAudioChannelId()
|
||||
{
|
||||
return mAudioChannelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive updated identifiers from decoder state(s).
|
||||
*/
|
||||
@Override
|
||||
public Listener<IdentifierUpdateNotification> getIdentifierUpdateListener()
|
||||
{
|
||||
return mIdentifierCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier collection containing the current set of identifiers received from the decoder state(s).
|
||||
*/
|
||||
public MutableIdentifierCollection getIdentifierCollection()
|
||||
{
|
||||
return mIdentifierCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an audio packet listener to receive the output from this audio module.
|
||||
*/
|
||||
@Override
|
||||
public void setAudioPacketListener(Listener<ReusableAudioPacket> listener)
|
||||
{
|
||||
mAudioPacketListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the audio packet listener from receiving audio packets from this module.
|
||||
*/
|
||||
@Override
|
||||
public void removeAudioPacketListener()
|
||||
{
|
||||
mAudioPacketListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registered listener for receiving audio packets produced by this module
|
||||
*/
|
||||
public Listener<ReusableAudioPacket> getAudioPacketListener()
|
||||
{
|
||||
return mAudioPacketListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if there is a listener registered to receive audio packets from this audio module.
|
||||
*/
|
||||
public boolean hasAudioPacketListener()
|
||||
{
|
||||
return mAudioPacketListener != null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* 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.audio;
|
||||
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.sample.buffer.ReusableAudioPacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Processes audio packets to assign attributes to each packet based on alias list settings. Updates the
|
||||
* monitoring, recording and streaming attributes.
|
||||
*/
|
||||
public class AudioMetadataProcessor
|
||||
{
|
||||
private static final Logger mLog = LoggerFactory.getLogger(AudioMetadataProcessor.class);
|
||||
private AliasModel mAliasModel;
|
||||
private Map<Integer, AliasList> mAliasListMap = new HashMap<>();
|
||||
private Set<Integer> mAliasListRetrievedSet = new TreeSet<>();
|
||||
|
||||
public AudioMetadataProcessor(AliasModel aliasModel)
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
}
|
||||
|
||||
public void process(ReusableAudioPacket audioPacket)
|
||||
{
|
||||
if(audioPacket.hasIdentifierCollection() && audioPacket.getIdentifierCollection().hasAliasListConfiguration())
|
||||
{
|
||||
AliasList aliasList = null;
|
||||
|
||||
if(mAliasListRetrievedSet.contains(audioPacket.getAudioChannelId()))
|
||||
{
|
||||
aliasList = mAliasListMap.get(audioPacket.getAudioChannelId());
|
||||
}
|
||||
else
|
||||
{
|
||||
aliasList = mAliasModel.getAliasList(audioPacket.getIdentifierCollection().getAliasListConfiguration());
|
||||
|
||||
if(aliasList != null)
|
||||
{
|
||||
mAliasListMap.put(audioPacket.getAudioChannelId(), aliasList);
|
||||
mAliasListRetrievedSet.add(audioPacket.getAudioChannelId());
|
||||
}
|
||||
}
|
||||
|
||||
if(aliasList != null)
|
||||
{
|
||||
audioPacket.addBroadcastChannels(aliasList.getBroadcastChannels(audioPacket.getIdentifierCollection()));
|
||||
audioPacket.setRecordable(aliasList.isRecordable(audioPacket.getIdentifierCollection()));
|
||||
audioPacket.setMonitoringPriority(aliasList.getAudioPlaybackPriority(audioPacket.getIdentifierCollection()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,11 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.audio;
|
||||
|
||||
import io.github.dsheirer.audio.squelch.ISquelchStateListener;
|
||||
import io.github.dsheirer.audio.squelch.SquelchState;
|
||||
import io.github.dsheirer.channel.metadata.Metadata;
|
||||
import io.github.dsheirer.dsp.filter.design.FilterDesignException;
|
||||
import io.github.dsheirer.dsp.filter.fir.FIRFilterSpecification;
|
||||
import io.github.dsheirer.dsp.filter.fir.real.RealFIRFilter2;
|
||||
import io.github.dsheirer.dsp.filter.fir.remez.RemezFIRFilterDesigner;
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.IReusableBufferListener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableAudioPacket;
|
||||
@@ -39,12 +36,10 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
* This class is designed to support 8 kHz sample rate demodulated audio.
|
||||
*/
|
||||
public class AudioModule extends Module implements IAudioPacketProvider, IReusableBufferListener,
|
||||
ISquelchStateListener, Listener<ReusableFloatBuffer>
|
||||
public class AudioModule extends AbstractAudioModule implements IReusableBufferListener, Listener<ReusableFloatBuffer>
|
||||
{
|
||||
protected static final Logger mLog = LoggerFactory.getLogger(AudioModule.class);
|
||||
private ReusableAudioPacketQueue mAudioPacketQueue = new ReusableAudioPacketQueue("AudioModule");
|
||||
|
||||
private static final Logger mLog = LoggerFactory.getLogger(AudioModule.class);
|
||||
private static float[] sHighPassFilterCoefficients;
|
||||
|
||||
static
|
||||
@@ -73,32 +68,29 @@ public class AudioModule extends Module implements IAudioPacketProvider, IReusab
|
||||
}
|
||||
}
|
||||
|
||||
private ReusableAudioPacketQueue mAudioPacketQueue = new ReusableAudioPacketQueue("AudioModule");
|
||||
private RealFIRFilter2 mHighPassFilter = new RealFIRFilter2(sHighPassFilterCoefficients);
|
||||
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
|
||||
private SquelchState mSquelchState = SquelchState.SQUELCH;
|
||||
private Listener<ReusableAudioPacket> mAudioPacketListener;
|
||||
private Metadata mMetadata;
|
||||
|
||||
/**
|
||||
* Creates an Audio Module.
|
||||
*
|
||||
* @param metadata to use for audio packets produced by this audio module.
|
||||
*/
|
||||
public AudioModule(Metadata metadata)
|
||||
public AudioModule()
|
||||
{
|
||||
mMetadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
mAudioPacketListener = null;
|
||||
removeAudioPacketListener();
|
||||
mSquelchStateListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
getIdentifierCollection().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,26 +103,17 @@ public class AudioModule extends Module implements IAudioPacketProvider, IReusab
|
||||
public void stop()
|
||||
{
|
||||
/* Issue an end-audio packet in case a recorder is still rolling */
|
||||
if(mAudioPacketListener != null)
|
||||
if(hasAudioPacketListener())
|
||||
{
|
||||
ReusableAudioPacket endAudioPacket = mAudioPacketQueue.getEndAudioBuffer();
|
||||
endAudioPacket.setMetadata(mMetadata.copyOf());
|
||||
endAudioPacket.resetAttributes();
|
||||
endAudioPacket.setAudioChannelId(getAudioChannelId());
|
||||
endAudioPacket.setIdentifierCollection(getIdentifierCollection().copyOf());
|
||||
endAudioPacket.incrementUserCount();
|
||||
mAudioPacketListener.receive(endAudioPacket);
|
||||
getAudioPacketListener().receive(endAudioPacket);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAudioPacketListener(Listener<ReusableAudioPacket> listener)
|
||||
{
|
||||
mAudioPacketListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAudioPacketListener()
|
||||
{
|
||||
mAudioPacketListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<SquelchState> getSquelchStateListener()
|
||||
@@ -141,15 +124,17 @@ public class AudioModule extends Module implements IAudioPacketProvider, IReusab
|
||||
@Override
|
||||
public void receive(ReusableFloatBuffer reusableFloatBuffer)
|
||||
{
|
||||
if(mAudioPacketListener != null && mSquelchState == SquelchState.UNSQUELCH)
|
||||
if(hasAudioPacketListener() && mSquelchState == SquelchState.UNSQUELCH)
|
||||
{
|
||||
ReusableFloatBuffer highPassFiltered = mHighPassFilter.filter(reusableFloatBuffer);
|
||||
|
||||
ReusableAudioPacket audioPacket = mAudioPacketQueue.getBuffer(highPassFiltered.getSampleCount());
|
||||
audioPacket.resetAttributes();
|
||||
audioPacket.setAudioChannelId(getAudioChannelId());
|
||||
audioPacket.loadAudioFrom(highPassFiltered);
|
||||
audioPacket.setMetadata(mMetadata.copyOf());
|
||||
audioPacket.setIdentifierCollection(getIdentifierCollection().copyOf());
|
||||
|
||||
mAudioPacketListener.receive(audioPacket);
|
||||
getAudioPacketListener().receive(audioPacket);
|
||||
|
||||
highPassFiltered.decrementUserCount();
|
||||
}
|
||||
@@ -174,11 +159,13 @@ public class AudioModule extends Module implements IAudioPacketProvider, IReusab
|
||||
@Override
|
||||
public void receive(SquelchState state)
|
||||
{
|
||||
if(state == SquelchState.SQUELCH && mAudioPacketListener != null)
|
||||
if(state == SquelchState.SQUELCH && hasAudioPacketListener())
|
||||
{
|
||||
ReusableAudioPacket endAudioPacket = mAudioPacketQueue.getEndAudioBuffer();
|
||||
endAudioPacket.setMetadata(mMetadata.copyOf());
|
||||
mAudioPacketListener.receive(endAudioPacket);
|
||||
endAudioPacket.resetAttributes();
|
||||
endAudioPacket.setAudioChannelId(getAudioChannelId());
|
||||
endAudioPacket.setIdentifierCollection(getIdentifierCollection().copyOf());
|
||||
getAudioPacketListener().receive(endAudioPacket);
|
||||
}
|
||||
|
||||
mSquelchState = state;
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* 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.audio;
|
||||
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.dsp.filter.channelizer.ContinuousReusableBufferProcessor;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableAudioPacket;
|
||||
import io.github.dsheirer.sample.buffer.ReusableBufferBroadcaster;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Processes audio packets from all decoder channels, assigns alias attributes and distributes packets
|
||||
* for playback, streaming and recording.
|
||||
*/
|
||||
public class AudioPacketManager implements Listener<ReusableAudioPacket>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(AudioPacketManager.class);
|
||||
private AudioMetadataProcessor mAudioMetadataProcessor;
|
||||
private ReusableBufferBroadcaster<ReusableAudioPacket> mBroadcaster = new ReusableBufferBroadcaster<>();
|
||||
private ContinuousReusableBufferProcessor<ReusableAudioPacket> mBufferProcessor;
|
||||
|
||||
public AudioPacketManager(AliasModel aliasModel)
|
||||
{
|
||||
mAudioMetadataProcessor = new AudioMetadataProcessor(aliasModel);
|
||||
mBufferProcessor = new ContinuousReusableBufferProcessor<>(10000, 500);
|
||||
mBufferProcessor.setListener(new Listener<List<ReusableAudioPacket>>()
|
||||
{
|
||||
@Override
|
||||
public void receive(List<ReusableAudioPacket> reusableAudioPackets)
|
||||
{
|
||||
for(ReusableAudioPacket audioPacket: reusableAudioPackets)
|
||||
{
|
||||
mAudioMetadataProcessor.process(audioPacket);
|
||||
mBroadcaster.broadcast(audioPacket);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
mLog.info("Audio packet manager started");
|
||||
mBufferProcessor.start();
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
mLog.info("Audio packet manager stopped");
|
||||
mBufferProcessor.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary processing method for receiving audio packets from all processing channels.
|
||||
*/
|
||||
@Override
|
||||
public void receive(ReusableAudioPacket audioPacket)
|
||||
{
|
||||
mBufferProcessor.receive(audioPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listener to receive enriched audio packets from this manager
|
||||
*/
|
||||
public void addListener(Listener<ReusableAudioPacket> listener)
|
||||
{
|
||||
mBroadcaster.addListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the listener from receiving enriched audio packets from this manager
|
||||
*/
|
||||
public void removeListener(Listener<ReusableAudioPacket> listener)
|
||||
{
|
||||
mBroadcaster.removeListener(listener);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.github.dsheirer.audio;
|
||||
|
||||
import io.github.dsheirer.audio.output.AudioOutput;
|
||||
import io.github.dsheirer.audio.playback.AudioOutput;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.source.mixer.MixerChannelConfiguration;
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.audio;
|
||||
|
||||
/**
|
||||
* Standard voice inversion foldover frequencies
|
||||
*
|
||||
* Reference: http://en.wikipedia.org/wiki/Voice_inversion
|
||||
*/
|
||||
public enum InversionFrequency
|
||||
{
|
||||
HZ_2500( 2500 ),
|
||||
HZ_2550( 2550 ),
|
||||
HZ_2600( 2600 ),
|
||||
HZ_2632( 2632 ),
|
||||
HZ_2675( 2675 ),
|
||||
HZ_2718( 2718 ),
|
||||
HZ_2800( 2800 ),
|
||||
HZ_2868( 2868 ),
|
||||
HZ_2950( 2950 ),
|
||||
HZ_3023( 3023 ),
|
||||
HZ_3075( 3075 ),
|
||||
HZ_3107( 3107 ),
|
||||
HZ_3150( 3150 ),
|
||||
HZ_3196( 3196 ),
|
||||
HZ_3333( 3333 ),
|
||||
HZ_3339( 3339 ),
|
||||
HZ_3400( 3400 ),
|
||||
HZ_3496( 3496 ),
|
||||
HZ_3729( 3729 ),
|
||||
HZ_4096( 4096 );
|
||||
|
||||
private int mFrequency;
|
||||
|
||||
private InversionFrequency( int frequency )
|
||||
{
|
||||
mFrequency = frequency;
|
||||
}
|
||||
|
||||
public int getFrequency()
|
||||
{
|
||||
return mFrequency;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.audio.invert;
|
||||
|
||||
import io.github.dsheirer.audio.InversionFrequency;
|
||||
import io.github.dsheirer.dsp.filter.Filters;
|
||||
import io.github.dsheirer.dsp.filter.FloatFIRFilter;
|
||||
import io.github.dsheirer.dsp.mixer.IOscillator;
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* 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.audio.invert;
|
||||
|
||||
/**
|
||||
* Standard voice inversion foldover frequencies
|
||||
*
|
||||
* Reference: http://en.wikipedia.org/wiki/Voice_inversion
|
||||
*/
|
||||
public enum InversionFrequency
|
||||
{
|
||||
HZ_2500( 2500 ),
|
||||
HZ_2550( 2550 ),
|
||||
HZ_2600( 2600 ),
|
||||
HZ_2632( 2632 ),
|
||||
HZ_2675( 2675 ),
|
||||
HZ_2718( 2718 ),
|
||||
HZ_2800( 2800 ),
|
||||
HZ_2868( 2868 ),
|
||||
HZ_2950( 2950 ),
|
||||
HZ_3023( 3023 ),
|
||||
HZ_3075( 3075 ),
|
||||
HZ_3107( 3107 ),
|
||||
HZ_3150( 3150 ),
|
||||
HZ_3196( 3196 ),
|
||||
HZ_3333( 3333 ),
|
||||
HZ_3339( 3339 ),
|
||||
HZ_3400( 3400 ),
|
||||
HZ_3496( 3496 ),
|
||||
HZ_3729( 3729 ),
|
||||
HZ_4096( 4096 );
|
||||
|
||||
private int mFrequency;
|
||||
|
||||
private InversionFrequency( int frequency )
|
||||
{
|
||||
mFrequency = frequency;
|
||||
}
|
||||
|
||||
public int getFrequency()
|
||||
{
|
||||
return mFrequency;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* 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
|
||||
@@ -14,14 +15,24 @@
|
||||
*
|
||||
* 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.audio;
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.audio.playback;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.audio.output.AudioOutput;
|
||||
import io.github.dsheirer.channel.metadata.Metadata;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.audio.AudioEvent;
|
||||
import io.github.dsheirer.eventbus.MyEventBus;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
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.preference.PreferenceType;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.preference.identifier.TalkgroupFormatPreference;
|
||||
import io.github.dsheirer.properties.SystemProperties;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.settings.ColorSetting;
|
||||
@@ -32,11 +43,15 @@ import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.Color;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Font;
|
||||
import java.util.List;
|
||||
|
||||
public class AudioChannelPanel extends JPanel
|
||||
implements Listener<AudioEvent>, SettingChangeListener
|
||||
public class AudioChannelPanel extends JPanel implements Listener<AudioEvent>, SettingChangeListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger mLog = LoggerFactory.getLogger(AudioChannelPanel.class);
|
||||
@@ -56,27 +71,35 @@ public class AudioChannelPanel extends JPanel
|
||||
|
||||
private IconManager mIconManager;
|
||||
private SettingsManager mSettingsManager;
|
||||
private UserPreferences mUserPreferences;
|
||||
private TalkgroupFormatPreference mTalkgroupFormatPreference;
|
||||
private AudioOutput mAudioOutput;
|
||||
|
||||
private JLabel mMutedLabel = new JLabel("M");
|
||||
private JLabel mChannelName = new JLabel(" ");
|
||||
private JLabel mToAlias = new JLabel(" ");
|
||||
private JLabel mTo = new JLabel("-----");
|
||||
private JLabel mIconLabel = new JLabel(" ");
|
||||
private JLabel mIdentifierLabel = new JLabel("-----");
|
||||
private Identifier mIdentifier;
|
||||
private Alias mAlias;
|
||||
|
||||
private boolean mConfigured = false;
|
||||
private AliasModel mAliasModel;
|
||||
|
||||
public AudioChannelPanel(IconManager iconManager, SettingsManager settingsManager, AudioOutput audioOutput)
|
||||
public AudioChannelPanel(IconManager iconManager, UserPreferences userPreferences, SettingsManager settingsManager,
|
||||
AudioOutput audioOutput, AliasModel aliasModel)
|
||||
{
|
||||
mIconManager = iconManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mSettingsManager.addListener(this);
|
||||
|
||||
mAliasModel = aliasModel;
|
||||
mUserPreferences = userPreferences;
|
||||
mTalkgroupFormatPreference = mUserPreferences.getTalkgroupFormatPreference();
|
||||
mAudioOutput = audioOutput;
|
||||
|
||||
if(mAudioOutput != null)
|
||||
{
|
||||
mAudioOutput.addAudioEventListener(this);
|
||||
mAudioOutput.setMetadataListener(new AudioMetadataProcessor());
|
||||
mAudioOutput.setIdentifierCollectionListener(new AudioMetadataProcessor());
|
||||
}
|
||||
|
||||
mBackgroundColor = SystemProperties.getInstance().get(PROPERTY_COLOR_BACKGROUND, Color.BLACK);
|
||||
@@ -87,8 +110,30 @@ public class AudioChannelPanel extends JPanel
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives preference update notifications via the event bus
|
||||
* @param preferenceType that was updated
|
||||
*/
|
||||
@Subscribe
|
||||
public void preferenceUpdated(PreferenceType preferenceType)
|
||||
{
|
||||
if(preferenceType == PreferenceType.IDENTIFIER)
|
||||
{
|
||||
updateLabels();
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
//Deregister from receiving preference update notifications
|
||||
MyEventBus.getEventBus().unregister(this);
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
//Register to receive preference updates
|
||||
MyEventBus.getEventBus().register(this);
|
||||
|
||||
setLayout(new MigLayout("align center center, insets 0 0 0 0",
|
||||
"[][][align right]0[grow,fill]", ""));
|
||||
setBackground(mBackgroundColor);
|
||||
@@ -103,13 +148,13 @@ public class AudioChannelPanel extends JPanel
|
||||
mChannelName.setForeground(mLabelColor);
|
||||
add(mChannelName);
|
||||
|
||||
mToAlias.setFont(mFont);
|
||||
mToAlias.setForeground(mValueColor);
|
||||
add(mToAlias);
|
||||
mIconLabel.setFont(mFont);
|
||||
mIconLabel.setForeground(mValueColor);
|
||||
add(mIconLabel);
|
||||
|
||||
mTo.setFont(mFont);
|
||||
mTo.setForeground(mValueColor);
|
||||
add(mTo,"wmin 10lp");
|
||||
mIdentifierLabel.setFont(mFont);
|
||||
mIdentifierLabel.setForeground(mValueColor);
|
||||
add(mIdentifierLabel, "wmin 10lp");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,72 +194,67 @@ public class AudioChannelPanel extends JPanel
|
||||
*/
|
||||
private void resetLabels()
|
||||
{
|
||||
updateLabel(mTo, null, mToAlias, null);
|
||||
|
||||
mIdentifier = null;
|
||||
mAlias = null;
|
||||
updateLabels();
|
||||
mConfigured = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncates the string to the specified length using an ellipses at the end
|
||||
* @param value to optionally truncate
|
||||
* @param length of the final formatted string
|
||||
* @return formatted string or null
|
||||
*/
|
||||
private static String truncate(String value, int length)
|
||||
{
|
||||
if(value != null && value.length() > length)
|
||||
{
|
||||
return value.substring(0, length - 3) + "...";
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the alias label with text and icon from the alias. Note: this
|
||||
* does not occur on the Swing event thread -- wrap any calls to this
|
||||
* method with an event thread call.
|
||||
*/
|
||||
private void updateLabel(JLabel textLabel, String value, JLabel iconLabel, Alias alias)
|
||||
private void updateLabels()
|
||||
{
|
||||
if(value != null)
|
||||
String identifier = mAlias != null ? mAlias.getName() : mTalkgroupFormatPreference.format(mIdentifier);
|
||||
final ImageIcon icon = mAlias != null ? mIconManager.getIcon(mAlias.getIconName(), 18) : null;
|
||||
final String identifierText = (identifier != null ? truncate(identifier, 33) : "-----");
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
|
||||
if(alias != null)
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
iconLabel.setIcon(mIconManager.getIcon(alias.getIconName(), 18));
|
||||
|
||||
String aliasName = alias.getName();
|
||||
|
||||
//Truncate label if length exceeds 33 characters - hack!
|
||||
if(aliasName.length() > 33)
|
||||
{
|
||||
textLabel.setText(aliasName.substring(0,30) + "...");
|
||||
}
|
||||
else
|
||||
{
|
||||
textLabel.setText(aliasName);
|
||||
}
|
||||
mIdentifierLabel.setText(identifierText);
|
||||
mIconLabel.setIcon(icon);
|
||||
mConfigured = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
iconLabel.setIcon(null);
|
||||
textLabel.setText(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iconLabel.setIcon(null);
|
||||
textLabel.setText("-----");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes audio metadata to update this panel's display values
|
||||
*/
|
||||
public class AudioMetadataProcessor implements Listener<Metadata>
|
||||
public class AudioMetadataProcessor implements Listener<IdentifierCollection>
|
||||
{
|
||||
@Override
|
||||
public void receive(final Metadata metadata)
|
||||
public void receive(final IdentifierCollection identifierCollection)
|
||||
{
|
||||
if(metadata.isUpdated() || !mConfigured)
|
||||
if(identifierCollection != null && (identifierCollection.isUpdated() || !mConfigured))
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
updateLabel(mTo, metadata.getPrimaryAddressTo().getIdentifier(),
|
||||
mToAlias, metadata.getPrimaryAddressTo().getAlias());
|
||||
|
||||
mConfigured = true;
|
||||
}
|
||||
});
|
||||
|
||||
List<Identifier> toIds = identifierCollection.getIdentifiers(IdentifierClass.USER, Role.TO);
|
||||
mIdentifier = !toIds.isEmpty() ? toIds.get(0) : null;
|
||||
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
|
||||
mAlias = (aliasList != null ? aliasList.getAlias(mIdentifier) : null);
|
||||
updateLabels();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,18 +265,18 @@ public class AudioChannelPanel extends JPanel
|
||||
{
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
ColorSetting colorSetting = (ColorSetting)setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if(mTo != null)
|
||||
if(mIdentifierLabel != null)
|
||||
{
|
||||
mTo.setForeground(mLabelColor);
|
||||
mIdentifierLabel.setForeground(mLabelColor);
|
||||
}
|
||||
if(mToAlias != null)
|
||||
if(mIconLabel != null)
|
||||
{
|
||||
mToAlias.setForeground(mLabelColor);
|
||||
mIconLabel.setForeground(mLabelColor);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* 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
|
||||
@@ -14,24 +15,29 @@
|
||||
*
|
||||
* 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.audio;
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.audio.playback;
|
||||
|
||||
import io.github.dsheirer.audio.output.AudioOutput;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.audio.IAudioController;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.settings.SettingsManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.util.List;
|
||||
|
||||
public class AudioChannelsPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
|
||||
public AudioChannelsPanel(IconManager iconManager, UserPreferences userPreferences, SettingsManager settingsManager,
|
||||
IAudioController controller, AliasModel aliasModel)
|
||||
{
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[][sg abc,grow,fill][][sg abc,grow,fill]", "[grow,fill]"));
|
||||
|
||||
@@ -43,7 +49,7 @@ public class AudioChannelsPanel extends JPanel
|
||||
|
||||
for(int x = 0; x < outputs.size(); x++)
|
||||
{
|
||||
add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)));
|
||||
add(new AudioChannelPanel(iconManager, userPreferences, settingsManager, outputs.get(x), aliasModel));
|
||||
|
||||
if(x < outputs.size() - 1)
|
||||
{
|
||||
@@ -56,7 +62,21 @@ public class AudioChannelsPanel extends JPanel
|
||||
if(outputs.size() == 1)
|
||||
{
|
||||
addSeparator();
|
||||
add(new AudioChannelPanel(iconManager, settingsManager, null), "growx");
|
||||
add(new AudioChannelPanel(iconManager, userPreferences, settingsManager, null, aliasModel), "growx");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares for dispose to allow deregistering from services
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
for(Component component: getComponents())
|
||||
{
|
||||
if(component instanceof AudioChannelPanel)
|
||||
{
|
||||
((AudioChannelPanel)component).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* 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
|
||||
@@ -14,12 +15,12 @@
|
||||
*
|
||||
* 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.audio.output;
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.audio.playback;
|
||||
|
||||
import io.github.dsheirer.audio.AudioEvent;
|
||||
import io.github.dsheirer.channel.metadata.Metadata;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.sample.Broadcaster;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.sample.buffer.ReusableAudioPacket;
|
||||
@@ -54,7 +55,7 @@ public abstract class AudioOutput implements Listener<ReusableAudioPacket>, Line
|
||||
private int mBufferStartThreshold;
|
||||
private int mBufferStopThreshold;
|
||||
|
||||
private Listener<Metadata> mMetadataListener;
|
||||
private Listener<IdentifierCollection> mIdentifierCollectionListener;
|
||||
private Broadcaster<AudioEvent> mAudioEventBroadcaster = new Broadcaster<>();
|
||||
|
||||
private ScheduledFuture<?> mProcessorTask;
|
||||
@@ -85,10 +86,7 @@ public abstract class AudioOutput implements Listener<ReusableAudioPacket>, Line
|
||||
* @param lineInfo to use when obtaining the source data line
|
||||
* @param requestedBufferSize of approximately 1 second of audio
|
||||
*/
|
||||
public AudioOutput(Mixer mixer,
|
||||
MixerChannel mixerChannel,
|
||||
AudioFormat audioFormat,
|
||||
Line.Info lineInfo,
|
||||
public AudioOutput(Mixer mixer, MixerChannel mixerChannel, AudioFormat audioFormat, Line.Info lineInfo,
|
||||
int requestedBufferSize)
|
||||
{
|
||||
mMixer = mixer;
|
||||
@@ -174,7 +172,7 @@ public abstract class AudioOutput implements Listener<ReusableAudioPacket>, Line
|
||||
|
||||
mAudioEventBroadcaster.dispose();
|
||||
mAudioEventBroadcaster = null;
|
||||
mMetadataListener = null;
|
||||
mIdentifierCollectionListener = null;
|
||||
|
||||
if(mOutput != null)
|
||||
{
|
||||
@@ -233,24 +231,24 @@ public abstract class AudioOutput implements Listener<ReusableAudioPacket>, Line
|
||||
* Registers a single listener to receive the audio metadata from each
|
||||
* audio packet
|
||||
*/
|
||||
public void setMetadataListener(Listener<Metadata> listener)
|
||||
public void setIdentifierCollectionListener(Listener<IdentifierCollection> listener)
|
||||
{
|
||||
mMetadataListener = listener;
|
||||
mIdentifierCollectionListener = listener;
|
||||
}
|
||||
|
||||
public void removeAudioMetadataListener()
|
||||
{
|
||||
mMetadataListener = null;
|
||||
mIdentifierCollectionListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts audio metadata to the registered listener
|
||||
* Broadcasts audio identifier collection metadata to the registered listener
|
||||
*/
|
||||
private void broadcast(Metadata metadata)
|
||||
private void broadcast(IdentifierCollection identifierCollection)
|
||||
{
|
||||
if(mMetadataListener != null)
|
||||
if(mIdentifierCollectionListener != null)
|
||||
{
|
||||
mMetadataListener.receive(metadata);
|
||||
mIdentifierCollectionListener.receive(identifierCollection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +310,7 @@ public abstract class AudioOutput implements Listener<ReusableAudioPacket>, Line
|
||||
{
|
||||
if(packet.getType() == ReusableAudioPacket.Type.AUDIO)
|
||||
{
|
||||
broadcast(packet.getMetadata());
|
||||
broadcast(packet.getIdentifierCollection());
|
||||
|
||||
ByteBuffer buffer = convert(packet);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* 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
|
||||
@@ -14,12 +15,16 @@
|
||||
*
|
||||
* 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.audio;
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.audio.playback;
|
||||
|
||||
import io.github.dsheirer.audio.output.AudioOutput;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.audio.AudioEvent;
|
||||
import io.github.dsheirer.audio.AudioException;
|
||||
import io.github.dsheirer.audio.IAudioController;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import io.github.dsheirer.preference.UserPreferences;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.settings.SettingsManager;
|
||||
import io.github.dsheirer.source.SourceManager;
|
||||
@@ -60,17 +65,21 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
||||
private SettingsManager mSettingsManager;
|
||||
private SourceManager mSourceManager;
|
||||
private IAudioController mController;
|
||||
private AliasModel mAliasModel;
|
||||
private UserPreferences mUserPreferences;
|
||||
|
||||
private JButton mMuteButton;
|
||||
private AudioChannelsPanel mAudioChannelsPanel;
|
||||
|
||||
public AudioPanel(IconManager iconManager, SettingsManager settingsManager, SourceManager sourceManager,
|
||||
IAudioController controller)
|
||||
public AudioPanel(IconManager iconManager, UserPreferences userPreferences, SettingsManager settingsManager,
|
||||
SourceManager sourceManager, IAudioController controller, AliasModel aliasModel)
|
||||
{
|
||||
mIconManager = iconManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mSourceManager = sourceManager;
|
||||
mController = controller;
|
||||
mAliasModel = aliasModel;
|
||||
mUserPreferences = userPreferences;
|
||||
|
||||
mController.addControllerListener(this);
|
||||
|
||||
@@ -86,7 +95,7 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
||||
mMuteButton.setBackground(getBackground());
|
||||
add(mMuteButton);
|
||||
|
||||
mAudioChannelsPanel = new AudioChannelsPanel(mIconManager, mSettingsManager, mController);
|
||||
mAudioChannelsPanel = new AudioChannelsPanel(mIconManager, mUserPreferences, mSettingsManager, mController, mAliasModel);
|
||||
|
||||
add(mAudioChannelsPanel);
|
||||
|
||||
@@ -107,13 +116,10 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
||||
public void run()
|
||||
{
|
||||
remove(mAudioChannelsPanel);
|
||||
|
||||
mAudioChannelsPanel = new AudioChannelsPanel(mIconManager, mSettingsManager, mController);
|
||||
|
||||
mAudioChannelsPanel.dispose();
|
||||
mAudioChannelsPanel = new AudioChannelsPanel(mIconManager, mUserPreferences, mSettingsManager, mController, mAliasModel);
|
||||
add(mAudioChannelsPanel);
|
||||
|
||||
mAudioChannelsPanel.repaint();
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* 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
|
||||
@@ -14,13 +15,13 @@
|
||||
*
|
||||
* 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.audio;
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.audio.playback;
|
||||
|
||||
import io.github.dsheirer.audio.output.AudioOutput;
|
||||
import io.github.dsheirer.audio.output.MonoAudioOutput;
|
||||
import io.github.dsheirer.audio.output.StereoAudioOutput;
|
||||
import io.github.dsheirer.audio.AudioEvent;
|
||||
import io.github.dsheirer.audio.AudioException;
|
||||
import io.github.dsheirer.audio.IAudioController;
|
||||
import io.github.dsheirer.properties.SystemProperties;
|
||||
import io.github.dsheirer.sample.Broadcaster;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
@@ -44,9 +45,9 @@ import java.util.concurrent.LinkedTransferQueue;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AudioManager implements Listener<ReusableAudioPacket>, IAudioController
|
||||
public class AudioPlaybackManager implements Listener<ReusableAudioPacket>, IAudioController
|
||||
{
|
||||
private static final Logger mLog = LoggerFactory.getLogger(AudioManager.class);
|
||||
private static final Logger mLog = LoggerFactory.getLogger(AudioPlaybackManager.class);
|
||||
|
||||
public static final int AUDIO_TIMEOUT = 1000; //1 second
|
||||
|
||||
@@ -79,7 +80,7 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
* packets to any combination of outputs based on any alias audio routing
|
||||
* options specified by the user.
|
||||
*/
|
||||
public AudioManager(MixerManager mixerManager)
|
||||
public AudioPlaybackManager(MixerManager mixerManager)
|
||||
{
|
||||
mMixerManager = mixerManager;
|
||||
|
||||
@@ -185,9 +186,9 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
|
||||
for(AudioOutputConnection connection : mAudioOutputConnections)
|
||||
{
|
||||
if(connection.isInactive() && mChannelConnectionMap.containsKey(connection.getChannelMetadataID()))
|
||||
if(connection.isInactive() && mChannelConnectionMap.containsKey(connection.getAudioChannelId()))
|
||||
{
|
||||
mChannelConnectionMap.remove(connection.getChannelMetadataID());
|
||||
mChannelConnectionMap.remove(connection.getAudioChannelId());
|
||||
connection.disconnect();
|
||||
mAvailableConnectionCount++;
|
||||
changed = true;
|
||||
@@ -365,12 +366,12 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
*/
|
||||
private AudioOutputConnection getConnection(ReusableAudioPacket audioPacket)
|
||||
{
|
||||
int channelMetadataID = audioPacket.getMetadata().getMetadataID();
|
||||
int audioChannelId = audioPacket.getAudioChannelId();
|
||||
|
||||
//Use an existing connection
|
||||
if(mChannelConnectionMap.containsKey(channelMetadataID))
|
||||
if(mChannelConnectionMap.containsKey(audioChannelId))
|
||||
{
|
||||
return mChannelConnectionMap.get(channelMetadataID);
|
||||
return mChannelConnectionMap.get(audioChannelId);
|
||||
}
|
||||
|
||||
//Connect to an unused, available connection
|
||||
@@ -380,8 +381,8 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
{
|
||||
if(connection.isDisconnected())
|
||||
{
|
||||
connection.connect(channelMetadataID, audioPacket.getMetadata().getAudioPriority());
|
||||
mChannelConnectionMap.put(channelMetadataID, connection);
|
||||
connection.connect(audioChannelId, audioPacket.getMonitoringPriority());
|
||||
mChannelConnectionMap.put(audioChannelId, connection);
|
||||
mAvailableConnectionCount--;
|
||||
return connection;
|
||||
}
|
||||
@@ -390,17 +391,17 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
//Preempt an existing lower priority connection and connect when this is a higher priority packet
|
||||
else
|
||||
{
|
||||
int priority = audioPacket.getMetadata().getAudioPriority();
|
||||
int priority = audioPacket.getMonitoringPriority();
|
||||
|
||||
AudioOutputConnection connection = mLowestPriorityConnection;
|
||||
|
||||
if(connection != null && priority < connection.getPriority())
|
||||
{
|
||||
mChannelConnectionMap.remove(connection.getChannelMetadataID());
|
||||
mChannelConnectionMap.remove(connection.getAudioChannelId());
|
||||
|
||||
connection.connect(channelMetadataID, priority);
|
||||
connection.connect(audioChannelId, priority);
|
||||
|
||||
mChannelConnectionMap.put(channelMetadataID, connection);
|
||||
mChannelConnectionMap.put(audioChannelId, connection);
|
||||
|
||||
return connection;
|
||||
}
|
||||
@@ -427,7 +428,7 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
for(ReusableAudioPacket packet : mPackets)
|
||||
{
|
||||
/* Don't process any packet's marked as do not monitor */
|
||||
if(!packet.getMetadata().isDoNotMonitor() && packet.getType() == ReusableAudioPacket.Type.AUDIO)
|
||||
if(!packet.isDoNotMonitor() && packet.getType() == ReusableAudioPacket.Type.AUDIO)
|
||||
{
|
||||
AudioOutputConnection connection = getConnection(packet);
|
||||
|
||||
@@ -469,11 +470,11 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
*/
|
||||
public class AudioOutputConnection
|
||||
{
|
||||
private static final int DISCONNECTED = -1;
|
||||
private static final int DISCONNECTED = Integer.MIN_VALUE;
|
||||
|
||||
private AudioOutput mAudioOutput;
|
||||
private int mPriority = 0;
|
||||
private int mChannelMetadataID = DISCONNECTED;
|
||||
private int mAudioChannelId = DISCONNECTED;
|
||||
|
||||
public AudioOutputConnection(AudioOutput audioOutput)
|
||||
{
|
||||
@@ -482,9 +483,9 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
|
||||
public void receive(ReusableAudioPacket packet)
|
||||
{
|
||||
if(packet.hasMetadata() && packet.getMetadata().getMetadataID() == mChannelMetadataID)
|
||||
if(packet.hasIdentifierCollection() && packet.getAudioChannelId() == mAudioChannelId)
|
||||
{
|
||||
int priority = packet.getMetadata().getAudioPriority();
|
||||
int priority = packet.getMonitoringPriority();
|
||||
|
||||
if(mPriority != priority)
|
||||
{
|
||||
@@ -499,10 +500,10 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
}
|
||||
else
|
||||
{
|
||||
if(packet.hasMetadata())
|
||||
if(packet.hasIdentifierCollection())
|
||||
{
|
||||
mLog.error("Received audio packet from channel metadata [" + packet.getMetadata().getMetadataID() +
|
||||
"] however this assignment is currently connected to metadata [" + mChannelMetadataID + "]");
|
||||
mLog.error("Received audio packet from channel metadata [" + packet.getAudioChannelId() +
|
||||
"] however this assignment is currently connected to metadata [" + mAudioChannelId + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -525,7 +526,7 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
*/
|
||||
public boolean isDisconnected()
|
||||
{
|
||||
return mChannelMetadataID == DISCONNECTED;
|
||||
return mAudioChannelId == DISCONNECTED;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -542,7 +543,7 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
*/
|
||||
public void connect(int source, int priority)
|
||||
{
|
||||
mChannelMetadataID = source;
|
||||
mAudioChannelId = source;
|
||||
mPriority = priority;
|
||||
updateLowestPriorityAssignment();
|
||||
|
||||
@@ -552,9 +553,9 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
/**
|
||||
* Currently connected source or -1 if disconnected
|
||||
*/
|
||||
public int getChannelMetadataID()
|
||||
public int getAudioChannelId()
|
||||
{
|
||||
return mChannelMetadataID;
|
||||
return mAudioChannelId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -563,7 +564,7 @@ public class AudioManager implements Listener<ReusableAudioPacket>, IAudioContro
|
||||
*/
|
||||
public void disconnect()
|
||||
{
|
||||
mChannelMetadataID = DISCONNECTED;
|
||||
mAudioChannelId = DISCONNECTED;
|
||||
mPriority = 0;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.audio.output;
|
||||
package io.github.dsheirer.audio.playback;
|
||||
|
||||
import io.github.dsheirer.audio.AudioFormats;
|
||||
import io.github.dsheirer.sample.buffer.ReusableAudioPacket;
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.audio.output;
|
||||
package io.github.dsheirer.audio.playback;
|
||||
|
||||
import io.github.dsheirer.audio.AudioFormats;
|
||||
import io.github.dsheirer.sample.buffer.ReusableAudioPacket;
|
||||
Reference in New Issue
Block a user