X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2FFilter.java;h=924ccee678fdeda36bc30ee123b2978919a9ef15;hb=48ff2dfc3ec8aafa119b8e25dade695c5d40312b;hp=897da01af286b59baf2e34c8b004e815015f821a;hpb=518d9e00f19f21e63b541e89f21c21186f674018;p=sonitus.git
diff --git a/src/main/java/net/pterodactylus/sonitus/data/Filter.java b/src/main/java/net/pterodactylus/sonitus/data/Filter.java
index 897da01..924ccee 100644
--- a/src/main/java/net/pterodactylus/sonitus/data/Filter.java
+++ b/src/main/java/net/pterodactylus/sonitus/data/Filter.java
@@ -17,11 +17,100 @@
package net.pterodactylus.sonitus.data;
+import java.io.IOException;
+import java.util.List;
+
/**
- * A filter processes an input to produce an output.
+ * A filter is both a source and a sink for audio data. It is used to process
+ * the audio date in whatever way seems appropriate.
*
* @author David âBombeâ Roden
*/
-public interface Filter extends Source, Sink{
+public interface Filter {
+
+ /**
+ * Adds the given listener to the list of registered listeners.
+ *
+ * @param metadataListener
+ * The metadata listener to add
+ */
+ void addMetadataListener(MetadataListener metadataListener);
+
+ /**
+ * Removes the given listener from the list of registered listeners.
+ *
+ * @param metadataListener
+ * The metadata listener to remove
+ */
+ void removeMetadataListener(MetadataListener metadataListener);
+
+ /**
+ * Returns the name of this filter.
+ *
+ * @return The name of this filter
+ */
+ String name();
+
+ /**
+ * Returns the controllers offered by this filter.
+ *
+ * @return The controllers of this filter
+ */
+ List> controllers();
+
+ /**
+ * Returns the metadata of the audio stream.
+ *
+ * @return The metadata of the audio stream
+ */
+ Metadata metadata();
+
+ /**
+ * Notifies the filter that the metadata of the audio stream has changed. This
+ * method should return as fast as possible, i.e. every heavy lifting should be
+ * done from another thread.
+ *
+ * @param metadata
+ * The new metadata
+ */
+ void metadataUpdated(Metadata metadata);
+
+ /**
+ * Retrieves data from the audio stream.
+ *
+ * @param bufferSize
+ * The maximum amount of bytes to retrieve from the audio stream
+ * @return A data packet containing the metadata of the stream (optional) and
+ * the buffer filled with up to {@code bufferSize} bytes of data; the
+ * returned buffer may contain less data than requested but will not
+ * contain excess elements (i.e. it can be smaller than the requested
+ * size)
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ DataPacket get(int bufferSize) throws IOException;
+
+ /**
+ * Opens this filter using the format parameters of the given metadata.
+ *
+ * @param metadata
+ * The metadata of the stream
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ void open(Metadata metadata) throws IOException;
+
+ /** Closes this filter. */
+ void close();
+
+ /**
+ * Processes the given data packet.
+ *
+ * @param dataPacket
+ * The data to process
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ void process(DataPacket dataPacket) throws IOException;
}