public static void instantiateDownloaded(JLabel update) {
    // These are found in the downloadedListenerClasses list
    for (Class<?> clazz : downloadedListenerClasses) {
      ExternalListener instance;

      try {
        doUpdate(update, Messages.getString("NetworkTab.48") + " " + clazz.getSimpleName());
        postInstall(clazz);
        LOGGER.debug("do inst of " + clazz.getSimpleName());
        instance = (ExternalListener) clazz.newInstance();
        doUpdate(update, instance.name() + " " + Messages.getString("NetworkTab.49"));
        registerListener(instance);

        if (PMS.get().getFrame() instanceof LooksFrame) {
          LooksFrame frame = (LooksFrame) PMS.get().getFrame();

          if (!frame.getPt().appendPlugin(instance)) {
            LOGGER.warn("Plugin limit of 30 has been reached");
          }
        }
      } catch (InstantiationException | IllegalAccessException e) {
        LOGGER.error("Error instantiating plugin", e);
      }
    }

    downloadedListenerClasses.clear();
  }
예제 #2
0
  public static String renameForSorting(String filename) {
    if (PMS.getConfiguration().isPrettifyFilenames()) {
      // This chunk makes anime sort properly
      int squareBracketIndex;
      if (filename.substring(0, 1).matches("\\[")) {
        filename = filename.replaceAll("_", " ");
        squareBracketIndex = filename.indexOf(']');
        if (squareBracketIndex != -1) {
          filename = filename.substring(squareBracketIndex + 1);
          if (filename.substring(0, 1).matches("\\s")) {
            filename = filename.substring(1);
          }
        }
      }

      // Replace periods with spaces
      filename = filename.replaceAll("\\.", " ");
    }

    if (PMS.getConfiguration().isIgnoreTheWordThe()) {
      // Remove "The" from the beginning of files
      filename = filename.replaceAll("^(?i)The[ .]", "");
    }

    return filename;
  }
예제 #3
0
    @Override
    public void handle(HttpExchange t) throws IOException {
      LOGGER.debug("root req " + t.getRequestURI());
      if (RemoteUtil.deny(t)) {
        throw new IOException("Access denied");
      }
      if (t.getRequestURI().getPath().contains("favicon")) {
        RemoteUtil.sendLogo(t);
        return;
      }

      HashMap<String, Object> vars = new HashMap<>();
      vars.put("logs", getLogs(true));
      if (configuration.getUseCache()) {
        vars.put(
            "cache",
            "http://"
                + PMS.get().getServer().getHost()
                + ":"
                + PMS.get().getServer().getPort()
                + "/console/home");
      }

      String response = parent.getResources().getTemplate("doc.html").execute(vars);
      RemoteUtil.respond(t, response, 200, "text/html");
    }
  public void cleanup() {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      conn = getConnection();
      ps = conn.prepareStatement("SELECT COUNT(*) FROM FILES");
      rs = ps.executeQuery();
      dbCount = 0;

      if (rs.next()) {
        dbCount = rs.getInt(1);
      }

      rs.close();
      ps.close();
      PMS.get().getFrame().setStatusLine(Messages.getString("DLNAMediaDatabase.2") + " 0%");
      int i = 0;
      int oldpercent = 0;

      if (dbCount > 0) {
        ps =
            conn.prepareStatement(
                "SELECT FILENAME, MODIFIED, ID FROM FILES",
                ResultSet.TYPE_FORWARD_ONLY,
                ResultSet.CONCUR_UPDATABLE);
        rs = ps.executeQuery();
        while (rs.next()) {
          String filename = rs.getString("FILENAME");
          long modified = rs.getTimestamp("MODIFIED").getTime();
          File file = new File(filename);
          if (!file.exists() || file.lastModified() != modified) {
            rs.deleteRow();
          }
          i++;
          int newpercent = i * 100 / dbCount;
          if (newpercent > oldpercent) {
            PMS.get()
                .getFrame()
                .setStatusLine(Messages.getString("DLNAMediaDatabase.2") + newpercent + "%");
            oldpercent = newpercent;
          }
        }
      }
    } catch (SQLException se) {
      LOGGER.error(null, se);
    } finally {
      close(rs);
      close(ps);
      close(conn);
    }
  }
  public void addEngines() {
    ArrayList<Player> disPlayers = new ArrayList<Player>();
    ArrayList<Player> ordPlayers = new ArrayList<Player>();
    PMS r = PMS.get();

    for (String id : configuration.getEnginesAsList(r.getRegistry())) {
      // boolean matched = false;
      for (Player p : PlayerFactory.getAllPlayers()) {
        if (p.id().equals(id)) {
          ordPlayers.add(p);
          // matched = true;
        }
      }
    }

    for (Player p : PlayerFactory.getAllPlayers()) {
      if (!ordPlayers.contains(p)) {
        ordPlayers.add(p);
        disPlayers.add(p);
      }
    }

    for (Player p : ordPlayers) {
      TreeNodeSettings en = new TreeNodeSettings(p.name(), p, null);
      if (disPlayers.contains(p)) {
        en.setEnable(false);
      }
      JComponent jc = en.getConfigPanel();
      if (jc == null) {
        jc = buildEmpty();
      }
      jc.addComponentListener(
          new ComponentAdapter() {
            @Override
            public void componentShown(ComponentEvent e) {
              handleCardComponentChange(e.getComponent());
            }
          });
      tabbedPane.add(en.id(), jc);
      parent[p.purpose()].add(en);
    }

    for (int i = 0; i < tree.getRowCount(); i++) {
      tree.expandRow(i);
    }

    tree.setSelectionRow(0);
  }
