diff options
author | Sven Gothel <[email protected]> | 2014-05-20 01:06:28 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-05-20 01:06:28 +0200 |
commit | 0959f73ed6740724736c4871a7b63e3449f2f185 (patch) | |
tree | 034212fafc1c89e963e5a2f25674242295953401 /src/jogl/classes/jogamp/opengl | |
parent | cca2782818bec79f63a5da1719b11e15244dbea2 (diff) |
GLMediaPlayerImpl: Change access of most fields to private for clarity and API stability
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
6 files changed, 94 insertions, 112 deletions
diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 25a0bc15d..5778a1b6c 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 == streamLoc ) { + if( null == getURI() ) { return; } if( null == mp && null == cam ) { @@ -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(streamLoc.toString()); + final Uri _uri = Uri.parse(getURI().toString()); mp.setDataSource(StaticContext.getContext(), _uri); } catch (IllegalArgumentException e) { throw new RuntimeException(e); @@ -293,7 +293,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { try { mp.prepare(); } catch (IOException ioe) { - throw new IOException("MediaPlayer failed to process stream <"+streamLoc.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 (IOException ioe) { - throw new RuntimeException("MediaPlayer failed to process stream <"+streamLoc.toString()+">: "+ioe.getMessage(), ioe); + throw new RuntimeException("MediaPlayer failed to process stream <"+getURI().toString()+">: "+ioe.getMessage(), ioe); } } if( null != surface ) { @@ -455,7 +455,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { protected final TextureSequence.TextureFrame createTexImage(GL gl, int texName) { sTexFrameCount++; if( 1 == sTexFrameCount ) { - singleSTexFrame = new SurfaceTextureFrame( createTexImageImpl(gl, texName, width, height), new SurfaceTexture(texName) ); + singleSTexFrame = new SurfaceTextureFrame( createTexImageImpl(gl, texName, getWidth(), getHeight()), new SurfaceTexture(texName) ); } return singleSTexFrame; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java index c39b78bb8..25686a170 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java @@ -86,7 +86,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { @Override protected TextureSequence.TextureFrame createTexImage(GL gl, int texName) { - final Texture texture = super.createTexImageImpl(gl, texName, width, height); + final Texture texture = super.createTexImageImpl(gl, texName, getWidth(), getHeight()); final Buffer clientBuffer; final long image; final long sync; diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index a6d5e8e2a..73b14b3d1 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -74,25 +74,26 @@ import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private static final int STREAM_WORKER_DELAY = Debug.getIntProperty("jogl.debug.GLMediaPlayer.StreamWorker.delay", false, 0); - protected static final String unknown = "unknown"; + private static final String unknown = "unknown"; - protected volatile State state; + private volatile State state; private final Object stateLock = new Object(); - protected int textureCount; - protected int textureTarget; - protected int textureFormat; - protected int textureInternalFormat; - protected int textureType; - protected int texUnit; + private int textureCount; + private int textureTarget; + private int textureFormat; + private int textureInternalFormat; + private int textureType; + private int texUnit; private int textureFragmentShaderHashCode; - protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST }; - protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; + private final int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST }; + private final int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; /** User requested URI stream location. */ - protected URI streamLoc = null; + private URI streamLoc = null; + /** * In case {@link #streamLoc} is a {@link GLMediaPlayer#CameraInputScheme}, * {@link #cameraPath} holds the URI's path portion @@ -103,42 +104,42 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { /** Optional camera properties, see {@link #cameraPath}. */ protected Map<String, String> cameraProps = null; - protected volatile float playSpeed = 1.0f; - protected float audioVolume = 1.0f; + private volatile float playSpeed = 1.0f; + private float audioVolume = 1.0f; /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int vid = GLMediaPlayer.STREAM_ID_AUTO; + private int vid = GLMediaPlayer.STREAM_ID_AUTO; /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int aid = GLMediaPlayer.STREAM_ID_AUTO; + private int aid = GLMediaPlayer.STREAM_ID_AUTO; /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int width = 0; + private int width = 0; /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int height = 0; + private int height = 0; /** Video avg. fps. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected float fps = 0; + private float fps = 0; /** Video avg. frame duration in ms. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected float frame_duration = 0f; + private float frame_duration = 0f; /** Stream bps. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int bps_stream = 0; + private int bps_stream = 0; /** Video bps. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int bps_video = 0; + private int bps_video = 0; /** Audio bps. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int bps_audio = 0; + private int bps_audio = 0; /** In frames. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int videoFrames = 0; + private int videoFrames = 0; /** In frames. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int audioFrames = 0; + private int audioFrames = 0; /** In ms. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected int duration = 0; + private int duration = 0; /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected String acodec = unknown; + private String acodec = unknown; /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ - protected String vcodec = unknown; + private String vcodec = unknown; - protected volatile int decodedFrameCount = 0; - protected int presentedFrameCount = 0; - protected int displayedFrameCount = 0; - protected volatile int video_pts_last = 0; + private volatile int decodedFrameCount = 0; + private int presentedFrameCount = 0; + private int displayedFrameCount = 0; + private volatile int video_pts_last = 0; /** * Help detect EOS, limit is {@link #MAX_FRAMELESS_MS_UNTIL_EOS}. @@ -177,14 +178,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { /** Trigger video PTS reset with given cause as bitfield. */ private boolean videoSCR_reset = false; - protected TextureFrame[] videoFramesOrig = null; - protected Ringbuffer<TextureFrame> videoFramesFree = null; - protected Ringbuffer<TextureFrame> videoFramesDecoded = null; - protected volatile TextureFrame lastFrame = null; + private TextureFrame[] videoFramesOrig = null; + private Ringbuffer<TextureFrame> videoFramesFree = null; + private Ringbuffer<TextureFrame> videoFramesDecoded = null; + private volatile TextureFrame lastFrame = null; /** * @see #isGLOriented() */ - protected boolean isInGLOrientation = false; + private boolean isInGLOrientation = false; private final ArrayList<GLMediaEventListener> eventListeners = new ArrayList<GLMediaEventListener>(); @@ -195,6 +196,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.textureInternalFormat = GL.GL_RGBA; this.textureType = GL.GL_UNSIGNED_BYTE; this.texUnit = 0; + this.textureFragmentShaderHashCode = 0; this.state = State.Uninitialized; } @@ -207,6 +209,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final int getTextureTarget() { return textureTarget; } + protected final int getTextureFormat() { return textureFormat; } + + protected final int getTextureType() { return textureType; } + @Override public final int getTextureCount() { return textureCount; } @@ -322,6 +328,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final State getState() { return state; } + protected final void setState(final State s) { state=s; } + @Override public final State play() { synchronized( stateLock ) { @@ -355,7 +363,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final State preState = state; if( State.Playing == state ) { event_mask = addStateEventMask(event_mask, GLMediaPlayer.State.Paused); - state = State.Paused; + setState( State.Paused ); if( null != streamWorker ) { streamWorker.doPause(); } @@ -404,7 +412,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { case Playing: case Paused: final State _state = state; - state = State.Paused; + setState( State.Paused ); if( null != streamWorker ) { streamWorker.doPause(); } @@ -425,7 +433,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( null != streamWorker ) { streamWorker.doResume(); } - state = _state; + setState( _state ); break; default: pts1 = 0; @@ -437,9 +445,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected abstract int seekImpl(int msec); @Override - public final float getPlaySpeed() { - return playSpeed; - } + public final float getPlaySpeed() { return playSpeed; } @Override public final boolean setPlaySpeed(float rate) { @@ -782,8 +788,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } - protected TextureFrame cachedFrame = null; - protected long lastTimeMillis = 0; + private TextureFrame cachedFrame = null; + private long lastTimeMillis = 0; private final boolean[] stGotVFrame = { false }; @@ -1367,7 +1373,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected final void changeState(int event_mask, State newState) { event_mask = addStateEventMask(event_mask, newState); if( 0 != event_mask ) { - state = newState; + setState( newState ); if( !isTextureAvailable() ) { textureFragmentShaderHashCode = 0; } @@ -1383,7 +1389,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( wasUninitialized ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_INIT; - state = State.Initialized; + setState( State.Initialized ); } if( STREAM_ID_AUTO == vid ) { vid = STREAM_ID_NONE; @@ -1458,17 +1464,17 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { System.err.println("XXX gl-orient "+isInGLOrientation+" -> "+isGLOriented); } isInGLOrientation = isGLOriented; - for(int i=0; i<videoFramesOrig.length; i++) { - videoFramesOrig[i].getTexture().setMustFlipVertically(!isGLOriented); + if( null != videoFramesOrig ) { + for(int i=0; i<videoFramesOrig.length; i++) { + videoFramesOrig[i].getTexture().setMustFlipVertically(!isGLOriented); + } + attributesUpdated(GLMediaEventListener.EVENT_CHANGE_SIZE); } - attributesUpdated(GLMediaEventListener.EVENT_CHANGE_SIZE); } } @Override - public final URI getURI() { - return streamLoc; - } + public final URI getURI() { return streamLoc; } @Override public final int getVID() { return vid; } @@ -1477,64 +1483,40 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final int getAID() { return aid; } @Override - public final String getVideoCodec() { - return vcodec; - } + public final String getVideoCodec() { return vcodec; } @Override - public final String getAudioCodec() { - return acodec; - } + public final String getAudioCodec() { return acodec; } @Override - public final int getVideoFrames() { - return videoFrames; - } + public final int getVideoFrames() { return videoFrames; } @Override - public final int getAudioFrames() { - return audioFrames; - } + public final int getAudioFrames() { return audioFrames; } @Override - public final int getDuration() { - return duration; - } + public final int getDuration() { return duration; } @Override - public final long getStreamBitrate() { - return bps_stream; - } + public final long getStreamBitrate() { return bps_stream; } @Override - public final int getVideoBitrate() { - return bps_video; - } + public final int getVideoBitrate() { return bps_video; } @Override - public final int getAudioBitrate() { - return bps_audio; - } + public final int getAudioBitrate() { return bps_audio; } @Override - public final float getFramerate() { - return fps; - } + public final float getFramerate() { return fps; } @Override - public final boolean isGLOriented() { - return isInGLOrientation; - } + public final boolean isGLOriented() { return isInGLOrientation; } @Override - public final int getWidth() { - return width; - } + public final int getWidth() { return width; } @Override - public final int getHeight() { - return height; - } + public final int getHeight() { return height; } @Override public final String toString() { diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index 27716e74d..2b4a386d4 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -144,7 +144,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } @Override protected final void initGLImpl(GL gl) throws IOException, GLException { - isInGLOrientation = true; + setIsGLOriented(true); } /** @@ -160,7 +160,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { @Override protected final TextureSequence.TextureFrame createTexImage(GL gl, int texName) { - final Texture texture = super.createTexImageImpl(gl, texName, width, height); + final Texture texture = super.createTexImageImpl(gl, texName, getWidth(), getHeight()); if(null != texData) { texture.updateImage(gl, texData); } @@ -181,8 +181,8 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { pos_ms = getDuration(); considerPausing = true; } - if(considerPausing && state == State.Playing) { - state = State.Paused; + if( considerPausing && State.Playing == getState() ) { + setState(State.Paused); } } } 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 b950b5748..4ce48bfaf 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -287,7 +287,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("initStream: p1 "+this); } - final String streamLocS = IOUtil.decodeURIIfFilePath(streamLoc); + final String streamLocS = IOUtil.decodeURIIfFilePath(getURI()); destroyAudioSink(); if( GLMediaPlayer.STREAM_ID_NONE == aid ) { audioSink = AudioSinkFactory.createNull(); @@ -340,7 +340,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 "+streamLoc+" -> "+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); @@ -355,7 +355,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { throw new GLException("AudioSink null"); } final int audioQueueLimit; - if( null != gl && STREAM_ID_NONE != vid ) { + if( null != gl && STREAM_ID_NONE != getVID() ) { final GLContextImpl ctx = (GLContextImpl)gl.getContext(); AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override @@ -376,7 +376,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("initGL: p3 avChosen "+avChosenAudioFormat); } - if( STREAM_ID_NONE == aid ) { + if( STREAM_ID_NONE == getAID() ) { audioSink.destroy(); audioSink = AudioSinkFactory.createNull(); audioSink.init(AudioSink.DefaultFormat, 0, AudioSink.DefaultInitialQueueSize, AudioSink.DefaultQueueGrowAmount, audioQueueLimit); @@ -400,7 +400,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("initGL: p4 chosen "+audioSink); } - if( null != gl && STREAM_ID_NONE != vid ) { + if( null != gl && STREAM_ID_NONE != getVID() ) { int tf, tif=GL.GL_RGBA; // texture format and internal format int tt = GL.GL_UNSIGNED_BYTE; switch(vBytesPerPixelPerPlane) { @@ -650,7 +650,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { */ @Override public final String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException { - if(State.Uninitialized == state) { + if( State.Uninitialized == getState() ) { throw new IllegalStateException("Instance not initialized: "+this); } if( usesTexLookupShader ) { @@ -670,7 +670,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { */ @Override public final String getTextureLookupFragmentShaderImpl() throws IllegalStateException { - if(State.Uninitialized == state) { + if( State.Uninitialized == getState() ) { throw new IllegalStateException("Instance not initialized: "+this); } if( !usesTexLookupShader ) { @@ -813,7 +813,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { /** Try decode up to 10 packets to find one containing video. */ for(int i=0; TimeFrameI.INVALID_PTS == vPTS && 10 > i; i++) { - vPTS = natives.readNextPacket0(moviePtr, textureTarget, textureFormat, textureType); + vPTS = natives.readNextPacket0(moviePtr, getTextureTarget(), getTextureFormat(), getTextureType()); } if( null != nextFrame ) { nextFrame.setPTS(vPTS); @@ -823,7 +823,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { final void pushSound(ByteBuffer sampleData, int data_size, int audio_pts) { setFirstAudioPTS2SCR( audio_pts ); - if( 1.0f == playSpeed || audioSinkPlaySpeedSet ) { + if( 1.0f == getPlaySpeed() || audioSinkPlaySpeedSet ) { audioSink.enqueueData( audio_pts, sampleData, data_size); } } 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 05a94def8..ecf91124e 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(!streamLoc.getScheme().equals("file")) { - throw new IOException("Only file schemes are allowed: "+streamLoc); + if(!getURI().getScheme().equals("file")) { + throw new IOException("Only file schemes are allowed: "+getURI()); } - final String path=streamLoc.getPath(); + final String path=getURI().getPath(); if(DEBUG) { System.out.println("initGLStream: clean path "+path); } @@ -111,7 +111,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { if(DEBUG) { System.out.println("initGLStream: p1 "+this); } - _setStream(moviePtr, textureCount, path); + _setStream(moviePtr, getTextureCount(), path); if(DEBUG) { System.out.println("initGLStream: p2 "+this); } @@ -119,7 +119,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { @Override protected final void initGLImpl(GL gl) throws IOException, GLException { // NOP - isInGLOrientation = true; + setIsGLOriented(true); } @Override |