2 * Copyright (C) <2016> Vivia Nikolaidou <vivia@toolsonair.com>
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.
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.
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.
20 #ifndef __GST_VIDEO_TIME_CODE_H__
21 #define __GST_VIDEO_TIME_CODE_H__
24 #include <gst/video/video-prelude.h>
28 typedef struct _GstVideoTimeCodeConfig GstVideoTimeCodeConfig;
29 typedef struct _GstVideoTimeCode GstVideoTimeCode;
30 typedef struct _GstVideoTimeCodeInterval GstVideoTimeCodeInterval;
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
38 * Flags related to the time code information.
39 * For drop frame, only 30000/1001 and 60000/1001 frame rates are supported.
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)
49 * GST_VIDEO_TIME_CODE_ALLOW_MORE_THAN_24H = (1<<2)
50 * GST_VIDEO_TIME_CODE_ALLOW_NEGATIVE = (1<<3)
52 } GstVideoTimeCodeFlags;
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
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.
64 * The configuration of the time code.
68 struct _GstVideoTimeCodeConfig {
71 GstVideoTimeCodeFlags flags;
72 GDateTime *latest_daily_jam;
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
84 * @field_count must be 0 for progressive video and 1 or 2 for interlaced.
86 * A representation of a SMPTE time code.
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.
95 struct _GstVideoTimeCode {
96 GstVideoTimeCodeConfig config;
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
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)
117 struct _GstVideoTimeCodeInterval {
124 #define GST_VIDEO_TIME_CODE_INIT { {0, 0, 0, NULL}, 0, 0, 0, 0, 0 }
126 #define GST_TYPE_VIDEO_TIME_CODE (gst_video_time_code_get_type())
128 GType gst_video_time_code_get_type (void);
131 GstVideoTimeCode * gst_video_time_code_new (guint fps_n,
133 GDateTime * latest_daily_jam,
134 GstVideoTimeCodeFlags flags,
142 GstVideoTimeCode * gst_video_time_code_new_empty (void);
145 GstVideoTimeCode * gst_video_time_code_new_from_string (const gchar * tc_str);
148 GstVideoTimeCode * gst_video_time_code_new_from_date_time (guint fps_n,
151 GstVideoTimeCodeFlags flags,
155 void gst_video_time_code_free (GstVideoTimeCode * tc);
158 GstVideoTimeCode * gst_video_time_code_copy (const GstVideoTimeCode * tc);
161 void gst_video_time_code_init (GstVideoTimeCode * tc,
164 GDateTime * latest_daily_jam,
165 GstVideoTimeCodeFlags flags,
173 void gst_video_time_code_init_from_date_time (GstVideoTimeCode * tc,
177 GstVideoTimeCodeFlags flags,
181 void gst_video_time_code_clear (GstVideoTimeCode * tc);
184 gboolean gst_video_time_code_is_valid (const GstVideoTimeCode * tc);
187 gint gst_video_time_code_compare (const GstVideoTimeCode * tc1,
188 const GstVideoTimeCode * tc2);
191 void gst_video_time_code_increment_frame (GstVideoTimeCode * tc);
194 void gst_video_time_code_add_frames (GstVideoTimeCode * tc,
198 gchar *gst_video_time_code_to_string (const GstVideoTimeCode * tc);
201 GDateTime *gst_video_time_code_to_date_time (const GstVideoTimeCode * tc);
204 guint64 gst_video_time_code_nsec_since_daily_jam (const GstVideoTimeCode * tc);
207 guint64 gst_video_time_code_frames_since_daily_jam (const GstVideoTimeCode * tc);
210 GstVideoTimeCode * gst_video_time_code_add_interval (const GstVideoTimeCode * tc, const GstVideoTimeCodeInterval * tc_inter);
212 #define GST_TYPE_VIDEO_TIME_CODE_INTERVAL (gst_video_time_code_interval_get_type())
214 GType gst_video_time_code_interval_get_type (void);
217 GstVideoTimeCodeInterval * gst_video_time_code_interval_new (guint hours,
223 GstVideoTimeCodeInterval * gst_video_time_code_interval_new_from_string (const gchar * tc_inter_str);
226 void gst_video_time_code_interval_free (GstVideoTimeCodeInterval * tc);
229 GstVideoTimeCodeInterval * gst_video_time_code_interval_copy (const GstVideoTimeCodeInterval * tc);
232 void gst_video_time_code_interval_init (GstVideoTimeCodeInterval * tc,
239 void gst_video_time_code_interval_clear (GstVideoTimeCodeInterval * tc);
243 #endif /* __GST_VIDEO_TIME_CODE_H__ */