예제 #6
0
  public static boolean isSubtitlesExists(File file, DLNAMediaInfo media, boolean usecache) {
    boolean found = false;
    if (file.exists()) {
      found = browseFolderForSubtitles(file.getParentFile(), file, media, usecache);
    }
    String alternate = PMS.getConfiguration().getAlternateSubtitlesFolder();

    if (isNotBlank(alternate)) { // https://code.google.com/p/ps3mediaserver/issues/detail?id=737#c5
      File subFolder = new File(alternate);

      if (!subFolder.isAbsolute()) {
        subFolder = new File(file.getParent() + "/" + alternate);
        try {
          subFolder = subFolder.getCanonicalFile();
        } catch (IOException e) {
          LOGGER.debug("Caught exception", e);
        }
      }

      if (subFolder.exists()) {
        found = found || browseFolderForSubtitles(subFolder, file, media, usecache);
      }
    }

    return found;
  }
예제 #7
0
  public BufferedOutputFile getDirectBuffer() throws IOException {
    if (!PMS.get().isWindows()) {
      return null;
    }

    return mk.getDirectBuffer();
  }
예제 #8
0
 @Override
 public ProcessWrapper launchTranscode(
     String fileName, DLNAResource dlna, DLNAMediaInfo media, OutputParams params)
     throws IOException {
   params.maxBufferSize = PMS.getConfiguration().getMaxAudioBuffer();
   params.waitbeforestart = 2000;
   params.manageFastStart();
   String args[] = args();
   if (params.mediaRenderer.isTranscodeToMP3()) {
     args = new String[] {"-f", "mp3", "-ar", "48000", "-ab", "320000"};
   }
   if (params.mediaRenderer.isTranscodeToWAV()) {
     args = new String[] {"-f", "wav", "-ar", "48000"};
   }
   if (params.mediaRenderer.isTranscodeAudioTo441()) {
     args[3] = "44100";
   }
   if (!configuration.isAudioResample()) {
     args[2] = "-vn";
     args[3] = "-vn";
   }
   if (params.mediaRenderer.isTranscodeAudioTo441()) {
     args[3] = "44100";
   }
   return getFFMpegTranscode(fileName, dlna, media, params, args);
 }
  public static void addURLResolver(URLResolver res) {
    if (urlResolvers.contains(res)) {
      return;
    }
    if (urlResolvers.isEmpty()) {
      urlResolvers.add(res);
      return;
    }

    String[] tmp = PMS.getConfiguration().getURLResolveOrder();
    if (tmp.length == 0) {
      // no order at all, just add it
      urlResolvers.add(res);
      return;
    }
    int id = -1;
    for (int i = 0; i < tmp.length; i++) {
      if (tmp[i].equalsIgnoreCase(res.name())) {
        id = i;
        break;
      }
    }

    if (id == -1) {
      // no order here, just add it
      urlResolvers.add(res);
      return;
    }
    if (id > urlResolvers.size()) {
      // add it last
      urlResolvers.add(res);
      return;
    }
    urlResolvers.add(id, res);
  }
  @Override
  public JComponent config() {
    FormLayout layout =
        new FormLayout("left:pref, 3dlu, p, 3dlu, 0:grow", "p, 3dlu, p, 3dlu, 0:grow");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 5));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("FFMpegDVRMSRemux.0"), cc.xy(1, 3));
    altffpath = new JTextField(PMS.getConfiguration().getFfmpegAlternativePath());
    altffpath.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            PMS.getConfiguration().setFfmpegAlternativePath(altffpath.getText());
          }
        });
    builder.add(altffpath, cc.xyw(3, 3, 3));

    return builder.getPanel();
  }
  @Override
  public void detachInputStream() {
    PMS.get().getFrame().setReadValue(0, "");

    if (attachedThread != null) {
      attachedThread.setReadyToStop(true);
    }

    Runnable checkEnd =
        new Runnable() {
          @Override
          public void run() {
            try {
              Thread.sleep(CHECK_END_OF_PROCESS);
            } catch (InterruptedException e) {
              LOGGER.error(null, e);
            }

            if (attachedThread != null && attachedThread.isReadyToStop()) {
              if (!attachedThread.isDestroyed()) {
                attachedThread.stopProcess();
              }

              reset();
            }
          }
        };
    new Thread(checkEnd, "Buffered IO End Checker").start();
  }
