Top Description Inners Fields Constructors Methods
jogamp.opengl.util.av

public abstract Class GLMediaPlayerImpl

extends Object
implements GLMediaPlayer
Class Inheritance
All Implemented Interfaces
com.jogamp.opengl.util.av.GLMediaPlayer, com.jogamp.opengl.util.texture.TextureSequence
Known Direct Subclasses
jogamp.opengl.util.av.NullGLMediaPlayer, jogamp.opengl.util.av.impl.FFMPEGMediaPlayer, jogamp.opengl.util.av.EGLMediaPlayerImpl
Imports
java.io.IOException, java.util.ArrayList, .HashMap, .Iterator, .Map, com.jogamp.nativewindow.AbstractGraphicsDevice, com.jogamp.opengl.GL, .GL2GL3, .GLContext, .GLDrawable, .GLDrawableFactory, .GLES2, .GLException, .GLProfile, .GLExtensions, jogamp.opengl.Debug, com.jogamp.common.net.UriQueryProps, .Uri, com.jogamp.common.ExceptionUtils, com.jogamp.common.os.Platform, com.jogamp.common.util.InterruptSource, .InterruptedRuntimeException, .LFRingbuffer, .Ringbuffer, .SourcedInterruptedException, com.jogamp.opengl.util.TimeFrameI, com.jogamp.opengl.util.av.AudioSink, .GLMediaPlayer, com.jogamp.opengl.util.glsl.ShaderCode, com.jogamp.opengl.util.texture.Texture, .TextureSequence, .TextureSequence.TextureFrame

After object creation an implementation may customize the behavior:

See GLMediaPlayer.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
GLMediaPlayerImpl.StreamWorker

After initStreamImpl(..) is completed via updateAttributes(..), the latter decides whether StreamWorker is being used.

Field Summary

Modifier and TypeField and Description
private String
acodec

Shall be set by the initStreamImpl(int, int) method implementation.

private int
aid

Shall be set by the initStreamImpl(int, int) method implementation.

private final HashMap<String, Object>
private long
audio_scr_t0

System Clock Reference (SCR) of first audio PTS at start time.

private int
audioFrames

In frames.

private boolean
protected AudioSink
protected boolean
private float
private int
bps_audio

Audio bps.

private int
bps_stream

Stream bps.

private int
bps_video

Video bps.

private TextureSequence.TextureFrame
protected Uri.Encoded
cameraPath

In case streamLoc is a GLMediaPlayer#CameraInputScheme, cameraPath holds the URI's path portion as parsed in initStream(Uri, int, int, int).

protected Map<String, String>
cameraProps

Optional camera properties, see cameraPath.

private volatile int
private int
private int
duration

In ms.

private final ArrayList<GLMediaPlayer.GLMediaEventListener>
private final Object
private float
fps

Video avg.

private float
frame_duration

Video avg.

private int
height

Shall be set by the initStreamImpl(int, int) method implementation.

private boolean
private volatile TextureSequence.TextureFrame
private long
private static final int
MAX_FRAMELESS_MS_UNTIL_EOS

Help detect EOS, limit milliseconds without a valid frame.

private static final int
private int
private int
nullFrameCount

Help detect EOS, limit is MAX_FRAMELESS_MS_UNTIL_EOS.

private volatile float
private int
private volatile GLMediaPlayer.State
private final Object
private final boolean[]
private static final int
private volatile GLMediaPlayer.StreamException
private Uri
streamLoc

User requested URI stream location.

private volatile GLMediaPlayerImpl.StreamWorker
pack-priv static int
private final int[]
private int
private int
private int
private int
private int
private int
private int
private final int[]
private static final String
private String
vcodec

Shall be set by the initStreamImpl(int, int) method implementation.

private int
vid

Shall be set by the initStreamImpl(int, int) method implementation.

private static final float
VIDEO_DPTS_COEFF

Cumulative coefficient, value .

private int
video_dpts_count

Cumulative video frames.

private float
video_dpts_cum

Cumulative video pts diff.

private static final int
VIDEO_DPTS_MAX

Maximum valid video pts diff.

private static final int
VIDEO_DPTS_NUM

Number of min frame count required for video cumulative sync.

private volatile int
private int
video_scr_pts

System Clock Reference (SCR) PTS offset, i.e. first video PTS at start time.

private long
video_scr_t0

System Clock Reference (SCR) of first video frame at start time.

private int
videoFrames

In frames.

private Ringbuffer<TextureSequence.TextureFrame>
private Ringbuffer<TextureSequence.TextureFrame>
private TextureSequence.TextureFrame[]
private boolean
videoSCR_reset

Trigger video PTS reset with given cause as bitfield.

private int
width

Shall be set by the initStreamImpl(int, int) method implementation.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public final void
protected final int
addStateEventMask(int event_mask, final GLMediaPlayer.State newState)

public final Object
attachObject(final String name, final Object obj)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.attachObject.

