From: David ‘Bombe’ Roden Date: Fri, 15 Mar 2013 06:57:47 +0000 (+0100) Subject: Add sink interface. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=740ea4925e1e20cde0f15afcb105de1f11371dba;p=sonitus.git Add sink interface. --- diff --git a/src/main/java/net/pterodactylus/sonitus/data/ConnectException.java b/src/main/java/net/pterodactylus/sonitus/data/ConnectException.java new file mode 100644 index 0000000..004d88c --- /dev/null +++ b/src/main/java/net/pterodactylus/sonitus/data/ConnectException.java @@ -0,0 +1,65 @@ +/* + * Sonitus - ConnectException.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sonitus.data; + +/** + * Exception that signals an error when {@link Sink#connect(Source) connecting} + * a {@link Source} to a {@link Sink}. + * + * @author David ‘Bombe’ Roden + */ +public class ConnectException extends Exception { + + /** Creates a new connect exception. */ + public ConnectException() { + super(); + } + + /** + * Creates a new connect exception. + * + * @param message + * The message of the exception + */ + public ConnectException(String message) { + super(message); + } + + /** + * Creates a new connect exception. + * + * @param cause + * The cause of the exception + */ + public ConnectException(Throwable cause) { + super(cause); + } + + /** + * Creates a new connect exception. + * + * @param message + * The message of the exception + * @param cause + * The cause of the exception + */ + public ConnectException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/src/main/java/net/pterodactylus/sonitus/data/Sink.java b/src/main/java/net/pterodactylus/sonitus/data/Sink.java new file mode 100644 index 0000000..5ca6a79 --- /dev/null +++ b/src/main/java/net/pterodactylus/sonitus/data/Sink.java @@ -0,0 +1,39 @@ +/* + * Sonitus - Sink.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sonitus.data; + +/** + * A sink is an endpoint for an audio stream. It might be a file on disk, it can + * be an audio output in the current system, or it can be sent to a remote + * streaming server for broadcasting. + * + * @author David ‘Bombe’ Roden + */ +public interface Sink { + + /** + * Connects this sink to the given source. + * + * @param source + * The source to connect to + * @throws ConnectException + * if the source can not be connected, e.g. due to a {@link Format} mismatch + */ + void connect(Source source) throws ConnectException; + +}