com.jogamp.opengl.util.av
Interface GLMediaPlayer

All Superinterfaces:
TextureSequence

public interface GLMediaPlayer
extends TextureSequence

Lifecycle of an GLMediaPlayer:

action state before state after
initGLStream(GL, URLConnection) Uninitialized Stopped
start() Stopped, Paused Playing
stop() Playing, Paused Stopped
pause() Playing Paused
destroy(GL) ANY Uninitialized

Current implementations (check each API doc link for details):

Variable type, value range and dimension has been chosen to suit embedded CPUs and characteristics of audio and video streaming. Milliseconds of type integer with a maximum value of Integer.MAX_VALUE will allow tracking time up 2,147,483.647 seconds or 24 days 20 hours 31 minutes and 23 seconds. Milliseconds granularity is also more than enough to deal with A-V synchronization, where the threshold usually lies within 100ms.


Nested Class Summary
static interface GLMediaPlayer.GLMediaEventListener
           
static class GLMediaPlayer.State
           
 
Nested classes/interfaces inherited from interface com.jogamp.opengl.util.texture.TextureSequence
TextureSequence.TexSeqEventListener<T extends TextureSequence>, TextureSequence.TextureFrame
 
Field Summary
static boolean DEBUG
           
 
Fields inherited from interface com.jogamp.opengl.util.texture.TextureSequence
GL_OES_EGL_image_external_Required_Prelude, sampler2D, samplerExternalOES
 
Method Summary
 void addEventListener(GLMediaPlayer.GLMediaEventListener l)
           
 GLMediaPlayer.State destroy(GL gl)
          Releases the GL and stream resources.
 int getAudioBitrate()
          Warning: Optional information, may not be supported by implementation.
 String getAudioCodec()
          Warning: Optional information, may not be supported by implementation.
 int getCurrentPosition()
           
 int getDuration()
           
 GLMediaPlayer.GLMediaEventListener[] getEventListeners()
           
 float getFramerate()
          Warning: Optional information, may not be supported by implementation.
 int getHeight()
           
 TextureSequence.TextureFrame getLastTexture()
          Returns the last updated texture.
 TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking)
          Returns the next texture to be rendered.
 float getPlaySpeed()
           
 GLMediaPlayer.State getState()
           
 long getStreamBitrate()
          Warning: Optional information, may not be supported by implementation.
 int getTextureCount()
           
 long getTotalFrames()
          Warning: Optional information, may not be supported by implementation.
 URLConnection getURLConnection()
           
 int getVideoBitrate()
          Warning: Optional information, may not be supported by implementation.
 String getVideoCodec()
          Warning: Optional information, may not be supported by implementation.
 int getWidth()
           
 GLMediaPlayer.State initGLStream(GL gl, URLConnection urlConn)
          Sets the stream to be used.
 GLMediaPlayer.State pause()
          Playing -> Paused
 void removeEventListener(GLMediaPlayer.GLMediaEventListener l)
           
 int seek(int msec)
          Allowed in state Stopped, Playing and Paused, otherwise ignored.
 void setPlaySpeed(float rate)
           
 void setTextureMinMagFilter(int[] minMagFilter)
          Sets the texture min-mag filter, defaults to GL.GL_NEAREST.
 void setTextureUnit(int u)
          Defaults to 0
 void setTextureWrapST(int[] wrapST)
          Sets the texture min-mag filter, defaults to GL.GL_CLAMP_TO_EDGE.
 GLMediaPlayer.State start()
          Stopped/Paused -> Playing
 GLMediaPlayer.State stop()
          Playing/Paused -> Stopped
 String toString()
           
 
Methods inherited from interface com.jogamp.opengl.util.texture.TextureSequence
getRequiredExtensionsShaderStub, getTextureLookupFragmentShaderImpl, getTextureLookupFunctionName, getTextureMinMagFilter, getTextureSampler2DType, getTextureUnit, getTextureWrapST
 

Field Detail

DEBUG

static final boolean DEBUG
Method Detail

getTextureCount

int getTextureCount()

setTextureUnit

void setTextureUnit(int u)
Defaults to 0


setTextureMinMagFilter

void setTextureMinMagFilter(int[] minMagFilter)
Sets the texture min-mag filter, defaults to GL.GL_NEAREST.