Attaches the user object for the given name.
protected final void
attributesUpdated(final int event_mask)

protected final void
changeState(int event_mask, final GLMediaPlayer.State newState)

private final void
protected TextureSequence.TextureFrame[]
createTexFrames(final GL gl, final int count)

protected abstract TextureSequence.TextureFrame
createTexImage(GL gl, int texName)

protected final Texture
createTexImageImpl(final GL gl, final int texName, final int tWidth, final int tHeight)

public final GLMediaPlayer.State
destroy(final GL gl)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.destroy.

Releases the GL, stream and other resources, including attached user objects.
private final GLMediaPlayer.State
destroyImpl(final GL gl, final int event_mask)

protected abstract void
protected void
public final Object
detachObject(final String name)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.detachObject.

Detaches the user object for the given name.
private void
public final int
public final Object
getAttachedObject(final String name)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getAttachedObject.

Returns the attached user object for the given name.
public final int
getAudioBitrate()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getAudioBitrate.

Warning

Optional information, may not be supported by implementation.

public final String
getAudioCodec()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getAudioCodec.

Warning

Optional information, may not be supported by implementation.

public final int
getAudioFrames()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getAudioFrames.

Warning

Optional information, may not be supported by implementation.

public final int
protected int
getAudioPTSImpl()

Override if not using audioSink!

public final AudioSink
getAudioSink()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getAudioSink.

If implementation uses a AudioSink, it's instance will be returned.
public final float
protected void
getAudioVolumeImpl()

Override if not using AudioSink, or AudioSink's AudioSink#getVolume() is not sufficient!

public final int
public final int
public final GLMediaPlayer.GLMediaEventListener[]
public final float
getFramerate()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getFramerate.

Warning

Optional information, may not be supported by implementation.

public final int
getHeight()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getHeight.

Returns the height of the video.
public final TextureSequence.TextureFrame
getLastTexture()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getLastTexture.

Returns the last updated texture.
protected final int
getNextSingleThreaded(final GL gl, final TextureSequence.TextureFrame nextFrame, final boolean[] gotVFrame)

public final TextureSequence.TextureFrame
getNextTexture(final GL gl)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getNextTexture.

Returns the next texture to be rendered.
protected abstract int

Returns:

the last processed video PTS value, maybe TimeFrameI#INVALID_PTS if video frame is invalid or n/a. Will be TimeFrameI#END_OF_STREAM_PTS if end of stream reached.
getNextTextureImpl
(GL
valid and current GL instance, shall be null for audio only.
gl
,
TextureSequence.TextureFrame
the TextureFrame to store the video PTS and texture data, shall be null for audio only.
nextFrame
)

Process stream until the next video frame, i.e. TextureFrame, has been reached.

public final String
getPerfString()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getPerfString.

Returns a string represantation of this player's performance values.
private final String
getPerfStringImpl(final int video_scr, final int video_pts, final int d_vpts, final int audio_scr, final int audio_pts, final int d_apts, final int video_dpts_avg_diff)

public final float
getPlaySpeed()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getPlaySpeed.

Returns the playback speed.
public final int
protected static final int
getPropIntVal(final Map<String, String> props, final String key)

public String
getRequiredExtensionsShaderStub()

Implements com.jogamp.opengl.util.texture.TextureSequence.getRequiredExtensionsShaderStub.

In case a shader extension is required, based on the implementation and the runtime GL profile, this method returns the preprocessor macros, e.g.:
#extension GL_OES_EGL_image_external : enable
public final GLMediaPlayer.State
public final long
getStreamBitrate()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getStreamBitrate.

Warning

Optional information, may not be supported by implementation.

public final GLMediaPlayer.StreamException
getStreamException()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getStreamException.

Returns the StreamException caught in the decoder thread, or null if none occured.
public final int
protected final int
public final int
public String
getTextureLookupFragmentShaderImpl()

Implements com.jogamp.opengl.util.texture.TextureSequence.getTextureLookupFragmentShaderImpl.

Returns the complete texture2D lookup function code of type
  vec4 funcName(in getTextureSampler2DType() image, in vec2 texCoord) {
     vec4 texColor = do_something_with(image, texCoord);
     return texColor;
  }
public String
getTextureLookupFunctionName(final String
desired lookup function name. If null or ignored by the implementation, a build-in name is returned.
desiredFuncName
)

Implements com.jogamp.opengl.util.texture.TextureSequence.getTextureLookupFunctionName.

This implementation simply returns the build-in function name of texture2D, if not overridden by specialization.
public final int[]
public String
getTextureSampler2DType()

Implements com.jogamp.opengl.util.texture.TextureSequence.getTextureSampler2DType.

Returns either sampler2D or samplerExternalOES depending on getLastTexture().
public final int
getTextureTarget()

Implements com.jogamp.opengl.util.texture.TextureSequence.getTextureTarget.

