| 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_DEPRECATED_FOR(gst_video_time_code_new_from_date_time_full) |
| 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 | GstVideoTimeCode * 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 | |
| 161 | GST_VIDEO_API |
| 162 | void gst_video_time_code_free (GstVideoTimeCode * tc); |
| 163 | |
| 164 | GST_VIDEO_API |
| 165 | GstVideoTimeCode * gst_video_time_code_copy (const GstVideoTimeCode * tc); |
| 166 | |
| 167 | GST_VIDEO_API |
| 168 | void 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 | |
| 179 | GST_VIDEO_DEPRECATED_FOR(gst_video_time_code_init_from_date_time_full) |
| 180 | void 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); |
| 186 | GST_VIDEO_API |
| 187 | gboolean 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 | |
| 194 | GST_VIDEO_API |
| 195 | void gst_video_time_code_clear (GstVideoTimeCode * tc); |
| 196 | |
| 197 | GST_VIDEO_API |
| 198 | gboolean gst_video_time_code_is_valid (const GstVideoTimeCode * tc); |
| 199 | |
| 200 | GST_VIDEO_API |
| 201 | gint gst_video_time_code_compare (const GstVideoTimeCode * tc1, |
| 202 | const GstVideoTimeCode * tc2); |
| 203 | |
| 204 | GST_VIDEO_API |
| 205 | void gst_video_time_code_increment_frame (GstVideoTimeCode * tc); |
| 206 | |
| 207 | GST_VIDEO_API |
| 208 | void gst_video_time_code_add_frames (GstVideoTimeCode * tc, |
| 209 | gint64 frames); |
| 210 | |
| 211 | GST_VIDEO_API |
| 212 | gchar *gst_video_time_code_to_string (const GstVideoTimeCode * tc); |
| 213 | |
| 214 | GST_VIDEO_API |
| 215 | GDateTime *gst_video_time_code_to_date_time (const GstVideoTimeCode * tc); |
| 216 | |
| 217 | GST_VIDEO_API |
| 218 | guint64 gst_video_time_code_nsec_since_daily_jam (const GstVideoTimeCode * tc); |
| 219 | |
| 220 | GST_VIDEO_API |
| 221 | guint64 gst_video_time_code_frames_since_daily_jam (const GstVideoTimeCode * tc); |
| 222 | |
| 223 | GST_VIDEO_API |
| 224 | GstVideoTimeCode * 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()) |
| 227 | GST_VIDEO_API |
| 228 | GType gst_video_time_code_interval_get_type (void); |
| 229 | |
| 230 | GST_VIDEO_API |
| 231 | GstVideoTimeCodeInterval * gst_video_time_code_interval_new (guint hours, |
| 232 | guint minutes, |
| 233 | guint seconds, |
| 234 | guint frames); |
| 235 | |
| 236 | GST_VIDEO_API |
| 237 | GstVideoTimeCodeInterval * gst_video_time_code_interval_new_from_string (const gchar * tc_inter_str); |
| 238 | |
| 239 | GST_VIDEO_API |
| 240 | void gst_video_time_code_interval_free (GstVideoTimeCodeInterval * tc); |
| 241 | |
| 242 | GST_VIDEO_API |
| 243 | GstVideoTimeCodeInterval * gst_video_time_code_interval_copy (const GstVideoTimeCodeInterval * tc); |
| 244 | |
| 245 | GST_VIDEO_API |
| 246 | void gst_video_time_code_interval_init (GstVideoTimeCodeInterval * tc, |
| 247 | guint hours, |
| 248 | guint minutes, |
| 249 | guint seconds, |
| 250 | guint frames); |
| 251 | |
| 252 | GST_VIDEO_API |
| 253 | void gst_video_time_code_interval_clear (GstVideoTimeCodeInterval * tc); |
| 254 | |
| 255 | G_END_DECLS |
| 256 | |
| 257 | #endif /* __GST_VIDEO_TIME_CODE_H__ */ |
| 258 | |