JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
SubtitleEvent.java
Go to the documentation of this file.
1package com.jogamp.opengl.util.av;
2
3import com.jogamp.common.av.PTS;
4
5/**
6 * Generic subtitle event
7 * <p>
8 * It is mandatory that the receiver {@link #release()} this instance
9 * after processing, allowing the resource owner to free or reuse it.
10 * </p>
11 */
12public abstract class SubtitleEvent {
13 /** {@link SubtitleEvent} Implementation Type */
14 public enum Type {
15 /** {@link SubTextEvent} */
17 /** {@link SubBitmapEvent} */
19 /** {@link SubEmptyEvent} */
20 Empty
21 };
22 /** Implementation {@link Type} of this instance. */
23 public final Type type;
24 /** {@link CodecID} of this subtitle event. */
25 public final CodecID codec;
26 /** Language code, supposed to be 3-letters of `ISO 639-2 language codes` */
27 public final String lang;
28 /** PTS start time in milliseconds to start showing this subtitle event. */
29 public final int pts_start;
30 /**
31 * PTS end time in milliseconds to end showing this subtitle event.
32 * <p>
33 * {@link SubBitmapEvent} often (e.g. {@link CodecID#HDMV_PGS}) have an infinite end-time, i.e. ({@link Integer#MAX_VALUE},
34 * and shall be overwritten by the next one or {@link SubEmptyEvent}.
35 * </p>
36 * @see #isEndDefined()
37 */
38 public final int pts_end;
39
40 /**
41 *
42 * @param type
43 * @param codec the {@link CodecID}
44 * @param lang language code, supposed to be 3-letters of `ISO 639-2 language codes`
45 * @param pts_start pts start in ms, see {@link #pts_start}
46 * @param pts_end pts end in ms, see {@link #pts_end}
47 */
48 public SubtitleEvent(final Type type, final CodecID codec, final String lang, final int pts_start, final int pts_end) {
49 this.type = type;
50 this.codec = codec;
51 this.lang = lang;
52 this.pts_start = pts_start;
53 this.pts_end = pts_end;
54 }
55
56 /** Release the resources, if any, back to the owner. */
57 public abstract void release();
58
59 public final int getDuration() { return pts_end - pts_start + 1; }
60
61 /** See {@link #pts_end}. */
62 public final boolean isEndDefined() { return pts_end < Integer.MAX_VALUE; }
63
64 public final String getStartString() {
65 final boolean ied = isEndDefined();
66 final String pts_start_s = 0 <= pts_start ? PTS.toTimeStr(pts_start, true) : "undef";
67 final String pts_end_s = 0 <= pts_end && ied ? PTS.toTimeStr(pts_end, true) : "undef";
68 return "Sub[codec "+codec+", lang '"+lang+"', type "+type+", ["+pts_start_s+".."+pts_end_s+"] "+(ied?getDuration():"undef")+" ms";
69 }
70}
final String lang
Language code, supposed to be 3-letters of ISO 639-2 language codes
abstract void release()
Release the resources, if any, back to the owner.
SubtitleEvent(final Type type, final CodecID codec, final String lang, final int pts_start, final int pts_end)
final int pts_end
PTS end time in milliseconds to end showing this subtitle event.
final int pts_start
PTS start time in milliseconds to start showing this subtitle event.
final Type type
Implementation Type of this instance.
final CodecID codec
CodecID of this subtitle event.
final boolean isEndDefined()
See pts_end.
FFmpeg/libAV analog AVCodecID.
Definition: CodecID.java:37
SubtitleEvent Implementation Type