Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / ext / pango / gstclockoverlay.c
index 24a8238..4f6c279 100644 (file)
 
 /**
  * SECTION:element-clockoverlay
- * @see_also: #GstTextOverlay, #GstTimeOverlay
+ * @see_also: #GstBaseTextOverlay, #GstTimeOverlay
  *
  * This element overlays the current clock time on top of a video
  * stream. You can position the text and configure the font details
- * using the properties of the #GstTextOverlay class. By default, the
+ * using the properties of the #GstBaseTextOverlay class. By default, the
  * time is displayed in the top left corner of the picture, with some
  * padding to the left and to the top.
  *
@@ -34,7 +34,7 @@
  * gst-launch -v videotestsrc ! clockoverlay ! xvimagesink
  * ]| Display the current time in the top left corner of the video picture
  * |[
- * gst-launch -v videotestsrc ! clockoverlay halign=right valign=bottom text="Edge City" shaded-background=true ! ffmpegcolorspace ! ximagesink
+ * gst-launch -v videotestsrc ! clockoverlay halign=right valign=bottom text="Edge City" shaded-background=true ! videoconvert ! ximagesink
  * ]| Another pipeline that displays the current time with some leading
  * text in the bottom right corner of the video picture, with the background
  * of the text being shaded in order to make it more legible on top of a
@@ -60,20 +60,8 @@ enum
   PROP_LAST
 };
 
-GST_BOILERPLATE (GstClockOverlay, gst_clock_overlay, GstTextOverlay,
-    GST_TYPE_TEXT_OVERLAY);
-
-static void
-gst_clock_overlay_base_init (gpointer g_class)
-{
-  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
-  gst_element_class_set_details_simple (element_class, "Clock overlay",
-      "Filter/Editor/Video",
-      "Overlays the current clock time on a video stream",
-      "Tim-Philipp Müller <tim@centricular.net>");
-}
-
+#define gst_clock_overlay_parent_class parent_class
+G_DEFINE_TYPE (GstClockOverlay, gst_clock_overlay, GST_TYPE_BASE_TEXT_OVERLAY);
 
 static void gst_clock_overlay_finalize (GObject * object);
 static void gst_clock_overlay_set_property (GObject * object, guint prop_id,
@@ -114,7 +102,8 @@ gst_clock_overlay_render_time (GstClockOverlay * overlay)
 
 /* Called with lock held */
 static gchar *
-gst_clock_overlay_get_text (GstTextOverlay * overlay, GstBuffer * video_frame)
+gst_clock_overlay_get_text (GstBaseTextOverlay * overlay,
+    GstBuffer * video_frame)
 {
   gchar *time_str, *txt, *ret;
   GstClockOverlay *clock_overlay = GST_CLOCK_OVERLAY (overlay);
@@ -145,17 +134,24 @@ static void
 gst_clock_overlay_class_init (GstClockOverlayClass * klass)
 {
   GObjectClass *gobject_class;
-  GstTextOverlayClass *gsttextoverlay_class;
+  GstElementClass *gstelement_class;
+  GstBaseTextOverlayClass *gsttextoverlay_class;
   PangoContext *context;
   PangoFontDescription *font_description;
 
   gobject_class = (GObjectClass *) klass;
-  gsttextoverlay_class = (GstTextOverlayClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+  gsttextoverlay_class = (GstBaseTextOverlayClass *) 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;
 
+  gst_element_class_set_details_simple (gstelement_class, "Clock overlay",
+      "Filter/Editor/Video",
+      "Overlays the current clock time on a video stream",
+      "Tim-Philipp Müller <tim@centricular.net>");
+
   gsttextoverlay_class->get_text = gst_clock_overlay_get_text;
 
   g_object_class_install_property (gobject_class, PROP_TIMEFORMAT,
@@ -163,8 +159,8 @@ gst_clock_overlay_class_init (GstClockOverlayClass * klass)
           "Format to use for time and date value, as in strftime.",
           DEFAULT_PROP_TIMEFORMAT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-  g_mutex_lock (GST_TEXT_OVERLAY_CLASS (klass)->pango_lock);
-  context = GST_TEXT_OVERLAY_CLASS (klass)->pango_context;
+  g_mutex_lock (gsttextoverlay_class->pango_lock);
+  context = gsttextoverlay_class->pango_context;
 
   pango_context_set_language (context, pango_language_from_string ("en_US"));
   pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
@@ -178,7 +174,7 @@ gst_clock_overlay_class_init (GstClockOverlayClass * klass)
   pango_font_description_set_size (font_description, 18 * PANGO_SCALE);
   pango_context_set_font_description (context, font_description);
   pango_font_description_free (font_description);
-  g_mutex_unlock (GST_TEXT_OVERLAY_CLASS (klass)->pango_lock);
+  g_mutex_unlock (gsttextoverlay_class->pango_lock);
 }
 
 
@@ -196,14 +192,14 @@ gst_clock_overlay_finalize (GObject * object)
 
 
 static void
-gst_clock_overlay_init (GstClockOverlay * overlay, GstClockOverlayClass * klass)
+gst_clock_overlay_init (GstClockOverlay * overlay)
 {
-  GstTextOverlay *textoverlay;
+  GstBaseTextOverlay *textoverlay;
 
-  textoverlay = GST_TEXT_OVERLAY (overlay);
+  textoverlay = GST_BASE_TEXT_OVERLAY (overlay);
 
-  textoverlay->valign = GST_TEXT_OVERLAY_VALIGN_TOP;
-  textoverlay->halign = GST_TEXT_OVERLAY_HALIGN_LEFT;
+  textoverlay->valign = GST_BASE_TEXT_OVERLAY_VALIGN_TOP;
+  textoverlay->halign = GST_BASE_TEXT_OVERLAY_HALIGN_LEFT;
 
   overlay->format = g_strdup (DEFAULT_PROP_TIMEFORMAT);
 }