mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
ext/pango/gstclockoverlay.*: API: Add ability to specify format for date/time display by adding a "time-format" prope...
Original commit message from CVS: Patch by: Pavel Zeldin <pzeldin at gmail dot com> * ext/pango/gstclockoverlay.c: (gst_clock_overlay_render_time), (gst_clock_overlay_class_init), (gst_clock_overlay_finalize), (gst_clock_overlay_init), (gst_clock_overlay_set_property), (gst_clock_overlay_get_property): * ext/pango/gstclockoverlay.h: API: Add ability to specify format for date/time display by adding a "time-format" property. Fixes bug #554879.
This commit is contained in:
parent
76b6a56acb
commit
947ecd72c4
3 changed files with 100 additions and 1 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2008-10-08 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||||
|
|
||||||
|
Patch by: Pavel Zeldin <pzeldin at gmail dot com>
|
||||||
|
|
||||||
|
* ext/pango/gstclockoverlay.c: (gst_clock_overlay_render_time),
|
||||||
|
(gst_clock_overlay_class_init), (gst_clock_overlay_finalize),
|
||||||
|
(gst_clock_overlay_init), (gst_clock_overlay_set_property),
|
||||||
|
(gst_clock_overlay_get_property):
|
||||||
|
* ext/pango/gstclockoverlay.h:
|
||||||
|
API: Add ability to specify format for date/time display by
|
||||||
|
adding a "time-format" property.
|
||||||
|
Fixes bug #554879.
|
||||||
|
|
||||||
2008-10-08 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2008-10-08 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||||
|
|
||||||
Patch by: Jan Gerber <j at oil21 dot org>
|
Patch by: Jan Gerber <j at oil21 dot org>
|
||||||
|
|
|
@ -50,6 +50,16 @@
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define DEFAULT_PROP_TIMEFORMAT "%H:%M:%S"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_TIMEFORMAT,
|
||||||
|
PROP_LAST
|
||||||
|
};
|
||||||
|
|
||||||
static const GstElementDetails clock_overlay_details =
|
static const GstElementDetails clock_overlay_details =
|
||||||
GST_ELEMENT_DETAILS ("Clock overlay",
|
GST_ELEMENT_DETAILS ("Clock overlay",
|
||||||
"Filter/Editor/Video",
|
"Filter/Editor/Video",
|
||||||
|
@ -66,11 +76,19 @@ GST_BOILERPLATE (GstClockOverlay, gst_clock_overlay, GstTextOverlay,
|
||||||
gst_element_class_set_details (element_class, &clock_overlay_details);
|
gst_element_class_set_details (element_class, &clock_overlay_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void gst_clock_overlay_finalize (GObject * object);
|
||||||
|
static void gst_clock_overlay_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
static void gst_clock_overlay_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
gst_clock_overlay_render_time (GstClockOverlay * overlay)
|
gst_clock_overlay_render_time (GstClockOverlay * overlay)
|
||||||
{
|
{
|
||||||
struct tm *t;
|
struct tm *t;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
gchar buf[256];
|
||||||
|
|
||||||
#ifdef HAVE_LOCALTIME_R
|
#ifdef HAVE_LOCALTIME_R
|
||||||
struct tm dummy;
|
struct tm dummy;
|
||||||
|
@ -88,7 +106,9 @@ gst_clock_overlay_render_time (GstClockOverlay * overlay)
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
return g_strdup ("--:--:--");
|
return g_strdup ("--:--:--");
|
||||||
|
|
||||||
return g_strdup_printf ("%02u:%02u:%02u", t->tm_hour, t->tm_min, t->tm_sec);
|
if (strftime (buf, sizeof (buf), overlay->format, t) == 0)
|
||||||
|
return g_strdup ("");
|
||||||
|
return g_strdup (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called with lock held */
|
/* Called with lock held */
|
||||||
|
@ -118,13 +138,37 @@ gst_clock_overlay_get_text (GstTextOverlay * overlay, GstBuffer * video_frame)
|
||||||
static void
|
static void
|
||||||
gst_clock_overlay_class_init (GstClockOverlayClass * klass)
|
gst_clock_overlay_class_init (GstClockOverlayClass * klass)
|
||||||
{
|
{
|
||||||
|
GObjectClass *gobject_class;
|
||||||
GstTextOverlayClass *gsttextoverlay_class;
|
GstTextOverlayClass *gsttextoverlay_class;
|
||||||
|
|
||||||
|
gobject_class = (GObjectClass *) klass;
|
||||||
gsttextoverlay_class = (GstTextOverlayClass *) klass;
|
gsttextoverlay_class = (GstTextOverlayClass *) klass;
|
||||||
|
|
||||||
|
gobject_class->finalize = gst_clock_overlay_finalize;
|
||||||
|
gobject_class->set_property = gst_clock_overlay_set_property;
|
||||||
|
gobject_class->get_property = gst_clock_overlay_get_property;
|
||||||
|
|
||||||
gsttextoverlay_class->get_text = gst_clock_overlay_get_text;
|
gsttextoverlay_class->get_text = gst_clock_overlay_get_text;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_TIMEFORMAT,
|
||||||
|
g_param_spec_string ("time-format", "Date/Time Format",
|
||||||
|
"Format to use for time and date value, as in strftime.",
|
||||||
|
DEFAULT_PROP_TIMEFORMAT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_clock_overlay_finalize (GObject * object)
|
||||||
|
{
|
||||||
|
GstClockOverlay *overlay = GST_CLOCK_OVERLAY (object);
|
||||||
|
|
||||||
|
g_free (overlay->format);
|
||||||
|
overlay->format = NULL;
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_clock_overlay_init (GstClockOverlay * overlay, GstClockOverlayClass * klass)
|
gst_clock_overlay_init (GstClockOverlay * overlay, GstClockOverlayClass * klass)
|
||||||
{
|
{
|
||||||
|
@ -151,4 +195,45 @@ gst_clock_overlay_init (GstClockOverlay * overlay, GstClockOverlayClass * klass)
|
||||||
|
|
||||||
textoverlay->valign = GST_TEXT_OVERLAY_VALIGN_TOP;
|
textoverlay->valign = GST_TEXT_OVERLAY_VALIGN_TOP;
|
||||||
textoverlay->halign = GST_TEXT_OVERLAY_HALIGN_LEFT;
|
textoverlay->halign = GST_TEXT_OVERLAY_HALIGN_LEFT;
|
||||||
|
|
||||||
|
overlay->format = g_strdup (DEFAULT_PROP_TIMEFORMAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_clock_overlay_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstClockOverlay *overlay = GST_CLOCK_OVERLAY (object);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (overlay);
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_TIMEFORMAT:
|
||||||
|
g_free (overlay->format);
|
||||||
|
overlay->format = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GST_OBJECT_UNLOCK (overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_clock_overlay_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstClockOverlay *overlay = GST_CLOCK_OVERLAY (object);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (overlay);
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_TIMEFORMAT:
|
||||||
|
g_value_set_string (value, overlay->format);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GST_OBJECT_UNLOCK (overlay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ typedef struct _GstClockOverlayClass GstClockOverlayClass;
|
||||||
*/
|
*/
|
||||||
struct _GstClockOverlay {
|
struct _GstClockOverlay {
|
||||||
GstTextOverlay textoverlay;
|
GstTextOverlay textoverlay;
|
||||||
|
gchar *format; /* as in strftime () */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstClockOverlayClass {
|
struct _GstClockOverlayClass {
|
||||||
|
|
Loading…
Reference in a new issue