diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util')
3 files changed, 48 insertions, 27 deletions
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 |