Interface GLMediaPlayer
-
- All Superinterfaces:
TextureSequence
public interface GLMediaPlayer extends TextureSequence
GLMediaPlayer interface specifies aTextureSequencestate machine using a multiplexed audio/video stream as it's source.Audio maybe supported and played back internally or via an
AudioSinkimplementation.Audio and video streams can be selected or muted via
playStream(Uri, int, int, int, int)orplayStream(Uri, int, String, int, String, int, int)using the appropriate stream id's.Camera input can be selected using the
CameraInputSchemeUri.StreamWorker Decoding Thread
Most of the stream processing is performed on the decoding thread, a.k.a. StreamWorker:
- Stream initialization triggered by
playStream(..)- User gets notified whether the stream has been initialized or not viaattributesChanges(..). - Stream decoding - User gets notified of a new frame via
newFrameAvailable(...). - Caught exceptions on the decoding thread are delivered as
GLMediaPlayer.StreamExceptions.
GLContext, shared with the one passed toinitGL(GL). The sharedGLContextallows the decoding thread to push the video frame data directly into the designatedTextureSequence.TextureFrame, later returned viagetNextTexture(GL)and used by the user.StreamWorker Error Handling Caught exceptions on StreamWorker are delivered as
GLMediaPlayer.StreamExceptions, which either degrades theGLMediaPlayer.StatetoGLMediaPlayer.State.UninitializedorGLMediaPlayer.State.Paused.An occurring
GLMediaPlayer.StreamExceptiontriggers aEVENT_CHANGE_ERRevent, which can be listened to viaGLMediaEventListener#attributesChanged(GLMediaPlayer, int, long).An occurred
GLMediaPlayer.StreamExceptioncan be read viagetStreamException().GLMediaPlayer Lifecycle
Action GLMediaPlayer.StateBeforeGLMediaPlayer.StateAfterEventplayStream(Uri, int, int, int, int)UninitializedInitialized1,UninitializedInitor (Error+Uninit)initGL(GL)Initialized,UninitializedPlaying,UninitializedPlayor (Error+Uninit)pause(boolean)PlayingPausedPauseresume()PausedPlayingPlaystop()Playing,PausedUninitializedPauseseek(int)Paused,PlayingPaused,Playingnone getNextTexture(GL)any same none getLastTexture()any same none END_OF_STREAMPlayingPausedEOS+PauseGLMediaPlayer.StreamExceptionany Paused,UninitializedError+ (PauseorUninit)destroy(GL)any UninitializedUninitAudio and video Stream IDs
value request get STREAM_ID_NONEmute not available STREAM_ID_AUTOauto unspecified ≥0 specific stream specific stream Current implementations (check each API doc link for details):
NullGLMediaPlayerOMXGLMediaPlayerFFMPEGMediaPlayerAndroidGLMediaPlayerAPI14
Implementations of this interface must implement:
public static final boolean isAvailable();to be properly considered byGLMediaPlayerFactory.create(ClassLoader, String)andGLMediaPlayerFactory.createDefault().Timestamp Accuracy
Timestamp type and value range has been chosen to suit embedded CPUs and characteristics of audio and video streaming. See
TimeFrameI.Audio and video synchronization
The class follows a passive A/V synchronization pattern. Audio is being untouched, while
getNextTexture(GL)delivers a new video frame only, if its timestamp is less thanMAX_VIDEO_ASYNCahead of time. If its timestamp is more thanMAX_VIDEO_ASYNCahead of time, the previous frame is returned. If its timestamp is more thanMAX_VIDEO_ASYNCafter time, the frame is dropped and the next frame is being fetched.https://en.wikipedia.org/wiki/Audio_to_video_synchronization
d_av = v_pts - a_pts;
Recommendation of audio/video pts time lead/lag at production:
- Overall: +40ms and -60ms audio ahead video / audio after video
- Each stage: +5ms and -15ms. audio ahead video / audio after video
Recommendation of av pts time lead/lag at presentation:
- TV: +15ms and -45ms. audio ahead video / audio after video.
- Film: +22ms and -22ms. audio ahead video / audio after video.
Test Streams
Big Buck Bunny 24f 16:9 Big Buck Bunny 320p h264 aac 48000Hz 2 chan http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4 Big Buck Bunny 240p h264 aac 48000Hz 2 chan http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4 Big Buck Bunny 720p mpeg4 ac3 48000Hz 5.1 chan http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_surround.avi Big Buck Bunny 720p msmpeg4v2 mp3 48000Hz 2 chan http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_stereo.avi Big Buck Bunny 720p theora vorbis 48000Hz 2 chan http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_stereo.ogg Big Buck Bunny 1080p mpeg4 ac3 48000Hz 5.1 chan http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_1080p_surround.avi WebM/Matroska (vp8/vorbis) Big Buck Bunny Trailer 640p vp8 vorbis 44100Hz 1 chan http://video.webmfiles.org/big-buck-bunny_trailer.webm Elephants Dream 540p vp8 vorbis 44100Hz 1 chan http://video.webmfiles.org/elephants-dream.webm You Tube http/rtsp Sintel http://www.youtube.com/watch?v=eRsGyueVLvQ rtsp://v3.cache1.c.youtube.com/CiILENy73wIaGQn0LpXnygYbeRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp Audio/Video Sync Five-minute-sync-test1080p https://www.youtube.com/watch?v=szoOsG9137U rtsp://v7.cache8.c.youtube.com/CiILENy73wIaGQm133VvsA46sxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp Audio-Video-Sync-Test-Calibration-23.98fps-24fps https://www.youtube.com/watch?v=cGgf_dbDMsw sound_in_sync_test https://www.youtube.com/watch?v=O-zIZkhXNLE -
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classGLMediaPlayer.ChapterChapter meta-data of stream, seegetChapters().static classGLMediaPlayer.EventMaskChanges attributes event maskstatic interfaceGLMediaPlayer.GLMediaEventListenerAs the contract ofGLMediaPlayer.GLMediaFrameListenerandTextureSequence.TexSeqEventListenerrequests, implementations ofGLMediaPlayer.GLMediaEventListenershall: off-load complex orGLMediaPlayercommands on another thread, or simply changing a volatile state of theirGLEventListenerimplementation.static interfaceGLMediaPlayer.GLMediaFrameListenerstatic classGLMediaPlayer.StateSee Lifecycle.static classGLMediaPlayer.StreamExceptionA StreamException encapsulates a caught exception in the decoder thread, a.k.a StreamWorker, see See StreamWorker Error Handling.-
Nested classes/interfaces inherited from interface com.jogamp.opengl.util.texture.TextureSequence
TextureSequence.TexSeqEventListener<T extends TextureSequence>, TextureSequence.TextureFrame
-
-
Field Summary
Fields Modifier and Type Field Description static Uri.EncodedCameraInputSchemeUri schemename for camera input.static StringCameraPropHeightCamera property "height".static StringCameraPropRateCamera property "rate".static StringCameraPropSizeSCamera property "size", size as string, e.g.static StringCameraPropWidthCamera property "width".static booleanDEBUGstatic booleanDEBUG_AVSYNCstatic booleanDEBUG_NATIVEstatic intMAX_VIDEO_ASYNCMaximum video frame async of 22 milliseconds.static intMIN_VIDEO_ASYNCstatic intSTREAM_ID_AUTOConstant -1 for auto or unspecified.static intSTREAM_ID_NONEConstant -2 for mute or not available.static intTEXTURE_COUNT_DEFAULTDefault texture count, value 3.static intTEXTURE_COUNT_MINMinimum texture count, value 1.-
Fields inherited from interface com.jogamp.opengl.util.texture.TextureSequence
sampler2D, samplerExternalOES
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddEventListener(GLMediaPlayer.GLMediaEventListener l)Adds aGLMediaPlayer.GLMediaEventListenerto this player.voidaddFrameListener(GLMediaPlayer.GLMediaFrameListener l)Adds aGLMediaPlayer.GLMediaFrameListenerto this player.ObjectattachObject(String name, Object obj)Attaches the user object for the given name.GLMediaPlayer.Statedestroy(GL gl)Releases the GL, stream and other resources, includingattached user objects.ObjectdetachObject(String name)Detaches the user object for the given name.intgetAID()Return the audio stream id, see audio and video Stream IDs.String[]getALangs()Return an array of detected audio stream language codes, matchinggetAStreams()array and its indices.com.jogamp.math.Vec4fgetARatioLetterboxBackColor()ReturnsTextureSequence.useARatioLetterbox()background color for added letter-box space, defaults to transparent zero.int[]getAStreams()Return an array of detected audio stream IDs.ObjectgetAttachedObject(String name)Returns the attached user object for the given name.intgetAudioBitrate()Warning: Optional information, may not be supported by implementation.StringgetAudioCodec()Warning: Optional information, may not be supported by implementation.CodecIDgetAudioCodecID()Warning: Optional information, may not be supported by implementation.intgetAudioFrames()Warning: Optional information, may not be supported by implementation.intgetAudioPTS()Returns current audio presentation timestamp (PTS) in milliseconds, try usinggetPTS().AudioSinkgetAudioSink()If implementation uses aAudioSink, it's instance will be returned.floatgetAudioVolume()Returns the audio volume.GLMediaPlayer.ChaptergetChapter(int msec)ReturnsGLMediaPlayer.Chaptercovering given time position in milliseconds or null if none covers given timeGLMediaPlayer.Chapter[]getChapters()ReturnsGLMediaPlayer.Chaptermeta-data from stream, available afterGLMediaPlayer.State.Initializedis reached after issuingplayStream(Uri, int, int, int, int).intgetDecodedFrameCount()intgetDuration()Return total duration of stream in msec.GLMediaPlayer.GLMediaEventListener[]getEventListeners()Return allGLMediaPlayer.GLMediaEventListenerof this player.GLMediaPlayer.GLMediaFrameListener[]getFrameListeners()Return allGLMediaPlayer.GLMediaFrameListenerof this player.floatgetFramerate()Warning: Optional information, may not be supported by implementation.intgetHeight()Returns the height of the video.StringgetLang(int id)Return the matching language code of given stream ID, matching one of the stream IDs ingetVStreams(),getAStreams()orgetSStreams().TextureSequence.TextureFramegetLastTexture()Returns the last updated texture.intgetNextAID()Returns the next audio stream id, rotates.intgetNextSID()Returns the next subtitle stream id, rotates including no-streamTextureSequence.TextureFramegetNextTexture(GL gl)Returns the next texture to be rendered.intgetNextVID()Returns the next video stream id, rotates.StringgetPerfString()Returns a string representation of this player's performance values.floatgetPlaySpeed()Returns the playback speed.intgetPresentedFrameCount()PTSgetPTS()Returns current System Clock Reference (SCR) presentation timestamp (PTS).intgetSID()Return the subtitle stream id, see audio and video Stream IDs.String[]getSLangs()Return an array of detected subtitle stream language codes, matchinggetSStreams()array and its indices.int[]getSStreams()Return an array of detected subtitle stream IDs.GLMediaPlayer.StategetState()See Lifecycle.longgetStreamBitrate()Warning: Optional information, may not be supported by implementation.GLMediaPlayer.StreamExceptiongetStreamException()Returns theGLMediaPlayer.StreamExceptioncaught in the decoder thread, ornullif none occured.StringgetSubtitleCodec()Warning: Optional information, may not be supported by implementation.CodecIDgetSubtitleCodecID()Warning: Optional information, may not be supported by implementation.SubtitleEventListenergetSubtitleEventListener()Returns thesetSubtitleEventListener(SubtitleEventListener)of this player.intgetTextureCount()StringgetTitle()Returns title meta-data from stream, available afterGLMediaPlayer.State.Initializedis reached after issuingplayStream(Uri, int, int, int, int).UrigetUri()Return the stream location, as set byplayStream(Uri, int, int, int, int).intgetVID()Return the video stream id, see audio and video Stream IDs.intgetVideoBitrate()Warning: Optional information, may not be supported by implementation.StringgetVideoCodec()Warning: Optional information, may not be supported by implementation.CodecIDgetVideoCodecID()Warning: Optional information, may not be supported by implementation.intgetVideoFrames()Warning: Optional information, may not be supported by implementation.intgetVideoPTS()Returns current video presentation timestamp (PTS) in milliseconds ofgetLastTexture(), try usinggetPTS().String[]getVLangs()Return an array of detected video stream language codes, matchinggetVStreams()array and its indices.int[]getVStreams()Return an array of detected video stream IDs.intgetWidth()Returns the width of the video.booleanhasStreamID(int id)Return whether the given stream ID is available, i.e.voidinitGL(GL gl)Initializes OpenGL related resources.booleanisAudioMuted()Returns true if audio is muted, i.e.booleanisGLOriented()Returnstrueif the video frame is oriented in OpenGL's coordinate system, origin at bottom left.GLMediaPlayer.Statepause(boolean flush)Pauses the StreamWorker decoding thread.voidplayStream(Uri streamLoc, int vid, int aid, int sid, int textureCount)Issues asynchronous stream initialization.voidplayStream(Uri streamLoc, int vid, String alang, int aid, String slang, int sid, int reqTextureCount)Same asplayStream(Uri, int, int, int, int), but providing desired audio- and subtile languages to be selected.voidprintNativeInfo(PrintStream out)Print native library information of used implementation to given out PrintStream.voidremoveEventListener(GLMediaPlayer.GLMediaEventListener l)Removes aGLMediaPlayer.GLMediaEventListenerto this player.voidremoveFrameListener(GLMediaPlayer.GLMediaFrameListener l)Removes aGLMediaPlayer.GLMediaFrameListenerto this player.GLMediaPlayer.Stateresume()Starts or resumes the StreamWorker decoding thread.intseek(int msec)Seeks to the new absolute position.voidsetARatioAdjustment(boolean v)TogglesTextureSequence.useARatioLetterbox().voidsetARatioLetterbox(boolean v, com.jogamp.math.Vec4f backColor)TogglesTextureSequence.useARatioLetterbox().voidsetAudioChannelLimit(int cc)Limit maximum supported audio channels by user.booleansetAudioVolume(float v)Sets the audio volume, [0f..1f].booleansetPlaySpeed(float rate)Sets the playback speed.voidsetSubtitleEventListener(SubtitleEventListener l)Sets theSubtitleEventListenerfor this player.voidsetTextureMinMagFilter(int[] minMagFilter)Sets the texture min-mag filter, defaults toGL.GL_NEAREST.voidsetTextureUnit(int u)Sets the texture unit.voidsetTextureWrapST(int[] wrapST)Sets the texture min-mag filter, defaults toGL.GL_CLAMP_TO_EDGE.GLMediaPlayer.Statestop()Stops streaming and releases the GL, stream and other resources, but keepsattached user objects.voidswitchStream(int vid, int aid, int sid)Switches currentplayStream(Uri, int, int, int, int)to given stream IDs and continues at samegetVideoPTS().StringtoString()Returns a string representation of this player, incl.booleanuseARatioAdjustment()Returningtrueindicates texture correction for aspect-ratio in the shader.booleanuseARatioLetterbox()Returns whetherTextureSequence.useARatioAdjustment()shall add letter-box space to match aspect-ratio, otherwise it will be zoomed in.-
Methods inherited from interface com.jogamp.opengl.util.texture.TextureSequence
getRequiredExtensionsShaderStub, getTextureFragmentShaderHashCode, getTextureFragmentShaderHashID, getTextureLookupFragmentShaderImpl, getTextureLookupFunctionName, getTextureMinMagFilter, getTextureSampler2DType, getTextureTarget, getTextureUnit, getTextureWrapST, isTextureAvailable, setTextureLookupFunctionName
-
-
-
Field Detail
-
DEBUG
static final boolean DEBUG
-
DEBUG_AVSYNC
static final boolean DEBUG_AVSYNC
-
DEBUG_NATIVE
static final boolean DEBUG_NATIVE
-
TEXTURE_COUNT_DEFAULT
static final int TEXTURE_COUNT_DEFAULT
Default texture count, value 3.- See Also:
- Constant Field Values
-
TEXTURE_COUNT_MIN
static final int TEXTURE_COUNT_MIN
Minimum texture count, value 1. Using the minimum texture count disables multi-threaded decoding.- See Also:
- Constant Field Values
-
STREAM_ID_NONE
static final int STREAM_ID_NONE
Constant -2 for mute or not available. See Audio and video Stream IDs.- See Also:
- Constant Field Values
-
STREAM_ID_AUTO
static final int STREAM_ID_AUTO
Constant -1 for auto or unspecified. See Audio and video Stream IDs.- See Also:
- Constant Field Values
-
CameraInputScheme
static final Uri.Encoded CameraInputScheme
Uri schemename for camera input. E.g.camera:/0for the 1st camera device.The
Uri pathis being used to identify the camera (<id>), where the root fwd-slash is being cut-off.The <id> is usually an integer value indexing the camera ranging from [0..max-number].
The <somewhere> is usually empty, since it would imply a networking camera protocol.
The
Uri queryis used to pass options to the camera using ; as the separator. The latter avoids trouble w/ escaping.camera:/<id> camera:/<id>?width=640;height=480;rate=15 camera:/<id>?size=640x480;rate=15 camera://<somewhere>/<id> camera://<somewhere>/<id>?width=640;height=480;rate=15 camera://<somewhere>/<id>?size=640x480;rate=15 camera:///<id>?width=640;height=480;rate=15 camera:///<id>?size=640x480;rate=15Uri: [scheme:][//authority][path][?query][#fragment] w/ authority: [user-info@]host[:port] Note: 'path' starts w/ fwd slash
-
CameraPropSizeS
static final String CameraPropSizeS
Camera property "size", size as string, e.g.1280x720,hd720. May not be supported on all platforms. SeeCameraInputScheme.- See Also:
- Constant Field Values
-
CameraPropWidth
static final String CameraPropWidth
Camera property "width". SeeCameraInputScheme.- See Also:
- Constant Field Values
-
CameraPropHeight
static final String CameraPropHeight
Camera property "height". SeeCameraInputScheme.- See Also:
- Constant Field Values
-
CameraPropRate
static final String CameraPropRate
Camera property "rate". SeeCameraInputScheme.- See Also:
- Constant Field Values
-
MAX_VIDEO_ASYNC
static final int MAX_VIDEO_ASYNC
Maximum video frame async of 22 milliseconds.- See Also:
- Constant Field Values
-
MIN_VIDEO_ASYNC
static final int MIN_VIDEO_ASYNC
- See Also:
- Constant Field Values
-
-
Method Detail
-
printNativeInfo
void printNativeInfo(PrintStream out)
Print native library information of used implementation to given out PrintStream.
-
getTextureCount
int getTextureCount()
-
setTextureUnit
void setTextureUnit(int u)
Sets the texture unit. Defaults to 0.
-
setTextureMinMagFilter
void setTextureMinMagFilter(int[] minMagFilter)
Sets the texture min-mag filter, defaults toGL.GL_NEAREST.
-
setTextureWrapST
void setTextureWrapST(int[] wrapST)
Sets the texture min-mag filter, defaults toGL.GL_CLAMP_TO_EDGE.
-
useARatioAdjustment
boolean useARatioAdjustment()
Returningtrueindicates texture correction for aspect-ratio in the shader. Graph'sRegionshader will utilizeTextureSequence.setTexCoordBBox(Texture, AABBox, boolean, float[], boolean)for texture-coordinate bounding-box calculation.Returning
falseindicates no correction for aspect-ratio in the shader. Graph'sRegionshader will utilizeTextureSequence.setTexCoordBBoxSimple(Texture, AABBox, float[], boolean)for texture-coordinate bounding-box calculation.Default value is implementation specific and toggling is optional.
Defaults to
trueand toggling not supported.
-
setARatioAdjustment
void setARatioAdjustment(boolean v)
TogglesTextureSequence.useARatioLetterbox().Default value is implementation specific and toggling is optional.
Defaults to
trueand toggling is not supported.- Specified by:
setARatioAdjustmentin interfaceTextureSequence- See Also:
TextureSequence.useARatioLetterbox(),TextureSequence.useARatioAdjustment()
-
useARatioLetterbox
boolean useARatioLetterbox()
Returns whetherTextureSequence.useARatioAdjustment()shall add letter-box space to match aspect-ratio, otherwise it will be zoomed in.Default value is implementation specific and toggling is optional.
Defaults to
falseand toggling is supported viasetARatioLetterbox(boolean, Vec4f)- Specified by:
useARatioLetterboxin interfaceTextureSequence- See Also:
TextureSequence.useARatioAdjustment(),TextureSequence.setARatioLetterbox(boolean, Vec4f)
-
getARatioLetterboxBackColor
com.jogamp.math.Vec4f getARatioLetterboxBackColor()
ReturnsTextureSequence.useARatioLetterbox()background color for added letter-box space, defaults to transparent zero.- Specified by:
getARatioLetterboxBackColorin interfaceTextureSequence
-
setARatioLetterbox
void setARatioLetterbox(boolean v, com.jogamp.math.Vec4f backColor)TogglesTextureSequence.useARatioLetterbox().Default value is implementation specific and toggling is optional.
Impacts only if
TextureSequence.useARatioAdjustment()returnstrue.Defaults to
false.- Specified by:
setARatioLetterboxin interfaceTextureSequence- Parameters:
v- new value forTextureSequence.useARatioLetterbox()backColor- optional background color for added letter-box space, defaults to transparent zero- See Also:
TextureSequence.useARatioLetterbox(),TextureSequence.useARatioAdjustment()
-
setAudioChannelLimit
void setAudioChannelLimit(int cc)
Limit maximum supported audio channels by user.Must be set before
playStream(Uri, int, int, int, int)May be utilized to enforce 1 channel (mono) downsampling in combination with JOAL/OpenAL to experience spatial 3D position effects.
- Parameters:
cc- maximum supported audio channels, will be clipped [1..x], with x being the underlying audio subsystem's maximum- See Also:
playStream(Uri, int, int, int, int)
-
playStream
void playStream(Uri streamLoc, int vid, int aid, int sid, int textureCount) throws IllegalStateException, IllegalArgumentException
Issues asynchronous stream initialization.Lifecycle:
GLMediaPlayer.State.Uninitialized->GLMediaPlayer.State.Initialized1 orGLMediaPlayer.State.UninitializedGLMediaPlayer.State.Initializedis reached asynchronous, i.e. user gets notified viaattributesChanges(..).A possible caught asynchronous
GLMediaPlayer.StreamExceptionwhile initializing the stream off-thread will be thrown atinitGL(GL).Muted audio can be achieved by passing
STREAM_ID_NONEtoaid.Muted video can be achieved by passing
STREAM_ID_NONEtovid, in which casetextureCountis ignored as well as the passed GL object of the subsequentinitGL(GL)call.- Parameters:
streamLoc- the stream locationvid- video stream id, see audio and video Stream IDsaid- audio stream id, see audio and video Stream IDssid- subtitle stream id, see audio and video Stream IDstextureCount- desired number of buffered textures to be decoded off-thread, will be validated by implementation. The minimum value isTEXTURE_COUNT_MIN(single-threaded) or above to enable multi-threaded stream decoding. Default isTEXTURE_COUNT_DEFAULT. Value is ignored if video is muted.- Throws:
IllegalStateException- if not invoked inGLMediaPlayer.State.UninitializedIllegalArgumentException- if arguments are invalid- Since:
- 2.6.0
- See Also:
playStream(Uri, int, String, int, String, int, int)
-
playStream
void playStream(Uri streamLoc, int vid, String alang, int aid, String slang, int sid, int reqTextureCount) throws IllegalStateException, IllegalArgumentException
Same asplayStream(Uri, int, int, int, int), but providing desired audio- and subtile languages to be selected.- Parameters:
streamLoc- the stream locationvid- video stream id, see audio and video Stream IDsalang- desired audio language, passnullto useaidaid- fallback audio stream id in casealangisnull, see audio and video Stream IDsslang- desired subtitle language, passnullto usesidsid- fallback subtitle stream id in casealangisnull, see audio and video Stream IDstextureCount- desired number of buffered textures to be decoded off-thread, will be validated by implementation. The minimum value isTEXTURE_COUNT_MIN(single-threaded) or above to enable multi-threaded stream decoding. Default isTEXTURE_COUNT_DEFAULT. Value is ignored if video is muted.- Throws:
IllegalStateException- if not invoked inGLMediaPlayer.State.UninitializedIllegalArgumentException- if arguments are invalid- Since:
- 2.6.0
- See Also:
playStream(Uri, int, int, int, int)
-
switchStream
void switchStream(int vid, int aid, int sid) throws IllegalStateException, IllegalArgumentExceptionSwitches currentplayStream(Uri, int, int, int, int)to given stream IDs and continues at samegetVideoPTS().Implementation just issues
stop(),seek(int)andplayStream(Uri, int, int, int, int).- Parameters:
vid- video stream id, see audio and video Stream IDsaid- audio stream id, see audio and video Stream IDssid- subtitle stream id, see audio and video Stream IDs- Throws:
IllegalStateExceptionIllegalArgumentException- Since:
- 2.6.0
-
getStreamException
GLMediaPlayer.StreamException getStreamException()
Returns theGLMediaPlayer.StreamExceptioncaught in the decoder thread, ornullif none occured.Method clears the cached
GLMediaPlayer.StreamException, hence an immediate subsequent call will returnnull.- See Also:
GLMediaEventListener#EVENT_CHANGE_ERR,GLMediaPlayer.StreamException
-
initGL
void initGL(GL gl) throws IllegalStateException, GLMediaPlayer.StreamException, GLException
Initializes OpenGL related resources.Lifecycle:
ArgumentGLMediaPlayer.State.Initialized->GLMediaPlayer.State.PausedorGLMediaPlayer.State.Initializedglis ignored if video is muted, seeplayStream(Uri, int, int, int, int).- Parameters:
gl- current GL object. Maybenull, for audio only.- Throws:
IllegalStateException- if not invoked inGLMediaPlayer.State.Initialized.GLMediaPlayer.StreamException- forwarded from the off-thread stream initializationGLException- in case of difficulties to initialize the GL resources
-
getAudioSink
AudioSink getAudioSink()
If implementation uses aAudioSink, it's instance will be returned.The
AudioSinkinstance is available afterplayStream(Uri, int, int, int, int), if used by implementation.
-
destroy
GLMediaPlayer.State destroy(GL gl)
Releases the GL, stream and other resources, includingattached user objects.
-
stop
GLMediaPlayer.State stop()
Stops streaming and releases the GL, stream and other resources, but keepsattached user objects.
-
setPlaySpeed
boolean setPlaySpeed(float rate)
Sets the playback speed.To simplify test, play speed is normalized, i.e.
1.0f: ifMath.abs(1.0f - rate) < 0.01f
- Returns:
- true if successful, otherwise false, i.e. due to unsupported value range of implementation.
-
getPlaySpeed
float getPlaySpeed()
Returns the playback speed.
-
setAudioVolume
boolean setAudioVolume(float v)
Sets the audio volume, [0f..1f].To simplify test, volume is normalized, i.e.
0.0f: ifMath.abs(v) < 0.01f1.0f: ifMath.abs(1.0f - v) < 0.01f
- Returns:
- true if successful, otherwise false, i.e. due to unsupported value range of implementation.
-
getAudioVolume
float getAudioVolume()
Returns the audio volume.
-
isAudioMuted
boolean isAudioMuted()
Returns true if audio is muted, i.e.setAudioVolume(float)to zero.
-
resume
GLMediaPlayer.State resume()
Starts or resumes the StreamWorker decoding thread.Lifecycle:
GLMediaPlayer.State.Paused->GLMediaPlayer.State.Playing
-
pause
GLMediaPlayer.State pause(boolean flush)
Pauses the StreamWorker decoding thread.Lifecycle:
GLMediaPlayer.State.Playing->GLMediaPlayer.State.PausedIf a new frame is desired after the next
resume()call, e.g. to make a snapshot of a camera input stream,flushshall be set totrue.- Parameters:
flush- iftrueflushes the video and audio buffers, otherwise keep them intact.
-
seek
int seek(int msec)
Seeks to the new absolute position. The StreamWorker decoding thread is paused while doing so and the A/V buffers are flushed.Allowed in state
GLMediaPlayer.State.PlayingandGLMediaPlayer.State.Paused, otherwise ignored, see Lifecycle.- Parameters:
msec- absolute desired time position in milliseconds- Returns:
- time current position in milliseconds, after seeking to the desired position
-
getState
GLMediaPlayer.State getState()
See Lifecycle.- Returns:
- the current state, either
GLMediaPlayer.State.Uninitialized,GLMediaPlayer.State.Initialized,GLMediaPlayer.State.PlayingorGLMediaPlayer.State.Paused
-
getVStreams
int[] getVStreams()
Return an array of detected video stream IDs.
-
getVLangs
String[] getVLangs()
Return an array of detected video stream language codes, matchinggetVStreams()array and its indices.The language code is supposed to be 3-letters of `ISO 639-2 language codes`.
- See Also:
getLang(int)
-
getVID
int getVID()
Return the video stream id, see audio and video Stream IDs.
-
getNextVID
int getNextVID()
Returns the next video stream id, rotates.
-
getAStreams
int[] getAStreams()
Return an array of detected audio stream IDs.
-
getALangs
String[] getALangs()
Return an array of detected audio stream language codes, matchinggetAStreams()array and its indices.The language code is supposed to be 3-letters of `ISO 639-2 language codes`.
- See Also:
getLang(int)
-
getAID
int getAID()
Return the audio stream id, see audio and video Stream IDs.
-
getNextAID
int getNextAID()
Returns the next audio stream id, rotates.
-
getSStreams
int[] getSStreams()
Return an array of detected subtitle stream IDs.
-
getSLangs
String[] getSLangs()
Return an array of detected subtitle stream language codes, matchinggetSStreams()array and its indices.The language code is supposed to be 3-letters of `ISO 639-2 language codes`.
- See Also:
getLang(int)
-
getSID
int getSID()
Return the subtitle stream id, see audio and video Stream IDs.
-
getNextSID
int getNextSID()
Returns the next subtitle stream id, rotates including no-stream
-
hasStreamID
boolean hasStreamID(int id)
Return whether the given stream ID is available, i.e. matching one of the stream IDs ingetVStreams(),getAStreams()orgetSStreams().
-
getLang
String getLang(int id)
Return the matching language code of given stream ID, matching one of the stream IDs ingetVStreams(),getAStreams()orgetSStreams().The language code is supposed to be 3-letters of `ISO 639-2 language codes`.
If the stream ID is not available,
undis returned- See Also:
getVStreams(),getAStreams(),getSStreams(),getVLangs(),getALangs(),getSLangs()
-
getDecodedFrameCount
int getDecodedFrameCount()
- Returns:
- the current decoded video frame count since
resume()andseek(int)as increased bygetNextTexture(GL)or the decoding thread.
-
getPresentedFrameCount
int getPresentedFrameCount()
- Returns:
- the current presented video frame count since
resume()andseek(int)as increased bygetNextTexture(GL)for new frames.
-
getPTS
PTS getPTS()
Returns current System Clock Reference (SCR) presentation timestamp (PTS).To retrieve the current interpolated PTS against the stored System Clock Reference (SCR), use:
int pts = mPlayer.getPTS().get(Clock.currentMillis());
-
getVideoPTS
int getVideoPTS()
Returns current video presentation timestamp (PTS) in milliseconds ofgetLastTexture(), try usinggetPTS().The relative millisecond PTS since start of the presentation stored in integer covers a time span of 2'147'483'647 ms (see
Integer.MAX_VALUEor 2'147'483 seconds or 24.855 days.- See Also:
getPTS()
-
getAudioPTS
int getAudioPTS()
Returns current audio presentation timestamp (PTS) in milliseconds, try usinggetPTS().The relative millisecond PTS since start of the presentation stored in integer covers a time span of 2'147'483'647 ms (see
Integer.MAX_VALUEor 2'147'483 seconds or 24.855 days.- See Also:
getPTS()
-
getLastTexture
TextureSequence.TextureFrame getLastTexture() throws IllegalStateException
Returns the last updated texture.In case the instance is just initialized, it shall return a
Not blocking.TextureFrameobject with valid attributes. The texture content may be undefined until the first call ofTextureSequence.getNextTexture(GL).
Returns the last decoded Video
TextureSequence.TextureFrame.- Specified by:
getLastTexturein interfaceTextureSequence- Throws:
IllegalStateException- if not invoked inGLMediaPlayer.State.PausedorGLMediaPlayer.State.Playing
-
getNextTexture
TextureSequence.TextureFrame getNextTexture(GL gl) throws IllegalStateException
Returns the next texture to be rendered.Implementation shall return the next frame if available, may block if a next frame may arrive soon. Otherwise implementation shall return the last frame.
Shall return
nullin case no next or last frame is available.Returns the next Video
TextureSequence.TextureFrameto be rendered in sync withgetPTS()and keeps decoding going.In case the current state is not
GLMediaPlayer.State.Playing,getLastTexture()is returned.- Specified by:
getNextTexturein interfaceTextureSequence- Throws:
IllegalStateException- if not invoked inGLMediaPlayer.State.PausedorGLMediaPlayer.State.Playing- See Also:
addEventListener(GLMediaEventListener),GLMediaEventListener#newFrameAvailable(GLMediaPlayer, TextureFrame, long)
-
getUri
Uri getUri()
Return the stream location, as set byplayStream(Uri, int, int, int, int).- Since:
- 2.3.0
-
getVideoCodecID
CodecID getVideoCodecID()
Warning: Optional information, may not be supported by implementation.- Returns:
- the
CodecIDof the video stream, if available
-
getVideoCodec
String getVideoCodec()
Warning: Optional information, may not be supported by implementation.- Returns:
- the codec of the video stream, if available
-
getAudioCodecID
CodecID getAudioCodecID()
Warning: Optional information, may not be supported by implementation.- Returns:
- the
CodecIDof the audio stream, if available
-
getAudioCodec
String getAudioCodec()
Warning: Optional information, may not be supported by implementation.- Returns:
- the codec of the audio stream, if available
-
getSubtitleCodecID
CodecID getSubtitleCodecID()
Warning: Optional information, may not be supported by implementation.- Returns:
- the
CodecIDof the subtitle stream, if available
-
getSubtitleCodec
String getSubtitleCodec()
Warning: Optional information, may not be supported by implementation.- Returns:
- the codec of the subtitle stream, if available
-
getVideoFrames
int getVideoFrames()
Warning: Optional information, may not be supported by implementation.- Returns:
- the total number of video frames
-
getAudioFrames
int getAudioFrames()
Warning: Optional information, may not be supported by implementation.- Returns:
- the total number of audio frames
-
getDuration
int getDuration()
Return total duration of stream in msec.The duration stored in integer covers 2'147'483'647 ms (see
Integer.MAX_VALUEor 2'147'483 seconds or 24.855 days.
-
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
-
isGLOriented
boolean isGLOriented()
Returnstrueif the video frame is oriented in OpenGL's coordinate system, origin at bottom left.Otherwise returns
false, i.e. video frame is oriented origin at top left.falseis the default assumption for videos, but user shall not rely on.falseGL orientation leads toTexture.getMustFlipVertically()==true, as reflected by allTextureSequence.TextureFrame'sTextures retrieved viagetLastTexture()orgetNextTexture(GL).
-
getWidth
int getWidth()
Returns the width of the video.
-
getHeight
int getHeight()
Returns the height of the video.
-
getTitle
String getTitle()
Returns title meta-data from stream, available afterGLMediaPlayer.State.Initializedis reached after issuingplayStream(Uri, int, int, int, int).In case no title meta-data is being used, the
getUri()basename w/o suffix is being returned.
-
getChapters
GLMediaPlayer.Chapter[] getChapters()
ReturnsGLMediaPlayer.Chaptermeta-data from stream, available afterGLMediaPlayer.State.Initializedis reached after issuingplayStream(Uri, int, int, int, int).
-
getChapter
GLMediaPlayer.Chapter getChapter(int msec)
ReturnsGLMediaPlayer.Chaptercovering given time position in milliseconds or null if none covers given time- Parameters:
msec- desired chapter covering time position in milliseconds
-
toString
String toString()
Returns a string representation of this player, incl. state and audio/video details.
-
getPerfString
String getPerfString()
Returns a string representation of this player's performance values.
-
addEventListener
void addEventListener(GLMediaPlayer.GLMediaEventListener l)
Adds aGLMediaPlayer.GLMediaEventListenerto this player.
-
removeEventListener
void removeEventListener(GLMediaPlayer.GLMediaEventListener l)
Removes aGLMediaPlayer.GLMediaEventListenerto this player.
-
getEventListeners
GLMediaPlayer.GLMediaEventListener[] getEventListeners()
Return allGLMediaPlayer.GLMediaEventListenerof this player.
-
addFrameListener
void addFrameListener(GLMediaPlayer.GLMediaFrameListener l)
Adds aGLMediaPlayer.GLMediaFrameListenerto this player.
-
removeFrameListener
void removeFrameListener(GLMediaPlayer.GLMediaFrameListener l)
Removes aGLMediaPlayer.GLMediaFrameListenerto this player.
-
getFrameListeners
GLMediaPlayer.GLMediaFrameListener[] getFrameListeners()
Return allGLMediaPlayer.GLMediaFrameListenerof this player.
-
setSubtitleEventListener
void setSubtitleEventListener(SubtitleEventListener l)
Sets theSubtitleEventListenerfor this player.
-
getSubtitleEventListener
SubtitleEventListener getSubtitleEventListener()
Returns thesetSubtitleEventListener(SubtitleEventListener)of this player.
-
getAttachedObject
Object getAttachedObject(String name)
Returns the attached user object for the given name.
-
attachObject
Object attachObject(String name, Object obj)
Attaches the user object for the given name. Returns the previously set object, may be null.
-
-