changeset 10022:0e03eab4b551 jdk-9+135

8160988: NoClassDefFound exception when using getDeclaredMethod method of MediaView class Reviewed-by: kcr, ddehaven
author almatvee
date Fri, 02 Sep 2016 15:47:59 -0700
parents 7aa598099c6d
children ecde4ce2ea8e 519565d94187
files modules/javafx.media/src/main/java/com/sun/media/jfxmedia/MediaPlayer.java modules/javafx.media/src/main/java/com/sun/media/jfxmedia/control/MediaPlayerOverlay.java modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMediaPlayer.java modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSMediaPlayer.java modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXMediaPlayer.java modules/javafx.media/src/main/java/javafx/scene/media/MediaView.java
diffstat 6 files changed, 186 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/MediaPlayer.java	Fri Sep 02 12:59:25 2016 -0700
+++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/MediaPlayer.java	Fri Sep 02 15:47:59 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -29,6 +29,7 @@
 import com.sun.media.jfxmedia.events.PlayerStateListener;
 import com.sun.media.jfxmedia.events.VideoTrackSizeListener;
 import com.sun.media.jfxmedia.control.VideoRenderControl;
+import com.sun.media.jfxmedia.control.MediaPlayerOverlay;
 import com.sun.media.jfxmedia.effects.AudioSpectrum;
 import com.sun.media.jfxmedia.events.AudioSpectrumListener;
 import com.sun.media.jfxmedia.events.MarkerListener;
@@ -179,6 +180,13 @@
     public VideoRenderControl getVideoRenderControl();
 
     /**
+     * Returns the media player overlay support interface.
+     *
+     * @return A <code>MediaPlayerOverlay</code> instance.
+     */
+    public MediaPlayerOverlay getMediaPlayerOverlay();
+
+    /**
      * Gets a Media object.
      *
      * @return Media object.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmedia/control/MediaPlayerOverlay.java	Fri Sep 02 15:47:59 2016 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.media.jfxmedia.control;
+
+/**
+ * MediaPlayerOverlay interface provides control of media player overlay.
+ */
+public interface MediaPlayerOverlay {
+
+    public void setOverlayX(final double x);
+
+    public void setOverlayY(final double y);
+
+    public void setOverlayVisible(final boolean visible);
+
+    public void setOverlayWidth(final double width);
+
+    public void setOverlayHeight(final double height);
+
+    public void setOverlayPreserveRatio(final boolean preserveRatio);
+
+    public void setOverlayOpacity(final double opacity);
+
+    public void setOverlayTransform(
+            final double mxx, final double mxy, final double mxz, final double mxt,
+            final double myx, final double myy, final double myz, final double myt,
+            final double mzx, final double mzy, final double mzz, final double mzt);
+}
--- a/modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMediaPlayer.java	Fri Sep 02 12:59:25 2016 -0700
+++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMediaPlayer.java	Fri Sep 02 15:47:59 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -30,6 +30,7 @@
 import com.sun.media.jfxmedia.effects.AudioEqualizer;
 import com.sun.media.jfxmedia.effects.AudioSpectrum;
 import com.sun.media.jfxmedia.locator.Locator;
