aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-11 19:46:37 +0200
committerSven Gothel <[email protected]>2012-04-11 19:46:37 +0200
commitf10b30c16aeec428378d1d560d030b2d39801c4e (patch)
tree869ca02373385659ed356d781a602fdc2d7d1666 /src/jogl/classes/jogamp
parent41b75429e3801f8bf8d5eea679487ccc49ce2584 (diff)
Refine GLMediaPlayer/TextureSequence, add MovieCube demo, fix minor bug in Texture
- Add TextureSequence, base interface of GLMediaPlayer to genralize texture streams - TextureSequence / GLMediaPlayer: Use inner classes for event and texture data - getLastTexture() shall never return 'null', initialization of TextureSequence (initGLStream(..), etc) shall provide a TextureFrame w/ the stream's dimension. - GLMediaPlayerImpl.createTexImageImpl() y-flip defaults to 'false' impl. shall define y-flip, if required. - Added MovieCube demo - Fix Texture: initialize aspectRation for 'wrapping' ctor -
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java26
-rw-r--r--src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java28
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java62
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java34
5 files changed, 78 insertions, 81 deletions
diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
index ae45662db..a50f1507f 100644
--- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
+++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
@@ -32,10 +32,10 @@ import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GLES2;
-import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.TextureSequence;
import jogamp.common.os.android.StaticContext;
-import jogamp.opengl.av.GLMediaPlayerImpl;
+import jogamp.opengl.util.av.GLMediaPlayerImpl;
import android.graphics.SurfaceTexture;
import android.graphics.SurfaceTexture.OnFrameAvailableListener;
@@ -51,7 +51,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
MediaPlayer mp;
volatile boolean updateSurface = false;
Object updateSurfaceLock = new Object();
- TextureFrame lastTexFrame = null;
+ TextureSequence.TextureFrame lastTexFrame = null;
/**
private static String toString(MediaPlayer m) {
@@ -133,12 +133,12 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
}
@Override
- public TextureFrame getLastTexture() {
+ public TextureSequence.TextureFrame getLastTexture() {
return lastTexFrame;
}
@Override
- public TextureFrame getNextTexture(GL gl, boolean blocking) {
+ public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) {
if(null != stex && null != mp) {
// Only block once, no while-loop.
// This relaxes locking code of non crucial resources/events.
@@ -166,11 +166,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
return lastTexFrame;
}
- @Override
- public TextureCoords getTextureCoords() {
- return texFrames[0].getTexture().getImageTexCoords();
- }
-
private void wakeUp(boolean newFrame) {
synchronized(updateSurfaceLock) {
if(newFrame) {
@@ -226,12 +221,19 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
totalFrames = 0;
duration = mp.getDuration();
acodec = "unknown";
- vcodec = "unknown";
+ vcodec = "unknown";
}
}
@Override
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ lastTexFrame = new TextureSequence.TextureFrame( createTexImageImpl(gl, idx, tex, true) );
+ // lastTexFrame = super.createTexImage(gl, idx, tex);
+ return lastTexFrame;
+ }
+
+ @Override
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
if(null != stex) {
stex.release();
stex = null;
diff --git a/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java
index 7c775dd9f..c005c2ea6 100644
--- a/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java
@@ -7,11 +7,10 @@ import java.net.URL;
import javax.media.opengl.GL;
import javax.media.opengl.GLException;
-import com.jogamp.opengl.av.GLMediaEventListener;
-import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.TextureSequence;
-import jogamp.opengl.av.EGLMediaPlayerImpl;
import jogamp.opengl.egl.EGL;
+import jogamp.opengl.util.av.EGLMediaPlayerImpl;
public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
protected long moviePtr = 0;
@@ -26,7 +25,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
protected long o_totalFrames = 0;
protected long o_duration = 0;
- protected TextureFrame lastTex = null;
+ protected TextureSequence.TextureFrame lastTex = null;
public OMXGLMediaPlayer() {
super(TextureType.KHRImage, true);
@@ -41,7 +40,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
}
@Override
- protected TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
final EGLTextureFrame eglTex = (EGLTextureFrame) super.createTexImage(gl, idx, tex);
_setStreamEGLImageTexture2D(moviePtr, idx, tex[idx], eglTex.getImage(), eglTex.getSync());
lastTex = eglTex;
@@ -49,8 +48,9 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
}
@Override
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
- super.destroyTexImage(gl, imgTex);
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
+ lastTex = null;
+ super.destroyTexImage(gl, imgTex);
}
@Override
@@ -76,7 +76,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
System.out.println("setURL: p1 "+this);
_setStream(moviePtr, textureCount, path);
- System.out.println("setURL: p2 "+this);
+ System.out.println("setURL: p2 "+this);
}
@Override
@@ -135,18 +135,18 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
}
@Override
- public TextureFrame getLastTexture() {
+ public TextureSequence.TextureFrame getLastTexture() {
return lastTex;
}
@Override
- public synchronized TextureFrame getNextTexture(GL gl, boolean blocking) {
+ public synchronized TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) {
if(0==moviePtr) {
throw new GLException("OMX native instance null");
}
final int nextTex = _getNextTextureID(moviePtr, blocking);
if(0 < nextTex) {
- final TextureFrame eglImgTex = texFrameMap.get(new Integer(_getNextTextureID(moviePtr, blocking)));
+ final TextureSequence.TextureFrame eglImgTex = texFrameMap.get(new Integer(_getNextTextureID(moviePtr, blocking)));
if(null!=eglImgTex) {
lastTex = eglImgTex;
}
@@ -154,12 +154,6 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
return lastTex;
}
- @Override
- public TextureCoords getTextureCoords() {
- return lastTex.getTexture().getImageTexCoords();
- }
-
-
protected void attributesUpdated() {
int event_mask = 0;
if( o_width != width || o_height != height ) {
diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java
index 2f6744fc5..52378d0fd 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java
@@ -25,7 +25,7 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package jogamp.opengl.av;
+package jogamp.opengl.util.av;
import java.nio.IntBuffer;
@@ -33,6 +33,7 @@ import javax.media.opengl.GL;
import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureSequence;
import jogamp.opengl.egl.EGL;
import jogamp.opengl.egl.EGLContext;
@@ -53,7 +54,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl {
}
}
- public static class EGLTextureFrame extends TextureFrame {
+ public static class EGLTextureFrame extends TextureSequence.TextureFrame {
public EGLTextureFrame(Texture t, long khrImage, long khrSync) {
super(t);
@@ -83,7 +84,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl {
}
@Override
- protected TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
final Texture texture = super.createTexImageImpl(gl, idx, tex, true);
final long image;
final long sync;
@@ -123,7 +124,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl {
}
@Override
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
final EGLContext eglCtx = (EGLContext) gl.getContext();
final EGLExt eglExt = eglCtx.getEGLExt();
final EGLDrawable eglDrawable = (EGLDrawable) eglCtx.getGLDrawable();
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index acd707288..bc3fa0919 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -25,7 +25,7 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package jogamp.opengl.av;
+package jogamp.opengl.util.av;
import java.io.IOException;
import java.net.URLConnection;
@@ -37,9 +37,9 @@ import javax.media.opengl.GL;
import javax.media.opengl.GLES2;
import javax.media.opengl.GLException;
-import com.jogamp.opengl.av.GLMediaPlayer;
-import com.jogamp.opengl.av.GLMediaEventListener;
+import com.jogamp.opengl.util.av.GLMediaPlayer;
import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureSequence;
/**
* After object creation an implementation may customize the behavior:
@@ -86,8 +86,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
protected long frameNumber = 0;
- protected TextureFrame[] texFrames = null;
- protected HashMap<Integer, TextureFrame> texFrameMap = new HashMap<Integer, TextureFrame>();
+ protected TextureSequence.TextureFrame[] texFrames = null;
+ protected HashMap<Integer, TextureSequence.TextureFrame> texFrameMap = new HashMap<Integer, TextureSequence.TextureFrame>();
private ArrayList<GLMediaEventListener> eventListeners = new ArrayList<GLMediaEventListener>();
protected GLMediaPlayerImpl() {
@@ -172,27 +172,29 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
}
this.urlConn = urlConn;
if (this.urlConn != null) {
- try {
- if(null!=texFrames) {
- removeAllImageTextures(gl);
- } else {
- texFrames = new TextureFrame[textureCount];
- }
-
- final int[] tex = new int[textureCount];
- {
- gl.glGenTextures(textureCount, tex, 0);
- final int err = gl.glGetError();
- if( GL.GL_NO_ERROR != err ) {
- throw new RuntimeException("TextureNames creation failed (num: "+textureCount+"): err "+toHexString(err));
+ try {
+ if(null != gl) {
+ if(null!=texFrames) {
+ // re-init ..
+ removeAllImageTextures(gl);
+ } else {
+ texFrames = new TextureSequence.TextureFrame[textureCount];
+ }
+ final int[] tex = new int[textureCount];
+ {
+ gl.glGenTextures(textureCount, tex, 0);
+ final int err = gl.glGetError();
+ if( GL.GL_NO_ERROR != err ) {
+ throw new RuntimeException("TextureNames creation failed (num: "+textureCount+"): err "+toHexString(err));
+ }
+ }
+ initGLStreamImpl(gl, tex);
+
+ for(int i=0; i<textureCount; i++) {
+ final TextureSequence.TextureFrame tf = createTexImage(gl, i, tex);
+ texFrames[i] = tf;
+ texFrameMap.put(tex[i], tf);
}
- }
- initGLStreamImpl(gl, tex);
-
- for(int i=0; i<textureCount; i++) {
- final TextureFrame tf = createTexImage(gl, i, tex);
- texFrames[i] = tf;
- texFrameMap.put(tex[i], tf);
}
state = State.Stopped;
return state;
@@ -216,9 +218,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
* @see #vcodec
*/
protected abstract void initGLStreamImpl(GL gl, int[] texNames) throws IOException;
-
- protected TextureFrame createTexImage(GL gl, int idx, int[] tex) {
- return new TextureFrame( createTexImageImpl(gl, idx, tex, true) );
+
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ return new TextureSequence.TextureFrame( createTexImageImpl(gl, idx, tex, false) );
}
protected Texture createTexImageImpl(GL gl, int idx, int[] tex, boolean mustFlipVertically) {
@@ -264,14 +266,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
mustFlipVertically);
}
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
imgTex.getTexture().destroy(gl);
}
protected void removeAllImageTextures(GL gl) {
if(null != texFrames) {
for(int i=0; i<textureCount; i++) {
- final TextureFrame imgTex = texFrames[i];
+ final TextureSequence.TextureFrame imgTex = texFrames[i];
if(null != imgTex) {
destroyTexImage(gl, imgTex);
texFrames[i] = null;
diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
index a5d41bc9c..c97f04225 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
@@ -25,7 +25,7 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package jogamp.opengl.av;
+package jogamp.opengl.util.av;
import java.io.IOException;
import java.net.URLConnection;
@@ -34,21 +34,21 @@ import java.nio.ByteBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GLProfile;
-import jogamp.opengl.av.GLMediaPlayerImpl;
+import jogamp.opengl.util.av.GLMediaPlayerImpl;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.util.IOUtil;
import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.util.texture.TextureSequence;
/***
* A dummy null media player implementation using a static test frame (if available).
*/
public class NullGLMediaPlayer extends GLMediaPlayerImpl {
private TextureData texData = null;
- private TextureFrame frame = null;
+ private TextureSequence.TextureFrame frame = null;
private long pos_ms = 0;
private long pos_start = 0;
@@ -91,21 +91,16 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl {
}
@Override
- public TextureFrame getLastTexture() {
+ public TextureSequence.TextureFrame getLastTexture() {
return frame;
}
@Override
- public TextureFrame getNextTexture(GL gl, boolean blocking) {
+ public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) {
return frame;
}
@Override
- public TextureCoords getTextureCoords() {
- return frame.getTexture().getImageTexCoords();
- }
-
- @Override
public long getCurrentPosition() {
pos_ms = System.currentTimeMillis() - pos_start;
validatePos();
@@ -151,20 +146,23 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl {
}
@Override
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
- super.destroyTexImage(gl, imgTex);
- }
-
- @Override
- protected TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
Texture texture = super.createTexImageImpl(gl, idx, tex, false);
if(null != texData) {
texture.updateImage(gl, texData);
+ texData.destroy();
+ texData = null;
}
- frame = new TextureFrame( texture );
+ frame = new TextureSequence.TextureFrame( texture );
return frame;
}
+ @Override
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
+ frame = null;
+ super.destroyTexImage(gl, imgTex);
+ }
+
private void validatePos() {
boolean considerPausing = false;
if( 0 > pos_ms) {