return;
}
}
}
boolean created = false;
IClientStream stream = streamConn.getStreamById(streamId);
if (stream == null) {
if (streamId <= 0) {
streamId = streamConn.reserveStreamId();
}
stream = streamConn.newPlaylistSubscriberStream(streamId);
stream.setBroadcastStreamPublishName(name);
stream.start();
created = true;
}
if (stream != null && stream instanceof ISubscriberStream) {
ISubscriberStream subscriberStream = (ISubscriberStream) stream;
IPlayItem item = simplePlayback.get() ? SimplePlayItem.build(name, start, length) : DynamicPlayItem.build(name, start, length);
if (subscriberStream instanceof IPlaylistSubscriberStream) {
IPlaylistSubscriberStream playlistStream = (IPlaylistSubscriberStream) subscriberStream;
if (flushPlaylist) {
playlistStream.removeAllItems();
}
playlistStream.addItem(item);
} else if (subscriberStream instanceof ISingleItemSubscriberStream) {
ISingleItemSubscriberStream singleStream = (ISingleItemSubscriberStream) subscriberStream;
singleStream.setPlayItem(item);
} else {
// not supported by this stream service
log.warn("Stream instance type: {} is not supported", subscriberStream.getClass().getName());
return;
}
try {
subscriberStream.play();
} catch (IOException err) {
if (created) {
stream.close();
streamConn.deleteStreamById(streamId);
}
sendNSFailed(streamConn, StatusCodes.NS_FAILED, err.getMessage(), name, streamId);
}
}