+import com.sun.media.jfxmedia.control.MediaPlayerOverlay;
 import com.sun.media.jfxmediaimpl.NativeMediaPlayer;
 
 /**
@@ -72,6 +73,11 @@
         return audioSpectrum;
     }
 
+    @Override
+    public MediaPlayerOverlay getMediaPlayerOverlay() {
+        return null; // Not needed
+    }
+
     // FIXME: this should be pushed down to native instead of returning an int value
     private void throwMediaErrorException(int code, String message)
             throws MediaException
--- a/modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSMediaPlayer.java	Fri Sep 02 12:59:25 2016 -0700
+++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSMediaPlayer.java	Fri Sep 02 15:47:59 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -31,6 +31,7 @@
 import com.sun.media.jfxmedia.effects.AudioSpectrum;
 import com.sun.media.jfxmedia.effects.EqualizerBand;
 import com.sun.media.jfxmedia.locator.Locator;
+import com.sun.media.jfxmedia.control.MediaPlayerOverlay;
 import com.sun.media.jfxmediaimpl.NativeMediaPlayer;
 
 import java.util.Map;
@@ -45,6 +46,7 @@
 
     private final NullAudioEQ audioEqualizer;
     private final NullAudioSpectrum audioSpectrum;
+    private final MediaPlayerOverlay mediaPlayerOverlay;
 
     private float mutedVolume = 1.0f;  // last volume before mute
     private boolean muteEnabled; // false by default
@@ -60,6 +62,7 @@
 
         audioEqualizer = new NullAudioEQ();
         audioSpectrum = new NullAudioSpectrum();
+        mediaPlayerOverlay = new MediaPlayerOverlayImpl();
     }
 
     IOSMediaPlayer(final Locator source) {
@@ -76,6 +79,11 @@
         return audioSpectrum;
     }
 
+    @Override
+    public MediaPlayerOverlay getMediaPlayerOverlay() {
+        return mediaPlayerOverlay;
+    }
+
     private void handleError(final int err) throws MediaException {
         if (0 != err) {
             final MediaError me = MediaError.getFromCode(err);
@@ -221,45 +229,6 @@
         iosMedia = null;
     }
 
-    public void setOverlayX(final double x) {
-        handleError(iosSetOverlayX(iosMedia.getNativeMediaRef(), x));
-    }
-
-    public void setOverlayY(final double y) {
-        handleError(iosSetOverlayY(iosMedia.getNativeMediaRef(), y));
-    }
-
-    public void setOverlayVisible(final boolean visible) {
-        handleError(iosSetOverlayVisible(iosMedia.getNativeMediaRef(), visible));
-    }
-
-    public void setOverlayWidth(final double width) {
-        handleError(iosSetOverlayWidth(iosMedia.getNativeMediaRef(), width));
-    }
-
-    public void setOverlayHeight(final double height) {
-        handleError(iosSetOverlayHeight(iosMedia.getNativeMediaRef(), height));
-    }
-
-    public void setOverlayPreserveRatio(final boolean preserveRatio) {
-        handleError(iosSetOverlayPreserveRatio(iosMedia.getNativeMediaRef(), preserveRatio));
-    }
-
-    public void setOverlayOpacity(final double opacity) {
-        handleError(iosSetOverlayOpacity(iosMedia.getNativeMediaRef(), opacity));
-    }
-
-    public void setOverlayTransform(
-            final double mxx, final double mxy, final double mxz, final double mxt,
-            final double myx, final double myy, final double myz, final double myt,
-            final double mzx, final double mzy, final double mzz, final double mzt) {
-        handleError(iosSetOverlayTransform(
-                iosMedia.getNativeMediaRef(),
-                mxx, mxy, mxz, mxt,
-                myx, myy, myz, myt,
-                mzx, mzy, mzz, mzt));
-    }
-
     // Native methods
     private native int iosInitPlayer(long refNativeMedia);
     private native int iosGetAudioSyncDelay(long refNativeMedia, long[] syncDelay);
@@ -420,4 +389,54 @@
             this.gain = gain;
         }
     }
+
+    private final class MediaPlayerOverlayImpl implements MediaPlayerOverlay {
+
+        @Override
+        public void setOverlayX(final double x) {
+            handleError(iosSetOverlayX(iosMedia.getNativeMediaRef(), x));
+        }
+
+        @Override
+        public void setOverlayY(final double y) {
+            handleError(iosSetOverlayY(iosMedia.getNativeMediaRef(), y));
+        }
+
+        @Override
+        public void setOverlayVisible(final boolean visible) {
+            handleError(iosSetOverlayVisible(iosMedia.getNativeMediaRef(), visible));
+        }
+
+        @Override
+        public void setOverlayWidth(final double width) {
+            handleError(iosSetOverlayWidth(iosMedia.getNativeMediaRef(), width));
+        }
+
+        @Override
+        public void setOverlayHeight(final double height) {
+            handleError(iosSetOverlayHeight(iosMedia.getNativeMediaRef(), height));
+        }
+
+        @Override
+        public void setOverlayPreserveRatio(final boolean preserveRatio) {
+            handleError(iosSetOverlayPreserveRatio(iosMedia.getNativeMediaRef(), preserveRatio));
+        }
+
+        @Override
+        public void setOverlayOpacity(final double opacity) {
+            handleError(iosSetOverlayOpacity(iosMedia.getNativeMediaRef(), opacity));
+        }
+
+        @Override
+        public void setOverlayTransform(
+                final double mxx, final double mxy, final double mxz, final double mxt,
+                final double myx, final double myy, final double myz, final double myt,
+                final double mzx, final double mzy, final double mzz, final double mzt) {
+            handleError(iosSetOverlayTransform(
+                    iosMedia.getNativeMediaRef(),
+                    mxx, mxy, mxz, mxt,
+                    myx, myy, myz, myt,
+                    mzx, mzy, mzz, mzt));
+        }
+    }
 }
--- a/modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXMediaPlayer.java	Fri Sep 02 12:59:25 2016 -0700
+++ b/modules/javafx.media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXMediaPlayer.java	Fri Sep 02 15:47:59 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -29,6 +29,7 @@
 import com.sun.media.jfxmedia.effects.AudioEqualizer;
 import com.sun.media.jfxmedia.effects.AudioSpectrum;
 import com.sun.media.jfxmedia.locator.Locator;
+import com.sun.media.jfxmedia.control.MediaPlayerOverlay;
 import com.sun.media.jfxmediaimpl.NativeMedia;
 import com.sun.media.jfxmediaimpl.NativeMediaPlayer;
 
@@ -65,6 +66,11 @@
     }
 
     @Override
+    public MediaPlayerOverlay getMediaPlayerOverlay() {
+        return null; // Not needed
+    }
+
+    @Override
     protected long playerGetAudioSyncDelay() throws MediaException {
         return osxGetAudioSyncDelay();
     }
--- a/modules/javafx.media/src/main/java/javafx/scene/media/MediaView.java	Fri Sep 02 12:59:25 2016 -0700
+++ b/modules/javafx.media/src/main/java/javafx/scene/media/MediaView.java	Fri Sep 02 15:47:59 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -37,7 +37,7 @@
 import com.sun.javafx.sg.prism.NGNode;
 import com.sun.javafx.tk.Toolkit;
 import com.sun.media.jfxmediaimpl.HostUtils;
-import com.sun.media.jfxmediaimpl.platform.ios.IOSMediaPlayer;
+import com.sun.media.jfxmedia.control.MediaPlayerOverlay;
 import javafx.application.Platform;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
@@ -184,9 +184,9 @@
         }
     }
 
-    /***************************************** iOS specific stuff ***************************/
+    /***************************************** Media Player Overlay support ***************************/
 
