summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/av
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-03 22:39:27 +0200
committerSven Gothel <[email protected]>2012-04-03 22:39:27 +0200
commit9e680fe86cd5b64aa758ce32666a6efa19118d3d (patch)
treea7d8b78d6c4b05f3e0321133004bc5eb746258f7 /src/jogl/classes/com/jogamp/opengl/av
parent081404e20ac6055244408c6a4a7e7c2089183983 (diff)
GLMediaPlayer/MovieSimple: Refine API (split setStream(GL, URL) -> initStream(URL) + initGL(GL)) .. IllegalStateException if wrong. Using internet streams of BigBuckBunny, if avail.
- Splitting the initialization in stream and GL allows using the stream information (eg: size, ..) for setting the GLDrawable properties .. - Make the impl. more bullet proof ..
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/av')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java
index 0d07f69ac..95f7cc8b4 100644
--- a/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java
@@ -4,6 +4,7 @@ import java.io.IOException;
import java.net.URL;
import javax.media.opengl.GL;
+import javax.media.opengl.GLException;
import jogamp.opengl.Debug;
@@ -12,17 +13,19 @@ import com.jogamp.opengl.util.texture.Texture;
/**
* Lifecycle of an GLMediaPlayer:
* <ul>
- * <li>{@link #setStream(GL, URL)}</li>
- * <li>{@link #start()}</li>
- * <li>{@link #stop()}</li>
- * <li>{@link #destroy(GL)}</li>
+ * <li>{@link #initStream(URL)} - UninitializedStream -> UninitializedGL</li>
+ * <li>{@link #initGL(GL)} - UninitializedGL -> Stopped</li>
+ * <li>{@link #start()} - Stopped/Paused -> Playing</li>
+ * <li>{@link #stop()} - Playing/Paused -> Stopped</li>
+ * <li>{@link #pause()} - Playing -> Paused</li>
+ * <li>{@link #destroy(GL)} - ANY -> UninitializedStream</li>
* </ul>
*/
public interface GLMediaPlayer {
public static final boolean DEBUG = Debug.debug("GLMediaPlayer");
public enum State {
- Uninitialized(0), Stopped(1), Playing(2), Paused(3);
+ UninitializedStream(0), UninitializedGL(1), Stopped(2), Playing(3), Paused(4);
public final int id;
@@ -61,21 +64,32 @@ public interface GLMediaPlayer {
public int[] getTextureWrapST();
/**
- * Sets the stream to be used. Initializes all stream related states and GL resources.
- * <ul>
- * <li>ANY -> Uninitialized - invokes destroy(GL)</li>
- * <li>Uninitialized -> Stopped</li>
- * </ul>
+ * Sets the stream to be used. Initializes all stream related states.
+ * <p>
+ * UninitializedStream -> UninitializedGL
+ * </p>
+ * @throws IOException in case of difficulties to open or process the stream
+ * @throws IllegalStateException if not invoked in state UninitializedStream
*/
- public void setStream(GL gl, URL url) throws IOException;
+ public State initStream(URL url) throws IllegalStateException, IOException;
+ /**
+ * Initializes all GL related resources.
+ * <p>
+ * UninitializedGL -> Stopped
+ * </p>
+ * @throws GLException in case of difficulties to initialize the GL resources
+ * @throws IllegalStateException if not invoked in state UninitializedGL
+ */
+ public State initGL(GL gl) throws IllegalStateException, GLException;
+
/**
* Releases the GL and stream resources.
* <p>
* <code>ANY</code> -> Uninitialized
* </p>
*/
- public void destroy(GL gl);
+ public State destroy(GL gl);
public void setPlaySpeed(float rate);
@@ -107,6 +121,8 @@ public interface GLMediaPlayer {
public long getCurrentPosition();
/**
+ * Allowed in state Stopped, Playing and Paused, otherwise ignored.
+ *
* @param msec absolute desired time position in milliseconds
* @return time current position in milliseconds, after seeking to the desired position
**/
@@ -125,8 +141,6 @@ public interface GLMediaPlayer {
*/
public TextureFrame getNextTexture();
- public boolean isValid();
-
public URL getURL();
/**