diff options
author | Sven Gothel <[email protected]> | 2013-08-17 01:30:25 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-08-17 01:30:25 +0200 |
commit | 2cb284545a2a0fd35762a104fee8107234808389 (patch) | |
tree | 657e1865c4a941aaee2afaf09f2652c11510034f /src/test/com/jogamp/opengl | |
parent | 3f262a9f4653a09b28a84442378428c18b64775f (diff) |
GLMediaPlayer: Use URI instead of URL / Misc refinements
- GLMediaPlayer: Use URI instead of URL, allowing passing a non resolved location
- Java's URL doesn't allow 'other' protocols, i.e. RTSP
- GLMediaPlayer: Add Table of test streams and their location ..
- FFMPEGMediaPlayer
- Handle av_read_play/pause response on java side, ignore error - simply dump in DEBUG_NATIVE mode
Diffstat (limited to 'src/test/com/jogamp/opengl')
5 files changed, 120 insertions, 55 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index e905bfeab..2c434f38a 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -28,6 +28,9 @@ package com.jogamp.opengl.test.android; import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URLConnection; import java.util.Arrays; @@ -65,12 +68,12 @@ public class MovieCubeActivity0 extends NewtBaseActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - String[] urls0 = new String[] { + String[] streamLocs = new String[] { System.getProperty("jnlp.media0_url2"), System.getProperty("jnlp.media0_url1"), System.getProperty("jnlp.media0_url0") }; - final URLConnection urlConnection0 = getResource(urls0, 0); - if(null == urlConnection0) { throw new RuntimeException("no media reachable: "+Arrays.asList(urls0)); } + final URI streamLoc = getURI(streamLocs, 0, false); + if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } // also initializes JOGL final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2()); @@ -85,7 +88,7 @@ public class MovieCubeActivity0 extends NewtBaseActivity { final Animator animator = new Animator(); // Main - final MovieCube demoMain = new MovieCube(urlConnection0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, -2.3f, 0f, 0f); + final MovieCube demoMain = new MovieCube(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, -2.3f, 0f, 0f); final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); glWindowMain.setFullscreen(true); setContentView(getWindow(), glWindowMain); @@ -106,14 +109,32 @@ public class MovieCubeActivity0 extends NewtBaseActivity { Log.d(TAG, "onCreate - X"); } - static URLConnection getResource(String path[], int off) { - URLConnection uc = null; - for(int i=off; null==uc && i<path.length; i++) { + static URI getURI(String path[], int off, boolean checkAvail) { + URI uri = null; + for(int i=off; null==uri && i<path.length; i++) { if(null != path[i] && path[i].length()>0) { - uc = IOUtil.getResource(path[i], null); - Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uc)); + if( checkAvail ) { + final URLConnection uc = IOUtil.getResource(path[i], null); + if( null != uc ) { + try { + uri = uc.getURL().toURI(); + } catch (URISyntaxException e) { + uri = null; + } + if( uc instanceof HttpURLConnection ) { + ((HttpURLConnection)uc).disconnect(); + } + } + } else { + try { + uri = new URI(path[i]); + } catch (URISyntaxException e) { + uri = null; + } + } + Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uri)); } } - return uc; + return uri; } } diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index 7a92360fb..2c8f0eb50 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -28,6 +28,9 @@ package com.jogamp.opengl.test.android; import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URLConnection; import java.util.Arrays; @@ -65,12 +68,12 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - String[] urls0 = new String[] { + final String[] streamLocs = new String[] { System.getProperty("jnlp.media0_url2"), System.getProperty("jnlp.media0_url1"), System.getProperty("jnlp.media0_url0") }; - final URLConnection urlConnection0 = getResource(urls0, 0); - if(null == urlConnection0) { throw new RuntimeException("no media reachable: "+Arrays.asList(urls0)); } + final URI streamLoc = getURI(streamLocs, 0, false); + if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } // also initializes JOGL final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2()); @@ -85,7 +88,7 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { final Animator animator = new Animator(); // Main - final MovieSimple demoMain = new MovieSimple(urlConnection0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO); + final MovieSimple demoMain = new MovieSimple(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO); demoMain.setScaleOrig(true); final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); glWindowMain.setFullscreen(true); @@ -106,14 +109,32 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { Log.d(TAG, "onCreate - X"); } - static URLConnection getResource(String path[], int off) { - URLConnection uc = null; - for(int i=off; null==uc && i<path.length; i++) { + static URI getURI(String path[], int off, boolean checkAvail) { + URI uri = null; + for(int i=off; null==uri && i<path.length; i++) { if(null != path[i] && path[i].length()>0) { - uc = IOUtil.getResource(path[i], null); - Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uc)); + if( checkAvail ) { + final URLConnection uc = IOUtil.getResource(path[i], null); + if( null != uc ) { + try { + uri = uc.getURL().toURI(); + } catch (URISyntaxException e) { + uri = null; + } + if( uc instanceof HttpURLConnection ) { + ((HttpURLConnection)uc).disconnect(); + } + } + } else { + try { + uri = new URI(path[i]); + } catch (URISyntaxException e) { + uri = null; + } + } + Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uri)); } } - return uc; + return uri; } } diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index d0fb41828..df6b91582 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -28,6 +28,9 @@ package com.jogamp.opengl.test.android; import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URLConnection; import java.util.Arrays; @@ -74,22 +77,22 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { final boolean mPlayerSharedHUD = mPlayerHUD && Boolean.valueOf(System.getProperty("jnlp.mplayer.hud.shared")); Log.d(TAG, "onCreate - 0 - mPlayerLocal "+mPlayerLocal+", mPlayerNoScale "+mPlayerNoZoom+", mPlayerHUD "+mPlayerHUD+", mPlayerSharedHUD "+mPlayerSharedHUD); - String[] urls0 = new String[] { + String[] streamLocs = new String[] { System.getProperty("jnlp.media0_url2"), System.getProperty("jnlp.media0_url1"), System.getProperty("jnlp.media0_url0") }; - final URLConnection urlConnection0 = getResource(urls0, mPlayerLocal ? 2 : 0); - if(null == urlConnection0) { throw new RuntimeException("no media reachable: "+Arrays.asList(urls0)); } + final URI streamLoc0 = getURI(streamLocs, mPlayerLocal ? 2 : 0, false); + if(null == streamLoc0) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } - final URLConnection urlConnection1; + final URI streamLoc1; { - URLConnection _urlConnection1 = null; + URI _streamLoc1 = null; if(mPlayerHUD && !mPlayerSharedHUD) { String[] urls1 = new String[] { System.getProperty("jnlp.media1_url0") }; - _urlConnection1 = getResource(urls1, 0); + _streamLoc1 = getURI(urls1, 0, false); } - if(null == _urlConnection1) { _urlConnection1 = urlConnection0; } - urlConnection1 = _urlConnection1; + if(null == _streamLoc1) { _streamLoc1 = streamLoc0; } + streamLoc1 = _streamLoc1; } setTransparencyTheme(); @@ -111,7 +114,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { final Animator animator = new Animator(); // Main - final MovieSimple demoMain = new MovieSimple(urlConnection0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO); + final MovieSimple demoMain = new MovieSimple(streamLoc0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO); if(mPlayerHUD) { demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP); demoMain.setTransparency(0.9f); @@ -154,7 +157,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { glWindowHUD.addGLEventListener(new MovieSimple(sharedPlayer)); } else { try { - glWindowHUD.addGLEventListener(new MovieSimple(urlConnection1, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO)); + glWindowHUD.addGLEventListener(new MovieSimple(streamLoc1, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO)); } catch (IOException e) { e.printStackTrace(); } @@ -190,14 +193,32 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { Log.d(TAG, "onCreate - X"); } - static URLConnection getResource(String path[], int off) { - URLConnection uc = null; - for(int i=off; null==uc && i<path.length; i++) { + static URI getURI(String path[], int off, boolean checkAvail) { + URI uri = null; + for(int i=off; null==uri && i<path.length; i++) { if(null != path[i] && path[i].length()>0) { - uc = IOUtil.getResource(path[i], null); - Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uc)); + if( checkAvail ) { + final URLConnection uc = IOUtil.getResource(path[i], null); + if( null != uc ) { + try { + uri = uc.getURL().toURI(); + } catch (URISyntaxException e) { + uri = null; + } + if( uc instanceof HttpURLConnection ) { + ((HttpURLConnection)uc).disconnect(); + } + } + } else { + try { + uri = new URI(path[i]); + } catch (URISyntaxException e) { + uri = null; + } + } + Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uri)); } } - return uc; + return uri; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index b673a9d2a..a9c200943 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -34,9 +34,8 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; +import java.net.URI; +import java.net.URISyntaxException; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; @@ -65,19 +64,19 @@ import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; public class MovieCube implements GLEventListener, GLMediaEventListener { static boolean waitForKey = false; int textureCount = 3; // default - threaded - final URLConnection stream; + final URI streamLoc; final int vid, aid; final float zoom0, rotx, roty; TextureSequenceCubeES2 cube=null; GLMediaPlayer mPlayer=null; - public MovieCube() throws IOException { - this(new URL("http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4").openConnection(), + public MovieCube() throws IOException, URISyntaxException { + this(new URI("http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"), GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, -2.3f, 0f, 0f); } - public MovieCube(URLConnection stream, int vid, int aid, float zoom0, float rotx, float roty) throws IOException { - this.stream = stream; + public MovieCube(URI streamLoc, int vid, int aid, float zoom0, float rotx, float roty) throws IOException { + this.streamLoc = streamLoc; this.zoom0 = zoom0; this.rotx = rotx; this.roty = roty; @@ -170,7 +169,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { UITestCase.waitForKey("Init>"); } try { - mPlayer.initGLStream(gl, textureCount, stream, vid, aid); + mPlayer.initGLStream(gl, textureCount, streamLoc, vid, aid); } catch (Exception e) { e.printStackTrace(); if(null != mPlayer) { @@ -225,7 +224,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { cube.display(drawable); } - public static void main(String[] args) throws MalformedURLException, IOException, InterruptedException { + public static void main(String[] args) throws IOException, InterruptedException, URISyntaxException { int width = 510; int height = 300; int textureCount = 3; // default - threaded @@ -283,7 +282,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { System.err.println("forceGL3 "+forceGL3); System.err.println("forceGLDef "+forceGLDef); - final MovieCube mc = new MovieCube(new URL(url_s).openConnection(), vid, aid, -2.3f, 0f, 0f); + final MovieCube mc = new MovieCube(new URI(url_s), vid, aid, -2.3f, 0f, 0f); final GLProfile glp; if(forceGLDef) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index af9454464..9d91ce8c8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -29,9 +29,8 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.FloatBuffer; import javax.media.opengl.GL; @@ -72,6 +71,9 @@ import com.jogamp.opengl.util.texture.TextureCoords; import com.jogamp.opengl.util.texture.TextureSequence; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; +/** + * + */ public class MovieSimple implements GLEventListener, GLMediaEventListener { static boolean waitForKey = false; private int winWidth, winHeight; @@ -103,7 +105,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { } GLMediaPlayer mPlayer; - final URLConnection stream; + final URI stream; final int vid, aid; boolean mPlayerExternal; boolean mPlayerShared; @@ -213,13 +215,13 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { } }; - public MovieSimple(URLConnection stream, int vid, int aid) throws IOException { + public MovieSimple(URI streamLoc, int vid, int aid) throws IOException { mPlayerScaleOrig = false; mPlayerShared = false; mPlayerExternal = false; mPlayer = GLMediaPlayerFactory.createDefault(); mPlayer.addEventListener(this); - this.stream = stream; + this.stream = streamLoc; this.vid = vid; this.aid = aid; System.out.println("pC.1 "+mPlayer); @@ -590,7 +592,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { st.useProgram(gl, false); } - public static void main(String[] args) throws IOException, MalformedURLException { + public static void main(String[] args) throws IOException, URISyntaxException { int width = 640; int height = 600; int textureCount = 3; // default - threaded @@ -654,7 +656,8 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { System.err.println("forceGL3 "+forceGL3); System.err.println("forceGLDef "+forceGLDef); - final MovieSimple ms = new MovieSimple(new URL(url_s).openConnection(), vid, aid); + final URI streamURI = new URI(url_s); + final MovieSimple ms = new MovieSimple(streamURI, vid, aid); ms.setTextureCount(textureCount); ms.setScaleOrig(!zoom); ms.setOrthoProjection(ortho); |