-    private /*volatile*/ boolean mediaPlayerReady;
+    private MediaPlayerOverlay mediaPlayerOverlay = null;
 
     private ChangeListener<Parent> parentListener;
     private ChangeListener<Boolean> treeVisibleListener;
@@ -206,53 +206,49 @@
         };
     }
 
-    private IOSMediaPlayer getIOSPlayer() {
-        return (IOSMediaPlayer) getMediaPlayer().retrieveJfxPlayer();
-    }
-
     private boolean determineVisibility() {
         return (getParent() != null && isVisible());
     }
 
     private synchronized void updateOverlayVisibility() {
-        if (mediaPlayerReady) {
-            getIOSPlayer().setOverlayVisible(determineVisibility());
+        if (mediaPlayerOverlay != null) {
+            mediaPlayerOverlay.setOverlayVisible(determineVisibility());
         }
     }
 
     private synchronized void updateOverlayOpacity() {
-        if (mediaPlayerReady) {
-            getIOSPlayer().setOverlayOpacity(getOpacity());
+        if (mediaPlayerOverlay != null) {
+            mediaPlayerOverlay.setOverlayOpacity(getOpacity());
         }
     }
 
     private synchronized void updateOverlayX() {
-        if (mediaPlayerReady) {
-            getIOSPlayer().setOverlayX(getX());
+        if (mediaPlayerOverlay != null) {
+            mediaPlayerOverlay.setOverlayX(getX());
         }
     }
 
     private synchronized void updateOverlayY() {
-        if (mediaPlayerReady) {
-            getIOSPlayer().setOverlayY(getY());
+        if (mediaPlayerOverlay != null) {
+            mediaPlayerOverlay.setOverlayY(getY());
         }
     }
 
     private synchronized void updateOverlayWidth() {
-        if (mediaPlayerReady) {
-            getIOSPlayer().setOverlayWidth(getFitWidth());
+        if (mediaPlayerOverlay != null) {
+            mediaPlayerOverlay.setOverlayWidth(getFitWidth());
         }
     }
 
     private synchronized void updateOverlayHeight() {
-        if (mediaPlayerReady) {
-            getIOSPlayer().setOverlayHeight(getFitHeight());
+        if (mediaPlayerOverlay != null) {
+            mediaPlayerOverlay.setOverlayHeight(getFitHeight());
         }
     }
 
     private synchronized void updateOverlayPreserveRatio() {
-        if (mediaPlayerReady) {
-            getIOSPlayer().setOverlayPreserveRatio(isPreserveRatio());
+        if (mediaPlayerOverlay != null) {
+            mediaPlayerOverlay.setOverlayPreserveRatio(isPreserveRatio());
         }
     }
 
@@ -266,29 +262,25 @@
         return transform;
     }
 
-    private void updateOverlayTransformDirectly() {
-        final Affine3D trans = MediaView.calculateNodeToSceneTransform(this);
-        getIOSPlayer().setOverlayTransform(
-                trans.getMxx(), trans.getMxy(), trans.getMxz(), trans.getMxt(),
-                trans.getMyx(), trans.getMyy(), trans.getMyz(), trans.getMyt(),
-                trans.getMzx(), trans.getMzy(), trans.getMzz(), trans.getMzt());
-    }
-
-    private synchronized void updateOverlayTransform() {
-        if (mediaPlayerReady) {
-            updateOverlayTransformDirectly();
+    private void updateOverlayTransform() {
+        if (mediaPlayerOverlay != null) {
+            final Affine3D trans = MediaView.calculateNodeToSceneTransform(this);
+            mediaPlayerOverlay.setOverlayTransform(
+                    trans.getMxx(), trans.getMxy(), trans.getMxz(), trans.getMxt(),
+                    trans.getMyx(), trans.getMyy(), trans.getMyz(), trans.getMyt(),
+                    trans.getMzx(), trans.getMzy(), trans.getMzz(), trans.getMzt());
         }
     }
 
-    private void updateIOSOverlay() {
-        getIOSPlayer().setOverlayX(getX());
-        getIOSPlayer().setOverlayY(getY());
-        getIOSPlayer().setOverlayPreserveRatio(isPreserveRatio());
-        getIOSPlayer().setOverlayWidth(getFitWidth());
-        getIOSPlayer().setOverlayHeight(getFitHeight());
-        getIOSPlayer().setOverlayOpacity(getOpacity());
-        getIOSPlayer().setOverlayVisible(determineVisibility());
-        updateOverlayTransformDirectly();
+    private void updateMediaPlayerOverlay() {
+        mediaPlayerOverlay.setOverlayX(getX());
+        mediaPlayerOverlay.setOverlayY(getY());
+        mediaPlayerOverlay.setOverlayPreserveRatio(isPreserveRatio());
+        mediaPlayerOverlay.setOverlayWidth(getFitWidth());
+        mediaPlayerOverlay.setOverlayHeight(getFitHeight());
+        mediaPlayerOverlay.setOverlayOpacity(getOpacity());
+        mediaPlayerOverlay.setOverlayVisible(determineVisibility());
+        updateOverlayTransform();
     }
 
     /*
@@ -296,7 +288,7 @@
      * Note: This method MUST only be called via its accessor method.
      */
     private void doTransformsChanged() {
-        if (HostUtils.isIOS()) {
+        if (mediaPlayerOverlay != null) {
             updateOverlayTransform();
         }
     }
@@ -324,12 +316,6 @@
         setSmooth(Toolkit.getToolkit().getDefaultImageSmooth());
         decodedFrameRateListener = createVideoFrameRateListener();
         setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
-        if (HostUtils.isIOS()) {
-            createListeners();
-            parentProperty().addListener(parentListener);
-            NodeHelper.treeVisibleProperty(this).addListener(treeVisibleListener);
-            opacityProperty().addListener(opacityListener);
-        }
     }
 
     /**
@@ -1044,14 +1030,25 @@
      * Called by MediaPlayer when it becomes ready
      */
     void _mediaPlayerOnReady() {
-        if (decodedFrameRateListener != null && getMediaPlayer().retrieveJfxPlayer() != null && registerVideoFrameRateListener) {
-            getMediaPlayer().retrieveJfxPlayer().getVideoRenderControl().addVideoFrameRateListener(decodedFrameRateListener);
-            registerVideoFrameRateListener = false;
-        }
-        if (HostUtils.isIOS()) {
-            synchronized (this) {
-                updateIOSOverlay();
-                mediaPlayerReady = true;
+        com.sun.media.jfxmedia.MediaPlayer jfxPlayer = getMediaPlayer().retrieveJfxPlayer();
+        if (jfxPlayer != null) {
+            if (decodedFrameRateListener != null && registerVideoFrameRateListener) {
+                jfxPlayer.getVideoRenderControl().addVideoFrameRateListener(decodedFrameRateListener);
+                registerVideoFrameRateListener = false;
+            }
+
+            // Get media player overlay
+            mediaPlayerOverlay = jfxPlayer.getMediaPlayerOverlay();
+            if (mediaPlayerOverlay != null) {
+                // Init media player overlay support
+                createListeners();
+                parentProperty().addListener(parentListener);
+                NodeHelper.treeVisibleProperty(this).addListener(treeVisibleListener);
+                opacityProperty().addListener(opacityListener);
+
+                synchronized (this) {
+                    updateMediaPlayerOverlay();
+                }
             }
         }
     }