1/* GStreamer
2 * Copyright (C) <2016> Vivia Nikolaidou <vivia@toolsonair.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef __GST_VIDEO_TIME_CODE_H__
21#define __GST_VIDEO_TIME_CODE_H__
22
23#include <gst/gst.h>
24#include <gst/video/video-prelude.h>
25
26G_BEGIN_DECLS
27
28typedef struct _GstVideoTimeCodeConfig GstVideoTimeCodeConfig;
29typedef struct _GstVideoTimeCode GstVideoTimeCode;
30typedef struct _GstVideoTimeCodeInterval GstVideoTimeCodeInterval;
31
32/**
33 * GstVideoTimeCodeFlags:
34 * @GST_VIDEO_TIME_CODE_FLAGS_NONE: No flags
35 * @GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME: Whether we have drop frame rate
36 * @GST_VIDEO_TIME_CODE_FLAGS_INTERLACED: Whether we have interlaced video
37 *
38 * Flags related to the time code information.
39 * For drop frame, only 30000/1001 and 60000/1001 frame rates are supported.
40 *
41 * Since: 1.10
42 */
43typedef enum
44{
45 GST_VIDEO_TIME_CODE_FLAGS_NONE = 0,
46 GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME = (1<<0),
47 GST_VIDEO_TIME_CODE_FLAGS_INTERLACED = (1<<1)
48 /* Not supported yet:
49 * GST_VIDEO_TIME_CODE_ALLOW_MORE_THAN_24H = (1<<2)
50 * GST_VIDEO_TIME_CODE_ALLOW_NEGATIVE = (1<<3)
51 */
52} GstVideoTimeCodeFlags;
53
54/**
55 * GstVideoTimeCodeConfig:
56 * @fps_n: Numerator of the frame rate
57 * @fps_d: Denominator of the frame rate
58 * @flags: the corresponding #GstVideoTimeCodeFlags
59 * @latest_daily_jam: The latest daily jam information, if present, or NULL
60 *
61 * Supported frame rates: 30000/1001, 60000/1001 (both with and without drop
62 * frame), and integer frame rates e.g. 25/1, 30/1, 50/1, 60/1.
63 *
64 * The configuration of the time code.
65 *
66 * Since: 1.10
67 */
68struct _GstVideoTimeCodeConfig {
69 guint fps_n;
70 guint fps_d;
71 GstVideoTimeCodeFlags flags;
72 GDateTime *latest_daily_jam;
73};
74
75/**
76 * GstVideoTimeCode:
77 * @hours: the hours field of #GstVideoTimeCode
78 * @minutes: the minutes field of #GstVideoTimeCode
79 * @seconds: the seconds field of #GstVideoTimeCode
80 * @frames: the frames field of #GstVideoTimeCode
81 * @field_count: Interlaced video field count
82 * @config: the corresponding #GstVideoTimeCodeConfig
83 *
84 * @field_count must be 0 for progressive video and 1 or 2 for interlaced.
85 *
86 * A representation of a SMPTE time code.
87 *
88 * @hours must be positive and less than 24. Will wrap around otherwise.
89 * @minutes and @seconds must be positive and less than 60.
90 * @frames must be less than or equal to @config.fps_n / @config.fps_d
91 * These values are *NOT* automatically normalized.
92 *
93 * Since: 1.10
94 */
95struct _GstVideoTimeCode {
96 GstVideoTimeCodeConfig config;
97
98 guint hours;
99 guint minutes;
100 guint seconds;
101 guint frames;
102 guint field_count;
103};
104
105/**
106 * GstVideoTimeCodeInterval:
107 * @hours: the hours field of #GstVideoTimeCodeInterval
108 * @minutes: the minutes field of #GstVideoTimeCodeInterval
109 * @seconds: the seconds field of #GstVideoTimeCodeInterval
110 * @frames: the frames field of #GstVideoTimeCodeInterval
111 *
112 * A representation of a difference between two #GstVideoTimeCode instances.
113 * Will not necessarily correspond to a real timecode (e.g. 00:00:10;00)
114 *
115 * Since: 1.12
116 */
117struct _GstVideoTimeCodeInterval {
118 guint hours;
119 guint minutes;
120 guint seconds;
121 guint frames;
122};
123
124#define GST_VIDEO_TIME_CODE_INIT { {0, 0, 0, NULL}, 0, 0, 0, 0, 0 }
125
126#define GST_TYPE_VIDEO_TIME_CODE (gst_video_time_code_get_type())
127GST_VIDEO_API
128GType gst_video_time_code_get_type (void);
129
130GST_VIDEO_API
131GstVideoTimeCode * gst_video_time_code_new (guint fps_n,
132 guint fps_d,
133 GDateTime * latest_daily_jam,
134 GstVideoTimeCodeFlags flags,
135 guint hours,
136 guint minutes,
137 guint seconds,
138 guint frames,
139 guint field_count);
140
141GST_VIDEO_API
142GstVideoTimeCode * gst_video_time_code_new_empty (void);
143
144GST_VIDEO_API
145GstVideoTimeCode * gst_video_time_code_new_from_string (const gchar * tc_str);
146
147GST_VIDEO_DEPRECATED_FOR(gst_video_time_code_new_from_date_time_full)
148GstVideoTimeCode * gst_video_time_code_new_from_date_time (guint fps_n,
149 guint fps_d,
150 GDateTime * dt,
151 GstVideoTimeCodeFlags flags,
152 guint field_count);
153
154GST_VIDEO_API
155GstVideoTimeCode * gst_video_time_code_new_from_date_time_full (guint fps_n,
156 guint fps_d,
157 GDateTime * dt,
158 GstVideoTimeCodeFlags flags,
159 guint field_count);
160
161GST_VIDEO_API
162void gst_video_time_code_free (GstVideoTimeCode * tc);
163
164GST_VIDEO_API
165GstVideoTimeCode * gst_video_time_code_copy (const GstVideoTimeCode * tc);
166
167GST_VIDEO_API
168void gst_video_time_code_init (GstVideoTimeCode * tc,
169 guint fps_n,
170 guint fps_d,
171 GDateTime * latest_daily_jam,
172 GstVideoTimeCodeFlags flags,
173 guint hours,
174 guint minutes,
175 guint seconds,
176 guint frames,
177 guint field_count);
178
179GST_VIDEO_DEPRECATED_FOR(gst_video_time_code_init_from_date_time_full)
180void gst_video_time_code_init_from_date_time (GstVideoTimeCode * tc,
181 guint fps_n,
182 guint fps_d,
183 GDateTime * dt,
184 GstVideoTimeCodeFlags flags,
185 guint field_count);
186GST_VIDEO_API
187gboolean gst_video_time_code_init_from_date_time_full (GstVideoTimeCode * tc,
188 guint fps_n,
189 guint fps_d,
190 GDateTime * dt,
191 GstVideoTimeCodeFlags flags,
192 guint field_count);
193
194GST_VIDEO_API
195void gst_video_time_code_clear (GstVideoTimeCode * tc);
196
197GST_VIDEO_API
198gboolean gst_video_time_code_is_valid (const GstVideoTimeCode * tc);
199
200GST_VIDEO_API
201gint gst_video_time_code_compare (const GstVideoTimeCode * tc1,
202 const GstVideoTimeCode * tc2);
203
204GST_VIDEO_API
205void gst_video_time_code_increment_frame (GstVideoTimeCode * tc);
206
207GST_VIDEO_API
208void gst_video_time_code_add_frames (GstVideoTimeCode * tc,
209 gint64 frames);
210
211GST_VIDEO_API
212gchar *gst_video_time_code_to_string (const GstVideoTimeCode * tc);
213
214GST_VIDEO_API
215GDateTime *gst_video_time_code_to_date_time (const GstVideoTimeCode * tc);
216
217GST_VIDEO_API
218guint64 gst_video_time_code_nsec_since_daily_jam (const GstVideoTimeCode * tc);
219
220GST_VIDEO_API
221guint64 gst_video_time_code_frames_since_daily_jam (const GstVideoTimeCode * tc);
222
223GST_VIDEO_API
224GstVideoTimeCode * gst_video_time_code_add_interval (const GstVideoTimeCode * tc, const GstVideoTimeCodeInterval * tc_inter);
225
226#define GST_TYPE_VIDEO_TIME_CODE_INTERVAL (gst_video_time_code_interval_get_type())
227GST_VIDEO_API
228GType gst_video_time_code_interval_get_type (void);
229
230GST_VIDEO_API
231GstVideoTimeCodeInterval * gst_video_time_code_interval_new (guint hours,
232 guint minutes,
233 guint seconds,
234 guint frames);
235
236GST_VIDEO_API
237GstVideoTimeCodeInterval * gst_video_time_code_interval_new_from_string (const gchar * tc_inter_str);
238
239GST_VIDEO_API
240void gst_video_time_code_interval_free (GstVideoTimeCodeInterval * tc);
241
242GST_VIDEO_API
243GstVideoTimeCodeInterval * gst_video_time_code_interval_copy (const GstVideoTimeCodeInterval * tc);
244
245GST_VIDEO_API
246void gst_video_time_code_interval_init (GstVideoTimeCodeInterval * tc,
247 guint hours,
248 guint minutes,
249 guint seconds,
250 guint frames);
251
252GST_VIDEO_API
253void gst_video_time_code_interval_clear (GstVideoTimeCodeInterval * tc);
254
255G_END_DECLS
256
257#endif /* __GST_VIDEO_TIME_CODE_H__ */
258

source code of include/gstreamer-1.0/gst/video/gstvideotimecode.h