import java.net.Socket;
import java.net.URLEncoder;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.pterodactylus.sonitus.data.Controller;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Sink;
import net.pterodactylus.sonitus.io.InputStreamDrainer;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
+import com.google.common.eventbus.EventBus;
import com.google.common.io.BaseEncoding;
import com.google.common.io.Closeables;
/** The logger. */
private static final Logger logger = Logger.getLogger(Icecast2Sink.class.getName());
+ /** The event bus. */
+ private final EventBus eventBus;
+
/** The server name. */
private final String server;
private OutputStream socketOutputStream;
+ /** The current metadata. */
+ private Metadata metadata;
+
/**
* Creates a new Icecast2 sink.
*
+ * @param eventBus
+ * The event bus
* @param server
* The hostname of the server
* @param port
* {@code true} to publish the server in a public directory, {@code false} to
* not publish it
*/
- public Icecast2Sink(String server, int port, String password, String mountPoint, String serverName, String serverDescription, String genre, boolean publishServer) {
+ public Icecast2Sink(EventBus eventBus, String server, int port, String password, String mountPoint, String serverName, String serverDescription, String genre, boolean publishServer) {
+ this.eventBus = eventBus;
this.server = server;
this.port = port;
this.password = password;
}
//
+ // CONTROLLED METHODS
+ //
+
+ @Override
+ public String name() {
+ return String.format("icecast://%s:%d/%s", server, port, mountPoint);
+ }
+
+ @Override
+ public Metadata metadata() {
+ return metadata;
+ }
+
+ @Override
+ public List<Controller<?>> controllers() {
+ return Collections.emptyList();
+ }
+
+ //
// SINK METHODS
//
@Override
public void metadataUpdated(final Metadata metadata) {
+ this.metadata = metadata;
new Thread(new Runnable() {
@Override