/**
   * Register a known set of audio or video transcoders.
   *
   * @param configuration PMS configuration settings.
   */
  private static void registerPlayers(final PmsConfiguration configuration) {

    if (Platform.isWindows()) {
      registerPlayer(new FFMpegVideo());
    }

    registerPlayer(new FFMpegAudio(configuration));
    registerPlayer(new MEncoderVideo(configuration));

    if (Platform.isWindows()) {
      registerPlayer(new MEncoderAviSynth(configuration));
    }

    registerPlayer(new MPlayerAudio(configuration));
    registerPlayer(new MEncoderWebVideo(configuration));
    registerPlayer(new MPlayerWebVideoDump(configuration));
    registerPlayer(new MPlayerWebAudio(configuration));
    registerPlayer(new TSMuxerVideo(configuration));
    registerPlayer(new TsMuxerAudio(configuration));
    registerPlayer(new VideoLanAudioStreaming(configuration));
    registerPlayer(new VideoLanVideoStreaming(configuration));

    if (Platform.isWindows()) {
      registerPlayer(new FFMpegDVRMSRemux());
    }

    registerPlayer(new RAWThumbnailer());
  }
  public DLNAMediaDatabase(String name) {
    String dir = "database";
    dbName = name;
    File fileDir = new File(dir);

    if (Platform.isWindows()) {
      String profileDir = configuration.getProfileDirectory();
      url = String.format("jdbc:h2:%s\\%s/%s", profileDir, dir, dbName);
      fileDir = new File(profileDir, dir);
    } else {
      url = Constants.START_URL + dir + "/" + dbName;
    }
    dbDir = fileDir.getAbsolutePath();
    LOGGER.debug("Using database URL: " + url);
    LOGGER.info("Using database located at: " + dbDir);

    try {
      Class.forName("org.h2.Driver");
    } catch (ClassNotFoundException e) {
      LOGGER.error(null, e);
    }

    JdbcDataSource ds = new JdbcDataSource();
    ds.setURL(url);
    ds.setUser("sa");
    ds.setPassword("");
    cp = JdbcConnectionPool.create(ds);
  }
Example #3
0
 /**
  * Create a new mouse hook.
  *
  * @param relativeTo component to report mouse coordinates relative to
  */
 public WindowsMouseHook(Component relativeTo) {
   Logger.debug("WindowsMouseHook(relativeTo={})", relativeTo);
   if (!Platform.isWindows()) {
     throw new IllegalStateException("Windows only");
   }
   this.relativeTo = relativeTo;
 }
 /** Finds the OS type the plugin is running on and calls the setup for it */
 protected void doOsSetup() {
   if (Platform.isWindows()) {
     logger.debug("Windows operating system detected");
     // WindowsStartup.startup(); TODO: comment back in once arguments are being passed
   } else {
     // TODO: Add mac and linux logic
   }
 }
Example #5
0
 static {
   if (Platform.isWindows()) {
     String path = System.getProperty("java.library.path");
     String winPath = "c:\\Windows\\" + (Platform.is64Bit() ? "SysWOW64" : "System32");
     if (path == null) path = winPath;
     else path = path + ";" + winPath;
     System.setProperty("java.library.path", path);
   }
 }
 static {
   if (Platform.isSolaris()) {
     System.loadLibrary("nsl");
     System.loadLibrary("socket");
   }
   if (!Platform.isWindows() && !Platform.isWindowsCE()) {
     Native.register("c");
   }
 }
