move pango to base

Original commit message from CVS:
move pango to base
This commit is contained in:
Thomas Vander Stichele 2005-12-01 15:22:25 +00:00
parent fe967d4fe8
commit 94b7b4dc7f
12 changed files with 15 additions and 1926 deletions

View file

@ -1,3 +1,18 @@
2005-12-01 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
* configure.ac:
* ext/Makefile.am:
* ext/pango/Makefile.am:
* ext/pango/gstclockoverlay.c:
* ext/pango/gstclockoverlay.h:
* ext/pango/gsttextoverlay.c:
* ext/pango/gsttextoverlay.h:
* ext/pango/gsttextrender.c:
* ext/pango/gsttextrender.h:
* ext/pango/gsttimeoverlay.c:
* ext/pango/gsttimeoverlay.h:
move pango to base
2005-12-01 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
* gst/rtp/Makefile.am:

View file

@ -413,15 +413,6 @@ GST_CHECK_FEATURE(DV1394, [raw1394 and avc1394 library], dv1394src, [
fi
])
dnl *** pango ***
translit(dnm, m, l) AM_CONDITIONAL(USE_PANGO, true)
GST_CHECK_FEATURE(PANGO, [pango], pango, [
PKG_CHECK_MODULES(PANGO, pango pangoft2,
HAVE_PANGO="yes", HAVE_PANGO="no")
AC_SUBST(PANGO_CFLAGS)
AC_SUBST(PANGO_LIBS)
])
dnl *** shout2 ***
translit(dnm, m, l) AM_CONDITIONAL(USE_SHOUT2, true)
GST_CHECK_FEATURE(SHOUT2, [shout2 plug-in], shout2send, [
@ -566,7 +557,6 @@ ext/gconf/Makefile
ext/ladspa/Makefile
ext/libcaca/Makefile
ext/libpng/Makefile
ext/pango/Makefile
ext/raw1394/Makefile
ext/shout2/Makefile
ext/speex/Makefile

View file

@ -76,12 +76,6 @@ endif
MIKMOD_DIR =
# endif
if USE_PANGO
PANGO_DIR = pango
else
PANGO_DIR =
endif
if USE_DV1394
DV1394_DIR = raw1394
else
@ -115,7 +109,6 @@ SUBDIRS = \
$(LIBMNG_DIR) \
$(LIBPNG_DIR) \
$(MIKMOD_DIR) \
$(PANGO_DIR) \
$(SHOUT2_DIR) \
$(SPEEX_DIR)
@ -130,7 +123,6 @@ DIST_SUBDIRS = \
ladspa \
libcaca \
libpng \
pango \
raw1394 \
shout2 \
speex

View file

@ -1,28 +0,0 @@
plugin_LTLIBRARIES = libgstpango.la
noinst_HEADERS = \
gstclockoverlay.h \
gsttextoverlay.h \
gsttextrender.h \
gsttimeoverlay.h
libgstpango_la_SOURCES = \
gstclockoverlay.c \
gsttextoverlay.c \
gsttextrender.c \
gsttimeoverlay.c
libgstpango_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) \
$(PANGO_CFLAGS)
libgstpango_la_LIBADD = \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(PANGO_LIBS)
libgstpango_la_LDFLAGS = \
$(GST_PLUGIN_LDFLAGS)

View file

@ -1,119 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2005> Tim-Philipp Müller <tim@centricular.net>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gstclockoverlay.h>
#include <gst/video/video.h>
#include <time.h>
static GstElementDetails clock_overlay_details =
GST_ELEMENT_DETAILS ("Time Overlay",
"Filter/Editor/Video",
"Overlays the time on a video stream",
"Tim-Philipp Müller <tim@centricular.net>");
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 (element_class, &clock_overlay_details);
}
static gchar *
gst_clock_overlay_render_time (GstClockOverlay * overlay)
{
struct tm t;
time_t now;
now = time (NULL);
if (localtime_r (&now, &t) == NULL)
return g_strdup ("--:--:--");
return g_strdup_printf ("%02u:%02u:%02u", t.tm_hour, t.tm_min, t.tm_sec);
}
static gchar *
gst_clock_overlay_get_text (GstTextOverlay * overlay, GstBuffer * video_frame)
{
gchar *time_str, *txt, *ret;
overlay->need_render = TRUE;
GST_OBJECT_LOCK (overlay);
txt = g_strdup (overlay->default_text);
GST_OBJECT_UNLOCK (overlay);
time_str = gst_clock_overlay_render_time (GST_CLOCK_OVERLAY (overlay));
if (txt != NULL && *txt != '\0') {
ret = g_strdup_printf ("%s %s", txt, time_str);
} else {
ret = time_str;
time_str = NULL;
}
g_free (txt);
g_free (time_str);
return ret;
}
static void
gst_clock_overlay_class_init (GstClockOverlayClass * klass)
{
GstTextOverlayClass *gsttextoverlay_class;
gsttextoverlay_class = (GstTextOverlayClass *) klass;
gsttextoverlay_class->get_text = gst_clock_overlay_get_text;
}
static void
gst_clock_overlay_init (GstClockOverlay * overlay, GstClockOverlayClass * klass)
{
PangoFontDescription *font_description;
GstTextOverlay *textoverlay;
PangoContext *context;
textoverlay = GST_TEXT_OVERLAY (overlay);
context = GST_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);
font_description = pango_font_description_new ();
pango_font_description_set_family (font_description, g_strdup ("Monospace"));
pango_font_description_set_style (font_description, PANGO_STYLE_NORMAL);
pango_font_description_set_variant (font_description, PANGO_VARIANT_NORMAL);
pango_font_description_set_weight (font_description, PANGO_WEIGHT_NORMAL);
pango_font_description_set_stretch (font_description, PANGO_STRETCH_NORMAL);
pango_font_description_set_size (font_description, 18 * PANGO_SCALE);
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;
}