예제 #12
0
  /**
   * Creates an InputStream based on a URL. This is used while accessing external resources like
   * online radio stations.
   *
   * @param u URL.
   * @param saveOnDisk If true, the file is first downloaded to the temporary folder.
   * @return InputStream that can be used for sending to the media renderer.
   * @throws IOException
   * @see #downloadAndSendBinary(String)
   */
  protected static InputStream downloadAndSend(String u, boolean saveOnDisk) throws IOException {
    URL url = new URL(u);
    File f = null;

    if (saveOnDisk) {
      String host = url.getHost();
      String hostName = convertURLToFileName(host);
      String fileName = url.getFile();
      fileName = convertURLToFileName(fileName);
      File hostDir = new File(PMS.getConfiguration().getTempFolder(), hostName);

      if (!hostDir.isDirectory()) {
        if (!hostDir.mkdir()) {
          LOGGER.debug("Cannot create directory: {}", hostDir.getAbsolutePath());
        }
      }

      f = new File(hostDir, fileName);

      if (f.exists()) {
        return new FileInputStream(f);
      }
    }

    byte[] content = downloadAndSendBinary(u, saveOnDisk, f);
    return new ByteArrayInputStream(content);
  }
예제 #13
0
  /**
   * This method populates the supplied {@link OutputParams} object with the correct audio track
   * (aid) based on the MediaInfo metadata and PMS configuration settings.
   *
   * @param media The MediaInfo metadata for the file.
   * @param params The parameters to populate.
   */
  public static void setAudioOutputParameters(DLNAMediaInfo media, OutputParams params) {
    PmsConfiguration configuration = PMS.getConfiguration(params);
    if (params.aid == null && media != null && media.getFirstAudioTrack() != null) {
      // check for preferred audio
      DLNAMediaAudio dtsTrack = null;
      StringTokenizer st = new StringTokenizer(configuration.getAudioLanguages(), ",");
      while (st.hasMoreTokens()) {
        String lang = st.nextToken().trim();
        LOGGER.trace("Looking for an audio track with lang: " + lang);
        for (DLNAMediaAudio audio : media.getAudioTracksList()) {
          if (audio.matchCode(lang)) {
            params.aid = audio;
            LOGGER.trace("Matched audio track: " + audio);
            return;
          }

          if (dtsTrack == null && audio.isDTS()) {
            dtsTrack = audio;
          }
        }
      }

      // preferred audio not found, take a default audio track, dts first if available
      if (dtsTrack != null) {
        params.aid = dtsTrack;
        LOGGER.trace("Found priority audio track with DTS: " + dtsTrack);
      } else {
        params.aid = media.getAudioTracksList().get(0);
        LOGGER.trace("Chose a default audio track: " + params.aid);
      }
    }
  }
