aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-02-02 14:25:12 +0100
committerSven Göthel <[email protected]>2024-02-02 14:25:12 +0100
commit7928ed90104f71fb53ae8201b3140b8e347b83ee (patch)
treee34c9a984f6a565041735b5c01d3befca4814542
parent020f998cad685ce2267751196528b31ce939764c (diff)
Bug 1493: Supply language code to SubtitleEvent, perhaps allowsing player to select font for ASS/Text rendering; Remove GLMediaPlayer's getStreamLang() as replaced by getLang()
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java27
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/SubBitmapEvent.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/SubTextEvent.java11
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java19
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java9
6 files changed, 44 insertions, 29 deletions
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 958dc72b5..191b96e56 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
@@ -704,7 +704,10 @@ public interface GLMediaPlayer extends TextureSequence {
public int[] getVStreams();
/**
- * Return an array of detected video stream languages, matching {@link #getVStreams()} array and its indices.
+ * Return an array of detected video stream language codes, matching {@link #getVStreams()} array and its indices.
+ * <p>
+ * The language code is supposed to be 3-letters of `ISO 639-2 language codes`.
+ * </p>
*/
public String[] getVLangs();
@@ -722,7 +725,10 @@ public interface GLMediaPlayer extends TextureSequence {
public int[] getAStreams();
/**
- * Return an array of detected audio stream languages, matching {@link #getAStreams()} array and its indices.
+ * Return an array of detected audio stream language codes, matching {@link #getAStreams()} array and its indices.
+ * <p>
+ * The language code is supposed to be 3-letters of `ISO 639-2 language codes`.
+ * </p>
*/
public String[] getALangs();
@@ -740,7 +746,10 @@ public interface GLMediaPlayer extends TextureSequence {
public int[] getSStreams();
/**
- * Return an array of detected subtitle stream languages, matching {@link #getSStreams()} array and its indices.
+ * Return an array of detected subtitle stream language codes, matching {@link #getSStreams()} array and its indices.
+ * <p>
+ * The language code is supposed to be 3-letters of `ISO 639-2 language codes`.
+ * </p>
*/
public String[] getSLangs();
@@ -758,9 +767,12 @@ public interface GLMediaPlayer extends TextureSequence {
public boolean hasStreamID(int id);
/**
- * Return the matching language of given stream ID, matching one of the stream IDs in {@link #getVStreams()}, {@link #getAStreams()} or {@link #getSStreams()}.
+ * Return the matching language code of given stream ID, matching one of the stream IDs in {@link #getVStreams()}, {@link #getAStreams()} or {@link #getSStreams()}.
* <p>
- * If the stream ID is not available, {@code "und"} is returned
+ * The language code is supposed to be 3-letters of `ISO 639-2 language codes`.
+ * </p>
+ * <p>
+ * If the stream ID is not available, {@code und} is returned
* </p>
*/
public String getLang(int id);
@@ -975,11 +987,6 @@ public interface GLMediaPlayer extends TextureSequence {
*/
public Chapter getChapter(int msec);
- /**
- * Returns the stream language metadata for the given stream id if available, otherwise {@code null}.
- */
- public String getStreamLang(int id);
-
/** Returns a string representation of this player, incl. state and audio/video details. */
@Override
public String toString();
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/SubBitmapEvent.java b/src/jogl/classes/com/jogamp/opengl/util/av/SubBitmapEvent.java
index 0032aeffc..078450d2e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/SubBitmapEvent.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/SubBitmapEvent.java
@@ -53,6 +53,7 @@ public class SubBitmapEvent extends SubtitleEvent {
/**
* Texture Event ctor
* @param codec the {@link CodecID}
+ * @param lang language code, supposed to be 3-letters of `ISO 639-2 language codes`
* @param pos texture position
* @param dim texture dimension
* @param tex the {@link Texture} or {@code null} if unused
@@ -60,8 +61,8 @@ public class SubBitmapEvent extends SubtitleEvent {
* @param pts_end pts end in ms, often {@link #isEndDefined()} for bitmap'ed types see {@link #pts_end}
* @param owner {@link Texture} owner code-stub to release the texture
*/
- public SubBitmapEvent(final CodecID codec, final Vec2i pos, final Vec2i dim, final Texture tex, final int pts_start, final int pts_end, final TextureOwner owner) {
- super(SubtitleEvent.Type.Bitmap, codec, pts_start, pts_end);
+ public SubBitmapEvent(final CodecID codec, final String lang, final Vec2i pos, final Vec2i dim, final Texture tex, final int pts_start, final int pts_end, final TextureOwner owner) {
+ super(SubtitleEvent.Type.Bitmap, codec, lang, pts_start, pts_end);
position = pos;
dimension = dim;
texture = tex;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java b/src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java
index d6796dc4d..3f98665a0 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/SubEmptyEvent.java
@@ -34,7 +34,7 @@ public class SubEmptyEvent extends SubtitleEvent {
* Empty event ctor
*/
public SubEmptyEvent(final int pts_start, final int pts_end) {
- super(SubtitleEvent.Type.Empty, CodecID.NONE, pts_start, pts_end);
+ super(SubtitleEvent.Type.Empty, CodecID.NONE, "und", pts_start, pts_end);
}
@Override
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/SubTextEvent.java b/src/jogl/classes/com/jogamp/opengl/util/av/SubTextEvent.java
index d699d9300..622c5d29a 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/SubTextEvent.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/SubTextEvent.java
@@ -93,13 +93,14 @@ public class SubTextEvent extends SubtitleEvent {
/**
* ASS/SAA Event Line ctor
* @param codec the {@link CodecID}
- * @param fmt input format of {@code ass}, currently only {@link SubTextEvent.TextFormat#ASS} and {@link SubTextEvent.TextFormat#TEXT} is supported
+ * @param lang language code, supposed to be 3-letters of `ISO 639-2 language codes`
+ * @param fmt input format of {@code ass}
* @param ass ASS/SAA compatible event line according to {@link ASSType}
- * @param pts_start pts start in ms, provided for {@link SubTextEvent.TextFormat#ASS} and {@link SubTextEvent.TextFormat#TEXT}
- * @param pts_end pts end in ms, provided for {@link SubTextEvent.TextFormat#ASS} and {@link SubTextEvent.TextFormat#TEXT}
+ * @param pts_start pts start in ms
+ * @param pts_end pts end in ms
*/
- public SubTextEvent(final CodecID codec, final TextFormat fmt, final String ass, final int pts_start, final int pts_end) {
- super(SubtitleEvent.Type.Text, codec, pts_start, pts_end);
+ public SubTextEvent(final CodecID codec, final String lang, final TextFormat fmt, final String ass, final int pts_start, final int pts_end) {
+ super(SubtitleEvent.Type.Text, codec, lang, pts_start, pts_end);
this.textFormat = fmt;
ASSType assType = ASSType.TEXT;
int start = -1;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java b/src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java
index e75fff3f8..34efe34fb 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/SubtitleEvent.java
@@ -23,6 +23,8 @@ public abstract class SubtitleEvent {
public final Type type;
/** {@link CodecID} of this subtitle event. */
public final CodecID codec;
+ /** Language code, supposed to be 3-letters of `ISO 639-2 language codes` */
+ public final String lang;
/** PTS start time in milliseconds to start showing this subtitle event. */
public final int pts_start;
/**
@@ -35,9 +37,18 @@ public abstract class SubtitleEvent {
*/
public final int pts_end;
- public SubtitleEvent(final Type type, final CodecID codec, final int pts_start, final int pts_end) {
+ /**
+ *
+ * @param type
+ * @param codec the {@link CodecID}
+ * @param lang language code, supposed to be 3-letters of `ISO 639-2 language codes`
+ * @param pts_start pts start in ms, see {@link #pts_start}
+ * @param pts_end pts end in ms, see {@link #pts_end}
+ */
+ public SubtitleEvent(final Type type, final CodecID codec, final String lang, final int pts_start, final int pts_end) {
this.type = type;
this.codec = codec;
+ this.lang = lang;
this.pts_start = pts_start;
this.pts_end = pts_end;
}
@@ -54,8 +65,6 @@ public abstract class SubtitleEvent {
final boolean ied = isEndDefined();
final String pts_start_s = 0 <= pts_start ? PTS.toTimeStr(pts_start, true) : "undef";
final String pts_end_s = 0 <= pts_end && ied ? PTS.toTimeStr(pts_end, true) : "undef";
- return "Sub[codec "+codec+", type "+type+", ["+pts_start_s+".."+pts_end_s+"] "+(ied?getDuration():"undef")+" ms";
+ return "Sub[codec "+codec+", lang '"+lang+"', type "+type+", ["+pts_start_s+".."+pts_end_s+"] "+(ied?getDuration():"undef")+" ms";
}
-
-
-} \ No newline at end of file
+}
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index aa89713d3..8d45edb87 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -1783,12 +1783,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
}
protected final void pushSubtitleText(final String text, final int start_display_pts, final int end_display_pts) {
if( null != subEventListener ) {
- subEventListener.run( new SubTextEvent(this.scodecID, SubTextEvent.TextFormat.TEXT, text, start_display_pts, end_display_pts) );
+ subEventListener.run( new SubTextEvent(this.scodecID, getLang(getSID()), SubTextEvent.TextFormat.TEXT, text, start_display_pts, end_display_pts) );
}
}
protected final void pushSubtitleASS(final String ass, final int start_display_pts, final int end_display_pts) {
if( null != subEventListener ) {
- subEventListener.run( new SubTextEvent(this.scodecID, SubTextEvent.TextFormat.ASS, ass, start_display_pts, end_display_pts) );
+ subEventListener.run( new SubTextEvent(this.scodecID, getLang(getSID()), SubTextEvent.TextFormat.ASS, ass, start_display_pts, end_display_pts) );
}
}
/** {@link GLMediaPlayerImpl#pushSubtitleTex(Object, int, int, int, int, int, int, int, int, int)} */
@@ -1818,7 +1818,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
subTex.set(texWidth, texHeight, width, height);
}
if( null != subEventListener ) {
- subEventListener.run( new SubBitmapEvent(this.scodecID, new Vec2i(x, y), new Vec2i(width, height),
+ subEventListener.run( new SubBitmapEvent(this.scodecID, getLang(getSID()), new Vec2i(x, y), new Vec2i(width, height),
subTex, start_display_pts, end_display_pts, subTexRelease) );
} else {
subTexRelease.release(subTex); // release right away
@@ -2201,9 +2201,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
}
@Override
- public String getStreamLang(final int id) { return "n/a"; }
-
- @Override
public final String toString() {
final String tt = PTS.toTimeStr(getDuration());
final String loc = ( null != streamLoc ) ? streamLoc.toString() : "<undefined stream>" ;