video: GST_EXPORT -> GST_VIDEO_API
[platform/upstream/gstreamer.git] / gst-libs / gst / video / gstvideotimecode.h
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
26 G_BEGIN_DECLS
27
28 typedef struct _GstVideoTimeCodeConfig GstVideoTimeCodeConfig;
29 typedef struct _GstVideoTimeCode GstVideoTimeCode;
30 typedef 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  */
43 typedef 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  */
68 struct _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  */
95 struct _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  */
117 struct _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())
127 GST_VIDEO_API
128 GType gst_video_time_code_get_type (void);
129
130 GST_VIDEO_API
131 GstVideoTimeCode * 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
141 GST_VIDEO_API
142 GstVideoTimeCode * gst_video_time_code_new_empty    (void);
143
144 GST_VIDEO_API
145 GstVideoTimeCode * gst_video_time_code_new_from_string    (const gchar * tc_str);
146
147 GST_VIDEO_API
148 GstVideoTimeCode * 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
154 GST_VIDEO_API
155 void gst_video_time_code_free                       (GstVideoTimeCode       * tc);
156
157 GST_VIDEO_API
158 GstVideoTimeCode * gst_video_time_code_copy         (const GstVideoTimeCode * tc);
159
160 GST_VIDEO_API
161 void gst_video_time_code_init                       (GstVideoTimeCode       * tc,
162                                                      guint                    fps_n,
163                                                      guint                    fps_d,
164                                                      GDateTime              * latest_daily_jam,
165                                                      GstVideoTimeCodeFlags    flags,
166                                                      guint                    hours,
167                                                      guint                    minutes,
168                                                      guint                    seconds,
169                                                      guint                    frames,
170                                                      guint                    field_count);
171
172 GST_VIDEO_API
173 void gst_video_time_code_init_from_date_time        (GstVideoTimeCode       * tc,
174                                                      guint                    fps_n,
175                                                      guint                    fps_d,
176                                                      GDateTime              * dt,
177                                                      GstVideoTimeCodeFlags    flags,
178                                                      guint                    field_count);
179
180 GST_VIDEO_API
181 void gst_video_time_code_clear                      (GstVideoTimeCode       * tc);
182
183 GST_VIDEO_API
184 gboolean gst_video_time_code_is_valid               (const GstVideoTimeCode * tc);
185
186 GST_VIDEO_API
187 gint gst_video_time_code_compare                    (const GstVideoTimeCode * tc1,
188                                                      const GstVideoTimeCode * tc2);
189
190 GST_VIDEO_API
191 void gst_video_time_code_increment_frame            (GstVideoTimeCode       * tc);
192
193 GST_VIDEO_API
194 void gst_video_time_code_add_frames                 (GstVideoTimeCode       * tc,
195                                                      gint64                   frames);
196
197 GST_VIDEO_API
198 gchar *gst_video_time_code_to_string                (const GstVideoTimeCode * tc);
199
200 GST_VIDEO_API
201 GDateTime *gst_video_time_code_to_date_time         (const GstVideoTimeCode * tc);
202
203 GST_VIDEO_API
204 guint64 gst_video_time_code_nsec_since_daily_jam    (const GstVideoTimeCode * tc);
205
206 GST_VIDEO_API
207 guint64 gst_video_time_code_frames_since_daily_jam  (const GstVideoTimeCode * tc);
208
209 GST_VIDEO_API
210 GstVideoTimeCode * gst_video_time_code_add_interval (const GstVideoTimeCode * tc, const GstVideoTimeCodeInterval * tc_inter);
211
212 #define GST_TYPE_VIDEO_TIME_CODE_INTERVAL (gst_video_time_code_interval_get_type())
213 GST_VIDEO_API
214 GType gst_video_time_code_interval_get_type (void);
215
216 GST_VIDEO_API
217 GstVideoTimeCodeInterval * gst_video_time_code_interval_new  (guint                    hours,
218                                                      guint                    minutes,
219                                                      guint                    seconds,
220                                                      guint                    frames);
221
222 GST_VIDEO_API
223 GstVideoTimeCodeInterval * gst_video_time_code_interval_new_from_string    (const gchar * tc_inter_str);
224
225 GST_VIDEO_API
226 void gst_video_time_code_interval_free                   (GstVideoTimeCodeInterval       * tc);
227
228 GST_VIDEO_API
229 GstVideoTimeCodeInterval * gst_video_time_code_interval_copy (const GstVideoTimeCodeInterval * tc);
230
231 GST_VIDEO_API
232 void gst_video_time_code_interval_init                   (GstVideoTimeCodeInterval       * tc,
233                                                      guint                    hours,
234                                                      guint                    minutes,
235                                                      guint                    seconds,
236                                                      guint                    frames);
237
238 GST_VIDEO_API
239 void gst_video_time_code_interval_clear                  (GstVideoTimeCodeInterval       * tc);
240
241 G_END_DECLS
242
243 #endif /* __GST_VIDEO_TIME_CODE_H__ */