aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demos/com/jogamp/opengl/demos/av/MovieCube.java7
-rw-r--r--src/demos/com/jogamp/opengl/demos/av/MovieSBSStereo.java8
-rw-r--r--src/demos/com/jogamp/opengl/demos/av/MovieSimple.java18
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java22
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java7
5 files changed, 43 insertions, 19 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;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
index e3ef27303..740d0fda8 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
@@ -37,8 +37,10 @@ import java.util.List;
import com.jogamp.common.av.AudioFormat;
import com.jogamp.common.av.AudioSink;
+import com.jogamp.common.av.PTS;
import com.jogamp.common.av.TimeFrameI;
import com.jogamp.common.net.Uri;
+import com.jogamp.common.os.Clock;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureSequence;
@@ -612,23 +614,39 @@ public interface GLMediaPlayer extends TextureSequence {
*/
public int getPresentedFrameCount();
+
+ /**
+ * Returns current System Clock Reference (SCR) presentation timestamp ({@link PTS}).
+ * <p>
+ * To retrieve the current interpolated PTS against the stored System Clock Reference (SCR), use:
+ * <pre>
+ * int pts = mPlayer.getPTS().get(Clock.currentMillis());
+ * </pre>
+ * </p>
+ **/
+ public PTS getPTS();
+
/**
- * Returns current video presentation timestamp (PTS) in milliseconds of {@link #getLastTexture()}
+ * Returns current video presentation timestamp (PTS) in milliseconds of {@link #getLastTexture()},
+ * try using {@link #getPTS()}.
* <p>
* The relative millisecond PTS since start of the presentation stored in integer
* covers a time span of 2'147'483'647 ms (see {@link Integer#MAX_VALUE}
* or 2'147'483 seconds or 24.855 days.
* </p>
+ * @see #getPTS()
**/
public int getVideoPTS();
/**
- * Returns current audio presentation timestamp (PTS) in milliseconds.
+ * Returns current audio presentation timestamp (PTS) in milliseconds,
+ * try using {@link #getPTS()}.
* <p>
* The relative millisecond PTS since start of the presentation stored in integer
* covers a time span of 2'147'483'647 ms (see {@link Integer#MAX_VALUE}
* or 2'147'483 seconds or 24.855 days.
* </p>
+ * @see #getPTS()
**/
public int getAudioPTS();
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index 3520ddf0a..106a374bf 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -350,12 +350,15 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
public final int getPresentedFrameCount() { return presentedFrameCount; }
@Override
- public final int getVideoPTS() { return video_pts_last.getLast(); }
+ public final PTS getPTS() { return av_scr; }
+
+ @Override
+ public final int getVideoPTS() { return video_pts_last.get(Clock.currentMillis()); }
@Override
public final int getAudioPTS() {
if( State.Uninitialized != state && null != audioSink ) {
- return audioSink.getPTS().getLast();
+ return audioSink.getPTS().get(Clock.currentMillis());
}
return 0;
}