import com.google.common.base.Optional;
import com.google.common.collect.Maps;
+import com.google.common.eventbus.EventBus;
import com.google.common.primitives.Ints;
/**
*/
public class StreamSource implements Source {
+ /** The event bus. */
+ private final EventBus eventBus;
+
/** The URL of the stream. */
private final String streamUrl;
+ /** The name of the station. */
+ private final String streamName;
+
/** The metadata stream. */
private final MetadataStream metadataStream;
* the response header for vital information (sampling frequency, number of
* channels, etc.).
*
+ * @param eventBus
+ * The event bus
* @param streamUrl
* The URL of the stream
* @throws IOException
* if an I/O error occurs
*/
- public StreamSource(String streamUrl) throws IOException {
+ public StreamSource(EventBus eventBus, String streamUrl) throws IOException {
+ this.eventBus = eventBus;
this.streamUrl = streamUrl;
URL url = new URL(streamUrl);
metadata = new Metadata(new FormatMetadata(audioParameters.get("ice-channels"), audioParameters.get("ice-samplerate"), "MP3"), new ContentMetadata());
metadataStream = new MetadataStream(new BufferedInputStream(httpUrlConnection.getInputStream()), metadataInterval);
+ streamName = httpUrlConnection.getHeaderField("ICY-Name");
}
//
//
@Override
+ public String name() {
+ return streamName;
+ }
+
+ @Override
public List<Controller<?>> controllers() {
return Collections.emptyList();
}
if (!streamMetadata.isPresent()) {
return metadata;
}
- return metadata = metadata.title(streamMetadata.get().title());
+ metadata = metadata.title(streamMetadata.get().title());
+ return metadata;
}
@Override