libbluray | branch: master | hpi1 <[email protected]> | Thu Oct 9 10:29:00 2014 +0300| [2398a75930eb3a553e47fdb73fcf208818c5afe1] | committer: hpi1
Cosmetics > http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=2398a75930eb3a553e47fdb73fcf208818c5afe1 --- src/libbluray/bdj/java/javax/media/Manager.java | 136 +++++++++-------------- 1 file changed, 55 insertions(+), 81 deletions(-) diff --git a/src/libbluray/bdj/java/javax/media/Manager.java b/src/libbluray/bdj/java/javax/media/Manager.java index c70237b..37a50d2 100644 --- a/src/libbluray/bdj/java/javax/media/Manager.java +++ b/src/libbluray/bdj/java/javax/media/Manager.java @@ -34,49 +34,41 @@ public final class Manager { dataSource.setLocator(sourceLocator); dataSource.connect(); return createPlayer(dataSource); - + // TODO: JMF seems to disconnect data sources in this method, based on this stack trace: // java.lang.NullPointerException // at com.sun.media.protocol.rtp.DataSource.disconnect(DataSource.java:207) // at javax.media.Manager.createPlayer(Manager.java:425) // at net.sf.fmj.ui.application.ContainerPlayer.createNewPlayer(ContainerPlayer.java:357) } - catch (NoPlayerException e) - { // no need to log, will be logged by call to createPlayer. + catch (NoPlayerException e) { + // no need to log, will be logged by call to createPlayer. continue; } - catch (ClassNotFoundException e) - { + catch (ClassNotFoundException e) { logger.warning("createPlayer: " + e); // no need for call stack continue; - } - catch (IOException e) - { + } + catch (IOException e) { logger.warning("" + e); continue; } - catch (NoClassDefFoundError e) - { + catch (NoClassDefFoundError e) { logger.warning("" + e); continue; } - catch (Exception e) - { + catch (Exception e) { logger.warning("" + e); continue; } - - } - + // if none found, try URLDataSource: final URL url; - try - { + try { url = sourceLocator.getURL(); } - catch (Exception e) - { + catch (Exception e) { logger.warning("" + e); throw new NoPlayerException(); } @@ -107,51 +99,39 @@ public final class Manager { { final String protocol = sourceLocator.getProtocol(); final Vector dataSourceList = getDataSourceList(protocol); - for (int i = 0; i < dataSourceList.size(); ++i) - { + for (int i = 0; i < dataSourceList.size(); ++i) { String dataSourceClassName = (String) dataSourceList.get(i); - try - { + try { final Class dataSourceClass = Class.forName(dataSourceClassName); final DataSource dataSource = (DataSource) dataSourceClass.newInstance(); dataSource.setLocator(sourceLocator); dataSource.connect(); return dataSource; - - } - catch (ClassNotFoundException e) - { + catch (ClassNotFoundException e) { logger.warning("createDataSource: " + e); // no need for call stack continue; } - catch (IOException e) - { + catch (IOException e) { logger.warning("" + e); continue; } - catch (NoClassDefFoundError e) - { + catch (NoClassDefFoundError e) { logger.warning("" + e); continue; } - catch (Exception e) - { + catch (Exception e) { logger.warning("" + e); continue; } - - } - + // if none found, try URLDataSource: final URL url; - try - { + try { url = sourceLocator.getURL(); } - catch (Exception e) - { + catch (Exception e) { logger.warning("" + e); throw new NoDataSourceException(); } @@ -174,59 +154,54 @@ public final class Manager { { return getClassList(toPackageFriendly(contentName), PackageManager.getContentPrefixList(), "content", "Handler"); } - + private static Player createPlayer(DataSource source, String contentType) throws IOException, NoPlayerException { final Vector handlerClassList = getHandlerClassList(contentType); - for (int i = 0; i < handlerClassList.size(); ++i) - { + for (int i = 0; i < handlerClassList.size(); ++i) { final String handlerClassName = (String) handlerClassList.get(i); - - try - { + + try { System.out.println(handlerClassName); final Class handlerClass = Class.forName(handlerClassName); - if (!Player.class.isAssignableFrom(handlerClass) && - !MediaProxy.class.isAssignableFrom(handlerClass)) - continue; // skip any classes that will not be matched below. + if (!Player.class.isAssignableFrom(handlerClass) && + !MediaProxy.class.isAssignableFrom(handlerClass)) { + continue; // skip any classes that will not be matched below. + } final MediaHandler handler = (MediaHandler) handlerClass.newInstance(); handler.setSource(source); - if (handler instanceof Player) - { return (Player) handler; - } - else if (handler instanceof MediaProxy) - { + + if (handler instanceof Player) { + return (Player) handler; + } else if (handler instanceof MediaProxy) { final MediaProxy mediaProxy = (MediaProxy) handler; return createPlayer(mediaProxy.getDataSource()); } } - catch (ClassNotFoundException e) - { - logger.warning("createPlayer: " + e); // no need for call stack + catch (ClassNotFoundException e) { + // no need for call stack + logger.warning("createPlayer: " + e); continue; - } - catch (IncompatibleSourceException e) - { - logger.warning("createPlayer(" + source + ", " + contentType + "): " + e); // no need for call stack + } + catch (IncompatibleSourceException e) { + // no need for call stack + logger.warning("createPlayer(" + source + ", " + contentType + "): " + e); continue; } - catch (IOException e) - { + catch (IOException e) { logger.warning("" + e); continue; } - catch (NoPlayerException e) - { // no need to log, will be logged by call to createPlayer. + catch (NoPlayerException e) { + // no need to log, will be logged by call to createPlayer. continue; } - catch (NoClassDefFoundError e) - { + catch (NoClassDefFoundError e) { logger.warning("" + e); continue; } - catch (Exception e) - { + catch (Exception e) { logger.warning("" + e); continue; } @@ -234,9 +209,10 @@ public final class Manager { logger.error("No player found for " + contentType + " / " + source.getLocator()); throw new NoPlayerException("No player found for " + source.getLocator()); } - + private static char toPackageFriendly(char c) - { if (c >= 'a' && c <= 'z') + { + if (c >= 'a' && c <= 'z') return c; else if (c >= 'A' && c <= 'Z') return c; @@ -246,36 +222,34 @@ public final class Manager { return c; else if (c == '/') return '.'; - else + else return '_'; } - + private static String toPackageFriendly(String contentName) { final StringBuffer b = new StringBuffer(); - for (int i = 0; i < contentName.length(); ++i) - { + for (int i = 0; i < contentName.length(); ++i) { final char c = contentName.charAt(i); b.append(toPackageFriendly(c)); } return b.toString(); } - + public static Vector getClassList(String contentName, Vector packages, String component2, String className) { final Vector result = new Vector(); //result.add("media." + component2 + "." + contentName + "." + className); - - for (int i = 0; i < packages.size(); ++i) - { + + for (int i = 0; i < packages.size(); ++i) { result.add(((String) packages.get(i)) + ".media." + component2 + "." + contentName + "." + className); } - + return result; } public static final String UNKNOWN_CONTENT_NAME = "unknown"; - + private static final TimeBase systemTimeBase = new SystemTimeBase(); private static final Logger logger = Logger.getLogger(Manager.class.getName()); } _______________________________________________ libbluray-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libbluray-devel
