Skip to content

Commit

Permalink
#2018 P25 Phase 1 resolves issue where NowPlaying identifiers were fl…
Browse files Browse the repository at this point in the history
…ickering as they are removed and readded with each TDULC terminator message. (#2019)

Co-authored-by: Dennis Sheirer <[email protected]>
  • Loading branch information
DSheirer and Dennis Sheirer authored Oct 15, 2024
1 parent 9a02416 commit 024a624
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.github.dsheirer.identifier.talkgroup.TalkgroupIdentifier;
import io.github.dsheirer.log.LoggingSuppressor;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.message.TimeslotMessage;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.dmr.channel.DMRAbsoluteChannel;
import io.github.dsheirer.module.decode.dmr.channel.DMRChannel;
Expand Down Expand Up @@ -1459,14 +1460,22 @@ public String getActivitySummary()
{
StringBuilder sb = new StringBuilder();

boolean networkAdded = false;

if(mNetworkConfigurationMonitor != null)
{
sb.append(mNetworkConfigurationMonitor.getActivitySummary());
sb.append("\n\n");
sb.append(mTrafficChannelManager.getTalkerAliasManager().getAliasSummary());
networkAdded = true;
}
else

//Only add the talker alias summary to timeslot 1 activity summary since we aggregate across both timeslots.
if(getTimeslot() == TimeslotMessage.TIMESLOT_1)
{
if(networkAdded)
{
sb.append("\n\n");
}

sb.append(mTrafficChannelManager.getTalkerAliasManager().getAliasSummary());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import io.github.dsheirer.module.decode.p25.phase2.enumeration.ScrambleParameters;
import io.github.dsheirer.module.decode.p25.phase2.message.mac.MacOpcode;
import io.github.dsheirer.module.decode.p25.reference.ServiceOptions;
import io.github.dsheirer.module.decode.p25.reference.VoiceServiceOptions;
import io.github.dsheirer.module.decode.traffic.TrafficChannelManager;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.source.config.SourceConfigTuner;
Expand Down Expand Up @@ -729,27 +730,36 @@ public void processP1TrafficCallStart(long frequency, Identifier<?> talkgroup, I
{
P25TrafficChannelEventTracker tracker = getTracker(frequency, P25P1Message.TIMESLOT_1);

if(tracker != null)
//If the tracker is already started, it was for another call. Close it and recreate the event.
if(tracker != null && tracker.isStarted())
{
removeTracker(frequency, P25P1Message.TIMESLOT_1);
tracker = null;
}

DecodeEventType decodeEventType = getDecodeEventType(talkgroup, eki);

MutableIdentifierCollection mic = new MutableIdentifierCollection();
mic.update(talkgroup);
mic.update(radio);
mic.update(eki);

//Create a new event for the current call.
P25ChannelGrantEvent callEvent = P25ChannelGrantEvent.builder(decodeEventType, timestamp, serviceOptions)
.channelDescriptor(channelDescriptor)
.details("PHASE 1 CALL " + (serviceOptions != null ? serviceOptions : ""))
.identifiers(mic)
.build();
if(tracker != null)
{
tracker.addIdentifierIfMissing(talkgroup);
}
else
{
DecodeEventType decodeEventType = getDecodeEventType(talkgroup, eki);
MutableIdentifierCollection mic = new MutableIdentifierCollection();
mic.update(talkgroup);
mic.update(radio);
mic.update(eki);

//Create a new event for the current call.
P25ChannelGrantEvent callEvent = P25ChannelGrantEvent.builder(decodeEventType, timestamp, serviceOptions)
.channelDescriptor(channelDescriptor)
.details("PHASE 1 CALL " + (serviceOptions != null ? serviceOptions : ""))
.identifiers(mic)
.build();

tracker = new P25TrafficChannelEventTracker(callEvent);
addTracker(tracker, frequency, P25P1Message.TIMESLOT_1);
}

tracker = new P25TrafficChannelEventTracker(callEvent);
addTracker(tracker, frequency, P25P1Message.TIMESLOT_1);
broadcast(tracker);
}
finally
Expand Down Expand Up @@ -838,19 +848,22 @@ public void processP1TrafficCurrentUser(long frequency, Identifier identifier, l
* This is used primarily to add encryption, GPS, talker alias, etc. but can be used for any identifier update.
*
* @param frequency for the call event
* @param identifier to update within the event.
* @param identifiers to update within the event.
* @param timestamp for the update
*/
public void processP1TrafficCurrentUserIdentifiers(long frequency, List<Identifier> identifiers, long timestamp, String context)
public void processP1TrafficLDU1(long frequency, List<Identifier> identifiers, long timestamp, String context)
{
mLock.lock();

try
{
IChannelDescriptor channelDescriptor = null;

P25TrafficChannelEventTracker tracker = getTracker(frequency, P25P1Message.TIMESLOT_1);

if(tracker != null && tracker.isComplete())
{
channelDescriptor = tracker.getEvent().getChannelDescriptor();;
removeTracker(frequency, P25P1Message.TIMESLOT_1);
tracker = null;
}
Expand All @@ -871,6 +884,29 @@ public void processP1TrafficCurrentUserIdentifiers(long frequency, List<Identifi
tracker.updateDurationTraffic(timestamp);
broadcast(tracker);
}
else
{
MutableIdentifierCollection mic = new MutableIdentifierCollection(identifiers);
Identifier talkgroup = mic.getToIdentifier();
Identifier encryption = mic.getEncryptionIdentifier();

if(talkgroup != null && encryption instanceof EncryptionKeyIdentifier eki)
{
DecodeEventType decodeEventType = getDecodeEventType(talkgroup, eki);
//Create a new event for the current call.
ServiceOptions serviceOptions = (eki.isEncrypted() ? VoiceServiceOptions.createEncrypted() :
VoiceServiceOptions.createUnencrypted());
P25ChannelGrantEvent callEvent = P25ChannelGrantEvent.builder(decodeEventType, timestamp, serviceOptions)
.channelDescriptor(channelDescriptor)
.details("PHASE 1 CALL " + (eki.isEncrypted() ? eki.toString() : ""))
.identifiers(mic)
.build();

tracker = new P25TrafficChannelEventTracker(callEvent);
addTracker(tracker, frequency, P25P1Message.TIMESLOT_1);
broadcast(tracker);
}
}
}
finally
{
Expand Down
Loading

0 comments on commit 024a624

Please sign in to comment.