import net.pterodactylus.sonitus.data.Connection;
import net.pterodactylus.sonitus.data.Filter;
import net.pterodactylus.sonitus.data.Format;
+import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Source;
import net.pterodactylus.sonitus.io.InputStreamDrainer;
/** The logger. */
private final Logger logger = Logger.getLogger(getClass().getName());
- /** The format of the source. */
- private Format format;
+ /** The source. */
+ private Source source;
/** The input stream that will hold the converted source. */
private PipedInputStream pipedInputStream;
//
// FILTER METHODS
+ //
@Override
public Format format() {
- return format;
+ return source.format();
+ }
+
+ @Override
+ public Metadata metadata() {
+ return source.metadata();
}
@Override
public byte[] get(int bufferSize) throws EOFException, IOException {
byte[] buffer = new byte[bufferSize];
int read = pipedInputStream.read(buffer);
+ if (read == -1) {
+ throw new EOFException();
+ }
return Arrays.copyOf(buffer, read);
}
public void connect(Source source) throws ConnectException {
Preconditions.checkNotNull(source, "source must not be null");
- format = source.format();
+ this.source = source;
try {
- final Process process = Runtime.getRuntime().exec(Iterables.toArray(ImmutableList.<String>builder().add(binary(format)).addAll(parameters(format)).build(), String.class));
+ final Process process = Runtime.getRuntime().exec(Iterables.toArray(ImmutableList.<String>builder().add(binary(source.format())).addAll(parameters(source.format())).build(), String.class));
final InputStream processOutput = process.getInputStream();
final OutputStream processInput = process.getOutputStream();
final InputStream processError = process.getErrorStream();
}
}
+ @Override
+ public void metadataUpdated() {
+ /* ignore. */
+ }
+
//
// SUBCLASS METHODS
//