JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
SubBitmapEvent.java
Go to the documentation of this file.
1/**
2 * Copyright 2024 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.opengl.util.av;
29
30import com.jogamp.math.Vec2i;
31import com.jogamp.opengl.util.texture.Texture;
32
33/**
34 * Bitmap {@link Texture} event of {@link SubtitleEvent}
35 * <p>
36 * Consider {@link SubtitleEvent#pts_end} and {@link SubEmptyEvent}.
37 * </p>
38 */
39public class SubBitmapEvent extends SubtitleEvent {
40 /** To be implemented by the {@link Texture} owner to release the texture. */
41 public static interface TextureOwner {
42 /** The given {@link Texture} is to be released by the owner. */
43 void release(Texture tex);
44 }
45 /** Subtitle texture position */
46 public final Vec2i position;
47 /** Subtitle texture dimension */
48 public final Vec2i dimension;
49 /** Subtitle texture or {@code null} if unused */
51 private final TextureOwner owner;
52
53 /**
54 * Texture Event ctor
55 * @param codec the {@link CodecID}
56 * @param lang language code, supposed to be 3-letters of `ISO 639-2 language codes`
57 * @param pos texture position
58 * @param dim texture dimension
59 * @param tex the {@link Texture} or {@code null} if unused
60 * @param pts_start pts start in ms
61 * @param pts_end pts end in ms, often {@link #isEndDefined()} for bitmap'ed types see {@link #pts_end}
62 * @param owner {@link Texture} owner code-stub to release the texture
63 */
64 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) {
66 position = pos;
67 dimension = dim;
68 texture = tex;
69 this.owner = owner;
70 }
71
72 /**
73 * {@inheritDoc}
74 * <p>
75 * The {@link #texture} is released back to the owner
76 * </p>
77 */
78 @Override
79 public void release() {
80 final Texture t = texture;
81 texture = null;
82 if( null != t ) {
83 owner.release(t);
84 }
85 }
86 @Override
87 public String toString() {
88 return getStartString()+", pos "+position+", dim "+dimension+", "+texture+"]";
89 }
90}
2D Vector based upon two integer components.
Definition: Vec2i.java:34
Bitmap Texture event of SubtitleEvent.
final Vec2i dimension
Subtitle texture dimension.
Texture texture
Subtitle texture or null if unused.
final Vec2i position
Subtitle texture position.
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)
Texture Event ctor.
void release()
Release the resources, if any, back to the owner.
final String lang
Language code, supposed to be 3-letters of ISO 639-2 language codes
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 CodecID codec
CodecID of this subtitle event.
Represents an OpenGL texture object.
Definition: Texture.java:173
FFmpeg/libAV analog AVCodecID.
Definition: CodecID.java:37
SubtitleEvent Implementation Type
To be implemented by the Texture owner to release the texture.
void release(Texture tex)
The given Texture is to be released by the owner.