mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-18 11:37:26 -05:00
#2688 NXDN Type-D audio fixes. New call audio or late call audio correctly handled. Call response (CALL_RESP) now parsed correctly per TS 1-E Figure 6.4-21 to handle multi-system formats. (#2692)
Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
@@ -75,6 +75,9 @@ import io.github.dsheirer.module.decode.nxdn.layer3.mobility.RegistrationCommand
|
|||||||
import io.github.dsheirer.module.decode.nxdn.layer3.mobility.RegistrationResponse;
|
import io.github.dsheirer.module.decode.nxdn.layer3.mobility.RegistrationResponse;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.mobility.RegistrationResponseTypeD;
|
import io.github.dsheirer.module.decode.nxdn.layer3.mobility.RegistrationResponseTypeD;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.proprietary.TalkerAliasComplete;
|
import io.github.dsheirer.module.decode.nxdn.layer3.proprietary.TalkerAliasComplete;
|
||||||
|
import io.github.dsheirer.module.decode.nxdn.layer3.scch.Information1;
|
||||||
|
import io.github.dsheirer.module.decode.nxdn.layer3.scch.InitializationVectorPart1;
|
||||||
|
import io.github.dsheirer.module.decode.nxdn.layer3.type.CipherType;
|
||||||
import io.github.dsheirer.protocol.Protocol;
|
import io.github.dsheirer.protocol.Protocol;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -288,8 +291,9 @@ public class NXDNDecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
//Controller responds to a voice call request with either a channel grant, or this message if
|
//Controller responds to a voice call request with either a channel grant, or this message if
|
||||||
//it can't support the call or the called party is not available
|
//it can't support the call or the called party is not available
|
||||||
|
//Type-D call response doesn't carry a cause.
|
||||||
broadcastEvent(vcr.getIdentifiers(), vcr.getTimestamp(), DecodeEventType.RESPONSE,
|
broadcastEvent(vcr.getIdentifiers(), vcr.getTimestamp(), DecodeEventType.RESPONSE,
|
||||||
"VOICE CALL REQUEST - RESPONSE:" + vcr.getCause().toString());
|
vcr.isTypeD() ? "CALL RESPONSE" : "VOICE CALL REQUEST - RESPONSE:" + vcr.getCause());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TRAFFIC_OUT_01_CC_VOICE_CALL:
|
case TRAFFIC_OUT_01_CC_VOICE_CALL:
|
||||||
@@ -726,6 +730,24 @@ public class NXDNDecoderState extends DecoderState
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Messages that don't otherwise change the state (e.g. Type-D SCCH) but are carried in a frame that also carries
|
||||||
|
//voice are a continuation of the call. Otherwise, the ACTIVE state toggles the channel out of CALL state on
|
||||||
|
//every voice frame, squelching the audio module which then discards the call audio.
|
||||||
|
if(state == State.ACTIVE && event == DecoderStateEvent.Event.DECODE && layer3.getLICH().hasAudio())
|
||||||
|
{
|
||||||
|
//Type-D only sends the VOICE CALL at the start of a call. When we join late, or miss it, use the SCCH call
|
||||||
|
//info or initialization vector to determine the encryption state.
|
||||||
|
if(!mEncryptedCallStateDetermined && layer3 instanceof Information1 info1)
|
||||||
|
{
|
||||||
|
mEncryptedCallStateDetermined = true;
|
||||||
|
mEncryptedCall = info1 instanceof InitializationVectorPart1 ||
|
||||||
|
info1.getCipherType() != CipherType.UNENCRYPTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = (mEncryptedCallStateDetermined && mEncryptedCall) ? State.ENCRYPTED : State.CALL;
|
||||||
|
event = DecoderStateEvent.Event.CONTINUATION;
|
||||||
|
}
|
||||||
|
|
||||||
broadcast(new DecoderStateEvent(this, event, state));
|
broadcast(new DecoderStateEvent(this, event, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ import io.github.dsheirer.module.decode.nxdn.layer3.call.Audio;
|
|||||||
import io.github.dsheirer.module.decode.nxdn.layer3.call.Disconnect;
|
import io.github.dsheirer.module.decode.nxdn.layer3.call.Disconnect;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.call.TransmissionRelease;
|
import io.github.dsheirer.module.decode.nxdn.layer3.call.TransmissionRelease;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.call.VoiceCall;
|
import io.github.dsheirer.module.decode.nxdn.layer3.call.VoiceCall;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.call.VoiceCallWithOptionalLocation;
|
import io.github.dsheirer.module.decode.nxdn.layer3.scch.Information1;
|
||||||
|
import io.github.dsheirer.module.decode.nxdn.layer3.scch.InitializationVectorPart1;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.type.AudioCodec;
|
import io.github.dsheirer.module.decode.nxdn.layer3.type.AudioCodec;
|
||||||
|
import io.github.dsheirer.module.decode.nxdn.layer3.type.CipherType;
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.sample.Listener;
|
import io.github.dsheirer.sample.Listener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -100,11 +102,18 @@ public class NXDNAudioModule extends AmbeAudioModule
|
|||||||
mAudioCodec = voiceCall.getCallOption().getCodec();
|
mAudioCodec = voiceCall.getCallOption().getCodec();
|
||||||
processCachedAudio();
|
processCachedAudio();
|
||||||
}
|
}
|
||||||
else if(message instanceof VoiceCallWithOptionalLocation voiceCall)
|
//Note: VoiceCallWithOptionalLocation subclasses (request, response, assignment, etc.) don't carry the
|
||||||
|
//cipher type and key ID, so they can't be used to establish the encryption state.
|
||||||
|
else if(!mEncryptedCallStateEstablished && message instanceof Information1 info1 &&
|
||||||
|
info1.getLICH().hasAudio())
|
||||||
{
|
{
|
||||||
mEncryptedCall = voiceCall.getEncryptionKeyIdentifier().isEncrypted();
|
//Type-D only sends the VOICE CALL message at the start of the call. Use the SCCH call info or
|
||||||
|
//initialization vector from a voice frame to establish the encryption state when we join a call
|
||||||
|
//late, or when the VOICE CALL message was missed. Type-D only supports AMBE+ half-rate.
|
||||||
|
mEncryptedCall = info1 instanceof InitializationVectorPart1 ||
|
||||||
|
info1.getCipherType() != CipherType.UNENCRYPTED;
|
||||||
mEncryptedCallStateEstablished = true;
|
mEncryptedCallStateEstablished = true;
|
||||||
mAudioCodec = voiceCall.getCallOption().getCodec();
|
mAudioCodec = AudioCodec.HALF_RATE;
|
||||||
processCachedAudio();
|
processCachedAudio();
|
||||||
}
|
}
|
||||||
else if(message instanceof Disconnect || message instanceof TransmissionRelease)
|
else if(message instanceof Disconnect || message instanceof TransmissionRelease)
|
||||||
|
|||||||
@@ -25,15 +25,25 @@ import io.github.dsheirer.identifier.Identifier;
|
|||||||
import io.github.dsheirer.module.decode.nxdn.layer2.LICH;
|
import io.github.dsheirer.module.decode.nxdn.layer2.LICH;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.NXDNMessageType;
|
import io.github.dsheirer.module.decode.nxdn.layer3.NXDNMessageType;
|
||||||
import io.github.dsheirer.module.decode.nxdn.layer3.type.CauseVD;
|
import io.github.dsheirer.module.decode.nxdn.layer3.type.CauseVD;
|
||||||
|
import io.github.dsheirer.module.decode.nxdn.layer3.type.SystemID;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Voice call response
|
* Voice call response (VCALL_RESP) or Type-D call response (CALL_RESP).
|
||||||
|
*
|
||||||
|
* Note: the Type-D call response (NXDN TS 1-E, Figure 6.4-21) has no cause or cipher fields. Instead, octets 7-9
|
||||||
|
* optionally carry a System ID Option and System ID when the CC Option indicates a multi trunked system.
|
||||||
*/
|
*/
|
||||||
public class VoiceCallResponse extends VoiceCallWithOptionalLocation
|
public class VoiceCallResponse extends VoiceCallWithOptionalLocation
|
||||||
{
|
{
|
||||||
private static final IntField CAUSE_VD = IntField.length8(OCTET_7);
|
private static final IntField CAUSE_VD = IntField.length8(OCTET_7);
|
||||||
private static final int LOCATION_ID_OFFSET = OCTET_8;
|
private static final int LOCATION_ID_OFFSET = OCTET_8;
|
||||||
|
private static final int TYPE_D_MASK_MULTI_TRUNKED_SYSTEM = 0x10; //CC Option T-Type flag
|
||||||
|
private static final IntField TYPE_D_SYSTEM_ID_RELATED_UNIT = IntField.length2(OCTET_7);
|
||||||
|
private static final int TYPE_D_SYSTEM_ID_OFFSET = OCTET_7 + 5;
|
||||||
|
private static final int TYPE_D_RELATED_UNIT_SOURCE = 2;
|
||||||
|
private static final int TYPE_D_RELATED_UNIT_DESTINATION = 1;
|
||||||
|
private SystemID mTypeDSystemID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
@@ -58,6 +68,11 @@ public class VoiceCallResponse extends VoiceCallWithOptionalLocation
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
if(isTypeD())
|
||||||
|
{
|
||||||
|
return toStringTypeD();
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder sb = getMessageBuilder();
|
StringBuilder sb = getMessageBuilder();
|
||||||
|
|
||||||
if(getCallControlOption().isEmergency())
|
if(getCallControlOption().isEmergency())
|
||||||
@@ -88,28 +103,124 @@ public class VoiceCallResponse extends VoiceCallWithOptionalLocation
|
|||||||
sb.append(" FROM:").append(getSource());
|
sb.append(" FROM:").append(getSource());
|
||||||
sb.append(" TO:").append(getDestination());
|
sb.append(" TO:").append(getDestination());
|
||||||
sb.append(" ").append(getEncryptionKeyIdentifier());
|
sb.append(" ").append(getEncryptionKeyIdentifier());
|
||||||
|
|
||||||
if(isTypeD())
|
|
||||||
{
|
|
||||||
sb.append(" FREE REPEATER:").append(getMessage().getInt(CALL_OPTION));
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append(" ").append(getCallOption());
|
sb.append(" ").append(getCallOption());
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type-D call response formatted as a string.
|
||||||
|
*/
|
||||||
|
private String toStringTypeD()
|
||||||
|
{
|
||||||
|
StringBuilder sb = getMessageBuilder();
|
||||||
|
|
||||||
|
if(getCallControlOption().isEmergency())
|
||||||
|
{
|
||||||
|
sb.append("EMERGENCY ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getCallControlOption().isPriorityPaging())
|
||||||
|
{
|
||||||
|
sb.append("PRIORITY ");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append("TYPE-D ").append(getCallType()).append(" CALL RESPONSE");
|
||||||
|
sb.append(" FROM:").append(getSource());
|
||||||
|
sb.append(" TO:").append(getDestination());
|
||||||
|
|
||||||
|
if(hasTypeDSystemID())
|
||||||
|
{
|
||||||
|
sb.append(" MULTI-SYSTEM ").append(getTypeDSystemID());
|
||||||
|
|
||||||
|
if(isTypeDSystemIDForSource())
|
||||||
|
{
|
||||||
|
sb.append(" (SOURCE)");
|
||||||
|
}
|
||||||
|
else if(isTypeDSystemIDForDestination())
|
||||||
|
{
|
||||||
|
sb.append(" (DESTINATION)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append(" FREE REPEATER:").append(getFreeRepeater());
|
||||||
|
sb.append(" ").append(getCallOption());
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type-D free repeater number.
|
||||||
|
*/
|
||||||
|
public int getFreeRepeater()
|
||||||
|
{
|
||||||
|
return getMessage().getInt(CALL_OPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this Type-D call response carries the optional System ID, which is present for a multi trunked
|
||||||
|
* system.
|
||||||
|
*/
|
||||||
|
public boolean hasTypeDSystemID()
|
||||||
|
{
|
||||||
|
return isTypeD() && (getCallControlOption().value() & TYPE_D_MASK_MULTI_TRUNKED_SYSTEM) ==
|
||||||
|
TYPE_D_MASK_MULTI_TRUNKED_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional Type-D System ID.
|
||||||
|
* @return system ID or null if the message doesn't carry a system ID.
|
||||||
|
*/
|
||||||
|
public SystemID getTypeDSystemID()
|
||||||
|
{
|
||||||
|
if(mTypeDSystemID == null && hasTypeDSystemID())
|
||||||
|
{
|
||||||
|
mTypeDSystemID = new SystemID(getMessage(), TYPE_D_SYSTEM_ID_OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mTypeDSystemID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the Type-D System ID relates to the source unit.
|
||||||
|
*/
|
||||||
|
public boolean isTypeDSystemIDForSource()
|
||||||
|
{
|
||||||
|
return hasTypeDSystemID() && getMessage().getInt(TYPE_D_SYSTEM_ID_RELATED_UNIT) == TYPE_D_RELATED_UNIT_SOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the Type-D System ID relates to the destination unit.
|
||||||
|
*/
|
||||||
|
public boolean isTypeDSystemIDForDestination()
|
||||||
|
{
|
||||||
|
return hasTypeDSystemID() &&
|
||||||
|
getMessage().getInt(TYPE_D_SYSTEM_ID_RELATED_UNIT) == TYPE_D_RELATED_UNIT_DESTINATION;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amplifying cause for the response.
|
* Amplifying cause for the response.
|
||||||
|
* @return cause, or UNKNOWN for a Type-D call response which doesn't carry a cause.
|
||||||
*/
|
*/
|
||||||
public CauseVD getCause()
|
public CauseVD getCause()
|
||||||
{
|
{
|
||||||
|
if(isTypeD())
|
||||||
|
{
|
||||||
|
return CauseVD.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
return CauseVD.fromValue(getMessage().getInt(CAUSE_VD));
|
return CauseVD.fromValue(getMessage().getInt(CAUSE_VD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Identifier> getIdentifiers()
|
public List<Identifier> getIdentifiers()
|
||||||
{
|
{
|
||||||
|
if(isTypeD())
|
||||||
|
{
|
||||||
|
//Type-D call response doesn't carry an encryption key
|
||||||
|
return List.of(getSource(), getDestination());
|
||||||
|
}
|
||||||
|
|
||||||
return List.of(getSource(), getDestination(), getEncryptionKeyIdentifier());
|
return List.of(getSource(), getDestination(), getEncryptionKeyIdentifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user