Example #7
0
 {
   if (Platform.isWindows()) {
     this.currentPlatformEnum = PlatformEnum.WINDOWS;
   } else if (Platform.isLinux()) {
     this.currentPlatformEnum = PlatformEnum.LINUX;
   } else if (Platform.isMac()) {
     this.currentPlatformEnum = PlatformEnum.MACOSX;
   } else {
     this.currentPlatformEnum = PlatformEnum.UNKNOWN;
   }
 }
 static {
   try {
     if (!Platform.isWindows()) {
       C_LIB = ((CLib) Native.loadLibrary("c", CLib.class));
     }
   } catch (Exception e) {
     Logger log = Logger.getInstance(UnixProcessManager.class);
     log.warn("Can't load c library", e);
     C_LIB = null;
   }
 }
 public UnixDomainSocket(String path) throws IOException {
   if (Platform.isWindows() || Platform.isWindowsCE()) {
     throw new IOException("Unix domain sockets are not supported on Windows");
   }
   sockaddr = new SockAddr(path);
   try {
     fd = socket(AF_UNIX, SOCK_STREAM, PROTOCOL);
   } catch (LastErrorException lee) {
     throw new IOException("native socket() failed : " + formatError(lee));
   }
 }
Example #10
0
  public interface CV4l2 extends Library {

    CV4l2 INSTANCE =
        (CV4l2)
            Native.loadLibrary(
                (Platform.isWindows() ? "webcamstudio" : "webcamstudio"), CV4l2.class);

    int close_device(int device);

    int open_device(String path, int w, int h, int pixFormat);

    int writeData(int device, byte[] buffer, int length);
  }
Example #11
0
 /**
  * Get global hotkey provider for current platform
  *
  * @return new instance of Provider, or null if platform is not supported
  * @see X11Provider
  * @see WindowsProvider
  * @see CarbonProvider
  */
 public static Provider createProvider() {
   Provider provider;
   if (Platform.isX11()) {
     provider = new X11Provider();
   } else if (Platform.isWindows()) {
     provider = new WindowsProvider();
   } else if (Platform.isMac()) {
     provider = new CarbonProvider();
   } else {
     logger.warn("No suitable provider for " + System.getProperty("os.name"));
     return null;
   }
   provider.init(provider.eventQueue);
   return provider;
 }
  // deve saber se win ou linux
  public static IComunicacaoSensores getConector() {
    IComunicacaoSensores conector = null;

    if (Platform.isWindows()) {
      conector =
          (IComunicacaoSensores)
              Native.loadLibrary("comunicacaosensores.dll", IComunicacaoSensores.class);

    } else if (Platform.isLinux()) {
      conector =
          (IComunicacaoSensores)
              Native.loadLibrary("comunicacaosensores.so", IComunicacaoSensores.class);
    }
    return conector;
  }
 /**
  * Creates system utilities. These are needed to determine isAvis() in {@link
  * #registerPlayer(Player)}.
  *
  * @return The system utilities.
  */
 private static SystemUtils createSystemUtils() {
   if (Platform.isWindows()) {
     return new WinUtils();
   } else {
     if (Platform.isMac()) {
       return new MacSystemUtils();
     } else {
       if (Platform.isSolaris()) {
         return new SolarisUtils();
       } else {
         return new BasicSystemUtils();
       }
     }
   }
 }
  /**
   * Adds a single {@link Player} to the list of Players. Before the player is added to the list, it
   * is verified to be okay.
   *
   * @param player Player to be added to the list.
   */
  public static synchronized void registerPlayer(final Player player) {
    boolean ok = false;
    allPlayers.add(player);

    if (Player.NATIVE.equals(player.executable())) {
      ok = true;
    } else {
      if (Platform.isWindows()) {
        if (player.executable() == null) {
          LOGGER.info("Executable of transcoder profile " + player + " not defined");
          return;
        }

        File executable = new File(player.executable());
        File executable2 = new File(player.executable() + ".exe");

        if (executable.exists() || executable2.exists()) {
          ok = true;
        } else {
          LOGGER.info("Executable of transcoder profile " + player + " not found");
          return;
        }

        if (player.avisynth()) {
          ok = false;

          if (utils.isAvis()) {
            ok = true;
          } else {
            LOGGER.info(
                "Transcoder profile "
                    + player
                    + " will not be used because AviSynth was not found");
          }
        }
      } else if (!player.avisynth()) {
        ok = true;
      }
    }

    if (ok) {
      LOGGER.info("Registering transcoding engine: " + player);
      players.add(player);
    }
  }
  protected static int getPid(Process p) throws Exception {

    if (Platform.isWindows()) {
      Field f = p.getClass().getDeclaredField("handle");
      f.setAccessible(true);
      int pid = Kernel32.INSTANCE.GetProcessId((Long) f.get(p));
      return pid;

    } else if (Platform.isLinux()) {
      Field f = p.getClass().getDeclaredField("pid");
      f.setAccessible(true);
      int pid = (Integer) f.get(p);
      return pid;

    } else {
      throw new Exception("Cannot currently process pid for " + System.getProperty("os.name"));
    }
  }
