From 740ea4925e1e20cde0f15afcb105de1f11371dba Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 15 Mar 2013 07:57:47 +0100 Subject: [PATCH] Add sink interface. --- .../sonitus/data/ConnectException.java | 65 ++++++++++++++++++++++ .../java/net/pterodactylus/sonitus/data/Sink.java | 39 +++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 src/main/java/net/pterodactylus/sonitus/data/ConnectException.java create mode 100644 src/main/java/net/pterodactylus/sonitus/data/Sink.java 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; + +} -- 2.7.4