Returns the texture target used by implementation.
protected final int
public final int
getTextureUnit()

Implements com.jogamp.opengl.util.texture.TextureSequence.getTextureUnit.

Return the texture unit used to render the current frame.
public final int[]
public final Uri
getUri()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getUri.

Return the stream location, as set by initStream(Uri, int, int, int).
public final int
public final int
getVideoBitrate()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getVideoBitrate.

Warning

Optional information, may not be supported by implementation.

public final String
getVideoCodec()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getVideoCodec.

Warning

Optional information, may not be supported by implementation.

private final int
public final int
getVideoFrames()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getVideoFrames.

Warning

Optional information, may not be supported by implementation.

public final int
public final int
getWidth()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.getWidth.

Returns the width of the video.
public final void
initGL(final GL
current GL object. Maybe null, for audio only.
gl
)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.initGL.

Initializes OpenGL related resources.
protected abstract void
initGLImpl(GL
null for audio-only, otherwise a valid and current GL object.
gl
)

Shall initialize all GL related resources, if not audio-only.

public final void
initStream(final Uri
the stream location
streamLoc
,
final int
video stream id, see audio and video Stream IDs
vid
,
final int
video stream id, see audio and video Stream IDs
aid
,
final int
desired number of buffered textures to be decoded off-thread, will be validated by implementation. The minimum value is TEXTURE_COUNT_DEFAULT. Ignored if video is muted.
reqTextureCount
)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.initStream.

Issues asynchronous stream initialization.
protected abstract void
initStreamImpl(int vid, int aid)

Implementation shall set the following set of data here

public final boolean
isGLOriented()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.isGLOriented.

Returns true if the video frame is oriented in OpenGL's coordinate system, origin at bottom left.
public final boolean
isTextureAvailable()

Implements com.jogamp.opengl.util.texture.TextureSequence.isTextureAvailable.

Returns true if texture source is ready and a texture is available via getNextTexture(GL) and getLastTexture().
private final void
newFrameAvailable(final TextureSequence.TextureFrame frame, final long currentTimeMillis)

public final GLMediaPlayer.State
pause(final boolean
if true flushes the video and audio buffers, otherwise keep them intact.
flush
)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.pause.

Pauses the StreamWorker decoding thread.
private final GLMediaPlayer.State
pauseImpl(final boolean flush, int event_mask)

protected abstract boolean
public final GLMediaPlayer.State
play()

Implements com.jogamp.opengl.util.av.GLMediaPlayer.play.

Starts or resumes the StreamWorker decoding thread.
protected abstract boolean
protected void
protected void
private final void
public final void
private void
private void
public final int
seek(int
absolute desired time position in milliseconds
msec
)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.seek.

Seeks to the new absolute position.
protected abstract int
seekImpl(int msec)

public boolean
setAudioVolume(float v)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.setAudioVolume.

Sets the audio volume, [0f..1f].
protected boolean
setAudioVolumeImpl(final float v)

Override if not using AudioSink, or AudioSink's AudioSink#setVolume(float) is not sufficient!

protected void
setFirstAudioPTS2SCR(final int pts)

To be called from implementation at 1st PTS after start w/ current pts value in milliseconds.

protected void
setIsGLOriented(final boolean isGLOriented)

public final boolean
setPlaySpeed(float rate)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.setPlaySpeed.

Sets the playback speed.
protected boolean
setPlaySpeedImpl(final float rate)

Override if not using AudioSink, or AudioSink's AudioSink#setPlaySpeed(float) is not sufficient!

protected final void
protected final void
setTextureFormat(final int internalFormat, final int format)

public final void
setTextureMinMagFilter(final int[] minMagFilter)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.setTextureMinMagFilter.

Sets the texture min-mag filter, defaults to GL#GL_NEAREST.
protected final void
setTextureTarget(final int target)

protected final void
setTextureType(final int t)

public final void
setTextureUnit(final int u)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.setTextureUnit.

Sets the texture unit.
public final void
setTextureWrapST(final int[] wrapST)

Implements com.jogamp.opengl.util.av.GLMediaPlayer.setTextureWrapST.

Sets the texture min-mag filter, defaults to GL#GL_CLAMP_TO_EDGE.
protected static final String
toHexString(final long v)

protected static final String
toHexString(final int v)

public final String
toString()

Overrides java.lang.Object.toString.

Implements com.jogamp.opengl.util.av.GLMediaPlayer.toString.

Returns a string represantation of this player, incl.
protected final void
updateAttributes(int vid, final int aid, final int width, final int height, final int bps_stream, final int bps_video, final int bps_audio, final float fps, final int videoFrames, final int audioFrames, final int duration, final String vcodec, final String acodec)

Called initially by initStreamImpl(int, int), which is called off-thread by initStream(Uri, int, int, int).

protected int
validateTextureCount(final int desiredTextureCount)

Returns the validated number of textures to be handled.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait