static void gst_time_overlay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
+/**
+ * GstTimeOverlayTimeLine::elapsed-running-time:
+ *
+ * Overlay elapsed running time since the first observed running time.
+ *
+ * Since: 1.20
+ */
+
#define GST_TYPE_TIME_OVERLAY_TIME_LINE (gst_time_overlay_time_line_type())
static GType
gst_time_overlay_time_line_type (void)
{GST_TIME_OVERLAY_TIME_LINE_STREAM_TIME, "stream-time", "stream-time"},
{GST_TIME_OVERLAY_TIME_LINE_RUNNING_TIME, "running-time", "running-time"},
{GST_TIME_OVERLAY_TIME_LINE_TIME_CODE, "time-code", "time-code"},
+ {GST_TIME_OVERLAY_TIME_LINE_ELAPSED_RUNNING_TIME,
+ "elapsed-running-time", "elapsed-running-time"},
{0, NULL, NULL},
};
case GST_TIME_OVERLAY_TIME_LINE_RUNNING_TIME:
ts = gst_segment_to_running_time (segment, GST_FORMAT_TIME, ts_buffer);
break;
+ case GST_TIME_OVERLAY_TIME_LINE_ELAPSED_RUNNING_TIME:
+ ts = gst_segment_to_running_time (segment, GST_FORMAT_TIME, ts_buffer);
+ if (self->first_running_time == GST_CLOCK_TIME_NONE)
+ self->first_running_time = ts;
+ ts -= self->first_running_time;
+ break;
case GST_TIME_OVERLAY_TIME_LINE_BUFFER_TIME:
default:
ts = ts_buffer;
return ret;
}
+static GstStateChangeReturn
+gst_time_overlay_change_state (GstElement * element, GstStateChange transition)
+{
+ GstTimeOverlay *self = GST_TIME_OVERLAY (element);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ self->first_running_time = GST_CLOCK_TIME_NONE;
+ break;
+ default:
+ break;
+ }
+
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+}
+
static void
gst_time_overlay_finalize (GObject * gobject)
{
gsttextoverlay_class->get_text = gst_time_overlay_get_text;
+ gstelement_class->change_state = gst_time_overlay_change_state;
+
gobject_class->finalize = gst_time_overlay_finalize;
gobject_class->set_property = gst_time_overlay_set_property;
gobject_class->get_property = gst_time_overlay_get_property;
gst_type_mark_as_plugin_api (GST_TYPE_TIME_OVERLAY_TIME_LINE, 0);
}
+static gboolean
+gst_time_overlay_video_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
+{
+ GstTimeOverlay *overlay = GST_TIME_OVERLAY (parent);
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_FLUSH_STOP:
+ overlay->first_running_time = GST_CLOCK_TIME_NONE;
+ break;
+ default:
+ break;
+ }
+
+ return overlay->orig_video_event (pad, parent, event);
+}
+
static void
gst_time_overlay_init (GstTimeOverlay * overlay)
{
GstBaseTextOverlay *textoverlay;
PangoContext *context;
PangoFontDescription *font_description;
+ GstPad *video_sink;
textoverlay = GST_BASE_TEXT_OVERLAY (overlay);
pango_font_description_set_size (font_description, 18 * PANGO_SCALE);
pango_context_set_font_description (context, font_description);
pango_font_description_free (font_description);
+
+ video_sink = gst_element_get_static_pad (GST_ELEMENT (overlay), "video_sink");
+ overlay->orig_video_event = GST_PAD_EVENTFUNC (video_sink);
+ gst_pad_set_event_function (video_sink, gst_time_overlay_video_event);
}
static void
GST_TIME_OVERLAY_TIME_LINE_STREAM_TIME,
GST_TIME_OVERLAY_TIME_LINE_RUNNING_TIME,
GST_TIME_OVERLAY_TIME_LINE_TIME_CODE,
+ GST_TIME_OVERLAY_TIME_LINE_ELAPSED_RUNNING_TIME,
} GstTimeOverlayTimeLine;
/**
gboolean show_times_as_dates;
gchar *datetime_format;
GDateTime *datetime_epoch;
+
+ /* For GST_TIME_OVERLAY_TIME_LINE_ELAPSED_RUNNING_TIME mode */
+ GstClockTime first_running_time;
+ GstPadEventFunction orig_video_event;
};
struct _GstTimeOverlayClass {