mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
pango: Create a new base class for all the elements
This prevents the ugly hack where the text_sink pad template was only added for textoverlay but not for the subclasses. Also makes this work with the core change that made subclasses inherit the templates of their parent class.
This commit is contained in:
parent
8eceb64b99
commit
92d10cbb8c
9 changed files with 2979 additions and 2811 deletions
|
@ -1,12 +1,14 @@
|
|||
plugin_LTLIBRARIES = libgstpango.la
|
||||
|
||||
noinst_HEADERS = \
|
||||
gstbasetextoverlay.h \
|
||||
gstclockoverlay.h \
|
||||
gsttextoverlay.h \
|
||||
gsttextrender.h \
|
||||
gsttimeoverlay.h
|
||||
|
||||
libgstpango_la_SOURCES = \
|
||||
gstbasetextoverlay.c \
|
||||
gstclockoverlay.c \
|
||||
gsttextoverlay.c \
|
||||
gsttextrender.c \
|
||||
|
|
2727
ext/pango/gstbasetextoverlay.c
Normal file
2727
ext/pango/gstbasetextoverlay.c
Normal file
File diff suppressed because it is too large
Load diff
171
ext/pango/gstbasetextoverlay.h
Normal file
171
ext/pango/gstbasetextoverlay.h
Normal file
|
@ -0,0 +1,171 @@
|
|||
#ifndef __GST_BASE_TEXT_OVERLAY_H__
|
||||
#define __GST_BASE_TEXT_OVERLAY_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/controller/gstcontroller.h>
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_BASE_TEXT_OVERLAY (gst_base_text_overlay_get_type())
|
||||
#define GST_BASE_TEXT_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
GST_TYPE_BASE_TEXT_OVERLAY, GstBaseTextOverlay))
|
||||
#define GST_BASE_TEXT_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
|
||||
GST_TYPE_BASE_TEXT_OVERLAY,GstBaseTextOverlayClass))
|
||||
#define GST_BASE_TEXT_OVERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
|
||||
GST_TYPE_BASE_TEXT_OVERLAY, GstBaseTextOverlayClass))
|
||||
#define GST_IS_BASE_TEXT_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
|
||||
GST_TYPE_BASE_TEXT_OVERLAY))
|
||||
#define GST_IS_BASE_TEXT_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
|
||||
GST_TYPE_BASE_TEXT_OVERLAY))
|
||||
|
||||
typedef struct _GstBaseTextOverlay GstBaseTextOverlay;
|
||||
typedef struct _GstBaseTextOverlayClass GstBaseTextOverlayClass;
|
||||
|
||||
/**
|
||||
* GstBaseTextOverlayVAlign:
|
||||
* @GST_BASE_TEXT_OVERLAY_VALIGN_BASELINE: draw text on the baseline
|
||||
* @GST_BASE_TEXT_OVERLAY_VALIGN_BOTTOM: draw text on the bottom
|
||||
* @GST_BASE_TEXT_OVERLAY_VALIGN_TOP: draw text on top
|
||||
* @GST_BASE_TEXT_OVERLAY_VALIGN_POS: draw text according to the #GstBaseTextOverlay:ypos property
|
||||
* @GST_BASE_TEXT_OVERLAY_VALIGN_CENTER: draw text vertically centered
|
||||
*
|
||||
* Vertical alignment of the text.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_BASE_TEXT_OVERLAY_VALIGN_BASELINE,
|
||||
GST_BASE_TEXT_OVERLAY_VALIGN_BOTTOM,
|
||||
GST_BASE_TEXT_OVERLAY_VALIGN_TOP,
|
||||
GST_BASE_TEXT_OVERLAY_VALIGN_POS,
|
||||
GST_BASE_TEXT_OVERLAY_VALIGN_CENTER
|
||||
} GstBaseTextOverlayVAlign;
|
||||
|
||||
/**
|
||||
* GstBaseTextOverlayHAlign:
|
||||
* @GST_BASE_TEXT_OVERLAY_HALIGN_LEFT: align text left
|
||||
* @GST_BASE_TEXT_OVERLAY_HALIGN_CENTER: align text center
|
||||
* @GST_BASE_TEXT_OVERLAY_HALIGN_RIGHT: align text right
|
||||
* @GST_BASE_TEXT_OVERLAY_HALIGN_POS: position text according to the #GstBaseTextOverlay:xpos property
|
||||
*
|
||||
* Horizontal alignment of the text.
|
||||
*/
|
||||
/* FIXME 0.11: remove GST_BASE_TEXT_OVERLAY_HALIGN_UNUSED */
|
||||
typedef enum {
|
||||
GST_BASE_TEXT_OVERLAY_HALIGN_LEFT,
|
||||
GST_BASE_TEXT_OVERLAY_HALIGN_CENTER,
|
||||
GST_BASE_TEXT_OVERLAY_HALIGN_RIGHT,
|
||||
GST_BASE_TEXT_OVERLAY_HALIGN_UNUSED,
|
||||
GST_BASE_TEXT_OVERLAY_HALIGN_POS
|
||||
} GstBaseTextOverlayHAlign;
|
||||
|
||||
/**
|
||||
* GstBaseTextOverlayWrapMode:
|
||||
* @GST_BASE_TEXT_OVERLAY_WRAP_MODE_NONE: no wrapping
|
||||
* @GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD: do word wrapping
|
||||
* @GST_BASE_TEXT_OVERLAY_WRAP_MODE_CHAR: do char wrapping
|
||||
* @GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR: do word and char wrapping
|
||||
*
|
||||
* Whether to wrap the text and if so how.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_BASE_TEXT_OVERLAY_WRAP_MODE_NONE = -1,
|
||||
GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD = PANGO_WRAP_WORD,
|
||||
GST_BASE_TEXT_OVERLAY_WRAP_MODE_CHAR = PANGO_WRAP_CHAR,
|
||||
GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR = PANGO_WRAP_WORD_CHAR
|
||||
} GstBaseTextOverlayWrapMode;
|
||||
|
||||
/**
|
||||
* GstBaseTextOverlayLineAlign:
|
||||
* @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_LEFT: lines are left-aligned
|
||||
* @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_CENTER: lines are center-aligned
|
||||
* @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_RIGHT: lines are right-aligned
|
||||
*
|
||||
* Alignment of text lines relative to each other
|
||||
*/
|
||||
typedef enum {
|
||||
GST_BASE_TEXT_OVERLAY_LINE_ALIGN_LEFT = PANGO_ALIGN_LEFT,
|
||||
GST_BASE_TEXT_OVERLAY_LINE_ALIGN_CENTER = PANGO_ALIGN_CENTER,
|
||||
GST_BASE_TEXT_OVERLAY_LINE_ALIGN_RIGHT = PANGO_ALIGN_RIGHT
|
||||
} GstBaseTextOverlayLineAlign;
|
||||
|
||||
/**
|
||||
* GstBaseTextOverlay:
|
||||
*
|
||||
* Opaque textoverlay object structure
|
||||
*/
|
||||
struct _GstBaseTextOverlay {
|
||||
GstElement element;
|
||||
|
||||
GstPad *video_sinkpad;
|
||||
GstPad *text_sinkpad;
|
||||
GstPad *srcpad;
|
||||
|
||||
GstSegment segment;
|
||||
GstSegment text_segment;
|
||||
GstBuffer *text_buffer;
|
||||
gboolean text_linked;
|
||||
gboolean video_flushing;
|
||||
gboolean video_eos;
|
||||
gboolean text_flushing;
|
||||
gboolean text_eos;
|
||||
|
||||
GCond *cond; /* to signal removal of a queued text
|
||||
* buffer, arrival of a text buffer,
|
||||
* a text segment update, or a change
|
||||
* in status (e.g. shutdown, flushing) */
|
||||
|
||||
gint width;
|
||||
gint height;
|
||||
gint fps_n;
|
||||
gint fps_d;
|
||||
GstVideoFormat format;
|
||||
|
||||
GstBaseTextOverlayVAlign valign;
|
||||
GstBaseTextOverlayHAlign halign;
|
||||
GstBaseTextOverlayWrapMode wrap_mode;
|
||||
GstBaseTextOverlayLineAlign line_align;
|
||||
|
||||
gint xpad;
|
||||
gint ypad;
|
||||
gint deltax;
|
||||
gint deltay;
|
||||
gdouble xpos;
|
||||
gdouble ypos;
|
||||
gchar *default_text;
|
||||
gboolean want_shading;
|
||||
gboolean silent;
|
||||
gboolean wait_text;
|
||||
guint color;
|
||||
|
||||
PangoLayout *layout;
|
||||
gdouble shadow_offset;
|
||||
gdouble outline_offset;
|
||||
guchar *text_image;
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
gint baseline_y;
|
||||
|
||||
gboolean auto_adjust_size;
|
||||
gboolean need_render;
|
||||
|
||||
gint shading_value; /* for timeoverlay subclass */
|
||||
|
||||
gboolean have_pango_markup;
|
||||
gboolean use_vertical_render;
|
||||
};
|
||||
|
||||
struct _GstBaseTextOverlayClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
PangoContext *pango_context;
|
||||
GMutex *pango_lock;
|
||||
|
||||
gchar * (*get_text) (GstBaseTextOverlay *overlay, GstBuffer *video_frame);
|
||||
};
|
||||
|
||||
GType gst_base_text_overlay_get_type(void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_BASE_TEXT_OVERLAY_H */
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
@ -60,8 +60,8 @@ enum
|
|||
PROP_LAST
|
||||
};
|
||||
|
||||
GST_BOILERPLATE (GstClockOverlay, gst_clock_overlay, GstTextOverlay,
|
||||
GST_TYPE_TEXT_OVERLAY);
|
||||
GST_BOILERPLATE (GstClockOverlay, gst_clock_overlay, GstBaseTextOverlay,
|
||||
GST_TYPE_BASE_TEXT_OVERLAY);
|
||||
|
||||
static void
|
||||
gst_clock_overlay_base_init (gpointer g_class)
|
||||
|
@ -114,7 +114,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,10 +146,10 @@ static void
|
|||
gst_clock_overlay_class_init (GstClockOverlayClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstTextOverlayClass *gsttextoverlay_class;
|
||||
GstBaseTextOverlayClass *gsttextoverlay_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gsttextoverlay_class = (GstTextOverlayClass *) klass;
|
||||
gsttextoverlay_class = (GstBaseTextOverlayClass *) klass;
|
||||
|
||||
gobject_class->finalize = gst_clock_overlay_finalize;
|
||||
gobject_class->set_property = gst_clock_overlay_set_property;
|
||||
|
@ -180,12 +181,12 @@ static void
|
|||
gst_clock_overlay_init (GstClockOverlay * overlay, GstClockOverlayClass * klass)
|
||||
{
|
||||
PangoFontDescription *font_description;
|
||||
GstTextOverlay *textoverlay;
|
||||
GstBaseTextOverlay *textoverlay;
|
||||
PangoContext *context;
|
||||
|
||||
textoverlay = GST_TEXT_OVERLAY (overlay);
|
||||
textoverlay = GST_BASE_TEXT_OVERLAY (overlay);
|
||||
|
||||
context = GST_TEXT_OVERLAY_CLASS (klass)->pango_context;
|
||||
context = GST_BASE_TEXT_OVERLAY_CLASS (klass)->pango_context;
|
||||
|
||||
pango_context_set_language (context, pango_language_from_string ("en_US"));
|
||||
pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
|
||||
|
@ -200,8 +201,8 @@ gst_clock_overlay_init (GstClockOverlay * overlay, GstClockOverlayClass * klass)
|
|||
pango_context_set_font_description (context, font_description);
|
||||
pango_font_description_free (font_description);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef __GST_CLOCK_OVERLAY_H__
|
||||
#define __GST_CLOCK_OVERLAY_H__
|
||||
|
||||
#include "gsttextoverlay.h"
|
||||
#include "gstbasetextoverlay.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -46,13 +46,13 @@ typedef struct _GstClockOverlayClass GstClockOverlayClass;
|
|||
* Opaque clockoverlay data structure.
|
||||
*/
|
||||
struct _GstClockOverlay {
|
||||
GstTextOverlay textoverlay;
|
||||
GstBaseTextOverlay textoverlay;
|
||||
gchar *format; /* as in strftime () */
|
||||
gchar *text;
|
||||
};
|
||||
|
||||
struct _GstClockOverlayClass {
|
||||
GstTextOverlayClass parent_class;
|
||||
GstBaseTextOverlayClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_clock_overlay_get_type (void);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,171 +1,60 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2011 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GST_TEXT_OVERLAY_H__
|
||||
#define __GST_TEXT_OVERLAY_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/controller/gstcontroller.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include "gstbasetextoverlay.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_TEXT_OVERLAY (gst_text_overlay_get_type())
|
||||
#define GST_TEXT_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
GST_TYPE_TEXT_OVERLAY, GstTextOverlay))
|
||||
#define GST_TEXT_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
|
||||
GST_TYPE_TEXT_OVERLAY,GstTextOverlayClass))
|
||||
#define GST_TEXT_OVERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
|
||||
GST_TYPE_TEXT_OVERLAY, GstTextOverlayClass))
|
||||
#define GST_IS_TEXT_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
|
||||
GST_TYPE_TEXT_OVERLAY))
|
||||
#define GST_IS_TEXT_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
|
||||
GST_TYPE_TEXT_OVERLAY))
|
||||
#define GST_TYPE_TEXT_OVERLAY \
|
||||
(gst_text_overlay_get_type())
|
||||
#define GST_TEXT_OVERLAY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TEXT_OVERLAY,GstTextOverlay))
|
||||
#define GST_TEXT_OVERLAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TEXT_OVERLAY,GstTextOverlayClass))
|
||||
#define GST_IS_TEXT_OVERLAY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEXT_OVERLAY))
|
||||
#define GST_IS_TEXT_OVERLAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEXT_OVERLAY))
|
||||
|
||||
typedef struct _GstTextOverlay GstTextOverlay;
|
||||
typedef struct _GstTextOverlay GstTextOverlay;
|
||||
typedef struct _GstTextOverlayClass GstTextOverlayClass;
|
||||
|
||||
/**
|
||||
* GstTextOverlayVAlign:
|
||||
* @GST_TEXT_OVERLAY_VALIGN_BASELINE: draw text on the baseline
|
||||
* @GST_TEXT_OVERLAY_VALIGN_BOTTOM: draw text on the bottom
|
||||
* @GST_TEXT_OVERLAY_VALIGN_TOP: draw text on top
|
||||
* @GST_TEXT_OVERLAY_VALIGN_POS: draw text according to the #GstTextOverlay:ypos property
|
||||
* @GST_TEXT_OVERLAY_VALIGN_CENTER: draw text vertically centered
|
||||
*
|
||||
* Vertical alignment of the text.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_TEXT_OVERLAY_VALIGN_BASELINE,
|
||||
GST_TEXT_OVERLAY_VALIGN_BOTTOM,
|
||||
GST_TEXT_OVERLAY_VALIGN_TOP,
|
||||
GST_TEXT_OVERLAY_VALIGN_POS,
|
||||
GST_TEXT_OVERLAY_VALIGN_CENTER
|
||||
} GstTextOverlayVAlign;
|
||||
|
||||
/**
|
||||
* GstTextOverlayHAlign:
|
||||
* @GST_TEXT_OVERLAY_HALIGN_LEFT: align text left
|
||||
* @GST_TEXT_OVERLAY_HALIGN_CENTER: align text center
|
||||
* @GST_TEXT_OVERLAY_HALIGN_RIGHT: align text right
|
||||
* @GST_TEXT_OVERLAY_HALIGN_POS: position text according to the #GstTextOverlay:xpos property
|
||||
*
|
||||
* Horizontal alignment of the text.
|
||||
*/
|
||||
/* FIXME 0.11: remove GST_TEXT_OVERLAY_HALIGN_UNUSED */
|
||||
typedef enum {
|
||||
GST_TEXT_OVERLAY_HALIGN_LEFT,
|
||||
GST_TEXT_OVERLAY_HALIGN_CENTER,
|
||||
GST_TEXT_OVERLAY_HALIGN_RIGHT,
|
||||
GST_TEXT_OVERLAY_HALIGN_UNUSED,
|
||||
GST_TEXT_OVERLAY_HALIGN_POS
|
||||
} GstTextOverlayHAlign;
|
||||
|
||||
/**
|
||||
* GstTextOverlayWrapMode:
|
||||
* @GST_TEXT_OVERLAY_WRAP_MODE_NONE: no wrapping
|
||||
* @GST_TEXT_OVERLAY_WRAP_MODE_WORD: do word wrapping
|
||||
* @GST_TEXT_OVERLAY_WRAP_MODE_CHAR: do char wrapping
|
||||
* @GST_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR: do word and char wrapping
|
||||
*
|
||||
* Whether to wrap the text and if so how.
|
||||
*/
|
||||
typedef enum {
|
||||
GST_TEXT_OVERLAY_WRAP_MODE_NONE = -1,
|
||||
GST_TEXT_OVERLAY_WRAP_MODE_WORD = PANGO_WRAP_WORD,
|
||||
GST_TEXT_OVERLAY_WRAP_MODE_CHAR = PANGO_WRAP_CHAR,
|
||||
GST_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR = PANGO_WRAP_WORD_CHAR
|
||||
} GstTextOverlayWrapMode;
|
||||
|
||||
/**
|
||||
* GstTextOverlayLineAlign:
|
||||
* @GST_TEXT_OVERLAY_LINE_ALIGN_LEFT: lines are left-aligned
|
||||
* @GST_TEXT_OVERLAY_LINE_ALIGN_CENTER: lines are center-aligned
|
||||
* @GST_TEXT_OVERLAY_LINE_ALIGN_RIGHT: lines are right-aligned
|
||||
*
|
||||
* Alignment of text lines relative to each other
|
||||
*/
|
||||
typedef enum {
|
||||
GST_TEXT_OVERLAY_LINE_ALIGN_LEFT = PANGO_ALIGN_LEFT,
|
||||
GST_TEXT_OVERLAY_LINE_ALIGN_CENTER = PANGO_ALIGN_CENTER,
|
||||
GST_TEXT_OVERLAY_LINE_ALIGN_RIGHT = PANGO_ALIGN_RIGHT
|
||||
} GstTextOverlayLineAlign;
|
||||
|
||||
/**
|
||||
* GstTextOverlay:
|
||||
*
|
||||
* Opaque textoverlay object structure
|
||||
* Opaque textoverlay data structure.
|
||||
*/
|
||||
struct _GstTextOverlay {
|
||||
GstElement element;
|
||||
|
||||
GstPad *video_sinkpad;
|
||||
GstPad *text_sinkpad;
|
||||
GstPad *srcpad;
|
||||
|
||||
GstSegment segment;
|
||||
GstSegment text_segment;
|
||||
GstBuffer *text_buffer;
|
||||
gboolean text_linked;
|
||||
gboolean video_flushing;
|
||||
gboolean video_eos;
|
||||
gboolean text_flushing;
|
||||
gboolean text_eos;
|
||||
|
||||
GCond *cond; /* to signal removal of a queued text
|
||||
* buffer, arrival of a text buffer,
|
||||
* a text segment update, or a change
|
||||
* in status (e.g. shutdown, flushing) */
|
||||
|
||||
gint width;
|
||||
gint height;
|
||||
gint fps_n;
|
||||
gint fps_d;
|
||||
GstVideoFormat format;
|
||||
|
||||
GstTextOverlayVAlign valign;
|
||||
GstTextOverlayHAlign halign;
|
||||
GstTextOverlayWrapMode wrap_mode;
|
||||
GstTextOverlayLineAlign line_align;
|
||||
|
||||
gint xpad;
|
||||
gint ypad;
|
||||
gint deltax;
|
||||
gint deltay;
|
||||
gdouble xpos;
|
||||
gdouble ypos;
|
||||
gchar *default_text;
|
||||
gboolean want_shading;
|
||||
gboolean silent;
|
||||
gboolean wait_text;
|
||||
guint color;
|
||||
|
||||
PangoLayout *layout;
|
||||
gdouble shadow_offset;
|
||||
gdouble outline_offset;
|
||||
guchar *text_image;
|
||||
gint image_width;
|
||||
gint image_height;
|
||||
gint baseline_y;
|
||||
|
||||
gboolean auto_adjust_size;
|
||||
gboolean need_render;
|
||||
|
||||
gint shading_value; /* for timeoverlay subclass */
|
||||
|
||||
gboolean have_pango_markup;
|
||||
gboolean use_vertical_render;
|
||||
GstBaseTextOverlay parent;
|
||||
};
|
||||
|
||||
struct _GstTextOverlayClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
PangoContext *pango_context;
|
||||
GMutex *pango_lock;
|
||||
|
||||
gchar * (*get_text) (GstTextOverlay *overlay, GstBuffer *video_frame);
|
||||
GstBaseTextOverlayClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_text_overlay_get_type(void) G_GNUC_CONST;
|
||||
GType gst_text_overlay_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_TEXT_OVERLAY_H */
|
||||
#endif /* __GST_TEXT_OVERLAY_H__ */
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
/**
|
||||
* SECTION:element-timeoverlay
|
||||
* @see_also: #GstTextOverlay, #GstClockOverlay
|
||||
* @see_also: #GstBaseTextOverlay, #GstClockOverlay
|
||||
*
|
||||
* This element overlays the buffer time stamps of a video stream on
|
||||
* top of itself. 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 stamp is displayed in the top left corner of the picture, with some
|
||||
* padding to the left and to the top.
|
||||
*
|
||||
|
@ -50,8 +50,8 @@
|
|||
|
||||
#include <gsttimeoverlay.h>
|
||||
|
||||
GST_BOILERPLATE (GstTimeOverlay, gst_time_overlay, GstTextOverlay,
|
||||
GST_TYPE_TEXT_OVERLAY);
|
||||
GST_BOILERPLATE (GstTimeOverlay, gst_time_overlay, GstBaseTextOverlay,
|
||||
GST_TYPE_BASE_TEXT_OVERLAY);
|
||||
|
||||
static void
|
||||
gst_time_overlay_base_init (gpointer g_class)
|
||||
|
@ -82,7 +82,8 @@ gst_time_overlay_render_time (GstTimeOverlay * overlay, GstClockTime time)
|
|||
|
||||
/* Called with lock held */
|
||||
static gchar *
|
||||
gst_time_overlay_get_text (GstTextOverlay * overlay, GstBuffer * video_frame)
|
||||
gst_time_overlay_get_text (GstBaseTextOverlay * overlay,
|
||||
GstBuffer * video_frame)
|
||||
{
|
||||
GstClockTime time = GST_BUFFER_TIMESTAMP (video_frame);
|
||||
gchar *time_str, *txt, *ret;
|
||||
|
@ -115,9 +116,9 @@ gst_time_overlay_get_text (GstTextOverlay * overlay, GstBuffer * video_frame)
|
|||
static void
|
||||
gst_time_overlay_class_init (GstTimeOverlayClass * klass)
|
||||
{
|
||||
GstTextOverlayClass *gsttextoverlay_class;
|
||||
GstBaseTextOverlayClass *gsttextoverlay_class;
|
||||
|
||||
gsttextoverlay_class = (GstTextOverlayClass *) klass;
|
||||
gsttextoverlay_class = (GstBaseTextOverlayClass *) klass;
|
||||
|
||||
gsttextoverlay_class->get_text = gst_time_overlay_get_text;
|
||||
}
|
||||
|
@ -126,12 +127,12 @@ static void
|
|||
gst_time_overlay_init (GstTimeOverlay * overlay, GstTimeOverlayClass * klass)
|
||||
{
|
||||
PangoFontDescription *font_description;
|
||||
GstTextOverlay *textoverlay;
|
||||
GstBaseTextOverlay *textoverlay;
|
||||
PangoContext *context;
|
||||
|
||||
textoverlay = GST_TEXT_OVERLAY (overlay);
|
||||
textoverlay = GST_BASE_TEXT_OVERLAY (overlay);
|
||||
|
||||
context = GST_TEXT_OVERLAY_CLASS (klass)->pango_context;
|
||||
context = GST_BASE_TEXT_OVERLAY_CLASS (klass)->pango_context;
|
||||
|
||||
pango_context_set_language (context, pango_language_from_string ("en_US"));
|
||||
pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
|
||||
|
@ -146,6 +147,6 @@ gst_time_overlay_init (GstTimeOverlay * overlay, GstTimeOverlayClass * klass)
|
|||
pango_context_set_font_description (context, font_description);
|
||||
pango_font_description_free (font_description);
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef __GST_TIME_OVERLAY_H__
|
||||
#define __GST_TIME_OVERLAY_H__
|
||||
|
||||
#include "gsttextoverlay.h"
|
||||
#include "gstbasetextoverlay.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -46,11 +46,11 @@ typedef struct _GstTimeOverlayClass GstTimeOverlayClass;
|
|||
* Opaque timeoverlay data structure.
|
||||
*/
|
||||
struct _GstTimeOverlay {
|
||||
GstTextOverlay textoverlay;
|
||||
GstBaseTextOverlay textoverlay;
|
||||
};
|
||||
|
||||
struct _GstTimeOverlayClass {
|
||||
GstTextOverlayClass parent_class;
|
||||
GstBaseTextOverlayClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_time_overlay_get_type (void);
|
||||
|
|
Loading…
Reference in a new issue