Permalink
Browse files

improve audioparser

  • Loading branch information...
tballison committed May 29, 2018
1 parent dae1d5b commit 41bc34ca7e5c7d868755b0adaf992104cabd0c57
Showing with 16 additions and 0 deletions.
  1. +16 −0 tika-parsers/src/main/java/org/apache/tika/parser/audio/AudioParser.java
@@ -32,7 +32,9 @@
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.apache.commons.io.IOUtils;
import org.apache.tika.exception.TikaException;
import org.apache.tika.io.ProxyInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.XMPDM;
import org.apache.tika.mime.MediaType;
@@ -66,6 +68,7 @@ public void parse(
if (!stream.markSupported()) {
stream = new BufferedInputStream(stream);
}
stream = new SkipFullyInputStream(stream);
try {
AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(stream);
Type type = fileFormat.getType();
@@ -137,4 +140,17 @@ private void addMetadata(Metadata metadata, Map<String, Object> properties) {
}
}
private static class SkipFullyInputStream extends ProxyInputStream {
public SkipFullyInputStream(InputStream proxy) {
super(proxy);
}
@Override
public long skip(long ln) throws IOException {
IOUtils.skipFully(in, ln);
return ln;
}
}
}

0 comments on commit 41bc34c

Please sign in to comment.