GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
TimeFrameI.java
Go to the documentation of this file.
1/**
2 * Copyright 2013-2023 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.common.av;
29
30/**
31 * Integer time frame in milliseconds, maybe specialized for texture/video, audio, .. animated content.
32 * <p>
33 * Type and value range has been chosen to suit embedded CPUs
34 * and characteristics of audio / video streaming and animations.
35 * Milliseconds of type integer with a maximum value of {@link Integer#MAX_VALUE}
36 * will allow tracking time up 2,147,483.647 seconds or
37 * 24 days 20 hours 31 minutes and 23 seconds, see {@link #getPTS()} and {@link #getDuration()}.
38 * </p>
39 * <p>
40 * Milliseconds granularity is also more than enough to deal with A-V synchronization,
41 * where the threshold usually lies within 22ms.
42 * </p>
43 * <p>
44 * Milliseconds granularity for displaying video frames might seem inaccurate
45 * for each single frame, i.e. 60Hz != 16ms, however, accumulated values diminish
46 * this error and vertical sync is achieved by build-in V-Sync of the video drivers.
47 * </p>
48 */
49public class TimeFrameI {
50 /** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE == 0x80000000 == {@value}. Sync w/ native code. */
51 public static final int INVALID_PTS = 0x80000000;
52
53 /** Constant marking the end of the stream PTS, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ native code. */
54 public static final int END_OF_STREAM_PTS = 0x7FFFFFFF;
55
56 protected int pts;
57 protected int duration;
58
59 /**
60 * Ctor w/ zero duration and {@link #INVALID_PTS}.
61 */
62 public TimeFrameI() {
64 duration = 0;
65 }
66 /**
67 * Create a new instance
68 * @param pts frame pts in milliseconds, see {@link #getPTS()}
69 * @param duration frame duration in milliseconds, see {@link #getDuration()}
70 * @see #getPTS()
71 * @see #getDuration()
72 */
73 public TimeFrameI(final int pts, final int duration) {
74 this.pts = pts;
75 this.duration = duration;
76 }
77
78 /**
79 * Returns this frame's presentation timestamp (PTS) in milliseconds.
80 * <p>
81 * The relative millisecond PTS since start of the presentation stored in integer
82 * covers a time span of 2'147'483'647 ms (see {@link Integer#MAX_VALUE}
83 * or 2'147'483 seconds or 24.855 days.
84 * </p>
85 */
86 public final int getPTS() { return pts; }
87 /**
88 * Set this frame's presentation timestamp (PTS) in milliseconds.
89 * @see #getPTS()
90 */
91 public final void setPTS(final int pts) { this.pts = pts; }
92 /**
93 * Get this frame's duration in milliseconds.
94 * <p>
95 * The duration stored in integer covers 2'147'483'647 ms (see {@link Integer#MAX_VALUE}
96 * or 2'147'483 seconds or 24.855 days.
97 * </p>
98 */
99 public final int getDuration() { return duration; }
100 /**
101 * Set this frame's duration in milliseconds.
102 * @see #getDuration()
103 */
104 public final void setDuration(final int duration) { this.duration = duration; }
105
106 @Override
107 public String toString() {
108 return "TimeFrame[pts " + pts + " ms, l " + duration + " ms]";
109 }
110}
Integer time frame in milliseconds, maybe specialized for texture/video, audio, .
Definition: TimeFrameI.java:49
static final int END_OF_STREAM_PTS
Constant marking the end of the stream PTS, i.e.
Definition: TimeFrameI.java:54
final int getPTS()
Returns this frame's presentation timestamp (PTS) in milliseconds.
Definition: TimeFrameI.java:86
TimeFrameI()
Ctor w/ zero duration and INVALID_PTS.
Definition: TimeFrameI.java:62
static final int INVALID_PTS
Constant marking an invalid PTS, i.e.
Definition: TimeFrameI.java:51
final int getDuration()
Get this frame's duration in milliseconds.
Definition: TimeFrameI.java:99
final void setDuration(final int duration)
Set this frame's duration in milliseconds.
final void setPTS(final int pts)
Set this frame's presentation timestamp (PTS) in milliseconds.
Definition: TimeFrameI.java:91
TimeFrameI(final int pts, final int duration)
Create a new instance.
Definition: TimeFrameI.java:73