changeset 11257:c8cde739aa8e 13+7

8209180: Media fails to load source from custom image, with jrt: URL Reviewed-by: kcr
author almatvee
date Wed, 01 May 2019 14:35:33 -0700
parents 6cce713319b2
children 6e7ea94e3638
files modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/ConnectionHolder.java modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/Locator.java modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTPlatform.java
diffstat 3 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/ConnectionHolder.java	Wed May 01 14:20:54 2019 -0700
+++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/ConnectionHolder.java	Wed May 01 14:35:33 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -256,7 +256,9 @@
         }
 
         boolean isSeekable() {
-            return (urlConnection instanceof HttpURLConnection) || (urlConnection instanceof JarURLConnection);
+            return (urlConnection instanceof HttpURLConnection) ||
+                   (urlConnection instanceof JarURLConnection) ||
+                   isJRT();
         }
 
         boolean isRandomAccess() {
@@ -297,7 +299,7 @@
                         Locator.closeConnection(tmpURLConnection);
                     }
                 }
-            } else if (urlConnection instanceof JarURLConnection) {
+            } else if ((urlConnection instanceof JarURLConnection) || isJRT()) {
                 try {
                     closeConnection();
 
@@ -335,6 +337,11 @@
                     Channels.newChannel(urlConnection.getInputStream()) :
                     Channels.newChannel(inputStream);
         }
+
+        private boolean isJRT() {
+            String scheme = uri.getScheme().toLowerCase();
+            return "jrt".equals(scheme);
+        }
     }
 
     // A "ConnectionHolder" that "reads" from a ByteBuffer, generally loaded from
--- a/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/Locator.java	Wed May 01 14:20:54 2019 -0700
+++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/locator/Locator.java	Wed May 01 14:35:33 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -417,7 +417,7 @@
                             }
 
                             // FIXME: get cache settings from server, honor them
-                        } else if (scheme.equals("file") || scheme.equals("jar")) {
+                        } else if (scheme.equals("file") || scheme.equals("jar") || scheme.equals("jrt")) {
                             InputStream stream = getInputStream(uri);
                             stream.close();
                             isConnected = true;
--- a/modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTPlatform.java	Wed May 01 14:20:54 2019 -0700
+++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTPlatform.java	Wed May 01 14:35:33 2019 -0700
@@ -61,7 +61,8 @@
     private static final String[] PROTOCOLS = {
         "file",
         "http",
-        "https"
+        "https",
+        "jrt"
     };
 
     private static GSTPlatform globalInstance = null;