diff options
author | Sven Gothel <[email protected]> | 2023-10-16 04:03:24 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-10-16 04:03:24 +0200 |
commit | ee29eaf770d0d3627e5989dcae58a87cf27184d3 (patch) | |
tree | 60a9841ddb9a92878b7b6c1f6a52e39ada89c0e5 /src/demos/com/jogamp/opengl | |
parent | 76cf00ea0a157b33af9b2ffa608ded992f8c0ff2 (diff) |
Bug 1472: GLMediaPlayer: Expose SCR PTS and encourage its usage, removes user from selecting video or audio PTS.
Diffstat (limited to 'src/demos/com/jogamp/opengl')
-rw-r--r-- | src/demos/com/jogamp/opengl/demos/av/MovieCube.java | 7 | ||||
-rw-r--r-- | src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java | 8 | ||||
-rw-r--r-- | src/demos/com/jogamp/opengl/demos/av/MovieSimple.java | 18 |
3 files changed, 18 insertions, 15 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/av/MovieCube.java b/src/demos/com/jogamp/opengl/demos/av/MovieCube.java index d94a3a05b..f26bce920 100644 --- a/src/demos/com/jogamp/opengl/demos/av/MovieCube.java +++ b/src/demos/com/jogamp/opengl/demos/av/MovieCube.java @@ -41,6 +41,7 @@ import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLRunnable; import com.jogamp.common.net.Uri; +import com.jogamp.common.os.Clock; import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; @@ -214,8 +215,7 @@ public class MovieCube implements GLEventListener { final GLAnimatorControl anim = drawable.getAnimator(); final float lfps = null != anim ? anim.getLastFPS() : 0f; final float tfps = null != anim ? anim.getTotalFPS() : 0f; - final boolean hasVideo = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID(); - final float pts = ( hasVideo ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS() ) / 1000f; + final float pts = mPlayer.getPTS().get(Clock.currentMillis()) / 1000f; // Note: MODELVIEW is from [ -1 .. 1 ] @@ -296,7 +296,8 @@ public class MovieCube implements GLEventListener { return; } System.err.println("MC "+e); - final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); + final int pts0 = mPlayer.getPTS().get(Clock.currentMillis()); + int pts1 = 0; switch(e.getKeySymbol()) { case KeyEvent.VK_V: { diff --git a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java index 7fe8f821c..19d3ad115 100644 --- a/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java +++ b/src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java @@ -41,6 +41,7 @@ import com.jogamp.opengl.GLUniformData; import com.jogamp.opengl.fixedfunc.GLMatrixFunc; import com.jogamp.common.net.Uri; +import com.jogamp.common.os.Clock; import com.jogamp.common.os.Platform; import com.jogamp.common.util.InterruptSource; import com.jogamp.graph.curve.Region; @@ -172,8 +173,7 @@ public class MovieSBSStereo implements StereoGLEventListener { final GLAnimatorControl anim = drawable.getAnimator(); final float lfps = null != anim ? anim.getLastFPS() : 0f; final float tfps = null != anim ? anim.getTotalFPS() : 0f; - final boolean hasVideo = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID(); - final float pts = ( hasVideo ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS() ) / 1000f; + final float pts = mPlayer.getPTS().get(Clock.currentMillis()) / 1000f; // Note: MODELVIEW is from [ 0 .. height ] @@ -240,7 +240,7 @@ public class MovieSBSStereo implements StereoGLEventListener { if(y>surfHeight/2) { final float dp = (float)(x-prevMouseX)/(float)surfWidth; - final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); + final int pts0 = mPlayer.getPTS().get(Clock.currentMillis()); mPlayer.seek(pts0 + (int) (mPlayer.getDuration() * dp)); } else { mPlayer.resume(); @@ -266,7 +266,7 @@ public class MovieSBSStereo implements StereoGLEventListener { return; } System.err.println("MC "+e); - final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); + final int pts0 = mPlayer.getPTS().get(Clock.currentMillis()); int pts1 = 0; switch(e.getKeySymbol()) { case KeyEvent.VK_O: displayOSD = !displayOSD; break; diff --git a/src/demos/com/jogamp/opengl/demos/av/MovieSimple.java b/src/demos/com/jogamp/opengl/demos/av/MovieSimple.java index 9bf984d40..e754a0076 100644 --- a/src/demos/com/jogamp/opengl/demos/av/MovieSimple.java +++ b/src/demos/com/jogamp/opengl/demos/av/MovieSimple.java @@ -33,6 +33,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import com.jogamp.common.av.PTS; import com.jogamp.common.net.Uri; import com.jogamp.common.os.Clock; import com.jogamp.common.util.InterruptSource; @@ -154,9 +155,10 @@ public class MovieSimple implements GLEventListener { final GLAnimatorControl anim = drawable.getAnimator(); final float lfps = null != anim ? anim.getLastFPS() : 0f; final float tfps = null != anim ? anim.getTotalFPS() : 0f; - final boolean hasVideo = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID(); - final float pts = ( hasVideo ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS() ) / 1000f; - final float scr = ( Clock.currentMillis() - play_t0 ) / 1000f; + final long currentMillis = Clock.currentMillis(); + final PTS scr = mPlayer.getPTS(); + final float pts_s = scr.get(currentMillis) / 1000f; + final float now = currentMillis / 1000f; // Note: MODELVIEW is from [ 0 .. height ] @@ -166,7 +168,7 @@ public class MovieSimple implements GLEventListener { final String ptsPrec = null != regionFPS ? "3.1" : "3.0"; final String text1 = String.format("%0"+ptsPrec+"f/%0"+ptsPrec+"f/%0"+ptsPrec+"f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f, swap %d", - scr, pts, mPlayer.getDuration() / 1000f, + now, pts_s, mPlayer.getDuration() / 1000f, mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(), aspect, mPlayer.getFramerate(), lfps, tfps, drawable.getGL().getSwapInterval()); final String text2 = String.format("audio: id %d, kbps %d, codec %s", @@ -259,7 +261,7 @@ public class MovieSimple implements GLEventListener { if(y>surfHeight/2) { final float dp = (float)(x-prevMouseX)/(float)surfWidth; - final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); + final int pts0 = mPlayer.getPTS().get(Clock.currentMillis()); mPlayer.seek(pts0 + (int) (mPlayer.getDuration() * dp)); } else { mPlayer.resume(); @@ -291,7 +293,7 @@ public class MovieSimple implements GLEventListener { return; } System.err.println("MC "+e); - final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); + final int pts0 = mPlayer.getPTS().get(Clock.currentMillis()); int pts1 = 0; switch(e.getKeySymbol()) { case KeyEvent.VK_V: { @@ -313,6 +315,7 @@ public class MovieSimple implements GLEventListener { case KeyEvent.VK_PAGE_DOWN: pts1 = pts0 - 30000; break; case KeyEvent.VK_HOME: case KeyEvent.VK_BACK_SPACE: { + System.err.println("Seek: "+pts0+" -> 0"); mPlayer.seek(0); break; } @@ -373,6 +376,7 @@ public class MovieSimple implements GLEventListener { } if( 0 != pts1 ) { + System.err.println("Seek: "+pts0+" -> "+pts1); mPlayer.seek(pts1); } } }; @@ -629,7 +633,6 @@ public class MovieSimple implements GLEventListener { } if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Play) ) { window.getAnimator().resetFPSCounter(); - ms.play_t0 = Clock.currentMillis(); } boolean destroy = false; @@ -671,7 +674,6 @@ public class MovieSimple implements GLEventListener { } }; public final static MyGLMediaEventListener myGLMediaEventListener = new MyGLMediaEventListener(); - long play_t0 = 0; static boolean loopEOS = false; static boolean origSize; |