setTextureWrapST

void setTextureWrapST(int[] wrapST)
Sets the texture min-mag filter, defaults to GL.GL_CLAMP_TO_EDGE.


initGLStream

GLMediaPlayer.State initGLStream(GL gl,
                                 URLConnection urlConn)
                                 throws IllegalStateException,
                                        GLException,
                                        IOException
Sets the stream to be used. Initializes all stream related states inclusive OpenGL ones, if gl is not null.

Uninitialized -> Stopped

Parameters:
gl - current GL object. If null, no video output and textures will be available.
urlConn - the stream connection
Returns:
the new state
Throws:
IllegalStateException - if not invoked in state Uninitialized
IOException - in case of difficulties to open or process the stream
GLException - in case of difficulties to initialize the GL resources

destroy

GLMediaPlayer.State destroy(GL gl)
Releases the GL and stream resources.

ANY -> Uninitialized


setPlaySpeed

void setPlaySpeed(float rate)

getPlaySpeed

float getPlaySpeed()

start

GLMediaPlayer.State start()
Stopped/Paused -> Playing


pause

GLMediaPlayer.State pause()
Playing -> Paused


stop

GLMediaPlayer.State stop()
Playing/Paused -> Stopped


getState

GLMediaPlayer.State getState()
Returns:
the current state, either Uninitialized, Stopped, Playing, Paused

getCurrentPosition

int getCurrentPosition()
Returns:
time current position in milliseconds

seek

int seek(int msec)
Allowed in state Stopped, Playing and Paused, otherwise ignored.

Parameters:
msec - absolute desired time position in milliseconds
Returns:
time current position in milliseconds, after seeking to the desired position

getLastTexture

TextureSequence.TextureFrame getLastTexture()
                                            throws IllegalStateException
Returns the last updated texture.

In case the instance is just initialized, it shall return a TextureFrame object with valid attributes. The texture content may be undefined until the first call of TextureSequence.getNextTexture(GL, boolean).

Not blocking.

Specified by:
getLastTexture in interface TextureSequence
Throws:
IllegalStateException - if instance is not initialized

getNextTexture

TextureSequence.TextureFrame getNextTexture(GL gl,
                                            boolean blocking)
                                            throws IllegalStateException
Returns the next texture to be rendered.

Implementation shall block until next frame is available if blocking is true, otherwise it shall return the last frame in case a new frame is not available.

Shall return null in case no frame is available.

In case the current state is not GLMediaPlayer.State.Playing, getLastTexture() is returned.

Specified by:
getNextTexture in interface TextureSequence
Throws:
IllegalStateException - if instance is not initialized
See Also:
addEventListener(GLMediaEventListener), GLMediaEventListener#newFrameAvailable(GLMediaPlayer, long)

getURLConnection

URLConnection getURLConnection()

getVideoCodec

String getVideoCodec()
Warning: Optional information, may not be supported by implementation.

Returns:
the code of the video stream, if available

getAudioCodec

String getAudioCodec()
Warning: Optional information, may not be supported by implementation.

Returns:
the code of the audio stream, if available

getTotalFrames

long getTotalFrames()
Warning: Optional information, may not be supported by implementation.

Returns:
the total number of video frames

getDuration

int getDuration()
Returns:
total duration of stream in msec.

getStreamBitrate

long getStreamBitrate()
Warning: Optional information, may not be supported by implementation.

Returns:
the overall bitrate of the stream.

getVideoBitrate

int getVideoBitrate()
Warning: Optional information, may not be supported by implementation.

Returns:
video bitrate

getAudioBitrate

int getAudioBitrate()
Warning: Optional information, may not be supported by implementation.

Returns:
the audio bitrate

getFramerate

float getFramerate()
Warning: Optional information, may not be supported by implementation.

Returns:
the framerate of the video

getWidth

int getWidth()

getHeight

int getHeight()

toString

String toString()
Overrides:
toString in class Object

addEventListener

void addEventListener(GLMediaPlayer.GLMediaEventListener l)

removeEventListener

void removeEventListener(GLMediaPlayer.GLMediaEventListener l)

getEventListeners

GLMediaPlayer.GLMediaEventListener[] getEventListeners()


Copyright 2010 JogAmp Community.