From cc5d94f58d1cac3e30de044e53f8aa5a61989c2d Mon Sep 17 00:00:00 2001 From: Denny Sheirer Date: Sat, 11 Jan 2020 06:06:08 -0500 Subject: [PATCH] #639 Updates all streaming metadata to include radio identifier value as the from value. (#640) --- .../IcecastBroadcastMetadataUpdater.java | 23 ++++++++- .../ShoutcastV1BroadcastMetadataUpdater.java | 51 +++++++++++++------ .../v2/ShoutcastV2AudioBroadcaster.java | 24 ++++++++- .../metadata/ChannelMetadataModel.java | 5 +- 4 files changed, 82 insertions(+), 21 deletions(-) diff --git a/src/main/java/io/github/dsheirer/audio/broadcast/icecast/IcecastBroadcastMetadataUpdater.java b/src/main/java/io/github/dsheirer/audio/broadcast/icecast/IcecastBroadcastMetadataUpdater.java index 8b53e94c..ab97502e 100644 --- a/src/main/java/io/github/dsheirer/audio/broadcast/icecast/IcecastBroadcastMetadataUpdater.java +++ b/src/main/java/io/github/dsheirer/audio/broadcast/icecast/IcecastBroadcastMetadataUpdater.java @@ -1,7 +1,7 @@ /* * * * ****************************************************************************** - * * Copyright (C) 2014-2019 Dennis Sheirer + * * Copyright (C) 2014-2020 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 @@ -178,6 +178,15 @@ public class IcecastBroadcastMetadataUpdater implements IBroadcastMetadataUpdate to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.TO); } + if(to == null) + { + List toIdentifiers = identifierCollection.getIdentifiers(Role.TO); + if(!toIdentifiers.isEmpty()) + { + to = toIdentifiers.get(0); + } + } + if(to != null) { sb.append("TO:").append(to); @@ -194,7 +203,17 @@ public class IcecastBroadcastMetadataUpdater implements IBroadcastMetadataUpdate sb.append("TO:UNKNOWN"); } - Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.FROM); + Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.RADIO, Role.FROM); + + if(from == null) + { + List fromIdentifiers = identifierCollection.getIdentifiers(Role.FROM); + + if(!fromIdentifiers.isEmpty()) + { + from = fromIdentifiers.get(0); + } + } if(from != null) { diff --git a/src/main/java/io/github/dsheirer/audio/broadcast/shoutcast/v1/ShoutcastV1BroadcastMetadataUpdater.java b/src/main/java/io/github/dsheirer/audio/broadcast/shoutcast/v1/ShoutcastV1BroadcastMetadataUpdater.java index 5aeaba5f..ce80c707 100644 --- a/src/main/java/io/github/dsheirer/audio/broadcast/shoutcast/v1/ShoutcastV1BroadcastMetadataUpdater.java +++ b/src/main/java/io/github/dsheirer/audio/broadcast/shoutcast/v1/ShoutcastV1BroadcastMetadataUpdater.java @@ -1,21 +1,23 @@ /* - * ****************************************************************************** - * 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. + * * ****************************************************************************** + * * Copyright (C) 2014-2020 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 + * * ***************************************************************************** * - * 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 - * ***************************************************************************** */ package io.github.dsheirer.audio.broadcast.shoutcast.v1; @@ -203,6 +205,15 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.TO); } + if(to == null) + { + List toIdentifiers = identifierCollection.getIdentifiers(Role.TO); + if(!toIdentifiers.isEmpty()) + { + to = toIdentifiers.get(0); + } + } + if(to != null) { sb.append("TO:").append(to); @@ -219,7 +230,17 @@ public class ShoutcastV1BroadcastMetadataUpdater implements IBroadcastMetadataUp sb.append("TO:UNKNOWN"); } - Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.FROM); + Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.RADIO, Role.FROM); + + if(from == null) + { + List fromIdentifiers = identifierCollection.getIdentifiers(Role.FROM); + + if(!fromIdentifiers.isEmpty()) + { + from = fromIdentifiers.get(0); + } + } if(from != null) { diff --git a/src/main/java/io/github/dsheirer/audio/broadcast/shoutcast/v2/ShoutcastV2AudioBroadcaster.java b/src/main/java/io/github/dsheirer/audio/broadcast/shoutcast/v2/ShoutcastV2AudioBroadcaster.java index 35768fe2..37f78165 100644 --- a/src/main/java/io/github/dsheirer/audio/broadcast/shoutcast/v2/ShoutcastV2AudioBroadcaster.java +++ b/src/main/java/io/github/dsheirer/audio/broadcast/shoutcast/v2/ShoutcastV2AudioBroadcaster.java @@ -1,7 +1,7 @@ /* * * * ****************************************************************************** - * * Copyright (C) 2014-2019 Dennis Sheirer + * * Copyright (C) 2014-2020 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 @@ -291,6 +291,16 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr to = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.TO); } + if(to == null) + { + List toIdentifiers = identifierCollection.getIdentifiers(Role.TO); + + if(!toIdentifiers.isEmpty()) + { + to = toIdentifiers.get(0); + } + } + if(to != null) { sbTitle2.append("TO:").append(to); @@ -307,7 +317,17 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr sbTitle2.append("TO:UNKNOWN"); } - Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.TALKGROUP, Role.FROM); + Identifier from = identifierCollection.getIdentifier(IdentifierClass.USER, Form.RADIO, Role.FROM); + + if(from == null) + { + List fromIdentifiers = identifierCollection.getIdentifiers(Role.FROM); + + if(!fromIdentifiers.isEmpty()) + { + from = fromIdentifiers.get(0); + } + } if(from != null) { diff --git a/src/main/java/io/github/dsheirer/channel/metadata/ChannelMetadataModel.java b/src/main/java/io/github/dsheirer/channel/metadata/ChannelMetadataModel.java index 0b44878c..cb1ede9a 100644 --- a/src/main/java/io/github/dsheirer/channel/metadata/ChannelMetadataModel.java +++ b/src/main/java/io/github/dsheirer/channel/metadata/ChannelMetadataModel.java @@ -1,7 +1,7 @@ /* * * * ****************************************************************************** - * * Copyright (C) 2014-2019 Dennis Sheirer + * * Copyright (C) 2014-2020 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 @@ -199,7 +199,8 @@ public class ChannelMetadataModel extends AbstractTableModel implements IChannel } else { - return id.getValue() + " TS:" + channelMetadata.getTimeslot(); + String value = id.getValue().replace(" TS0", "").replace(" TS1", ""); + return value + " TS:" + channelMetadata.getTimeslot(); } } else