diff options
Diffstat (limited to 'src')
16 files changed, 113 insertions, 109 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 4fffd9fab..2ad102235 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -27,14 +27,13 @@ */ package com.jogamp.opengl.util.av; -import java.net.URI; - import javax.media.opengl.GL; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import jogamp.opengl.Debug; +import com.jogamp.common.net.Uri; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; import com.jogamp.opengl.util.TimeFrameI; @@ -46,18 +45,18 @@ import com.jogamp.opengl.util.TimeFrameI; * Audio maybe supported and played back internally or via an {@link AudioSink} implementation. * </p> * <p> - * Audio and video streams can be selected or muted via {@link #initStream(URI, int, int, int)} + * Audio and video streams can be selected or muted via {@link #initStream(Uri, int, int, int)} * using the appropriate <a href="#streamIDs">stream id</a>'s. * </p> * <p> - * Camera input can be selected using the {@link #CameraInputScheme} URI. + * Camera input can be selected using the {@link #CameraInputScheme} Uri. * </p> * * <a name="streamworker"><h5><i>StreamWorker</i> Decoding Thread</h5></a> * <p> * Most of the stream processing is performed on the decoding thread, a.k.a. <i>StreamWorker</i>: * <ul> - * <li>Stream initialization triggered by {@link #initStream(URI, int, int, int) initStream(..)} - User gets notified whether the stream has been initialized or not via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long) attributesChanges(..)}.</li> + * <li>Stream initialization triggered by {@link #initStream(Uri, int, int, int) initStream(..)} - User gets notified whether the stream has been initialized or not via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long) attributesChanges(..)}.</li> * <li>Stream decoding - User gets notified of a new frame via {@link GLMediaEventListener#newFrameAvailable(GLMediaPlayer, com.jogamp.opengl.util.texture.TextureSequence.TextureFrame, long) newFrameAvailable(...)}.</li> * <li>Caught <a href="#streamerror">exceptions on the decoding thread</a> are delivered as {@link StreamException}s.</li> * </ul> @@ -83,7 +82,7 @@ import com.jogamp.opengl.util.TimeFrameI; * <p> * <table border="1"> * <tr><th>Action</th> <th>{@link State} Before</th> <th>{@link State} After</th> <th>{@link GLMediaEventListener Event}</th></tr> - * <tr><td>{@link #initStream(URI, int, int, int)}</td> <td>{@link State#Uninitialized Uninitialized}</td> <td>{@link State#Initialized Initialized}<sup><a href="#streamworker">1</a></sup>, {@link State#Uninitialized Uninitialized}</td> <td>{@link GLMediaEventListener#EVENT_CHANGE_INIT EVENT_CHANGE_INIT} or ( {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} + {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} )</td></tr> + * <tr><td>{@link #initStream(Uri, int, int, int)}</td> <td>{@link State#Uninitialized Uninitialized}</td> <td>{@link State#Initialized Initialized}<sup><a href="#streamworker">1</a></sup>, {@link State#Uninitialized Uninitialized}</td> <td>{@link GLMediaEventListener#EVENT_CHANGE_INIT EVENT_CHANGE_INIT} or ( {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} + {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} )</td></tr> * <tr><td>{@link #initGL(GL)}</td> <td>{@link State#Initialized Initialized}</td> <td>{@link State#Paused Paused}, , {@link State#Uninitialized Uninitialized}</td> <td>{@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE} or ( {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} + {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} )</td></tr> * <tr><td>{@link #play()}</td> <td>{@link State#Paused Paused}</td> <td>{@link State#Playing Playing}</td> <td>{@link GLMediaEventListener#EVENT_CHANGE_PLAY EVENT_CHANGE_PLAY}</td></tr> * <tr><td>{@link #pause(boolean)}</td> <td>{@link State#Playing Playing}</td> <td>{@link State#Paused Paused}</td> <td>{@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE}</td></tr> @@ -183,6 +182,9 @@ import com.jogamp.opengl.util.TimeFrameI; * <!-- <tr><td> title </td><td colspan=3> url1 </td><td> url2 </td></tr> * </table> * </p> + * <p> + * Since 2.3.0 this interface uses {@link Uri} instead of {@link java.net.URI}. + * </p> */ public interface GLMediaPlayer extends TextureSequence { public static final boolean DEBUG = Debug.debug("GLMediaPlayer"); @@ -200,10 +202,10 @@ public interface GLMediaPlayer extends TextureSequence { public static final int STREAM_ID_AUTO = -1; /** - * {@link URI#getScheme() URI scheme} name {@value} for camera input. E.g. <code>camera:/0</code> + * {@link Uri#scheme Uri scheme} name {@value} for camera input. E.g. <code>camera:/0</code> * for the 1st camera device. * <p> - * The {@link URI#getRawPath() URI path} is being used to identify the camera (<i>ID</i>), + * The {@link Uri#path Uri path} is being used to identify the camera (<i>ID</i>), * where the root fwd-slash is being cut-off. * </p> * <p> @@ -211,7 +213,7 @@ public interface GLMediaPlayer extends TextureSequence { * ranging from [0..<i>max-number</i>]. * </p> * <p> - * The {@link URI#getRawQuery() URI query} is used to pass options to the camera + * The {@link Uri#query Uri query} is used to pass options to the camera * using <i>;</i> as the separator. The latter avoids trouble w/ escaping. * </p> * <pre> @@ -221,13 +223,13 @@ public interface GLMediaPlayer extends TextureSequence { * camera://somewhere/<id>?size=640x480;rate=15 * </pre> * <pre> - * URI: [scheme:][//authority][path][?query][#fragment] + * Uri: [scheme:][//authority][path][?query][#fragment] * w/ authority: [user-info@]host[:port] * Note: 'path' starts w/ fwd slash * </pre> * </p> */ - public static final String CameraInputScheme = "camera"; + public static final Uri.Encoded CameraInputScheme = Uri.Encoded.cast("camera"); /** Camera property {@value}, size as string, e.g. <code>1280x720</code>, <code>hd720</code>. May not be supported on all platforms. See {@link #CameraInputScheme}. */ public static final String CameraPropSizeS = "size"; /** Camera property {@value}. See {@link #CameraInputScheme}. */ @@ -361,8 +363,9 @@ public interface GLMediaPlayer extends TextureSequence { * Ignored if video is muted. * @throws IllegalStateException if not invoked in {@link State#Uninitialized} * @throws IllegalArgumentException if arguments are invalid + * @since 2.3.0 */ - public void initStream(URI streamLoc, int vid, int aid, int textureCount) throws IllegalStateException, IllegalArgumentException; + public void initStream(Uri streamLoc, int vid, int aid, int textureCount) throws IllegalStateException, IllegalArgumentException; /** * Returns the {@link StreamException} caught in the decoder thread, or <code>null</code> if none occured. @@ -379,7 +382,7 @@ public interface GLMediaPlayer extends TextureSequence { * <p> * <a href="#lifecycle">Lifecycle</a>: {@link State#Initialized} -> {@link State#Paused} or {@link State#Initialized} * </p> - * Argument <code>gl</code> is ignored if video is muted, see {@link #initStream(URI, int, int, int)}. + * Argument <code>gl</code> is ignored if video is muted, see {@link #initStream(Uri, int, int, int)}. * * @param gl current GL object. Maybe <code>null</code>, for audio only. * @throws IllegalStateException if not invoked in {@link State#Initialized}. @@ -391,7 +394,7 @@ public interface GLMediaPlayer extends TextureSequence { /** * If implementation uses a {@link AudioSink}, it's instance will be returned. * <p> - * The {@link AudioSink} instance is available after {@link #initStream(URI, int, int, int)}, + * The {@link AudioSink} instance is available after {@link #initStream(Uri, int, int, int)}, * if used by implementation. * </p> */ @@ -536,8 +539,11 @@ public interface GLMediaPlayer extends TextureSequence { @Override public TextureSequence.TextureFrame getNextTexture(GL gl) throws IllegalStateException; - /** Return the stream location, as set by {@link #initStream(URI, int, int, int)}. */ - public URI getURI(); + /** + * Return the stream location, as set by {@link #initStream(Uri, int, int, int)}. + * @since 2.3.0 + */ + public Uri getUri(); /** * <i>Warning:</i> Optional information, may not be supported by implementation. diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 6c507d209..8eed35ebb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.StringReader; +import java.net.URISyntaxException; import java.net.URLConnection; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -53,6 +54,7 @@ import javax.media.opengl.GLException; import jogamp.opengl.Debug; +import com.jogamp.common.net.Uri; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.VersionNumber; @@ -832,7 +834,8 @@ public class ShaderCode { URLConnection nextConn = null; // Try relative of current shader location - nextConn = IOUtil.openURL(IOUtil.getRelativeOf(conn.getURL(), includeFile), "ShaderCode.relativeOf "); + final Uri relUri = Uri.valueOf( conn.getURL() ).getRelativeOf(new Uri.Encoded( includeFile, Uri.PATH_LEGAL )); + nextConn = IOUtil.openURL(relUri.toURL(), "ShaderCode.relativeOf "); if (nextConn == null) { // Try relative of class and absolute nextConn = IOUtil.getResource(context, includeFile); @@ -846,6 +849,8 @@ public class ShaderCode { result.append(line + "\n"); } } + } catch (final URISyntaxException e) { + throw new IOException(e); } finally { IOUtil.close(reader, false); } diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 24b89cd02..495887e0f 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -254,7 +254,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { @Override protected final void initStreamImpl(final int vid, final int aid) throws IOException { - if( null == getURI() ) { + if( null == getUri() ) { return; } if( null == mp && null == cam ) { @@ -263,7 +263,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } else { int cameraId = 0; try { - cameraId = Integer.parseInt(cameraPath); + cameraId = Integer.parseInt(cameraPath.decode()); } catch (final NumberFormatException nfe) {} if( 0 <= cameraId && cameraId < Camera.getNumberOfCameras() ) { cam = Camera.open(cameraId); @@ -280,7 +280,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } // else FIXME: Select aid ! // Note: Both FIXMEs seem to be n/a via Android's MediaPlayer -> Switch to API level 16 MediaCodec/MediaExtractor .. try { - final Uri _uri = Uri.parse(getURI().toString()); + final Uri _uri = Uri.parse(getUri().toString()); mp.setDataSource(StaticContext.getContext(), _uri); } catch (final IllegalArgumentException e) { throw new RuntimeException(e); @@ -293,7 +293,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { try { mp.prepare(); } catch (final IOException ioe) { - throw new IOException("MediaPlayer failed to process stream <"+getURI().toString()+">: "+ioe.getMessage(), ioe); + throw new IOException("MediaPlayer failed to process stream <"+getUri().toString()+">: "+ioe.getMessage(), ioe); } final int r_aid = GLMediaPlayer.STREAM_ID_NONE == aid ? GLMediaPlayer.STREAM_ID_NONE : 1 /* fake */; final String icodec = "android"; @@ -381,7 +381,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { cam.setPreviewTexture(sTexFrame.surfaceTex); cam.startPreview(); } catch (final IOException ioe) { - throw new RuntimeException("MediaPlayer failed to process stream <"+getURI().toString()+">: "+ioe.getMessage(), ioe); + throw new RuntimeException("MediaPlayer failed to process stream <"+getUri().toString()+">: "+ioe.getMessage(), ioe); } } if( null != surface ) { diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 05e192bbc..0969199c6 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -28,7 +28,6 @@ package jogamp.opengl.util.av; import java.io.IOException; -import java.net.URI; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -46,7 +45,8 @@ import javax.media.opengl.GLProfile; import jogamp.opengl.Debug; -import com.jogamp.common.net.URIQueryProps; +import com.jogamp.common.net.UriQueryProps; +import com.jogamp.common.net.Uri; import com.jogamp.common.os.Platform; import com.jogamp.common.util.LFRingbuffer; import com.jogamp.common.util.Ringbuffer; @@ -92,15 +92,15 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private final int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; /** User requested URI stream location. */ - private URI streamLoc = null; + private Uri streamLoc = null; /** * In case {@link #streamLoc} is a {@link GLMediaPlayer#CameraInputScheme}, * {@link #cameraPath} holds the URI's path portion - * as parsed in {@link #initStream(URI, int, int, int)}. + * as parsed in {@link #initStream(Uri, int, int, int)}. * @see #cameraProps */ - protected String cameraPath = null; + protected Uri.Encoded cameraPath = null; /** Optional camera properties, see {@link #cameraPath}. */ protected Map<String, String> cameraProps = null; @@ -530,7 +530,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } @Override - public final void initStream(final URI streamLoc, final int vid, final int aid, final int reqTextureCount) throws IllegalStateException, IllegalArgumentException { + public final void initStream(final Uri streamLoc, final int vid, final int aid, final int reqTextureCount) throws IllegalStateException, IllegalArgumentException { synchronized( stateLock ) { if(State.Uninitialized != state) { throw new IllegalStateException("Instance not in state unintialized: "+this); @@ -556,13 +556,13 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { // Pre-parse for camera-input scheme cameraPath = null; cameraProps = null; - final String streamLocScheme = streamLoc.getScheme(); + final Uri.Encoded streamLocScheme = streamLoc.scheme; if( null != streamLocScheme && streamLocScheme.equals(CameraInputScheme) ) { - final String rawPath = streamLoc.getRawPath(); + final Uri.Encoded rawPath = streamLoc.path; if( null != rawPath && rawPath.length() > 0 ) { // cut-off root fwd-slash cameraPath = rawPath.substring(1); - final URIQueryProps props = URIQueryProps.create(streamLoc, ';'); + final UriQueryProps props = UriQueryProps.create(streamLoc, ';'); cameraProps = props.getProperties(); } else { throw new IllegalArgumentException("Camera path is empty: "+streamLoc.toString()); @@ -1472,7 +1472,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } @Override - public final URI getURI() { return streamLoc; } + public final Uri getUri() { return streamLoc; } @Override public final int getVID() { return vid; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 8ac1232b5..4601df67d 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -37,7 +37,6 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; -import com.jogamp.common.os.Platform; import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; @@ -292,7 +291,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("initStream: p1 "+this); } - final String streamLocS = IOUtil.decodeURIIfFilePath(getURI()); + final String streamLocS = IOUtil.getUriFilePathOrASCII(getUri()); destroyAudioSink(); if( GLMediaPlayer.STREAM_ID_NONE == aid ) { audioSink = AudioSinkFactory.createNull(); @@ -317,10 +316,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case HPUX: case LINUX: case SUNOS: - resStreamLocS = dev_video_linux + cameraPath; + resStreamLocS = dev_video_linux + cameraPath.decode(); break; case WINDOWS: - resStreamLocS = cameraPath; + resStreamLocS = cameraPath.decode(); break; case MACOS: case OPENKODE: @@ -345,7 +344,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc if(DEBUG) { System.err.println("initStream: p3 cameraPath "+cameraPath+", isCameraInput "+isCameraInput); - System.err.println("initStream: p3 stream "+getURI()+" -> "+streamLocS+" -> "+resStreamLocS); + System.err.println("initStream: p3 stream "+getUri()+" -> "+streamLocS+" -> "+resStreamLocS); System.err.println("initStream: p3 vid "+vid+", sizes "+sizes+", reqVideo "+rw+"x"+rh+"@"+rr+", aid "+aid+", aMaxChannelCount "+aMaxChannelCount+", aPrefSampleRate "+aPrefSampleRate); } natives.setStream0(moviePtr, resStreamLocS, isCameraInput, vid, sizes, rw, rh, rr, aid, aMaxChannelCount, aPrefSampleRate); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index 0eeb54bf6..5baf9e543 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -100,10 +100,10 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { if(0==moviePtr) { throw new GLException("OMX native instance null"); } - if(!getURI().getScheme().equals("file")) { - throw new IOException("Only file schemes are allowed: "+getURI()); + if( !getUri().isFileScheme() ) { + throw new IOException("Only file schemes are allowed: "+getUri()); } - final String path=getURI().getPath(); + final String path=getUri().path.decode(); if(DEBUG) { System.out.println("initGLStream: clean path "+path); } diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java index 79b6952ee..66959e90f 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java @@ -29,7 +29,6 @@ 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; @@ -39,12 +38,12 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; +import com.jogamp.common.net.Uri; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.opengl.GLWindow; - import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; @@ -75,7 +74,7 @@ public class MovieCubeActivity0a extends NewtBaseActivity { System.getProperty("jnlp.media0_url0"), System.getProperty("jnlp.media0_url1"), System.getProperty("jnlp.media0_url2") }; - final URI streamLoc = getURI(streamLocs, 0, false); + final Uri streamLoc = getUri(streamLocs, 0, false); if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } // also initializes JOGL @@ -136,15 +135,15 @@ public class MovieCubeActivity0a extends NewtBaseActivity { Log.d(TAG, "onCreate - X"); } - static URI getURI(final String path[], final int off, final boolean checkAvail) { - URI uri = null; + static Uri getUri(final String path[], final int off, final boolean checkAvail) { + Uri uri = null; for(int i=off; null==uri && i<path.length; i++) { if(null != path[i] && path[i].length()>0) { if( checkAvail ) { final URLConnection uc = IOUtil.getResource(path[i], null); if( null != uc ) { try { - uri = uc.getURL().toURI(); + uri = Uri.valueOf(uc.getURL()); } catch (final URISyntaxException e) { uri = null; } @@ -154,7 +153,7 @@ public class MovieCubeActivity0a extends NewtBaseActivity { } } else { try { - uri = new URI(path[i]); + uri = Uri.cast(path[i]); } catch (final URISyntaxException e) { uri = null; } diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java index 5303276a6..33dbe8fc5 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java @@ -29,7 +29,6 @@ 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; @@ -39,12 +38,12 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; +import com.jogamp.common.net.Uri; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.opengl.GLWindow; - import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; @@ -75,7 +74,7 @@ public class MovieCubeActivity0b extends NewtBaseActivity { System.getProperty("jnlp.media0_url0"), System.getProperty("jnlp.media0_url1"), System.getProperty("jnlp.media0_url2") }; - final URI streamLoc = getURI(streamLocs, 0, false); + final Uri streamLoc = getUri(streamLocs, 0, false); if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } // also initializes JOGL @@ -138,15 +137,15 @@ public class MovieCubeActivity0b extends NewtBaseActivity { Log.d(TAG, "onCreate - X"); } - static URI getURI(final String path[], final int off, final boolean checkAvail) { - URI uri = null; + static Uri getUri(final String path[], final int off, final boolean checkAvail) { + Uri uri = null; for(int i=off; null==uri && i<path.length; i++) { if(null != path[i] && path[i].length()>0) { if( checkAvail ) { final URLConnection uc = IOUtil.getResource(path[i], null); if( null != uc ) { try { - uri = uc.getURL().toURI(); + uri = Uri.valueOf(uc.getURL()); } catch (final URISyntaxException e) { uri = null; } @@ -156,7 +155,7 @@ public class MovieCubeActivity0b extends NewtBaseActivity { } } else { try { - uri = new URI(path[i]); + uri = Uri.cast(path[i]); } catch (final URISyntaxException e) { uri = null; } diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index 47e1b1796..5991e28ee 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.android; import java.net.HttpURLConnection; -import java.net.URI; import java.net.URISyntaxException; import java.net.URLConnection; import java.util.Arrays; @@ -38,13 +37,13 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; +import com.jogamp.common.net.Uri; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.opengl.GLWindow; - import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; @@ -74,7 +73,7 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { System.getProperty("jnlp.media0_url0"), System.getProperty("jnlp.media0_url1"), System.getProperty("jnlp.media0_url2") }; - final URI streamLoc = getURI(streamLocs, 0, false); + final Uri streamLoc = getUri(streamLocs, 0, false); if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } // also initializes JOGL @@ -129,15 +128,15 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { Log.d(TAG, "onCreate - X"); } - static URI getURI(final String path[], final int off, final boolean checkAvail) { - URI uri = null; + static Uri getUri(final String path[], final int off, final boolean checkAvail) { + Uri uri = null; for(int i=off; null==uri && i<path.length; i++) { if(null != path[i] && path[i].length()>0) { if( checkAvail ) { final URLConnection uc = IOUtil.getResource(path[i], null); if( null != uc ) { try { - uri = uc.getURL().toURI(); + uri = Uri.valueOf(uc.getURL()); } catch (final URISyntaxException e) { uri = null; } @@ -147,7 +146,7 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { } } else { try { - uri = new URI(path[i]); + uri = Uri.cast(path[i]); } catch (final URISyntaxException e) { uri = null; } diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index 7c99e2cf3..0267db514 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.android; import java.net.HttpURLConnection; -import java.net.URI; import java.net.URISyntaxException; import java.net.URLConnection; import java.util.Arrays; @@ -41,6 +40,7 @@ import javax.media.opengl.GLRunnable; import jogamp.newt.driver.android.NewtBaseActivity; +import com.jogamp.common.net.Uri; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Window; @@ -82,15 +82,15 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { System.getProperty("jnlp.media0_url0"), System.getProperty("jnlp.media0_url1"), System.getProperty("jnlp.media0_url2") }; - final URI streamLoc0 = getURI(streamLocs, 2, false); + final Uri streamLoc0 = getUri(streamLocs, 2, false); if(null == streamLoc0) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } - final URI streamLoc1; + final Uri streamLoc1; { - URI _streamLoc1 = null; + Uri _streamLoc1 = null; if(mPlayerHUD && !mPlayerSharedHUD) { final String[] urls1 = new String[] { System.getProperty("jnlp.media1_url0") }; - _streamLoc1 = getURI(urls1, 1, false); + _streamLoc1 = getUri(urls1, 1, false); } if(null == _streamLoc1) { _streamLoc1 = streamLoc0; } streamLoc1 = _streamLoc1; @@ -231,15 +231,15 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { Log.d(TAG, "onCreate - X"); } - static URI getURI(final String path[], final int off, final boolean checkAvail) { - URI uri = null; + static Uri getUri(final String path[], final int off, final boolean checkAvail) { + Uri uri = null; for(int i=off; null==uri && i<path.length; i++) { if(null != path[i] && path[i].length()>0) { if( checkAvail ) { final URLConnection uc = IOUtil.getResource(path[i], null); if( null != uc ) { try { - uri = uc.getURL().toURI(); + uri = Uri.valueOf(uc.getURL()); } catch (final URISyntaxException e) { uri = null; } @@ -249,7 +249,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { } } else { try { - uri = new URI(path[i]); + uri = Uri.cast(path[i]); } catch (final URISyntaxException e) { uri = null; } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index 784fe1009..b10a89a8f 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -2,7 +2,6 @@ package com.jogamp.opengl.test.junit.graph.demos; import java.io.File; import java.io.IOException; -import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; @@ -17,6 +16,7 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLPipelineFactory; import javax.media.opengl.GLRunnable; +import com.jogamp.common.net.Uri; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; @@ -536,7 +536,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { } } ); buttons.add(mPlayerButton); try { - final URI streamLoc = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); + final Uri streamLoc = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); mPlayer.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT); } catch (final URISyntaxException e1) { e1.printStackTrace(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java index e5e752d96..b2ebc7068 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av;
+import com.jogamp.common.net.Uri;
import com.jogamp.opengl.util.av.AudioSink;
import com.jogamp.opengl.util.av.GLMediaPlayer;
import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
@@ -36,7 +37,6 @@ import com.jogamp.opengl.util.av.GLMediaPlayerFactory; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame;
import java.io.File;
-import java.net.URI;
/**
* Parallel media player that demonstrate CrossFade of audio volume during playback.
@@ -141,7 +141,7 @@ public class CrossFadePlayer if(!file.exists()){
System.out.println("File do not exist");
} else {
- final URI uri = file.toURI();
+ final Uri uri = Uri.valueOf(file);
System.out.println("State of player "+ i +": " + player[i].getState().toString());
System.out.println("...initializing stream "+ i +"...");
player[i].initStream(uri, GLMediaPlayer.STREAM_ID_NONE, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT);
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 607bfd1b0..428eea42c 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 @@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av; import java.io.File; import java.io.IOException; -import java.net.URI; import java.net.URISyntaxException; import javax.media.opengl.GL; @@ -42,7 +41,7 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import com.jogamp.common.util.IOUtil; +import com.jogamp.common.net.Uri; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; @@ -81,13 +80,13 @@ public class MovieCube implements GLEventListener { private volatile boolean resetGLState = false; /** Blender's Big Buck Bunny: 24f 416p H.264, AAC 48000 Hz, 2 ch, mpeg stream. */ - public static final URI defURI; + public static final Uri defURI; static { - URI _defURI = null; + Uri _defURI = null; try { // Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream. // _defURI = new URI("http://video.webmfiles.org/big-buck-bunny_trailer.webm"); - _defURI = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); + _defURI = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); } catch (final URISyntaxException e) { e.printStackTrace(); } @@ -151,7 +150,7 @@ public class MovieCube implements GLEventListener { mPlayer = GLMediaPlayerFactory.createDefault(); } - public void initStream(final URI streamLoc, final int vid, final int aid, final int textureCount) { + public void initStream(final Uri streamLoc, final int vid, final int aid, final int textureCount) { mPlayer.initStream(streamLoc, vid, aid, textureCount); System.out.println("pC.1b "+mPlayer); } @@ -252,7 +251,7 @@ public class MovieCube implements GLEventListener { mPlayer.getAID(), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec()); final String text3 = String.format("video: id %d, kbps %d, codec %s", mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec()); - final String text4 = mPlayer.getURI().getRawPath(); + final String text4 = mPlayer.getUri().path.decode(); if( displayOSD && null != renderer ) { gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); if( null != regionFPS ) { @@ -517,11 +516,11 @@ public class MovieCube implements GLEventListener { } origSize = _origSize; } - final URI streamLoc; + final Uri streamLoc; if( null != url_s ) { - streamLoc = new URI(url_s); + streamLoc = Uri.cast( url_s ); } else if( null != file_s ) { - streamLoc = IOUtil.toURISimple(new File(file_s)); + streamLoc = Uri.valueOf(new File(file_s)); } else { streamLoc = defURI; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java index 9098ad00f..7a3a1ffc7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSBSStereo.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av; -import java.net.URI; import java.net.URISyntaxException; import java.nio.FloatBuffer; @@ -41,6 +40,7 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLUniformData; import javax.media.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.common.net.Uri; import com.jogamp.common.os.Platform; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; @@ -117,13 +117,13 @@ public class MovieSBSStereo implements StereoGLEventListener { private static final String myTextureLookupName = "myTexture2D"; /** Blender's Big Buck Bunny: 24f 416p H.264, AAC 48000 Hz, 2 ch, mpeg stream. */ - public static final URI defURI; + public static final Uri defURI; static { - URI _defURI = null; + Uri _defURI = null; try { // Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream. // _defURI = new URI("http://video.webmfiles.org/big-buck-bunny_trailer.webm"); - _defURI = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); + _defURI = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); } catch (final URISyntaxException e) { e.printStackTrace(); } @@ -189,7 +189,7 @@ public class MovieSBSStereo implements StereoGLEventListener { mPlayer.getAID(), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec()); final String text3 = String.format("video: id %d, kbps %d, codec %s", mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec()); - final String text4 = mPlayer.getURI().getRawPath(); + final String text4 = mPlayer.getUri().path.decode(); if( displayOSD && null != renderer ) { // We share ClearColor w/ MovieSimple's init ! final float pixelSize = font.getPixelSize(fontSize, dpiH); @@ -327,7 +327,7 @@ public class MovieSBSStereo implements StereoGLEventListener { System.out.println("pC.1a "+mPlayer); } - public void initStream(final URI streamLoc, final int vid, final int aid, final int textureCount) { + public void initStream(final Uri streamLoc, final int vid, final int aid, final int textureCount) { mPlayer.initStream(streamLoc, vid, aid, textureCount); System.out.println("pC.1b "+mPlayer); } 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 0d1191528..d963294b4 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 @@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av; import java.io.File; import java.io.IOException; -import java.net.URI; import java.net.URISyntaxException; import java.nio.FloatBuffer; @@ -46,8 +45,8 @@ import javax.media.opengl.GLProfile; import javax.media.opengl.GLUniformData; import javax.media.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.common.net.Uri; import com.jogamp.common.os.Platform; -import com.jogamp.common.util.IOUtil; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; @@ -122,13 +121,13 @@ public class MovieSimple implements GLEventListener { private static final String myTextureLookupName = "myTexture2D"; /** Blender's Big Buck Bunny: 24f 416p H.264, AAC 48000 Hz, 2 ch, mpeg stream. */ - public static final URI defURI; + public static final Uri defURI; static { - URI _defURI = null; + Uri _defURI = null; try { // Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream. // _defURI = new URI("http://video.webmfiles.org/big-buck-bunny_trailer.webm"); - _defURI = new URI("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); + _defURI = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4"); } catch (final URISyntaxException e) { e.printStackTrace(); } @@ -194,7 +193,7 @@ public class MovieSimple implements GLEventListener { mPlayer.getAID(), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec()); final String text3 = String.format("video: id %d, kbps %d, codec %s", mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec()); - final String text4 = mPlayer.getURI().getRawPath(); + final String text4 = mPlayer.getUri().path.decode(); if( displayOSD && null != renderer ) { // We share ClearColor w/ MovieSimple's init ! final float pixelSize = font.getPixelSize(fontSize, dpiH); @@ -388,7 +387,7 @@ public class MovieSimple implements GLEventListener { System.out.println("pC.1a shared "+mPlayerShared+", "+mPlayer); } - public void initStream(final URI streamLoc, final int vid, final int aid, final int textureCount) { + public void initStream(final Uri streamLoc, final int vid, final int aid, final int textureCount) { mPlayer.initStream(streamLoc, vid, aid, textureCount); System.out.println("pC.1b "+mPlayer); } @@ -988,14 +987,14 @@ public class MovieSimple implements GLEventListener { } origSize = _origSize; } - final URI streamLoc0; + final Uri streamLoc0; if( null != urls_s[0] ) { - streamLoc0 = new URI(urls_s[0]); + streamLoc0 = Uri.cast( urls_s[0] ); } else if( null != file_s1 ) { final File movieFile = new File(file_s1); - streamLoc0 = movieFile.toURI(); + streamLoc0 = Uri.valueOf(movieFile); } else if( null != file_s2 ) { - streamLoc0 = IOUtil.toURISimple(new File(file_s2)); + streamLoc0 = Uri.valueOf(new File(file_s2)); } else { streamLoc0 = defURI; } @@ -1049,12 +1048,12 @@ public class MovieSimple implements GLEventListener { windows[i].setVisible(true); anim.add(windows[i]); - final URI streamLocN; + final Uri streamLocN; if( 0 == i ) { streamLocN = streamLoc0; } else { if( null != urls_s[i] ) { - streamLocN = new URI(urls_s[i]); + streamLocN = Uri.cast(urls_s[i]); } else { streamLocN = defURI; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java index 142c941a5..89f69e000 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.stereo; import java.io.File; -import java.net.URI; import java.net.URISyntaxException; import java.util.Arrays; @@ -40,7 +39,7 @@ import javax.media.opengl.GLProfile; import jogamp.opengl.util.stereo.GenericStereoDevice; -import com.jogamp.common.util.IOUtil; +import com.jogamp.common.net.Uri; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; @@ -180,14 +179,14 @@ public class StereoDemo01 { } final StereoGLEventListener upstream; final MovieSBSStereo movieSimple; - final URI movieURI; + final Uri movieURI; if( null != useFilmFile ) { movieSimple = new MovieSBSStereo(); - movieURI = IOUtil.toURISimple(new File(useFilmFile)); + movieURI = Uri.valueOf(new File(useFilmFile)); upstream = movieSimple; } else if( null != useFilmURI ) { movieSimple = new MovieSBSStereo(); - movieURI = new URI(useFilmURI); + movieURI = Uri.cast(useFilmURI); upstream = movieSimple; } else { final GearsES2 demo = new GearsES2(0); @@ -204,7 +203,7 @@ public class StereoDemo01 { } public void doIt(final StereoDeviceFactory.DeviceType deviceType, final int deviceIndex, final int posx, final int posy, - final StereoGLEventListener upstream, final MovieSBSStereo movieSimple, final URI movieURI, + final StereoGLEventListener upstream, final MovieSBSStereo movieSimple, final Uri movieURI, final boolean biLinear, final int numSamples, final boolean useSingleFBO, final boolean useRecommendedDistortionBits, final boolean useVignette, final boolean useChromatic, final boolean useTimewarp, final boolean useAutoSwap, final boolean useAnimator, final boolean exclusiveContext) throws InterruptedException { |