aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-08-17 01:30:25 +0200
committerSven Gothel <[email protected]>2013-08-17 01:30:25 +0200
commit2cb284545a2a0fd35762a104fee8107234808389 (patch)
tree657e1865c4a941aaee2afaf09f2652c11510034f /src
parent3f262a9f4653a09b28a84442378428c18b64775f (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')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java38
-rw-r--r--src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java16
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java39
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java20
-rw-r--r--src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c20
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java41
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java41
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java53
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java21
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java19
11 files changed, 207 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 1b82bb994..512567f33 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
@@ -28,7 +28,7 @@
package com.jogamp.opengl.util.av;
import java.io.IOException;
-import java.net.URLConnection;
+import java.net.URI;
import javax.media.opengl.GL;
import javax.media.opengl.GLException;
@@ -42,14 +42,14 @@ import com.jogamp.opengl.util.texture.TextureSequence;
* with a video stream as it's source.
* <p>
* Audio maybe supported and played back internally or via an {@link AudioSink} implementation,
- * if an audio stream is selected in {@link #initGLStream(GL, int, URLConnection, int, int)}.
+ * if an audio stream is selected in {@link #initGLStream(GL, int, URI, int, int)}.
* </p>
*
* <a name="lifecycle"><h5>GLMediaPlayer Lifecycle</h5></a>
* <p>
* <table border="1">
* <tr><th>action</th> <th>state before</th> <th>state after</th></tr>
- * <tr><td>{@link #initGLStream(GL, int, URLConnection, int, int)}</td> <td>Uninitialized</td> <td>Paused</td></tr>
+ * <tr><td>{@link #initGLStream(GL, int, URI, int, int)}</td> <td>Uninitialized</td> <td>Paused</td></tr>
* <tr><td>{@link #play()}</td> <td>Paused</td> <td>Playing</td></tr>
* <tr><td>{@link #pause()}</td> <td>Playing</td> <td>Paused</td></tr>
* <tr><td>{@link #seek(int)}</td> <td>Playing, Paused</td> <td>Unchanged</td></tr>
@@ -121,6 +121,29 @@ import com.jogamp.opengl.util.texture.TextureSequence;
* <li>Film: +22ms and -22ms. audio ahead video / audio after video.</li>
* </ul>
* </p>
+ *
+ * <a name="teststreams"><h5>Test Streams</h5></a>
+ * <p>
+ * <table border="1">
+ * <tr><th colspan=5>Big Buck Bunny 24f 16:9</th></tr>
+ * <tr><td>Big Buck Bunny</td><td>320p</td><td>h264<td>aac 48000Hz 2 chan</td><td>http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4</td></tr>
+ * <tr><td>Big Buck Bunny</td><td>720p</td><td>mpeg4<td>ac3 48000Hz 5.1 chan</td><td>http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_surround.avi</td></tr>
+ * <tr><td>Big Buck Bunny</td><td>720p</td><td>msmpeg4v2<td>mp3 48000Hz 2 chan</td><td>http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_stereo.avi</td></tr>
+ * <tr><td>Big Buck Bunny</td><td>720p</td><td>theora<td>vorbis 48000Hz 2 chan</td><td>http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_stereo.ogg</td></tr>
+ * <tr><td>Big Buck Bunny</td><td>1080p</td><td>mpeg4<td>ac3 48000Hz 5.1 chan</td><td>http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_1080p_surround.avi</td></tr>
+ * <tr><th colspan=5>WebM/Matroska (vp8/vorbis)</th></tr>
+ * <tr><td>Big Buck Bunny Trailer</td><td>640p</td><td>vp8<td>vorbis 44100Hz 1 chan</td><td>http://video.webmfiles.org/big-buck-bunny_trailer.webm</td></tr>
+ * <tr><td>Elephants Dream</td><td>540p</td><td>vp8<td>vorbis 44100Hz 1 chan</td><td>http://video.webmfiles.org/elephants-dream.webm</td></tr>
+ * <tr><th colspan=5>You Tube http/rtsp</th></tr>
+ * <tr><td>Sintel</td><td colspan=3>http://www.youtube.com/watch?v=eRsGyueVLvQ</td><td>rtsp://v3.cache1.c.youtube.com/CiILENy73wIaGQn0LpXnygYbeRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp</td></tr>
+ * <tr><th colspan=5>Audio/Video Sync</th></tr>
+ * <tr><td>Five-minute-sync-test1080p</td><td colspan=3>https://www.youtube.com/watch?v=szoOsG9137U</td><td>rtsp://v7.cache8.c.youtube.com/CiILENy73wIaGQm133VvsA46sxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp</td></tr>
+ * <tr><td>Audio-Video-Sync-Test-Calibration-23.98fps-24fps</td><td colspan=4>https://www.youtube.com/watch?v=cGgf_dbDMsw</td></tr>
+ * <tr><td>sound_in_sync_test</td><td colspan=4>https://www.youtube.com/watch?v=O-zIZkhXNLE</td></tr>
+ * <!-- <tr><td> title </td><td>1080p</td><td>mpeg4<td>ac3 48000Hz 5.1 chan</td><td> url </td></tr> -->
+ * <!-- <tr><td> title </td><td colspan=3> url1 </td><td> url2 </td></tr>
+ * </table>
+ * </p>
*/
public interface GLMediaPlayer extends TextureSequence {
public static final boolean DEBUG = Debug.debug("GLMediaPlayer");
@@ -186,7 +209,7 @@ public interface GLMediaPlayer extends TextureSequence {
* </p>
* @param gl current GL object. If null, no video output and textures will be available.
* @param textureCount desired number of buffered textures to be decoded off-thread, use <code>1</code> for on-thread decoding.
- * @param urlConn the stream connection
+ * @param streamLoc the stream location
* @param vid video stream id, see <a href="#streamIDs">audio and video Stream IDs</a>
* @param aid video stream id, see <a href="#streamIDs">audio and video Stream IDs</a>
* @return the new state
@@ -195,12 +218,12 @@ public interface GLMediaPlayer extends TextureSequence {
* @throws IOException in case of difficulties to open or process the stream
* @throws GLException in case of difficulties to initialize the GL resources
*/
- public State initGLStream(GL gl, int textureCount, URLConnection urlConn, int vid, int aid) throws IllegalStateException, GLException, IOException;
+ public State initGLStream(GL gl, int textureCount, URI streamLoc, int vid, int aid) throws IllegalStateException, GLException, IOException;
/**
* If implementation uses a {@link AudioSink}, it's instance will be returned.
* <p>
- * The {@link AudioSink} instance is available after {@link #initGLStream(GL, int, URLConnection, int, int)},
+ * The {@link AudioSink} instance is available after {@link #initGLStream(GL, int, URI, int, int)},
* if used by implementation.
* </p>
*/
@@ -308,7 +331,8 @@ public interface GLMediaPlayer extends TextureSequence {
@Override
public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException;
- public URLConnection getURLConnection();
+ /** Return the stream location, as set by {@link #initGLStream(GL, int, URI, int, int)}. */
+ public URI getURI();
/**
* <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 86e6bc121..f87df950c 100644
--- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
+++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
@@ -187,15 +187,15 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
@Override
protected final void initGLStreamImpl(GL gl, int vid, int aid) throws IOException {
- if(null!=mp && null!=urlConn) {
+ if(null!=mp && null!=streamLoc) {
if( GLMediaPlayer.STREAM_ID_NONE == aid ) {
mp.setVolume(0f, 0f);
// FIXME: Disable audio handling
} // 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(urlConn.getURL().toExternalForm());
- mp.setDataSource(StaticContext.getContext(), uri);
+ final Uri _uri = Uri.parse(streamLoc.toString());
+ mp.setDataSource(StaticContext.getContext(), _uri);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (SecurityException e) {
@@ -210,7 +210,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
try {
mp.prepare();
} catch (IOException ioe) {
- throw new IOException("MediaPlayer failed to process stream <"+urlConn.getURL().toExternalForm()+">: "+ioe.getMessage(), ioe);
+ throw new IOException("MediaPlayer failed to process stream <"+streamLoc.toString()+">: "+ioe.getMessage(), ioe);
}
final int r_aid = GLMediaPlayer.STREAM_ID_NONE == aid ? GLMediaPlayer.STREAM_ID_NONE : GLMediaPlayer.STREAM_ID_AUTO;
final String icodec = "android";
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index 8456aca6f..a82c84d17 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -28,7 +28,7 @@
package jogamp.opengl.util.av;
import java.io.IOException;
-import java.net.URLConnection;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
@@ -82,7 +82,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 URLConnection urlConn = null;
+ protected URI streamLoc = null;
protected volatile float playSpeed = 1.0f;
@@ -378,7 +378,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
}
@Override
- public final State initGLStream(GL gl, int reqTextureCount, URLConnection urlConn, int vid, int aid) throws IllegalStateException, GLException, IOException {
+ public final State initGLStream(GL gl, int reqTextureCount, URI streamLoc, int vid, int aid) throws IllegalStateException, GLException, IOException {
synchronized( stateLock ) {
if(State.Uninitialized != state) {
throw new IllegalStateException("Instance not in state "+State.Uninitialized+", but "+state+", "+this);
@@ -386,8 +386,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
decodedFrameCount = 0;
presentedFrameCount = 0;
displayedFrameCount = 0;
- this.urlConn = urlConn;
- if (this.urlConn != null) {
+ this.streamLoc = streamLoc;
+ if (this.streamLoc != null) {
try {
if( null != gl ) {
removeAllTextureFrames(gl);
@@ -1014,8 +1014,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
protected abstract void destroyImpl(GL gl);
@Override
- public final URLConnection getURLConnection() {
- return urlConn;
+ public final URI getURI() {
+ return streamLoc;
}
@Override
@@ -1081,7 +1081,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
@Override
public final String toString() {
final float tt = getDuration() / 1000.0f;
- final String loc = ( null != urlConn ) ? urlConn.getURL().toExternalForm() : "<undefined stream>" ;
+ final String loc = ( null != streamLoc ) ? streamLoc.toString() : "<undefined stream>" ;
final int freeVideoFrames = null != videoFramesFree ? videoFramesFree.size() : 0;
final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0;
final int video_scr = video_scr_pts + (int) ( ( Platform.currentTimeMillis() - video_scr_t0 ) * playSpeed );
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 8998f689a..9838181ab 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -105,7 +105,10 @@ import jogamp.opengl.util.av.GLMediaPlayerImpl;
*/
public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
- // Count of zeroed buffers to return before switching to real sample provider
+ /** POSIX ENOSYS {@value}: Function not implemented. FIXME: Move to GlueGen ?!*/
+ private static final int ENOSYS = 38;
+
+ /** Count of zeroed buffers to return before switching to real sample provider */
private static final int TEMP_BUFFER_COUNT = 20;
// Instance data
@@ -220,11 +223,13 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
setGLFuncs0(moviePtr, procAddrGLTexSubImage2D, procAddrGLGetError);
}
- final String urlS=urlConn.getURL().toExternalForm();
+ final String streamLocS=streamLoc.toString();
aFrameCount = AFRAMES_PER_VFRAME * textureCount + AFRAMES_PER_VFRAME/2;
- System.err.println("setURL: p1 "+this);
+ if(DEBUG) {
+ System.err.println("initGLStream: p1 "+this);
+ }
destroyAudioSink();
AudioSink _audioSink;
if( GLMediaPlayer.STREAM_ID_NONE == aid ) {
@@ -234,12 +239,16 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
}
final AudioDataFormat preferredAudioFormat = _audioSink.getPreferredFormat();
// setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc
- setStream0(moviePtr, urlS, vid, aid, aFrameCount, preferredAudioFormat.channelCount, preferredAudioFormat.sampleRate);
+ setStream0(moviePtr, streamLocS, vid, aid, aFrameCount, preferredAudioFormat.channelCount, preferredAudioFormat.sampleRate);
// final int audioBytesPerFrame = bps_audio/8000 * frame_period * textureCount;
- System.err.println("setURL: p2 preferred "+preferredAudioFormat+", avChosen "+avChosenAudioFormat+", "+this);
+ if(DEBUG) {
+ System.err.println("initGLStream: p2 preferred "+preferredAudioFormat+", avChosen "+avChosenAudioFormat+", "+this);
+ }
sinkChosenAudioFormat = _audioSink.initSink(avChosenAudioFormat, aFrameCount);
- System.err.println("setURL: p3 avChosen "+avChosenAudioFormat+", chosen "+sinkChosenAudioFormat);
+ if(DEBUG) {
+ System.err.println("initGLStream: p3 avChosen "+avChosenAudioFormat+", chosen "+sinkChosenAudioFormat);
+ }
if( null == sinkChosenAudioFormat ) {
System.err.println("AudioSink "+_audioSink.getClass().getName()+" does not support "+avChosenAudioFormat+", using Null");
_audioSink.destroy();
@@ -434,15 +443,23 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
if(0==moviePtr) {
return false;
}
- return play0(moviePtr);
+ final int errno = play0(moviePtr);
+ if( DEBUG_NATIVE && errno != 0 && errno != -ENOSYS) {
+ System.err.println("libav play err: "+errno);
+ }
+ return true;
}
-
+
@Override
public final boolean pauseImpl() {
if(0==moviePtr) {
return false;
}
- return pause0(moviePtr);
+ final int errno = pause0(moviePtr);
+ if( DEBUG_NATIVE && errno != 0 && errno != -ENOSYS) {
+ System.err.println("libav pause err: "+errno);
+ }
+ return true;
}
@Override
@@ -541,8 +558,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
*/
private native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType);
- private native boolean play0(long moviePtr);
- private native boolean pause0(long moviePtr);
+ private native int play0(long moviePtr);
+ private native int pause0(long moviePtr);
private native int seek0(long moviePtr, int position);
public static enum SampleFormat {
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 c6f31d81e..d0517fc5f 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java
@@ -29,7 +29,6 @@
package jogamp.opengl.util.av.impl;
import java.io.IOException;
-import java.net.URL;
import javax.media.opengl.GL;
import javax.media.opengl.GLException;
@@ -101,16 +100,21 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
if(0==moviePtr) {
throw new GLException("OMX native instance null");
}
- final URL url = urlConn.getURL();
- if(!url.getProtocol().equals("file")) {
- throw new IOException("Only file URLs are allowed: "+url);
+ if(!streamLoc.getScheme().equals("file")) {
+ throw new IOException("Only file schemes are allowed: "+streamLoc);
+ }
+ final String path=streamLoc.getPath();
+ if(DEBUG) {
+ System.out.println("initGLStream: clean path "+path);
}
- final String path=url.getPath();
- System.out.println("setURL: clean path "+path);
- System.out.println("setURL: p1 "+this);
+ if(DEBUG) {
+ System.out.println("initGLStream: p1 "+this);
+ }
_setStream(moviePtr, textureCount, path);
- System.out.println("setURL: p2 "+this);
+ if(DEBUG) {
+ System.out.println("initGLStream: p2 "+this);
+ }
}
@Override
diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
index ca0bf9bb9..99b385e3c 100644
--- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
+++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
@@ -877,29 +877,17 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex
return resPTS;
}
-JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_play0
+JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_play0
(JNIEnv *env, jobject instance, jlong ptr)
{
FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr));
- int res = sp_av_read_play(pAV->pFormatCtx);
- if ( 0 != res && -ENOSYS != res ) { // Ignore ENOSYS (not impl.)
- fprintf(stderr, "PLAY: err %d 0x%X\n", res, res);
- return JNI_FALSE;
- } else {
- return JNI_TRUE;
- }
+ return sp_av_read_play(pAV->pFormatCtx);
}
-JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_pause0
+JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_pause0
(JNIEnv *env, jobject instance, jlong ptr)
{
FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr));
- int res = sp_av_read_pause(pAV->pFormatCtx);
- if ( 0 != res && -ENOSYS != res ) { // Ignore ENOSYS (not impl.)
- fprintf(stderr, "PAUSE: err %d 0x%X\n", res, res);
- return JNI_FALSE;
- } else {
- return JNI_TRUE;
- }
+ return sp_av_read_pause(pAV->pFormatCtx);
}
JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_seek0
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);