From 8effd977495d572712e8113c663c3802078b11f9 Mon Sep 17 00:00:00 2001 From: tadscottsmith <78445808+tadscottsmith@users.noreply.github.com> Date: Mon, 6 Nov 2023 10:54:41 -0600 Subject: [PATCH] Explicitly send filename to Rdio-Scanner. --- .../rdioscanner/RdioScannerBroadcaster.java | 4 ++++ .../broadcast/rdioscanner/RdioScannerBuilder.java | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/dsheirer/audio/broadcast/rdioscanner/RdioScannerBroadcaster.java b/src/main/java/io/github/dsheirer/audio/broadcast/rdioscanner/RdioScannerBroadcaster.java index 446364b5d..1587ddd0f 100644 --- a/src/main/java/io/github/dsheirer/audio/broadcast/rdioscanner/RdioScannerBroadcaster.java +++ b/src/main/java/io/github/dsheirer/audio/broadcast/rdioscanner/RdioScannerBroadcaster.java @@ -232,6 +232,9 @@ private void processRecordingQueue() String talkgroupLabel = getTalkgroupLabel(audioRecording); String talkgroupGroup = getTalkgroupGroup(audioRecording); String systemLabel = getSystemLabel(audioRecording); + String path = audioRecording.getPath().toString(); + // Remove TEMPORARY_STREAM_FILE_SUFFIX + String audioName = path.substring(path.substring(0, path.lastIndexOf("_")).lastIndexOf("_") + 1); try { @@ -252,6 +255,7 @@ private void processRecordingQueue() RdioScannerBuilder bodyBuilder = new RdioScannerBuilder(); bodyBuilder.addPart(FormField.KEY, getBroadcastConfiguration().getApiKey()) .addPart(FormField.SYSTEM, getBroadcastConfiguration().getSystemID()) + .addAudioName(audioName) .addFile(audioBytes) .addPart(FormField.DATE_TIME, timestampSeconds) .addPart(FormField.TALKGROUP_ID, talkgroup) diff --git a/src/main/java/io/github/dsheirer/audio/broadcast/rdioscanner/RdioScannerBuilder.java b/src/main/java/io/github/dsheirer/audio/broadcast/rdioscanner/RdioScannerBuilder.java index 2e19ea530..2906ffb26 100644 --- a/src/main/java/io/github/dsheirer/audio/broadcast/rdioscanner/RdioScannerBuilder.java +++ b/src/main/java/io/github/dsheirer/audio/broadcast/rdioscanner/RdioScannerBuilder.java @@ -34,7 +34,8 @@ public class RdioScannerBuilder private static final String DASH_DASH = "--"; private static final String BOUNDARY = "--sdrtrunk-sdrtrunk-sdrtrunk"; private List mParts = new ArrayList<>(); - private byte[] audioBytes = null; + private byte[] audioBytes = null; + private String audioName = null; /** * Constructs an instance @@ -51,6 +52,15 @@ public String getBoundary() return BOUNDARY; } + /** + * Adds a Audio file name part to the call + */ + public RdioScannerBuilder addAudioName(String value) + { + audioName = value; + return this; + } + /** * Adds a Audio bytes part to the call */ @@ -110,7 +120,8 @@ private String formatFilePart(String boundary) } StringBuilder sb= new StringBuilder(); sb.append(DASH_DASH).append(boundary).append("\r\n"); - sb.append("Content-Disposition: form-data; name=\"").append("audio").append("\"\r\n\r\n"); + sb.append("Content-Disposition: form-data; filename =\"").append(audioName); + sb.append("\"; name=\"").append("audio").append("\"\r\n\r\n"); return sb.toString(); }