summaryrefslogtreecommitdiff
path: root/gst/timecode/gsttimecodestamper.c
diff options
context:
space:
mode:
authorGeorg Lippitsch <glippitsch@toolsonair.com>2017-02-22 22:26:57 +0100
committerSebastian Dröge <sebastian@centricular.com>2017-02-23 20:00:55 +0200
commit290f3ca6d7a74a4e1ffdc5a618bf9af9a5495f77 (patch)
tree050a8b5717f03f2dd997dfbb647b0c07676bdb5b /gst/timecode/gsttimecodestamper.c
parentab2dc21b9bfa5a7b54e77f260e3e920051711778 (diff)
downloadgstreamer-plugins-bad-290f3ca6d7a74a4e1ffdc5a618bf9af9a5495f77.tar.gz
timecodestamper: First timecode property
Add an new property to start from a given timecode instead of zero. https://bugzilla.gnome.org/show_bug.cgi?id=778703
Diffstat (limited to 'gst/timecode/gsttimecodestamper.c')
-rw-r--r--gst/timecode/gsttimecodestamper.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/gst/timecode/gsttimecodestamper.c b/gst/timecode/gsttimecodestamper.c
index b10ff4847..4dfe4b181 100644
--- a/gst/timecode/gsttimecodestamper.c
+++ b/gst/timecode/gsttimecodestamper.c
@@ -58,7 +58,8 @@ enum
PROP_DROP_FRAME,
PROP_SOURCE_CLOCK,
PROP_DAILY_JAM,
- PROP_POST_MESSAGES
+ PROP_POST_MESSAGES,
+ PROP_FIRST_TIMECODE,
};
#define DEFAULT_OVERRIDE_EXISTING FALSE
@@ -135,6 +136,15 @@ gst_timecodestamper_class_init (GstTimeCodeStamperClass * klass)
g_param_spec_boolean ("post-messages", "Post element message",
"Post element message containing the current timecode",
DEFAULT_POST_MESSAGES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_FIRST_TIMECODE,
+ g_param_spec_boxed ("first-timecode",
+ "Timecode at the first frame",
+ "If set, take this timecode for the first frame and increment from "
+ "it. Only the values itself are taken, flags and frame rate are "
+ "always determined by timecodestamper itself. "
+ "If unset (and to-now is also not set), the timecode will start at 0",
+ GST_TYPE_VIDEO_TIME_CODE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_timecodestamper_sink_template));
@@ -155,6 +165,7 @@ gst_timecodestamper_init (GstTimeCodeStamper * timecodestamper)
timecodestamper->drop_frame = DEFAULT_DROP_FRAME;
timecodestamper->source_clock = DEFAULT_SOURCE_CLOCK;
timecodestamper->current_tc = gst_video_time_code_new_empty ();
+ timecodestamper->first_tc = NULL;
timecodestamper->current_tc->config.latest_daily_jam = DEFAULT_DAILY_JAM;
timecodestamper->post_messages = DEFAULT_POST_MESSAGES;
}
@@ -172,6 +183,9 @@ gst_timecodestamper_dispose (GObject * object)
if (timecodestamper->source_clock) {
gst_object_unref (timecodestamper->source_clock);
timecodestamper->source_clock = NULL;
+ if (timecodestamper->first_tc != NULL) {
+ gst_video_time_code_free (timecodestamper->first_tc);
+ timecodestamper->first_tc = NULL;
}
G_OBJECT_CLASS (gst_timecodestamper_parent_class)->dispose (object);
@@ -205,6 +219,11 @@ gst_timecodestamper_set_property (GObject * object, guint prop_id,
case PROP_POST_MESSAGES:
timecodestamper->post_messages = g_value_get_boolean (value);
break;
+ case PROP_FIRST_TIMECODE:
+ if (timecodestamper->first_tc)
+ gst_video_time_code_free (timecodestamper->first_tc);
+ timecodestamper->first_tc = g_value_dup_boxed (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -234,6 +253,9 @@ gst_timecodestamper_get_property (GObject * object, guint prop_id,
case PROP_POST_MESSAGES:
g_value_set_boolean (value, timecodestamper->post_messages);
break;
+ case PROP_FIRST_TIMECODE:
+ g_value_set_boxed (value, timecodestamper->first_tc);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -269,7 +291,10 @@ gst_timecodestamper_reset_timecode (GstTimeCodeStamper * timecodestamper)
{
GDateTime *jam = NULL;
- if (timecodestamper->current_tc->config.latest_daily_jam)
+ if (timecodestamper->first_tc &&
+ timecodestamper->first_tc->config.latest_daily_jam)
+ jam = g_date_time_ref (timecodestamper->first_tc->config.latest_daily_jam);
+ else if (timecodestamper->current_tc->config.latest_daily_jam)
jam =
g_date_time_ref (timecodestamper->current_tc->config.latest_daily_jam);
gst_video_time_code_clear (timecodestamper->current_tc);
@@ -281,6 +306,14 @@ gst_timecodestamper_reset_timecode (GstTimeCodeStamper * timecodestamper)
timecodestamper->vinfo.interlace_mode ==
GST_VIDEO_INTERLACE_MODE_PROGRESSIVE ? 0 :
GST_VIDEO_TIME_CODE_FLAGS_INTERLACED, 0, 0, 0, 0, 0);
+ if (timecodestamper->first_tc) {
+ timecodestamper->current_tc->hours = timecodestamper->first_tc->hours;
+ timecodestamper->current_tc->minutes = timecodestamper->first_tc->minutes;
+ timecodestamper->current_tc->seconds = timecodestamper->first_tc->seconds;
+ timecodestamper->current_tc->frames = timecodestamper->first_tc->frames;
+ timecodestamper->current_tc->field_count =
+ timecodestamper->first_tc->field_count;
+ }
gst_timecodestamper_set_drop_frame (timecodestamper);
}