aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java20
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java16
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java48
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java10
-rw-r--r--src/jogl/native/libav/ffmpeg_impl_template.c16
-rw-r--r--src/jogl/native/libav/ffmpeg_static.c2
7 files changed, 73 insertions, 47 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java
index 283e566f5..14d438abc 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java
@@ -618,22 +618,8 @@ public class MediaPlayer extends Widget {
return getInfo(mPlayer.getPTS().get(currentMillis), mPlayer.getDuration(), mPlayer, full);
}
public static String getInfo(final int ptsMS, final int durationMS, final GLMediaPlayer mPlayer, final boolean full) {
- final String name, chapter;
+ final String chapter;
{
- final String basename;
- final String s = mPlayer.getUri().path.decode();
- final int li = s.lastIndexOf('/');
- if( 0 < li ) {
- basename = s.substring(li+1);
- } else {
- basename = s;
- }
- final int di = basename.lastIndexOf('.');
- if( 0 < di ) {
- name = basename.substring(0, di);
- } else {
- name = basename;
- }
final GLMediaPlayer.Chapter c = mPlayer.getChapter(ptsMS);
if( null != c ) {
chapter = " - "+c.title;
@@ -652,7 +638,7 @@ public class MediaPlayer extends Widget {
mPlayer.getSID(), mPlayer.getLang(mPlayer.getSID()) );
final String text3 = String.format("video: id %d, kbps %d, codec %s",
mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec());
- return text1+"\n"+text2+"\n"+text3+"\n"+name+chapter;
+ return text1+"\n"+text2+"\n"+text3+"\n"+mPlayer.getTitle()+chapter;
} else {
final String vinfo, ainfo, sinfo;
if( mPlayer.getVID() != GLMediaPlayer.STREAM_ID_NONE ) {
@@ -673,7 +659,7 @@ public class MediaPlayer extends Widget {
final String text1 = String.format("%s / %s (%.0f %%), %s (%01.2fx, vol %1.2f), A/R %.2f%s%s%s",
PTS.millisToTimeStr(ptsMS, false), PTS.millisToTimeStr(durationMS, false), pct*100,
mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(), aspect, vinfo, ainfo, sinfo);
- return text1+"\n"+name+chapter;
+ return text1+"\n"+mPlayer.getTitle()+chapter;
}
}
public static String getMultilineTime(final long currentMillis, final GLMediaPlayer mPlayer) {
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 d129af621..646280f08 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
@@ -862,6 +862,14 @@ public interface GLMediaPlayer extends TextureSequence {
/** Returns the height of the video. */
public int getHeight();
+ /**
+ * Returns title meta-data from stream, available after {@link State#Initialized} is reached after issuing {@link #playStream(Uri, int, int, int, int)}.
+ * <p>
+ * In case no title meta-data is being used, the {@link #getUri()} basename w/o suffix is being returned.
+ * </p>
+ */
+ public String getTitle();
+
/** Returns {@link Chapter} meta-data from stream, available after {@link State#Initialized} is reached after issuing {@link #playStream(Uri, int, int, int, int)}. */
public Chapter[] getChapters();
/**
diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
index 3900e4089..3585f7ab2 100644
--- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
+++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
@@ -336,10 +336,10 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
r_alangs = new String[] { "n/a" };
}
final String icodec = "android";
- updateAttributes(new int[] { 0 }, new String[] { "und" }, 0 /* fake */,
- r_aids, r_alangs, r_aid,
- new int[0], new String[0], GLMediaPlayer.STREAM_ID_NONE,
- mp.getVideoWidth(), mp.getVideoHeight(), 0, 0, 0, 0f, 0, 0, mp.getDuration(), icodec, icodec);
+ updateAttributes(null, new int[] { 0 }, new String[] { "und" },
+ 0 /* fake */, r_aids, r_alangs,
+ r_aid, new int[0], new String[0],
+ GLMediaPlayer.STREAM_ID_NONE, mp.getVideoWidth(), mp.getVideoHeight(), 0, 0, 0, 0f, 0, 0, mp.getDuration(), icodec, icodec);
/**
mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
@@ -372,10 +372,10 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
}
}
}
- updateAttributes(new int[]{0}, new String[] { "und" }, 0 /* fake */,
- new int[0], new String[0], GLMediaPlayer.STREAM_ID_NONE,
- new int[0], new String[0], GLMediaPlayer.STREAM_ID_NONE,
- size.width, size.height, 0, 0, 0, fpsRange[1]/1000f, 0, 0, 0, icodec, icodec);
+ updateAttributes(null, new int[]{0}, new String[] { "und" },
+ 0 /* fake */, new int[0], new String[0],
+ GLMediaPlayer.STREAM_ID_NONE, new int[0], new String[0],
+ GLMediaPlayer.STREAM_ID_NONE, size.width, size.height, 0, 0, 0, fpsRange[1]/1000f, 0, 0, 0, icodec, icodec);
}
}
private static String camSz2Str(final Camera.Size csize) {
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index 01a385b0d..5df858b2d 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -132,6 +132,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
private float audioVolume = 1.0f;
/** Shall be set by the {@link #initStreamImpl(int, int, int)} method implementation. */
+ private String title = "undef";
+ /** Shall be set by the {@link #initStreamImpl(int, int, int)} method implementation. */
private int[] v_streams = new int[0];
/** Shall be set by the {@link #initStreamImpl(int, int, int)} method implementation. */
private String[] v_langs = new String[0];
@@ -749,9 +751,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
@Override
public void switchStream(final int vid, final int aid, final int sid) throws IllegalStateException, IllegalArgumentException {
- System.err.println("XXX VID "+getVID()+" -> "+vid);
- System.err.println("XXX AID "+getAID()+" -> "+aid);
- System.err.println("XXX SID "+getSID()+" -> "+sid);
final int v_pts = getVideoPTS();
stop();
seek(v_pts);
@@ -953,11 +952,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
final float _fps = 24f;
final int _duration = 10*60*1000; // msec
final int _totalFrames = (int) ( (_duration/1000)*_fps );
- updateAttributes(new int[0], new String[0], GLMediaPlayer.STREAM_ID_NONE,
- new int[0], new String[0], GLMediaPlayer.STREAM_ID_NONE, // audio
- new int[0], new String[0], GLMediaPlayer.STREAM_ID_NONE, // subs
- TestTexture.singleton.getWidth(),
- TestTexture.singleton.getHeight(), 0, 0, 0, _fps, _totalFrames, 0, _duration, "png-static", null);
+ updateAttributes("test", new int[0], new String[0],
+ GLMediaPlayer.STREAM_ID_NONE, new int[0], new String[0], // audio
+ GLMediaPlayer.STREAM_ID_NONE, new int[0], new String[0], // subs
+ GLMediaPlayer.STREAM_ID_NONE,
+ TestTexture.singleton.getWidth(), TestTexture.singleton.getHeight(), 0, 0, 0, _fps, _totalFrames, 0, _duration, "png-static", null);
}
protected abstract TextureFrame createTexImage(GL gl, int texName);
@@ -1700,11 +1699,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
* Further calls are issues off-thread by the decoder implementation.
* </p>
*/
- protected final void updateAttributes(final int[] v_streams, final String[] v_langs, int vid,
- final int[] a_streams, final String[] a_langs, int aid,
- final int[] s_streams, final String[] s_langs, int sid,
- 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) {
+ protected final void updateAttributes(final String title,
+ final int[] v_streams, final String[] v_langs,
+ int vid, final int[] a_streams, final String[] a_langs,
+ int aid, final int[] s_streams, final String[] s_langs,
+ int sid, 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) {
final GLMediaPlayer.EventMask eventMask = new GLMediaPlayer.EventMask();
final boolean wasUninitialized = state == State.Uninitialized;
@@ -1712,6 +1712,25 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
eventMask.setBit(GLMediaPlayer.EventMask.Bit.Init);
setState( State.Initialized );
}
+ if( null == title ) {
+ final String basename;
+ final String s = getUri().path.decode();
+ final int li = s.lastIndexOf('/');
+ if( 0 < li ) {
+ basename = s.substring(li+1);
+ } else {
+ basename = s;
+ }
+ final int di = basename.lastIndexOf('.');
+ if( 0 < di ) {
+ this.title = basename.substring(0, di);
+ } else {
+ this.title = basename;
+ }
+ } else {
+ this.title = title;
+ }
+
this.v_streams = v_streams;
this.v_langs = v_langs;
this.a_streams = a_streams;
@@ -1942,6 +1961,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
protected void updateMetadata() {}
@Override
+ public String getTitle() { return this.title; }
+
+ @Override
public Chapter[] getChapters() { return new Chapter[0]; }
@Override
diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
index f88894ce4..f0f06bf2a 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
@@ -144,15 +144,15 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl {
}
@Override
- protected final void initStreamImpl(final int vid, final int aid, int sid) throws IOException {
+ protected final void initStreamImpl(final int vid, final int aid, final int sid) throws IOException {
texData = createTestTextureData();
final float _fps = 24f;
final int _duration = 10*60*1000; // msec
final int _totalFrames = (int) ( (_duration/1000)*_fps );
- updateAttributes(new int[] { 0 }, new String[] { "und" }, 0 /* fake */,
- new int[0], new String[0], GLMediaPlayer.STREAM_ID_NONE,
- new int[0], new String[0], GLMediaPlayer.STREAM_ID_NONE,
- texData.getWidth(), texData.getHeight(), 0, 0, 0, _fps, _totalFrames, 0, _duration, "png-static", null);
+ updateAttributes("null", new int[] { 0 }, new String[] { "und" },
+ 0 /* fake */, new int[0], new String[0],
+ GLMediaPlayer.STREAM_ID_NONE, new int[0], new String[0],
+ GLMediaPlayer.STREAM_ID_NONE, texData.getWidth(), texData.getHeight(), 0, 0, 0, _fps, _totalFrames, 0, _duration, "png-static", null);
}
@Override
protected final void initGLImpl(final GL gl) throws IOException, GLException {
diff --git a/src/jogl/native/libav/ffmpeg_impl_template.c b/src/jogl/native/libav/ffmpeg_impl_template.c
index b6569751a..1d938102f 100644
--- a/src/jogl/native/libav/ffmpeg_impl_template.c
+++ b/src/jogl/native/libav/ffmpeg_impl_template.c
@@ -353,9 +353,9 @@ static inline const char* meta_get_value(AVDictionary *tags, const char* key)
}
return NULL;
}
-static inline const char* meta_get_chapter_title(AVChapter *chapter)
+static inline const char* meta_get_title(AVDictionary *tags)
{
- return meta_get_value(chapter->metadata, "title");
+ return meta_get_value(tags, "title");
}
static inline const char* meta_get_language(AVDictionary *tags)
{
@@ -431,6 +431,15 @@ static void _updateJavaAttributes(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) {
(*env)->SetObjectArrayElement(env, s_langs, i, (*env)->NewStringUTF(env, lang1));
}
}
+ jstring jtitle;
+ {
+ const char* title = meta_get_title(pAV->pFormatCtx->metadata);
+ if( NULL != title ) {
+ jtitle = (*env)->NewStringUTF(env, title);
+ } else {
+ jtitle = NULL;
+ }
+ }
(*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, ffmpeg_jni_mid_setupFFAttributes,
pAV->vid, pAV->vPixFmt, pAV->vBufferPlanes,
@@ -441,6 +450,7 @@ static void _updateJavaAttributes(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) {
JoglCommon_ExceptionCheck1_throwNewRuntimeException(env, "FFmpeg: Exception occured at setupFFAttributes(..)");
(*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, ffmpeg_jni_mid_updateAttributes,
+ jtitle,
v_streams, v_langs, pAV->vid,
a_streams, a_langs, pAV->aid,
s_streams, s_langs, pAV->sid,
@@ -1885,7 +1895,7 @@ JNIEXPORT jstring JNICALL FF_FUNC(getChapterTitle0)
return NULL;
}
AVChapter *chapter = pAV->pFormatCtx->chapters[idx];
- const char* title = meta_get_chapter_title(chapter);
+ const char* title = meta_get_title(chapter->metadata);
return NULL != title ? (*env)->NewStringUTF(env, title) : NULL;
}
diff --git a/src/jogl/native/libav/ffmpeg_static.c b/src/jogl/native/libav/ffmpeg_static.c
index b1ca77e1a..10b388e75 100644
--- a/src/jogl/native/libav/ffmpeg_static.c
+++ b/src/jogl/native/libav/ffmpeg_static.c
@@ -66,7 +66,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGStaticNatives_i
ffmpeg_jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V");
ffmpeg_jni_mid_updateAttributes = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes",
- "([I[Ljava/lang/String;I[I[Ljava/lang/String;I[I[Ljava/lang/String;IIIIIIFIIILjava/lang/String;Ljava/lang/String;)V");
+ "(Ljava/lang/String;[I[Ljava/lang/String;I[I[Ljava/lang/String;I[I[Ljava/lang/String;IIIIIIFIIILjava/lang/String;Ljava/lang/String;)V");
ffmpeg_jni_mid_setIsGLOriented = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "setIsGLOriented", "(Z)V");
ffmpeg_jni_mid_setupFFAttributes = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "setupFFAttributes", "(IIIIIIIIIIIIIII)V");
ffmpeg_jni_mid_isAudioFormatSupported = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "isAudioFormatSupported", "(III)Z");