static void gst_timecodestamper_dispose (GObject * object) { GstTimeCodeStamper *timecodestamper = GST_TIME_CODE_STAMPER (object); if (timecodestamper->current_tc != NULL) { gst_video_time_code_free (timecodestamper->current_tc); timecodestamper->current_tc = 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); }
static void gst_timecodewait_finalize (GObject * object) { GstTimeCodeWait *self = GST_TIMECODEWAIT (object); if (self->tc) { gst_video_time_code_free (self->tc); self->tc = NULL; } g_mutex_clear (&self->mutex); g_cond_clear (&self->cond); G_OBJECT_CLASS (parent_class)->finalize (object); }
static GstFlowReturn gst_timecodestamper_transform_ip (GstBaseTransform * vfilter, GstBuffer * buffer) { GstTimeCodeStamper *timecodestamper = GST_TIME_CODE_STAMPER (vfilter); GstVideoTimeCodeMeta *tc_meta; GstVideoTimeCode *tc; GST_OBJECT_LOCK (timecodestamper); tc_meta = gst_buffer_get_video_time_code_meta (buffer); if (tc_meta && !timecodestamper->override_existing) { GST_OBJECT_UNLOCK (timecodestamper); tc = gst_video_time_code_copy (&tc_meta->tc); goto beach; } else if (timecodestamper->override_existing) { gst_buffer_foreach_meta (buffer, remove_timecode_meta, NULL); } gst_buffer_add_video_time_code_meta (buffer, timecodestamper->current_tc); tc = gst_video_time_code_copy (timecodestamper->current_tc); gst_video_time_code_increment_frame (timecodestamper->current_tc); GST_OBJECT_UNLOCK (timecodestamper); beach: if (timecodestamper->post_messages) { GstClockTime stream_time, running_time, duration; GstStructure *s; GstMessage *msg; running_time = gst_segment_to_running_time (&vfilter->segment, GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)); stream_time = gst_segment_to_stream_time (&vfilter->segment, GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)); duration = gst_util_uint64_scale_int (GST_SECOND, timecodestamper->vinfo.fps_d, timecodestamper->vinfo.fps_n); s = gst_structure_new ("timecodestamper", "timestamp", G_TYPE_UINT64, GST_BUFFER_PTS (buffer), "stream-time", G_TYPE_UINT64, stream_time, "running-time", G_TYPE_UINT64, running_time, "duration", G_TYPE_UINT64, duration, "timecode", GST_TYPE_VIDEO_TIME_CODE, tc, NULL); msg = gst_message_new_element (GST_OBJECT (timecodestamper), s); gst_element_post_message (GST_ELEMENT (timecodestamper), msg); } gst_video_time_code_free (tc); return GST_FLOW_OK; }
static void gst_timecodewait_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstTimeCodeWait *self = GST_TIMECODEWAIT (object); switch (prop_id) { case PROP_TARGET_TIME_CODE_STRING:{ gchar **parts; const gchar *tc_str; guint hours, minutes, seconds, frames; tc_str = g_value_get_string (value); parts = g_strsplit (tc_str, ":", 4); if (!parts || parts[3] == NULL) { GST_ERROR_OBJECT (self, "Error: Could not parse timecode %s. Please input a timecode in the form 00:00:00:00", tc_str); g_strfreev (parts); return; } hours = g_ascii_strtoll (parts[0], NULL, 10); minutes = g_ascii_strtoll (parts[1], NULL, 10); seconds = g_ascii_strtoll (parts[2], NULL, 10); frames = g_ascii_strtoll (parts[3], NULL, 10); gst_video_time_code_init (self->tc, 0, 1, NULL, 0, hours, minutes, seconds, frames, 0); if (self->vinfo.finfo != NULL) { self->tc->config.fps_n = self->vinfo.fps_n; self->tc->config.fps_d = self->vinfo.fps_d; } self->from_string = TRUE; g_strfreev (parts); break; } case PROP_TARGET_TIME_CODE:{ if (self->tc) gst_video_time_code_free (self->tc); self->tc = g_value_dup_boxed (value); self->from_string = FALSE; break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void gst_timecodestamper_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstTimeCodeStamper *timecodestamper = GST_TIME_CODE_STAMPER (object); switch (prop_id) { case PROP_OVERRIDE_EXISTING: timecodestamper->override_existing = g_value_get_boolean (value); break; case PROP_DROP_FRAME: timecodestamper->drop_frame = g_value_get_boolean (value); break; case PROP_DAILY_JAM: if (timecodestamper->current_tc->config.latest_daily_jam) g_date_time_unref (timecodestamper->current_tc-> config.latest_daily_jam); timecodestamper->current_tc->config.latest_daily_jam = g_value_dup_boxed (value); break; 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; case PROP_FIRST_NOW: timecodestamper->first_tc_now = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }