file.createNewFile();
} else if (!file.canWrite()) {
throw new IOException("The file is read-only");
}
IStreamableFileService service = factory.getService(file);
IStreamableFile flv = service.getStreamableFile(file);
if (mode == null || mode.equals(IClientStream.MODE_RECORD)) {
writer = flv.getWriter();
//write the decoder config tag if it exists
if (videoConfigurationTag != null) {
writer.writeTag(videoConfigurationTag);
videoConfigurationTag = null;
}
if (audioConfigurationTag != null) {
writer.writeTag(audioConfigurationTag);
audioConfigurationTag = null;
}
} else if (mode.equals(IClientStream.MODE_APPEND)) {
writer = flv.getAppendWriter();
} else {
throw new IllegalStateException(String.format("Illegal mode type: %s", mode));
}
} else {
log.warn("Consumer is uninitialized");