View file

@ -1,56 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2005> Tim-Philipp Müller <tim@centricular.net>
*
* 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_CLOCK_OVERLAY_H__
#define __GST_CLOCK_OVERLAY_H__
#include "gsttextoverlay.h"
G_BEGIN_DECLS
#define GST_TYPE_CLOCK_OVERLAY \
(gst_clock_overlay_get_type())
#define GST_CLOCK_OVERLAY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLOCK_OVERLAY,GstClockOverlay))
#define GST_CLOCK_OVERLAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLOCK_OVERLAY,GstClockOverlayClass))
#define GST_IS_CLOCK_OVERLAY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLOCK_OVERLAY))
#define GST_IS_CLOCK_OVERLAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLOCK_OVERLAY))
typedef struct _GstClockOverlay GstClockOverlay;
typedef struct _GstClockOverlayClass GstClockOverlayClass;
struct _GstClockOverlay {
GstTextOverlay textoverlay;
};
struct _GstClockOverlayClass {
GstTextOverlayClass parent_class;
};
GType gst_clock_overlay_get_type (void);
G_END_DECLS
#endif /* __GST_CLOCK_OVERLAY_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,99 +0,0 @@
#ifndef __GST_TEXT_OVERLAY_H__
#define __GST_TEXT_OVERLAY_H__
#include <gst/gst.h>
#include <gst/base/gstcollectpads.h>
#include <pango/pangoft2.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))
typedef struct _GstTextOverlay GstTextOverlay;
typedef struct _GstTextOverlayClass GstTextOverlayClass;
typedef enum _GstTextOverlayVAlign GstTextOverlayVAlign;
typedef enum _GstTextOverlayHAlign GstTextOverlayHAlign;
typedef enum _GstTextOverlayWrapMode GstTextOverlayWrapMode;
enum _GstTextOverlayVAlign {
GST_TEXT_OVERLAY_VALIGN_BASELINE,
GST_TEXT_OVERLAY_VALIGN_BOTTOM,
GST_TEXT_OVERLAY_VALIGN_TOP
};
enum _GstTextOverlayHAlign {
GST_TEXT_OVERLAY_HALIGN_LEFT,
GST_TEXT_OVERLAY_HALIGN_CENTER,
GST_TEXT_OVERLAY_HALIGN_RIGHT
};
enum _GstTextOverlayWrapMode {
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
};
struct _GstTextOverlay {
GstElement element;
GstPad *video_sinkpad;
GstPad *text_sinkpad;
GstPad *srcpad;
GstCollectPads *collect;
GstCollectData *video_collect_data;
GstCollectData *text_collect_data;
gint width;
gint height;
gint fps_n;
gint fps_d;
GstTextOverlayVAlign valign;
GstTextOverlayHAlign halign;
GstTextOverlayWrapMode wrap_mode;
gint xpad;
gint ypad;
gint deltax;
gint deltay;
gchar *default_text;
gboolean want_shading;
PangoLayout *layout;
FT_Bitmap bitmap;
gint bitmap_buffer_size;
gint baseline_y;
gboolean need_render;
gint shading_value; /* for timeoverlay subclass */
};
struct _GstTextOverlayClass {
GstElementClass parent_class;
PangoContext *pango_context;
gchar * (*get_text) (GstTextOverlay *overlay, GstBuffer *video_frame);
};
GType gst_text_overlay_get_type(void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GST_TEXT_OVERLAY_H */

View file

@ -1,357 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2003> David Schleef <ds@schleef.org>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <gst/gst.h>
#include <gst/video/video.h>
#include "gsttextrender.h"
GST_DEBUG_CATEGORY_EXTERN (pango_debug);
#define GST_CAT_DEFAULT pango_debug
static GstElementDetails text_render_details = {
"Text Render",
"Filter/Editor/Video",
"Renders a text string to an image bitmap",
"David Schleef <ds@schleef.org>, "
"Ronald S. Bultje <rbultje@ronald.bitfreak.net>"
};
enum
{
ARG_0,
ARG_FONT_DESC
};
static GstStaticPadTemplate src_template_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV"))
);
static GstStaticPadTemplate sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("text/x-pango-markup; text/plain")
);
GST_BOILERPLATE (GstTextRender, gst_text_render, GstElement, GST_TYPE_ELEMENT)
static void gst_text_render_finalize (GObject * object);
static void gst_text_render_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_text_render_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_template_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template_factory));
gst_element_class_set_details (element_class, &text_render_details);
}
static void
gst_text_render_class_init (GstTextRenderClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = gst_text_render_finalize;
gobject_class->set_property = gst_text_render_set_property;
klass->pango_context = pango_ft2_get_context (72, 72);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FONT_DESC,
g_param_spec_string ("font-desc", "font description",
"Pango font description of font "
"to be used for rendering. "
"See documentation of "
"pango_font_description_from_string"
" for syntax.", "", G_PARAM_WRITABLE));
}
static void
resize_bitmap (GstTextRender * render, gint width, gint height)
{
FT_Bitmap *bitmap = &render->bitmap;
gint pitch = (width | 3) + 1;
gint size = pitch * height;
/* no need to keep reallocating; just keep the maximum size so far */
if (size <= render->bitmap_buffer_size) {
bitmap->rows = height;
bitmap->width = width;
bitmap->pitch = pitch;
memset (bitmap->buffer, 0, render->bitmap_buffer_size);
return;
}
if (!bitmap->buffer) {
/* initialize */
bitmap->pixel_mode = ft_pixel_mode_grays;
bitmap->num_grays = 256;
}
if (bitmap->buffer)
bitmap->buffer = g_realloc (bitmap->buffer, size);
else
bitmap->buffer = g_malloc (size);
bitmap->rows = height;
bitmap->width = width;
bitmap->pitch = pitch;
memset (bitmap->buffer, 0, size);
render->bitmap_buffer_size = size;
}
static void
gst_text_render_render_text (GstTextRender * render)
{
PangoRectangle ink_rect, logical_rect;
pango_layout_get_pixel_extents (render->layout, &ink_rect, &logical_rect);
resize_bitmap (render, ink_rect.width, ink_rect.height + ink_rect.y);
pango_ft2_render_layout (&render->bitmap, render->layout, -ink_rect.x, 0);
render->baseline_y = ink_rect.y;
}
static gboolean
gst_text_render_setcaps (GstPad * pad, GstCaps * caps)
{
GstTextRender *render = GST_TEXT_RENDER (gst_pad_get_parent (pad));
GstStructure *structure;
gboolean ret = FALSE;
gint width = 0, height = 0;
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "height", &height);
GST_DEBUG ("Got caps %" GST_PTR_FORMAT, caps);
if (width >= render->bitmap.width && height >= render->bitmap.rows) {
render->width = width;
render->height = height;
ret = TRUE;
}
gst_object_unref (render);
return ret;
}
static void
gst_text_render_fixate_caps (GstPad * pad, GstCaps * caps)
{
GstTextRender *render = GST_TEXT_RENDER (gst_pad_get_parent (pad));
GstStructure *s = gst_caps_get_structure (caps, 0);
GST_DEBUG ("Fixating caps %" GST_PTR_FORMAT, caps);
gst_structure_fixate_field_nearest_int (s, "width", render->bitmap.width);
gst_structure_fixate_field_nearest_int (s, "height", render->bitmap.rows);
GST_DEBUG ("Fixated to %" GST_PTR_FORMAT, caps);
gst_object_unref (render);
}
static void
gst_text_renderer_bitmap_to_ayuv (GstTextRender * render, FT_Bitmap * bitmap,
guchar * pixbuf)
{
int y; /* text bitmap coordinates */
int rowinc, bit_rowinc;
guchar *p, *bitp;
guchar v;
rowinc = render->width - bitmap->width;
bit_rowinc = bitmap->pitch - bitmap->width;
bitp = bitmap->buffer;
p = pixbuf;
for (y = 0; y < bitmap->rows; y++) {
int n;
for (n = bitmap->width; n > 0; --n) {
v = *bitp;
if (v) {
p[0] = v;
p[1] = 255;
p[2] = 0x80;
p[3] = 0x80;
}
p += 4;
bitp++;
}
p += rowinc * 4;
bitp += bit_rowinc;
}
}
static GstFlowReturn
gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
{
GstTextRender *render;
GstFlowReturn ret;
GstBuffer *outbuf;
GstCaps *caps = NULL;
guint8 *data = GST_BUFFER_DATA (inbuf);
guint size = GST_BUFFER_SIZE (inbuf);
gint n;
render = GST_TEXT_RENDER (gst_pad_get_parent (pad));
/* somehow pango barfs over "\0" buffers... */
while (size > 0 &&
(data[size - 1] == '\r' ||
data[size - 1] == '\n' || data[size - 1] == '\0')) {
size--;
}
/* render text */
GST_DEBUG ("rendering '%*s'", size, data);
pango_layout_set_markup (render->layout, (gchar *) data, size);
gst_text_render_render_text (render);
caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC,
GST_MAKE_FOURCC ('A', 'Y', 'U', 'V'), "width", G_TYPE_INT,
render->bitmap.width, "height", G_TYPE_INT, render->bitmap.rows,
"framerate", GST_TYPE_FRACTION, 1, 1, NULL);
if (!gst_pad_set_caps (render->srcpad, caps)) {
gst_caps_unref (caps);
GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL));
ret = GST_FLOW_ERROR;
goto done;
}
GST_DEBUG ("Allocating AYUV buffer WxH = %dx%d", render->width,
render->height);
ret =
gst_pad_alloc_buffer (render->srcpad, GST_BUFFER_OFFSET_NONE,
render->width * render->height * 4, caps, &outbuf);
if (ret != GST_FLOW_OK)
goto done;
gst_buffer_stamp (outbuf, inbuf);
data = GST_BUFFER_DATA (outbuf);
for (n = 0; n < render->width * render->height; n++) {
data[n * 4] = 0;
data[n * 4 + 1] = 0;
data[n * 4 + 2] = data[n * 4 + 3] = 128;
}
if (render->bitmap.buffer) {
gst_text_renderer_bitmap_to_ayuv (render, &render->bitmap, data);
}
ret = gst_pad_push (render->srcpad, outbuf);
done:
if (caps)
gst_caps_unref (caps);
gst_buffer_unref (inbuf);
gst_object_unref (render);
return ret;
}
static void
gst_text_render_finalize (GObject * object)
{
GstTextRender *render = GST_TEXT_RENDER (object);
g_free (render->bitmap.buffer);
if (render->layout)
g_object_unref (render->layout);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gst_text_render_init (GstTextRender * render, GstTextRenderClass * klass)
{
/* sink */
render->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&sink_template_factory), "sink");
gst_pad_set_chain_function (render->sinkpad,
GST_DEBUG_FUNCPTR (gst_text_render_chain));
gst_element_add_pad (GST_ELEMENT (render), render->sinkpad);
/* source */
render->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&src_template_factory), "src");
gst_pad_set_fixatecaps_function (render->srcpad,
GST_DEBUG_FUNCPTR (gst_text_render_fixate_caps));
gst_pad_set_setcaps_function (render->srcpad,
GST_DEBUG_FUNCPTR (gst_text_render_setcaps));
gst_element_add_pad (GST_ELEMENT (render), render->srcpad);
render->layout =
pango_layout_new (GST_TEXT_RENDER_GET_CLASS (render)->pango_context);
memset (&render->bitmap, 0, sizeof (render->bitmap));
}
static void
gst_text_render_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstTextRender *render = GST_TEXT_RENDER (object);
switch (prop_id) {
case ARG_FONT_DESC:
{
PangoFontDescription *desc;
desc = pango_font_description_from_string (g_value_get_string (value));
if (desc) {
GST_LOG ("font description set: %s", g_value_get_string (value));
GST_OBJECT_LOCK (render);
pango_layout_set_font_description (render->layout, desc);
pango_font_description_free (desc);
gst_text_render_render_text (render);
GST_OBJECT_UNLOCK (render);
} else {
GST_WARNING ("font description parse failed: %s",
g_value_get_string (value));
}
break;
}
default:
break;
}
}