예제 #14
0
 @Override
 public void mouseClicked(MouseEvent e) {
   try {
     PMS.get().getRegistry().browseURI(link);
   } catch (Exception e1) {
     logger.debug("Caught exception", e1);
   }
 }
 public void compact() {
   LOGGER.info("Compacting database...");
   PMS.get().getFrame().setStatusLine(Messages.getString("DLNAMediaDatabase.3"));
   String filename = "database/backup.sql";
   try {
     Script.execute(url, "sa", "", filename);
     DeleteDbFiles.execute(dbDir, dbName, true);
     RunScript.execute(url, "sa", "", filename, null, false);
   } catch (SQLException se) {
     LOGGER.error("Error in compacting database: ", se);
   } finally {
     File testsql = new File(filename);
     if (testsql.exists() && !testsql.delete()) {
       testsql.deleteOnExit();
     }
   }
   PMS.get().getFrame().setStatusLine(null);
 }
  private static void purgeCode(String mainClass, URL newUrl) {
    Class<?> clazz1 = null;

    for (Class<?> clazz : externalListenerClasses) {
      if (mainClass.equals(clazz.getCanonicalName())) {
        clazz1 = clazz;
        break;
      }
    }

    if (clazz1 == null) {
      return;
    }

    externalListenerClasses.remove(clazz1);
    ExternalListener remove = null;
    for (ExternalListener list : externalListeners) {
      if (list.getClass().equals(clazz1)) {
        remove = list;
        break;
      }
    }

    RendererConfiguration.resetAllRenderers();

    if (remove != null) {
      externalListeners.remove(remove);
      remove.shutdown();
      LooksFrame frame = (LooksFrame) PMS.get().getFrame();
      frame.getPt().removePlugin(remove);
    }

    for (int i = 0; i < 3; i++) {
      System.gc();
    }

    URLClassLoader cl = (URLClassLoader) clazz1.getClassLoader();
    URL[] urls = cl.getURLs();
    for (URL url : urls) {
      String mainClass1 = getMainClass(url);

      if (mainClass1 == null || !mainClass.equals(mainClass1)) {
        continue;
      }

      File f = url2file(url);
      File f1 = url2file(newUrl);

      if (f1 == null || f == null) {
        continue;
      }

      if (!f1.getName().equals(f.getName())) {
        addToPurgeFile(f);
      }
    }
  }
예제 #17
0
 public String getUrl() {
   if (server != null) {
     return (server instanceof HttpsServer ? "https://" : "http://")
         + PMS.get().getServer().getHost()
         + ":"
         + server.getAddress().getPort();
   }
   return null;
 }
예제 #18
0
 public static String getMsgString(String key, HttpExchange t) {
   if (PMS.getConfiguration().useWebLang()) {
     String lang = getFirstSupportedLanguage(t);
     if (!lang.isEmpty()) {
       return Messages.getString(key, Locale.forLanguageTag(lang));
     }
   }
   return Messages.getString(key);
 }
 @Override
 public void run() {
   try {
     PMS.get().getRootFolder(null).scan();
   } catch (Exception e) {
     LOGGER.error("Unhandled exception during library scan: {}", e.getMessage());
     LOGGER.trace("", e);
   }
 }
예제 #20
0
  public InputStream getInputStream() throws IOException {
    if (!PMS.get().isWindows()) {
      LOGGER.trace("Opening file " + linuxPipeName + " for reading...");
      RandomAccessFile raf = new RandomAccessFile(linuxPipeName, "r");

      return new FileInputStream(raf.getFD());
    }

    return mk.getReadable();
  }
예제 #21
0
  public OutputStream getOutputStream() throws IOException {
    if (!PMS.get().isWindows()) {
      LOGGER.trace("Opening file " + linuxPipeName + " for writing...");
      RandomAccessFile raf = new RandomAccessFile(linuxPipeName, "rw");

      return new FileOutputStream(raf.getFD());
    }

    return mk.getWritable();
  }
예제 #22
0
  public static String servePage(String resource) {
    StringBuilder sb = new StringBuilder();
    sb.append(
        "<html><head><title>"
            + PropertiesUtil.getProjectProperties().get("project.name")
            + " HTML Console</title></head><body>");

    DLNAMediaDatabase database = PMS.get().getDatabase();
    PmsConfiguration configuration = PMS.getConfiguration();
    if (resource.equals("compact") && configuration.getUseCache()) {
      database.compact();
      sb.append("<p align=center><b>Database compacted!</b></p><br>");
    }

    if (resource.equals("scan") && configuration.getUseCache()) {
      if (!database.isScanLibraryRunning()) {
        database.scanLibrary();
      }
      if (database.isScanLibraryRunning()) {
        sb.append(
            "<p align=center><b>Scan in progress! you can also <a href=\"stop\">stop it</a></b></p><br>");
      }
    }

    if (resource.equals("stop") && configuration.getUseCache() && database.isScanLibraryRunning()) {
      sb.append("<p align=center><b>Scan stopped!</b></p><br>");
    }

    sb.append(
        "<p align=center><img src='/images/thumbnail-256.png'><br>"
            + PropertiesUtil.getProjectProperties().get("project.name")
            + " HTML console<br><br>Menu:<br>");
    sb.append("<a href=\"home\">Home</a><br>");
    sb.append("<a href=\"scan\">Scan folders</a><br>");
    sb.append("<a href=\"compact\">Shrink cache database (not recommended)</a>");
    sb.append("</p></body></html>");
    return sb.toString();
  }