Example #16
0
  public JPicosat(String libDir) throws Exception {
    if (libDir == null || "".equals(libDir)) libDir = "lib";
    StringBuilder pref = new StringBuilder(libDir + DIR);

    if (Platform.isMac())
      if (Platform.is64Bit()) pref.append("/macosx/64");
      else pref.append("/macosx/32");
    else if (Platform.isLinux())
      if (Platform.is64Bit()) pref.append("/linux/64");
      else pref.append("/linux/32");
    else if (Platform.isWindows())
      if (Platform.is64Bit()) pref.append("/win/64");
      else pref.append("/win/32");
    else throw new Exception("JPicosat: Platform unsupported!");

    System.setProperty("jna.library.path", pref.toString());
    INSTANCE = (CPicosat) Native.loadLibrary("picosat", CPicosat.class);
    checkLibraryVersion(pref.toString());
  }
Example #17
0
 public static String[] getInstalledFontFamilyNames() {
   // todo: cannot load newly installed fonts, so this feature is disabled until i find a solution
   // for font loading problem
   if (Platform.isWindows()) {
     try {
       Class<?> clW32Fm = Class.forName("sun.awt.Win32FontManager");
       Class<?> clSunFm = Class.forName("sun.font.SunFontManager");
       Object fm = clW32Fm.newInstance();
       return (String[])
           clSunFm
               .getDeclaredMethod("getInstalledFontFamilyNames", Locale.class)
               .invoke(fm, Locale.getDefault());
     } catch (Throwable ex) {
       // catch everything to avoid class not found problems, because Win32FontManager is an
       // internal proprietary API
       Logger.getLogger(FontHelper.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
   return GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
 }
Example #18
0
 public WinDomainAdapter() {
   if (Platform.isWindows() == false) {
     throw new RuntimeException("This class is only supported on Windows platform.");
   }
 }
Example #19
0
  public static String getLibraryPath(
      String libraryName, boolean extractAllLibraries, Class<?> cl) {
    try {
      String customPath = System.getProperty("library." + libraryName);
      if (customPath == null) customPath = System.getenv(libraryName.toUpperCase() + "_LIBRARY");
      if (customPath != null) {
        File f = new File(customPath);
        if (!f.exists()) System.err.println("Library file '" + customPath + "' does not exist !");
        else return f.getAbsolutePath();
      }
      // ClassLoader cl = LibraryExtractor.class.getClassLoader();
      String prefix =
          "(?i)"
              + (Platform.isWindows() || Platform.isWindowsCE() ? "" : "lib")
              + libraryName
              + "[^A-Za-z_].*";
      String libsuffix = "(?i).*\\.(so|dll|dylib|jnilib)";
      // String othersuffix = "(?i).*\\.(pdb)";

      URL sourceURL = null;
      List<URL> otherURLs = new ArrayList<URL>();

      String arch = getCurrentOSAndArchString();
      // System.out.println("libURL = " + libURL);
      List<URL> list = URLUtils.listFiles(URLUtils.getResource(cl, "libraries/" + arch), null),
          noArchList = URLUtils.listFiles(URLUtils.getResource(cl, "libraries/noarch"), null);

      Set<String> names = new HashSet<String>();
      for (URL url : list) {
        String name = getFileName(url);
        names.add(name);
      }
      for (URL url : noArchList) {
        String name = getFileName(url);
        if (names.add(name)) list.add(url);
      }
      /*if (list.isEmpty()) {
      	for (URL u : URLUtils.listFiles(URLUtils.getResource(cl, "libraries"), null)) {
      		String f = u.getFile();
      		int i = f.lastIndexOf('/');
      		if (i >= 0)
      			f = f.substring(i + 1);
      		if (arch.startsWith(f)) {
      			list = URLUtils.listFiles(u, null);
      			break;
      		}
      	}

      }*/
      for (File f : new File(".").listFiles()) if (f.isFile()) list.add(f.toURI().toURL());

      for (URL url : list) {
        String name = getFileName(url);
        boolean pref = name.matches(prefix), suff = name.matches(libsuffix);
        if (pref && suff) sourceURL = url;
        else // if (suff || fileName.matches(othersuffix))
        otherURLs.add(url);
      }
      List<File> files = new ArrayList<File>();
      if (extractAllLibraries) {
        for (URL url : otherURLs) files.add(extract(url));
      }

      if (System.getProperty("javawebstart.version") != null) {
        if (Platform.isWindows()) {
          // File f = new File("c:\\Windows\\" + (Platform.is64Bit() ? "SysWOW64\\" : "System32\\")
          // + libraryName + ".dll");
          File f = new File("c:\\Windows\\" + "System32\\" + libraryName + ".dll");
          if (f.exists()) return f.toString();
        } else if (Platform.isMac()) {
          File f =
              new File("/System/Library/Frameworks/" + libraryName + ".framework/" + libraryName);
          if (f.exists()) return f.toString();
        }
      }

      if (sourceURL == null) return libraryName;
      else {
        File file = extract(sourceURL);
        files.add(file);

        int lastSize;
        do {
          lastSize = files.size();
          for (Iterator<File> it = files.iterator(); it.hasNext(); ) {
            File f = it.next();
            if (!f.getName().matches(libsuffix)) continue;

            try {
              System.load(f.toString());
              it.remove();
            } catch (Throwable ex) {
              System.err.println("Loading " + f.getName() + " failed (" + ex + ")");
            }
          }
        } while (files.size() < lastSize);

        return file.getCanonicalPath();
      }
    } catch (Throwable ex) {
      System.err.println("ERROR: Failed to extract library " + libraryName);
      ex.printStackTrace();
      return libraryName;
    }
  }
Example #20
0
 /**
  * Initialize the input using JKeymaster
  *
  * @throws JSONException
  */
 public void initializeInput() {
   JSONObject keys = snapper.getConfiguration().getJSONObject("hotkeys");
   // A little sanity check, just in case we don't have ANY keys set
   if (keys == null) {
     return;
   }
   if (keys.has("crop")) {
     provider.register(
         KeyStroke.getKeyStroke(keys.getString("crop")),
         new HotKeyListener() {
           @Override
           public void onHotKey(HotKey hotKey) {
             snapper.crop();
           }
         });
   }
   if (keys.has("full")) {
     provider.register(
         KeyStroke.getKeyStroke(keys.getString("full")),
         new HotKeyListener() {
           @Override
           public void onHotKey(HotKey hotKey) {
             snapper.full();
           }
         });
   }
   if (keys.has("clipboard")) {
     provider.register(
         KeyStroke.getKeyStroke(keys.getString("clipboard")),
         new HotKeyListener() {
           @Override
           public void onHotKey(HotKey hotKey) {
             snapper.clipboard();
           }
         });
   }
   if (keys.has("file")) {
     provider.register(
         KeyStroke.getKeyStroke(keys.getString("file")),
         new HotKeyListener() {
           @Override
           public void onHotKey(HotKey hotKey) {
             snapper.selectFile();
           }
         });
   }
   if (keys.has("options")) {
     provider.register(
         KeyStroke.getKeyStroke(keys.getString("options")),
         new HotKeyListener() {
           @Override
           public void onHotKey(HotKey hotKey) {
             if (!snapper.openSettings()) {
               snapper
                   .getTrayIcon()
                   .displayMessage(
                       "Error",
                       "Could not open settings, is there another window open?",
                       TrayIcon.MessageType.ERROR);
             }
           }
         });
   }
   // We support active windows only on windows/linux, but OSX SOON!
   if ((Platform.isWindows() || Platform.isLinux()) && keys.has("active")) {
     provider.register(
         KeyStroke.getKeyStroke(keys.getString("active")),
         new HotKeyListener() {
           @Override
           public void onHotKey(HotKey hotKey) {
             snapper.active();
           }
         });
   }
   initialized = true;
 }
Example #21
0
  /** Initialize the tray menu */
  private void initializeTray() {
    // Add uploaders from the list we loaded earlier
    final PopupMenu tray = new PopupMenu();
    // Add the action menu
    tray.add(new ActionMenuItem(Language.getString("cropupload"), ScreenshotAction.CROP));
    tray.add(new ActionMenuItem(Language.getString("fullupload"), ScreenshotAction.FULL));

    if (Platform.isWindows() || Platform.isLinux()) {
      tray.add(new ActionMenuItem(Language.getString("activeupload"), ScreenshotAction.ACTIVE));
    }

    tray.addSeparator();

    tray.add(new ActionMenuItem(Language.getString("clipboardupload"), ScreenshotAction.CLIPBOARD));
    tray.add(new ActionMenuItem(Language.getString("fileupload"), ScreenshotAction.FILE));

    tray.addSeparator();

    final MenuItem settings = new MenuItem(Language.getString("options"));
    settings.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (!openSettings()) {
              icon.displayMessage(
                  Language.getString("error"),
                  Language.getString("optionsOpenError"),
                  TrayIcon.MessageType.ERROR);
            }
          }
        });
    tray.add(settings);

    final MenuItem exit = new MenuItem(Language.getString("exit"));
    exit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            shutdown();
          }
        });
    tray.add(exit);

    icon =
        new TrayIcon(
            Toolkit.getDefaultToolkit().getImage(Resources.ICON),
            Application.NAME + " v" + Version.getVersionString());
    icon.setPopupMenu(tray);
    icon.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (lastUrl != null) {
              try {
                Util.openURL(new URL(lastUrl));
              } catch (final Exception e1) {
                showException(e1, "Unable to open URL");
              }
            }
          }
        });
    try {
      SystemTray.getSystemTray().add(icon);
    } catch (final AWTException e1) {
      this.showException(e1);
    }
  }
 public static VR createVR() {
   if (Platform.isWindows()) return new JRift();
   return new RiftFetcher();
 }
  public JComponent buildCommon() {
    String colSpec = FormLayoutUtil.getColSpec(COMMON_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, COMMON_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    maxbuffer = new JTextField("" + configuration.getMaxMemoryBufferSize());
    maxbuffer.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(maxbuffer.getText());
              configuration.setMaxMemoryBufferSize(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse max memory buffer size from \"" + maxbuffer.getText() + "\"");
            }
          }
        });

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

    builder.addLabel(
        Messages.getString("TrTab2.23")
            .replaceAll("MAX_BUFFER_SIZE", configuration.getMaxMemoryBufferSizeStr()),
        FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation));
    builder.add(maxbuffer, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.24") + Runtime.getRuntime().availableProcessors() + ")",
        FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation));

    String[] guiCores = new String[MAX_CORES];
    for (int i = 0; i < MAX_CORES; i++) {
      guiCores[i] = Integer.toString(i + 1);
    }
    nbcores = new JComboBox(guiCores);
    nbcores.setEditable(false);
    int nbConfCores = configuration.getNumberOfCpuCores();
    if (nbConfCores > 0 && nbConfCores <= MAX_CORES) {
      nbcores.setSelectedItem(Integer.toString(nbConfCores));
    } else {
      nbcores.setSelectedIndex(0);
    }

    nbcores.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setNumberOfCpuCores(Integer.parseInt(e.getItem().toString()));
          }
        });
    builder.add(nbcores, FormLayoutUtil.flip(cc.xy(3, 5), colSpec, orientation));

    chapter_interval = new JTextField("" + configuration.getChapterInterval());
    chapter_interval.setEnabled(configuration.isChapterSupport());
    chapter_interval.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(chapter_interval.getText());
              configuration.setChapterInterval(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse chapter interval from \"" + chapter_interval.getText() + "\"");
            }
          }
        });

    chapter_support = new JCheckBox(Messages.getString("TrTab2.52"));
    chapter_support.setContentAreaFilled(false);
    chapter_support.setSelected(configuration.isChapterSupport());

    chapter_support.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setChapterSupport((e.getStateChange() == ItemEvent.SELECTED));
            chapter_interval.setEnabled(configuration.isChapterSupport());
          }
        });

    builder.add(chapter_support, FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation));

    builder.add(chapter_interval, FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.3"),
            FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    channels =
        new JComboBox(
            new Object[] {
              Messages.getString("TrTab2.55"),
              Messages.getString("TrTab2.56") /*, "8 channels 7.1" */
            }); // 7.1 not supported by MPlayer :\
    channels.setEditable(false);
    if (configuration.getAudioChannelCount() == 2) {
      channels.setSelectedIndex(0);
    } else {
      channels.setSelectedIndex(1);
    }
    channels.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setAudioChannelCount(
                Integer.parseInt(e.getItem().toString().substring(0, 1)));
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.50"), FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));
    builder.add(channels, FormLayoutUtil.flip(cc.xy(3, 13), colSpec, orientation));

    forcePCM = new JCheckBox(Messages.getString("TrTab2.27"));
    forcePCM.setContentAreaFilled(false);
    if (configuration.isMencoderUsePcm()) {
      forcePCM.setSelected(true);
    }
    forcePCM.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderUsePcm(e.getStateChange() == ItemEvent.SELECTED);
          }
        });

    builder.add(forcePCM, FormLayoutUtil.flip(cc.xyw(1, 15, 3), colSpec, orientation));

    ac3remux =
        new JCheckBox(
            Messages.getString("TrTab2.26")
                + " "
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    ac3remux.setContentAreaFilled(false);
    if (configuration.isRemuxAC3()) {
      ac3remux.setSelected(true);
    }
    ac3remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setRemuxAC3((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(ac3remux, FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation));

    forceDTSinPCM =
        new JCheckBox(
            Messages.getString("TrTab2.28")
                + " "
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    forceDTSinPCM.setContentAreaFilled(false);
    if (configuration.isDTSEmbedInPCM()) {
      forceDTSinPCM.setSelected(true);
    }
    forceDTSinPCM.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            configuration.setDTSEmbedInPCM(forceDTSinPCM.isSelected());
            if (configuration.isDTSEmbedInPCM()) {
              JOptionPane.showMessageDialog(
                  (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                  Messages.getString("TrTab2.10"),
                  "Information",
                  JOptionPane.INFORMATION_MESSAGE);
            }
          }
        });

    builder.add(forceDTSinPCM, FormLayoutUtil.flip(cc.xyw(1, 19, 3), colSpec, orientation));

    abitrate = new JTextField("" + configuration.getAudioBitrate());
    abitrate.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(abitrate.getText());
              configuration.setAudioBitrate(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug("Could not parse audio bitrate from \"" + abitrate.getText() + "\"");
            }
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.29"), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation));
    builder.add(abitrate, FormLayoutUtil.flip(cc.xy(3, 21), colSpec, orientation));

    mpeg2remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.39")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    mpeg2remux.setContentAreaFilled(false);
    if (configuration.isMencoderRemuxMPEG2()) {
      mpeg2remux.setSelected(true);
    }
    mpeg2remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderRemuxMPEG2((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(mpeg2remux, FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.4"),
            FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("TrTab2.32"),
        FormLayoutUtil.flip(cc.xyw(1, 29, 3), colSpec, orientation));

    Object data[] =
        new Object[] {
          configuration.getMencoderMainSettings(), /* default */
          String.format(
              "keyint=5:vqscale=1:vqmin=2  /* %s */", Messages.getString("TrTab2.60")), /* great */
          String.format(
              "keyint=5:vqscale=1:vqmin=1  /* %s */",
              Messages.getString("TrTab2.61")), /* lossless */
          String.format(
              "keyint=5:vqscale=2:vqmin=3  /* %s */",
              Messages.getString("TrTab2.62")), /* good (wired) */
          String.format(
              "keyint=25:vqmax=5:vqmin=2  /* %s */",
              Messages.getString("TrTab2.63")), /* good (wireless) */
          String.format(
              "keyint=25:vqmax=7:vqmin=2  /* %s */",
              Messages.getString("TrTab2.64")), /* medium (wireless) */
          String.format(
              "keyint=25:vqmax=8:vqmin=3  /* %s */", Messages.getString("TrTab2.65")) /* low */
        };

    MyComboBoxModel cbm = new MyComboBoxModel(data);

    vq = new JComboBox(cbm);
    vq.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String s = (String) e.getItem();
              if (s.indexOf("/*") > -1) {
                s = s.substring(0, s.indexOf("/*")).trim();
              }
              configuration.setMencoderMainSettings(s);
            }
          }
        });
    vq.getEditor()
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              @Override
              public void keyPressed(KeyEvent e) {}

              @Override
              public void keyTyped(KeyEvent e) {}

              @Override
              public void keyReleased(KeyEvent e) {
                vq.getItemListeners()[0].itemStateChanged(
                    new ItemEvent(vq, 0, vq.getEditor().getItem(), ItemEvent.SELECTED));
              }
            });
    vq.setEditable(true);
    builder.add(vq, FormLayoutUtil.flip(cc.xyw(1, 31, 3), colSpec, orientation));

    String help1 = Messages.getString("TrTab2.39");
    help1 += Messages.getString("TrTab2.40");
    help1 += Messages.getString("TrTab2.41");
    help1 += Messages.getString("TrTab2.42");
    help1 += Messages.getString("TrTab2.43");
    help1 += Messages.getString("TrTab2.44");

    JTextArea decodeTips = new JTextArea(help1);
    decodeTips.setEditable(false);
    decodeTips.setBorder(BorderFactory.createEtchedBorder());
    decodeTips.setBackground(new Color(255, 255, 192));
    builder.add(decodeTips, FormLayoutUtil.flip(cc.xyw(1, 41, 3), colSpec, orientation));

    disableSubs = new JCheckBox(Messages.getString("TrTab2.51"));
    disableSubs.setContentAreaFilled(false);

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.7"),
            FormLayoutUtil.flip(cc.xyw(1, 33, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.add(disableSubs, FormLayoutUtil.flip(cc.xy(1, 35), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.8"), FormLayoutUtil.flip(cc.xy(1, 37), colSpec, orientation));

    notranscode = new JTextField(configuration.getNoTranscode());
    notranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setNoTranscode(notranscode.getText());
          }
        });
    builder.add(notranscode, FormLayoutUtil.flip(cc.xy(3, 37), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.9"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation));

    forcetranscode = new JTextField(configuration.getForceTranscode());
    forcetranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setForceTranscode(forcetranscode.getText());
          }
        });
    builder.add(forcetranscode, FormLayoutUtil.flip(cc.xy(3, 39), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
  }