/**
   * Initializes file provider. Creates streamable file factory and service, seeks to start position
   */
  private void init() throws IOException {
    IStreamableFileFactory factory =
        (IStreamableFileFactory)
            ScopeUtils.getScopeService(
                scope, IStreamableFileFactory.class, StreamableFileFactory.class);
    IStreamableFileService service;
    IStreamableFile streamFile;
    if (file == null && playlistXMLUrl != null) { // NIELS JOUBERT

      streamFile = new CompositeFile(playlistXMLUrl, urlResolver);

    } else {

      service = factory.getService(file);
      if (service == null) {
        log.error("No service found for " + file.getAbsolutePath());
        return;
      }
      streamFile = service.getStreamableFile(file);
    }
    reader = streamFile.getReader(scope);
    if (start > 0) {
      seek(start);
    }
  }
Ejemplo n.º 2
0
 /**
  * Initialization
  *
  * @throws IOException I/O exception
  */
 private void init() throws IOException {
   IStreamableFileFactory factory =
       (IStreamableFileFactory)
           ScopeUtils.getScopeService(
               scope, IStreamableFileFactory.class, StreamableFileFactory.class);
   File folder = file.getParentFile();
   if (!folder.exists())
     if (!folder.mkdirs()) throw new IOException("Could not create parent folder");
   if (!file.isFile()) {
     // Maybe the (previously existing) file has been deleted
     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();
   } else if (mode.equals(IClientStream.MODE_APPEND)) {
     writer = flv.getAppendWriter();
   } else {
     throw new IllegalStateException("Illegal mode type: " + mode);
   }
 }