예제 #23
0
 public static boolean downloadText(InputStream in, File f) throws Exception {
   PmsConfiguration configuration = PMS.getConfiguration();
   // String subtitleQuality = config.getMencoderVobsubSubtitleQuality();
   String subcp = configuration.getMencoderSubCp();
   OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(f), subcp);
   InputStreamReader inn = new InputStreamReader(in);
   char[] buf = new char[4096];
   int len;
   while ((len = inn.read(buf)) != -1) out.write(buf, 0, len);
   out.flush();
   out.close();
   in.close();
   return true;
 }
예제 #24
0
 /** Retrieve the given mustache template, compiling as necessary. */
 public Template getTemplate(String filename) {
   Template t = null;
   if (templates.containsKey(filename)) {
     t = templates.get(filename);
   } else {
     URL url = findResource(filename);
     if (url != null) {
       t = compile(getInputStream(filename));
       templates.put(filename, t);
       PMS.getFileWatcher().add(new FileWatcher.Watch(url.getFile(), recompiler));
     }
   }
   return t;
 }
  public void checkUnicode() {
    if (file != null && file.exists() && file.length() > 3) {
      FileInputStream fis = null;
      try {
        int is_file_unicode = 0;

        fis = new FileInputStream(file);
        int b1 = fis.read();
        int b2 = fis.read();
        int b3 = fis.read();
        if (b1 == 255 && b2 == 254) {
          is_file_unicode = 1;
        } else if (b1 == 254 && b2 == 255) {
          is_file_unicode = 2;
        } else if (b1 == 239 && b2 == 187 && b3 == 191) {
          is_file_utf8 = true;
        }

        // MPlayer doesn't handle UTF-16 encoded subs
        if (is_file_unicode > 0) {
          is_file_utf8 = true;
          utf8_file = new File(PMS.getConfiguration().getTempFolder(), "utf8_" + file.getName());
          if (!utf8_file.exists()) {
            InputStreamReader r =
                new InputStreamReader(
                    new FileInputStream(file), is_file_unicode == 1 ? "UTF-16" : "UTF-16BE");
            OutputStreamWriter osw =
                new OutputStreamWriter(new FileOutputStream(utf8_file), "UTF-8");
            int c;
            while ((c = r.read()) != -1) {
              osw.write(c);
            }
            osw.close();
            r.close();
          }
        }
      } catch (IOException e) {
        LOGGER.error(null, e);
      } finally {
        if (fis != null) {
          try {
            fis.close();
          } catch (IOException e) {
            LOGGER.debug("Caught exception", e);
          }
        }
      }
    }
  }
  protected ProcessWrapperImpl getFFMpegTranscode(
      String fileName, DLNAResource dlna, DLNAMediaInfo media, OutputParams params)
      throws IOException {
    PmsConfiguration configuration = PMS.getConfiguration();
    String ffmpegAlternativePath = configuration.getFfmpegAlternativePath();
    List<String> cmdList = new ArrayList<String>();

    if (ffmpegAlternativePath != null && ffmpegAlternativePath.length() > 0) {
      cmdList.add(ffmpegAlternativePath);
    } else {
      cmdList.add(executable());
    }

    if (params.timeseek > 0) {
      cmdList.add("-ss");
      cmdList.add("" + params.timeseek);
    }

    cmdList.add("-i");
    cmdList.add(fileName);

    for (String arg : args()) {
      cmdList.add(arg);
    }

    String[] ffmpegSettings = StringUtils.split(configuration.getFfmpegSettings());

    if (ffmpegSettings != null) {
      for (String option : ffmpegSettings) {
        cmdList.add(option);
      }
    }

    cmdList.add("pipe:");
    String[] cmdArray = new String[cmdList.size()];
    cmdList.toArray(cmdArray);

    cmdArray = finalizeTranscoderArgs(this, fileName, dlna, media, params, cmdArray);

    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    pw.runInNewThread();

    return pw;
  }