View file

@ -1,46 +0,0 @@
#ifndef __GST_TEXT_RENDER_H__
#define __GST_TEXT_RENDER_H__
#include <gst/gst.h>
#include <pango/pangoft2.h>
G_BEGIN_DECLS
#define GST_TYPE_TEXT_RENDER (gst_text_render_get_type())
#define GST_TEXT_RENDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
GST_TYPE_TEXT_RENDER, GstTextRender))
#define GST_TEXT_RENDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
GST_TYPE_ULAW, GstTextRender))
#define GST_TEXT_RENDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
GST_TYPE_TEXT_RENDER, GstTextRenderClass))
#define GST_IS_TEXT_RENDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
GST_TYPE_TEXT_RENDER))
#define GST_IS_TEXT_RENDER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),\
GST_TYPE_TEXT_RENDER))
typedef struct _GstTextRender GstTextRender;
typedef struct _GstTextRenderClass GstTextRenderClass;
struct _GstTextRender {
GstElement element;
GstPad *sinkpad, *srcpad;
gint width;
gint height;
PangoLayout *layout;
FT_Bitmap bitmap;
gint bitmap_buffer_size;
gint baseline_y;
};
struct _GstTextRenderClass {
GstElementClass parent_class;
PangoContext *pango_context;
};
GType gst_text_render_get_type(void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GST_TEXT_RENDER_H */

View file

@ -1,130 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2005> Tim-Philipp Müller <tim@centricular.net>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/video/video.h>
#include <gsttimeoverlay.h>
static GstElementDetails time_overlay_details =
GST_ELEMENT_DETAILS ("Time Overlay",
"Filter/Editor/Video",
"Overlays the time on a video stream",
"Tim-Philipp Müller <tim@centricular.net>");
GST_BOILERPLATE (GstTimeOverlay, gst_time_overlay, GstTextOverlay,
GST_TYPE_TEXT_OVERLAY)
static void gst_time_overlay_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &time_overlay_details);
}
static gchar *
gst_time_overlay_render_time (GstTimeOverlay * overlay, GstClockTime time)
{
guint hours, mins, secs, msecs;
if (!GST_CLOCK_TIME_IS_VALID (time))
return g_strdup ("");
hours = (guint) (time / (GST_SECOND * 60 * 60));
mins = (guint) ((time / (GST_SECOND * 60)) % 60);
secs = (guint) ((time / GST_SECOND) % 60);
msecs = (guint) ((time % GST_SECOND) / (1000 * 1000));
return g_strdup_printf ("%u:%02u:%02u.%03u", hours, mins, secs, msecs);
}
static gchar *
gst_time_overlay_get_text (GstTextOverlay * overlay, GstBuffer * video_frame)
{
GstClockTime time = GST_BUFFER_TIMESTAMP (video_frame);
gchar *time_str, *txt, *ret;
overlay->need_render = TRUE;
if (!GST_CLOCK_TIME_IS_VALID (time)) {
GST_DEBUG ("buffer without valid timestamp");
return g_strdup ("");
}
GST_DEBUG ("buffer with timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (time));
GST_OBJECT_LOCK (overlay);
txt = g_strdup (overlay->default_text);
GST_OBJECT_UNLOCK (overlay);
time_str = gst_time_overlay_render_time (GST_TIME_OVERLAY (overlay), time);
if (txt != NULL && *txt != '\0') {
ret = g_strdup_printf ("%s %s", txt, time_str);
} else {
ret = time_str;
time_str = NULL;
}
g_free (txt);
g_free (time_str);
return ret;
}
static void
gst_time_overlay_class_init (GstTimeOverlayClass * klass)
{
GstTextOverlayClass *gsttextoverlay_class;
gsttextoverlay_class = (GstTextOverlayClass *) klass;
gsttextoverlay_class->get_text = gst_time_overlay_get_text;
}
static void
gst_time_overlay_init (GstTimeOverlay * overlay, GstTimeOverlayClass * klass)
{
PangoFontDescription *font_description;
GstTextOverlay *textoverlay;
PangoContext *context;
textoverlay = GST_TEXT_OVERLAY (overlay);
context = GST_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);
font_description = pango_font_description_new ();
pango_font_description_set_family (font_description, g_strdup ("Monospace"));
pango_font_description_set_style (font_description, PANGO_STYLE_NORMAL);
pango_font_description_set_variant (font_description, PANGO_VARIANT_NORMAL);
pango_font_description_set_weight (font_description, PANGO_WEIGHT_NORMAL);
pango_font_description_set_stretch (font_description, PANGO_STRETCH_NORMAL);
pango_font_description_set_size (font_description, 18 * PANGO_SCALE);
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;
}

View file

@ -1,56 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2005> Tim-Philipp Müller <tim@centricular.net>
*
* 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_TIME_OVERLAY_H__
#define __GST_TIME_OVERLAY_H__
#include "gsttextoverlay.h"
G_BEGIN_DECLS
#define GST_TYPE_TIME_OVERLAY \
(gst_time_overlay_get_type())
#define GST_TIME_OVERLAY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TIME_OVERLAY,GstTimeOverlay))
#define GST_TIME_OVERLAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TIME_OVERLAY,GstTimeOverlayClass))
#define GST_IS_TIME_OVERLAY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TIME_OVERLAY))
#define GST_IS_TIME_OVERLAY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TIME_OVERLAY))
typedef struct _GstTimeOverlay GstTimeOverlay;
typedef struct _GstTimeOverlayClass GstTimeOverlayClass;
struct _GstTimeOverlay {
GstTextOverlay textoverlay;
};
struct _GstTimeOverlayClass {
GstTextOverlayClass parent_class;
};
GType gst_time_overlay_get_type (void);
G_END_DECLS
#endif /* __GST_TIME_OVERLAY_H__ */