diff options
author | Sven Gothel <[email protected]> | 2012-04-05 03:22:04 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-04-05 03:22:04 +0200 |
commit | 9d1ee2b69fc943559a17dcd5d59984f8bba15296 (patch) | |
tree | 8402f40f500a18f26e8e7580e0a2185c35c02726 /src/jogl/classes | |
parent | a4c8271adc1932903a34e34bee24ff274ed1a81e (diff) |
GLMediaPlayer: Use URLConnection to clarify emphasize passing an available connected URL. API doc: Useing html table for state chart
Diffstat (limited to 'src/jogl/classes')
4 files changed, 29 insertions, 44 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java index 95f7cc8b4..f3ff61e34 100644 --- a/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/av/GLMediaPlayer.java @@ -1,7 +1,7 @@ package com.jogamp.opengl.av; import java.io.IOException; -import java.net.URL; +import java.net.URLConnection; import javax.media.opengl.GL; import javax.media.opengl.GLException; @@ -12,14 +12,15 @@ import com.jogamp.opengl.util.texture.Texture; /** * Lifecycle of an GLMediaPlayer: - * <ul> - * <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> + * <table border="1"> + * <tr><th>action</th> <th>state before</th> <th>state after</th></tr> + * <tr><td>{@link #initStream(URLConnection)}</td> <td>UninitializedStream</td> <td>UninitializedGL</td></tr> + * <tr><td>{@link #initGL(GL)}</td> <td>UninitializedGL</td> <td>Stopped</td></tr> + * <tr><td>{@link #start()}</td> <td>Stopped, Paused</td> <td>Playing</td></tr> + * <tr><td>{@link #stop()}</td> <td>Playing, Paused</td> <td>Stopped</td></tr> + * <tr><td>{@link #pause()}</td> <td>Playing</td> <td>Paused</td></tr> + * <tr><td>{@link #destroy(GL)}</td> <td>ANY</td> <td>UninitializedStream</td></tr> + * </table> */ public interface GLMediaPlayer { public static final boolean DEBUG = Debug.debug("GLMediaPlayer"); @@ -71,7 +72,7 @@ public interface GLMediaPlayer { * @throws IOException in case of difficulties to open or process the stream * @throws IllegalStateException if not invoked in state UninitializedStream */ - public State initStream(URL url) throws IllegalStateException, IOException; + public State initStream(URLConnection urlConn) throws IllegalStateException, IOException; /** * Initializes all GL related resources. @@ -141,7 +142,7 @@ public interface GLMediaPlayer { */ public TextureFrame getNextTexture(); - public URL getURL(); + public URLConnection getURLConnection(); /** * <i>Warning:</i> Optional information, may not be supported by implementation. diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 037ab779c..4325dd8ee 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -150,9 +150,9 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { @Override protected void initStreamImplPreGL() throws IOException { - if(null!=mp && null!=url) { + if(null!=mp && null!=urlConn) { try { - final Uri uri = Uri.parse(url.toExternalForm()); + final Uri uri = Uri.parse(urlConn.getURL().toExternalForm()); mp.setDataSource(StaticContext.getContext(), uri); } catch (IllegalArgumentException e) { throw new RuntimeException(e); @@ -164,7 +164,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { try { mp.prepare(); } catch (IOException ioe) { - throw new IOException("MediaPlayer failed to process stream <"+url.toExternalForm()+">: "+ioe.getMessage(), ioe); + throw new IOException("MediaPlayer failed to process stream <"+urlConn.getURL().toExternalForm()+">: "+ioe.getMessage(), ioe); } width = mp.getVideoWidth(); diff --git a/src/jogl/classes/jogamp/opengl/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/av/GLMediaPlayerImpl.java index 5ca402196..93b56e316 100644 --- a/src/jogl/classes/jogamp/opengl/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/av/GLMediaPlayerImpl.java @@ -1,7 +1,7 @@ package jogamp.opengl.av; import java.io.IOException; -import java.net.URL; +import java.net.URLConnection; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -36,7 +36,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST }; protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; - protected URL url = null; + protected URLConnection urlConn = null; protected float playSpeed = 1.0f; @@ -135,12 +135,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final State getState() { return state; } @Override - public final State initStream(URL url) throws IllegalStateException, IOException { + public final State initStream(URLConnection urlConn) throws IllegalStateException, IOException { if(State.UninitializedStream != state) { throw new IllegalStateException("Instance not in state "+State.UninitializedStream+", but "+state); } - this.url = url; - if (this.url != null) { + this.urlConn = urlConn; + if (this.urlConn != null) { initStreamImplPreGL(); state = State.UninitializedGL; } @@ -234,7 +234,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, texMinMagFilter[0]); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[0]); + gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[1]); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, texWrapST[0]); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, texWrapST[1]); @@ -291,8 +291,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected abstract void destroyImpl(GL gl); @Override - public synchronized URL getURL() { - return url; + public synchronized URLConnection getURLConnection() { + return urlConn; } @Override @@ -338,7 +338,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public synchronized String toString() { final float ct = getCurrentPosition() / 1000.0f, tt = getDuration() / 1000.0f; - return "GLMediaPlayer ["+state+", "+frameNumber+"/"+totalFrames+" frames, "+ct+"/"+tt+"s, stream [video ["+vcodec+", "+width+"x"+height+", "+fps+"fps, "+bps+"bsp], "+url.toExternalForm()+"]]"; + return "GLMediaPlayer ["+state+", "+frameNumber+"/"+totalFrames+" frames, "+ct+"/"+tt+"s, stream [video ["+vcodec+", "+width+"x"+height+", "+fps+"fps, "+bps+"bsp], "+urlConn.getURL().toExternalForm()+"]]"; } @Override diff --git a/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java index 1005abd80..99639ae62 100644 --- a/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java @@ -1,16 +1,14 @@ package jogamp.opengl.omx; -import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; +import java.net.URL; import javax.media.opengl.GL; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import com.jogamp.opengl.av.GLMediaEventListener; -import com.jogamp.opengl.av.GLMediaPlayer.TextureFrame; import jogamp.opengl.av.EGLMediaPlayerImpl; import jogamp.opengl.egl.EGL; @@ -69,25 +67,11 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { if(0==moviePtr) { throw new GLException("OMX native instance null"); } - String path=null; - if (url.getProtocol() == null || "file".equals(url.getProtocol())) { - // CV only accepts absolute paths - try { - File file = new File(url.getPath()); - if (!file.exists()) { - throw new FileNotFoundException(file.toString()); - } - path = file.getCanonicalPath(); - System.out.println("setURL: path "+path); - } catch (Exception e) { - e.printStackTrace(); - throw new IOException(e); - } - } - path = replaceAll(path, "\\", "/").trim(); - if(null==path) { - throw new IOException("Couldn't parse stream URL: "+url); + final URL url = urlConn.getURL(); + if(!url.getProtocol().equals("file")) { + throw new IOException("Only file URLs are allowed: "+url); } + final String path=url.getPath(); System.out.println("setURL: clean path "+path); System.out.println("setURL: p1 "+this); |