mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-20 04:27:48 -05:00
Generate audio metadata with correct to/from (#1215)
#1215 Generate audio metadata with correct to/from, preferring patch group, then talkgroup then other, for TO talkgroups.
This commit is contained in:
@@ -278,29 +278,43 @@ public class IdentifierCollection
|
|||||||
*/
|
*/
|
||||||
public Identifier getFromIdentifier()
|
public Identifier getFromIdentifier()
|
||||||
{
|
{
|
||||||
List<Identifier> fromIdentifiers = getIdentifiers(Role.FROM);
|
Identifier from = getIdentifier(IdentifierClass.USER, Form.RADIO, Role.FROM);
|
||||||
|
|
||||||
if(!fromIdentifiers.isEmpty())
|
if(from == null)
|
||||||
{
|
{
|
||||||
return fromIdentifiers.get(0);
|
List<Identifier> fromIdentifiers = getIdentifiers(Role.FROM);
|
||||||
|
|
||||||
|
if(!fromIdentifiers.isEmpty())
|
||||||
|
{
|
||||||
|
from = fromIdentifiers.get(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return from;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first identifier in this collection that is assigned a FROM role
|
* Returns the first identifier in this collection that is assigned a TO role
|
||||||
*/
|
*/
|
||||||
public Identifier getToIdentifier()
|
public Identifier getToIdentifier()
|
||||||
{
|
{
|
||||||
List<Identifier> toIdentifiers = getIdentifiers(Role.TO);
|
Identifier to = getIdentifier(IdentifierClass.USER, Form.PATCH_GROUP, Role.TO);
|
||||||
|
|
||||||
if(!toIdentifiers.isEmpty())
|
if(to == null)
|
||||||
{
|
{
|
||||||
return toIdentifiers.get(0);
|
to = getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.TO);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
if(to == null)
|
||||||
|
{
|
||||||
|
List<Identifier> toIdentifiers = getIdentifiers(Role.TO);
|
||||||
|
if(!toIdentifiers.isEmpty())
|
||||||
|
{
|
||||||
|
to = toIdentifiers.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -89,37 +89,41 @@ public class AudioMetadataUtils
|
|||||||
|
|
||||||
if(identifierCollection != null)
|
if(identifierCollection != null)
|
||||||
{
|
{
|
||||||
for(Identifier to: identifierCollection.getIdentifiers(Role.TO))
|
StringBuilder sb;
|
||||||
|
|
||||||
|
Identifier to = identifierCollection.getToIdentifier();
|
||||||
|
if(to != null)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
sb.append(to.toString());
|
sb.append(to.toString());
|
||||||
|
|
||||||
List<Alias> aliases = aliasList.getAliases(to);
|
List<Alias> toAliases = aliasList.getAliases(to);
|
||||||
|
|
||||||
if(!aliases.isEmpty())
|
if(!toAliases.isEmpty())
|
||||||
{
|
{
|
||||||
sb.append("\"").append(Joiner.on("\",\"").join(aliases)).append("\"");
|
sb.append("\"").append(Joiner.on("\",\"").join(toAliases)).append("\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
audioMetadata.put(AudioMetadata.TRACK_TITLE, sb.toString());
|
audioMetadata.put(AudioMetadata.TRACK_TITLE, sb.toString());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Identifier from: identifierCollection.getIdentifiers(Role.FROM))
|
Identifier from = identifierCollection.getFromIdentifier();
|
||||||
|
if(from != null)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
sb = new StringBuilder();
|
||||||
sb.append(from.toString());
|
sb.append(from.toString());
|
||||||
|
|
||||||
List<Alias> aliases = aliasList.getAliases(from);
|
List<Alias> fromAliases = aliasList.getAliases(from);
|
||||||
|
|
||||||
for(Alias alias: aliases)
|
for(Alias alias: fromAliases)
|
||||||
{
|
{
|
||||||
sb.append(" ").append(alias.toString());
|
sb.append(" ").append(alias.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
audioMetadata.put(AudioMetadata.ARTIST_NAME, sb.toString());
|
audioMetadata.put(AudioMetadata.ARTIST_NAME, sb.toString());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sb = null;
|
||||||
|
|
||||||
Identifier system = identifierCollection.getIdentifier(IdentifierClass.CONFIGURATION, Form.SYSTEM, Role.ANY);
|
Identifier system = identifierCollection.getIdentifier(IdentifierClass.CONFIGURATION, Form.SYSTEM, Role.ANY);
|
||||||
if(system instanceof SystemConfigurationIdentifier)
|
if(system instanceof SystemConfigurationIdentifier)
|
||||||
|
|||||||
Reference in New Issue
Block a user