예제 #27
0
  /**
   * Returns a byte array representation of the file given by the URL. The file is downloaded and
   * optionally stored on the filesystem.
   *
   * @param u URL to retrieve.
   * @param @param saveOnDisk If true, store the file on the filesystem.
   * @param f If saveOnDisk is true, then store the contents of the file represented by u in the
   *     associated File. f needs to be opened before calling this function.
   * @return The byte array
   * @throws IOException
   */
  protected static byte[] downloadAndSendBinary(String u, boolean saveOnDisk, File f)
      throws IOException {
    URL url = new URL(u);

    // The URL may contain user authentication information
    Authenticator.setDefault(new HTTPResourceAuthenticator());
    HTTPResourceAuthenticator.addURL(url);

    LOGGER.debug("Retrieving " + url.toString());
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    URLConnection conn = url.openConnection();

    // GameTrailers blocks user-agents that identify themselves as "Java"
    conn.setRequestProperty(
        "User-agent",
        PropertiesUtil.getProjectProperties().get("project.name") + " " + PMS.getVersion());
    InputStream in = conn.getInputStream();
    FileOutputStream fOUT = null;

    if (saveOnDisk && f != null) {
      // fileName = convertURLToFileName(fileName);
      fOUT = new FileOutputStream(f);
    }

    byte[] buf = new byte[4096];

    int n;
    while ((n = in.read(buf)) > -1) {
      bytes.write(buf, 0, n);

      if (fOUT != null) {
        fOUT.write(buf, 0, n);
      }
    }

    in.close();

    if (fOUT != null) {
      fOUT.close();
    }

    return bytes.toByteArray();
  }
예제 #28
0
  public ProcessWrapper getPipeProcess() {
    if (!PMS.get().isWindows()) {
      OutputParams mkfifo_vid_params = new OutputParams(configuration);
      mkfifo_vid_params.maxBufferSize = 0.1;
      mkfifo_vid_params.log = true;
      String cmdArray[];

      if (Platform.isMac() || Platform.isFreeBSD() || Platform.isSolaris()) {
        cmdArray = new String[] {"mkfifo", "-m", "777", linuxPipeName};
      } else {
        cmdArray = new String[] {"mkfifo", "--mode=777", linuxPipeName};
      }

      ProcessWrapperImpl mkfifo_vid_process = new ProcessWrapperImpl(cmdArray, mkfifo_vid_params);
      return mkfifo_vid_process;
    }

    return mk;
  }
예제 #29
0
  public PipeProcess(String pipeName, OutputParams params, String... extras) {
    forcereconnect = false;
    boolean in = true;

    if (extras != null && extras.length > 0 && extras[0].equals("out")) {
      in = false;
    }

    if (extras != null) {
      for (int i = 0; i < extras.length; i++) {
        if (extras[i].equals("reconnect")) {
          forcereconnect = true;
        }
      }
    }

    if (PMS.get().isWindows()) {
      mk = new WindowsNamedPipe(pipeName, forcereconnect, in, params);
    } else {
      linuxPipeName = getPipeName(pipeName);
    }
  }
예제 #30
0
 private static String addSubs(String rUrl, String sub) {
   rUrl = append(rUrl, "&subs=", escape(sub));
   // -spuaa 3 -subcp ISO-8859-10 -subfont C:\Windows\Fonts\Arial.ttf -subfont-text-scale 2
   // -subfont-outline 1 -subfont-blur 1 -subpos 90 -quiet -quiet -sid 100 -fps 25 -ofps 25 -sub
   // C:\downloads\Kings Speech.srt -lavdopts fast -mc 0 -noskip -af lavcresample=48000 -srate
   // 48000 -o \\.\pipe\mencoder1299956406082
   PmsConfiguration configuration = PMS.getConfiguration();
   // String subtitleQuality = config.getMencoderVobsubSubtitleQuality();
   String subcp = configuration.getMencoderSubCp();
   rUrl = append(rUrl, "&subcp=", escape(subcp));
   rUrl = append(rUrl, "&subtext=", escape(configuration.getMencoderNoAssScale()));
   rUrl = append(rUrl, "&subout=", escape(configuration.getMencoderNoAssOutline()));
   rUrl = append(rUrl, "&subblur=", escape(configuration.getMencoderNoAssBlur()));
   int subpos = 1;
   try {
     subpos = Integer.parseInt(configuration.getMencoderNoAssSubPos());
   } catch (NumberFormatException n) {
   }
   rUrl = append(rUrl, "&subpos=", String.valueOf(100 - subpos));
   //  rUrl=append(rUrl,"&subdelay=","20000");
   return rUrl;
 }