ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* Copyright (C) <2003> David Schleef <ds@schleef.org>
|
2009-08-04 09:35:10 +00:00
|
|
|
* Copyright (C) <2009> Young-Ho Cha <ganadist@gmail.com>
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
*/
|
|
|
|
|
2005-12-02 16:52:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:element-textrender
|
|
|
|
* @see_also: #GstTextOverlay
|
|
|
|
*
|
|
|
|
* This plugin renders text received on the text sink pad to a video
|
|
|
|
* buffer (retaining the alpha channel), so it can later be overlayed
|
|
|
|
* on top of video streams using other elements.
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
2005-12-02 16:52:54 +00:00
|
|
|
* The text can contain newline characters. (FIXME: What about text
|
|
|
|
* wrapping? It does not make sense in this context)
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <title>Example launch lines</title>
|
|
|
|
* |[
|
2005-12-02 16:52:54 +00:00
|
|
|
* gst-launch -v filesrc location=subtitles.srt ! subparse ! textrender ! xvimagesink
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]|
|
2005-12-02 16:52:54 +00:00
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/video/video.h>
|
|
|
|
|
|
|
|
#include "gsttextrender.h"
|
2009-08-04 09:35:10 +00:00
|
|
|
#include <string.h>
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2009-08-06 07:13:14 +00:00
|
|
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
|
|
# define CAIRO_ARGB_A 3
|
|
|
|
# define CAIRO_ARGB_R 2
|
|
|
|
# define CAIRO_ARGB_G 1
|
|
|
|
# define CAIRO_ARGB_B 0
|
|
|
|
#else
|
|
|
|
# define CAIRO_ARGB_A 0
|
|
|
|
# define CAIRO_ARGB_R 1
|
|
|
|
# define CAIRO_ARGB_G 2
|
|
|
|
# define CAIRO_ARGB_B 3
|
|
|
|
#endif
|
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (pango_debug);
|
|
|
|
#define GST_CAT_DEFAULT pango_debug
|
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
#define MINIMUM_OUTLINE_OFFSET 1.0
|
|
|
|
|
2009-05-07 14:48:08 +00:00
|
|
|
#define DEFAULT_PROP_VALIGNMENT GST_TEXT_RENDER_VALIGN_BASELINE
|
|
|
|
#define DEFAULT_PROP_HALIGNMENT GST_TEXT_RENDER_HALIGN_CENTER
|
|
|
|
#define DEFAULT_PROP_LINE_ALIGNMENT GST_TEXT_RENDER_LINE_ALIGN_CENTER
|
|
|
|
#define DEFAULT_PROP_XPAD 25
|
|
|
|
#define DEFAULT_PROP_YPAD 25
|
|
|
|
|
|
|
|
#define DEFAULT_RENDER_WIDTH 720
|
|
|
|
#define DEFAULT_RENDER_HEIGHT 576
|
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
enum
|
|
|
|
{
|
2009-08-04 09:45:01 +00:00
|
|
|
PROP_0,
|
2009-05-07 14:48:08 +00:00
|
|
|
PROP_HALIGNMENT,
|
|
|
|
PROP_VALIGNMENT,
|
|
|
|
PROP_LINE_ALIGNMENT,
|
|
|
|
PROP_XPAD,
|
|
|
|
PROP_YPAD,
|
2009-08-04 09:45:01 +00:00
|
|
|
PROP_FONT_DESC
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
};
|
|
|
|
|
2011-06-16 10:48:33 +00:00
|
|
|
#define VIDEO_FORMATS "{ AYUV, ARGB } "
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate src_template_factory =
|
2011-06-16 10:48:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2011-06-16 10:48:33 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (VIDEO_FORMATS))
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_template_factory =
|
2012-09-02 01:41:34 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-09-02 01:41:34 +00:00
|
|
|
GST_STATIC_CAPS ("text/x-raw, format = { pango-markup, utf8 }")
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
);
|
|
|
|
|
2009-05-07 14:48:08 +00:00
|
|
|
#define GST_TYPE_TEXT_RENDER_VALIGN (gst_text_render_valign_get_type())
|
|
|
|
static GType
|
|
|
|
gst_text_render_valign_get_type (void)
|
|
|
|
{
|
|
|
|
static GType text_render_valign_type = 0;
|
|
|
|
static const GEnumValue text_render_valign[] = {
|
|
|
|
{GST_TEXT_RENDER_VALIGN_BASELINE, "baseline", "baseline"},
|
|
|
|
{GST_TEXT_RENDER_VALIGN_BOTTOM, "bottom", "bottom"},
|
|
|
|
{GST_TEXT_RENDER_VALIGN_TOP, "top", "top"},
|
|
|
|
{0, NULL, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!text_render_valign_type) {
|
|
|
|
text_render_valign_type =
|
|
|
|
g_enum_register_static ("GstTextRenderVAlign", text_render_valign);
|
|
|
|
}
|
|
|
|
return text_render_valign_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_TEXT_RENDER_HALIGN (gst_text_render_halign_get_type())
|
|
|
|
static GType
|
|
|
|
gst_text_render_halign_get_type (void)
|
|
|
|
{
|
|
|
|
static GType text_render_halign_type = 0;
|
|
|
|
static const GEnumValue text_render_halign[] = {
|
|
|
|
{GST_TEXT_RENDER_HALIGN_LEFT, "left", "left"},
|
|
|
|
{GST_TEXT_RENDER_HALIGN_CENTER, "center", "center"},
|
|
|
|
{GST_TEXT_RENDER_HALIGN_RIGHT, "right", "right"},
|
|
|
|
{0, NULL, NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!text_render_halign_type) {
|
|
|
|
text_render_halign_type =
|
|
|
|
g_enum_register_static ("GstTextRenderHAlign", text_render_halign);
|
|
|
|
}
|
|
|
|
return text_render_halign_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_TEXT_RENDER_LINE_ALIGN (gst_text_render_line_align_get_type())
|
|
|
|
static GType
|
|
|
|
gst_text_render_line_align_get_type (void)
|
|
|
|
{
|
|
|
|
static GType text_render_line_align_type = 0;
|
|
|
|
static const GEnumValue text_render_line_align[] = {
|
|
|
|
{GST_TEXT_RENDER_LINE_ALIGN_LEFT, "left", "left"},
|
|
|
|
{GST_TEXT_RENDER_LINE_ALIGN_CENTER, "center", "center"},
|
|
|
|
{GST_TEXT_RENDER_LINE_ALIGN_RIGHT, "right", "right"},
|
|
|
|
{0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!text_render_line_align_type) {
|
|
|
|
text_render_line_align_type =
|
|
|
|
g_enum_register_static ("GstTextRenderLineAlign",
|
|
|
|
text_render_line_align);
|
|
|
|
}
|
|
|
|
return text_render_line_align_type;
|
|
|
|
}
|
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
static void gst_text_render_adjust_values_with_fontdesc (GstTextRender *
|
|
|
|
render, PangoFontDescription * desc);
|
|
|
|
|
2011-04-19 12:11:32 +00:00
|
|
|
#define gst_text_render_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstTextRender, gst_text_render, GST_TYPE_ELEMENT);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2009-05-07 14:42:20 +00:00
|
|
|
static void gst_text_render_finalize (GObject * object);
|
|
|
|
static void gst_text_render_set_property (GObject * object,
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
2009-05-07 14:48:08 +00:00
|
|
|
static void gst_text_render_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_text_render_class_init (GstTextRenderClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2011-04-19 12:11:32 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2009-08-04 09:35:10 +00:00
|
|
|
PangoFontMap *fontmap;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
2011-04-19 12:11:32 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
gobject_class->finalize = gst_text_render_finalize;
|
|
|
|
gobject_class->set_property = gst_text_render_set_property;
|
2009-05-07 14:48:08 +00:00
|
|
|
gobject_class->get_property = gst_text_render_get_property;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&src_template_factory));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&sink_template_factory));
|
|
|
|
|
2012-04-09 23:45:16 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "Text renderer",
|
2011-04-19 12:11:32 +00:00
|
|
|
"Filter/Editor/Video",
|
|
|
|
"Renders a text string to an image bitmap",
|
|
|
|
"David Schleef <ds@schleef.org>, "
|
|
|
|
"GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
|
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
fontmap = pango_cairo_font_map_get_default ();
|
|
|
|
klass->pango_context =
|
2012-03-04 09:28:49 +00:00
|
|
|
pango_font_map_create_context (PANGO_FONT_MAP (fontmap));
|
2009-08-04 09:45:01 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FONT_DESC,
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
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"
|
2008-03-22 15:00:53 +00:00
|
|
|
" for syntax.", "", G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
2009-05-07 14:48:08 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_VALIGNMENT,
|
|
|
|
g_param_spec_enum ("valignment", "vertical alignment",
|
|
|
|
"Vertical alignment of the text", GST_TYPE_TEXT_RENDER_VALIGN,
|
|
|
|
DEFAULT_PROP_VALIGNMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_HALIGNMENT,
|
|
|
|
g_param_spec_enum ("halignment", "horizontal alignment",
|
|
|
|
"Horizontal alignment of the text", GST_TYPE_TEXT_RENDER_HALIGN,
|
|
|
|
DEFAULT_PROP_HALIGNMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_XPAD,
|
|
|
|
g_param_spec_int ("xpad", "horizontal paddding",
|
|
|
|
"Horizontal paddding when using left/right alignment", 0, G_MAXINT,
|
|
|
|
DEFAULT_PROP_XPAD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_YPAD,
|
|
|
|
g_param_spec_int ("ypad", "vertical padding",
|
|
|
|
"Vertical padding when using top/bottom alignment", 0, G_MAXINT,
|
|
|
|
DEFAULT_PROP_YPAD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LINE_ALIGNMENT,
|
|
|
|
g_param_spec_enum ("line-alignment", "line alignment",
|
|
|
|
"Alignment of text lines relative to each other.",
|
|
|
|
GST_TYPE_TEXT_RENDER_LINE_ALIGN, DEFAULT_PROP_LINE_ALIGNMENT,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_render_adjust_values_with_fontdesc (GstTextRender * render,
|
|
|
|
PangoFontDescription * desc)
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
{
|
2009-08-04 09:35:10 +00:00
|
|
|
gint font_size = pango_font_description_get_size (desc) / PANGO_SCALE;
|
|
|
|
|
|
|
|
render->shadow_offset = (double) (font_size) / 13.0;
|
|
|
|
render->outline_offset = (double) (font_size) / 15.0;
|
|
|
|
if (render->outline_offset < MINIMUM_OUTLINE_OFFSET)
|
|
|
|
render->outline_offset = MINIMUM_OUTLINE_OFFSET;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_render_render_pangocairo (GstTextRender * render)
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
{
|
2009-08-04 09:35:10 +00:00
|
|
|
cairo_t *cr;
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
cairo_t *cr_shadow;
|
|
|
|
cairo_surface_t *surface_shadow;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
PangoRectangle ink_rect, logical_rect;
|
2009-08-04 09:35:10 +00:00
|
|
|
gint width, height;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
pango_layout_get_pixel_extents (render->layout, &ink_rect, &logical_rect);
|
2009-08-04 09:35:10 +00:00
|
|
|
|
|
|
|
width = logical_rect.width + render->shadow_offset;
|
|
|
|
height = logical_rect.height + logical_rect.y + render->shadow_offset;
|
|
|
|
|
|
|
|
surface_shadow = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
|
|
|
|
cr_shadow = cairo_create (surface_shadow);
|
|
|
|
|
|
|
|
/* clear shadow surface */
|
|
|
|
cairo_set_operator (cr_shadow, CAIRO_OPERATOR_CLEAR);
|
|
|
|
cairo_paint (cr_shadow);
|
|
|
|
cairo_set_operator (cr_shadow, CAIRO_OPERATOR_OVER);
|
|
|
|
|
|
|
|
/* draw shadow text */
|
|
|
|
cairo_save (cr_shadow);
|
|
|
|
cairo_set_source_rgba (cr_shadow, 0.0, 0.0, 0.0, 0.5);
|
|
|
|
cairo_translate (cr_shadow, render->shadow_offset, render->shadow_offset);
|
|
|
|
pango_cairo_show_layout (cr_shadow, render->layout);
|
|
|
|
cairo_restore (cr_shadow);
|
|
|
|
|
|
|
|
/* draw outline text */
|
|
|
|
cairo_save (cr_shadow);
|
2009-08-06 18:47:33 +00:00
|
|
|
cairo_set_source_rgb (cr_shadow, 0.0, 0.0, 0.0);
|
2009-08-04 09:35:10 +00:00
|
|
|
cairo_set_line_width (cr_shadow, render->outline_offset);
|
|
|
|
pango_cairo_layout_path (cr_shadow, render->layout);
|
|
|
|
cairo_stroke (cr_shadow);
|
|
|
|
cairo_restore (cr_shadow);
|
|
|
|
|
|
|
|
cairo_destroy (cr_shadow);
|
|
|
|
|
|
|
|
render->text_image = g_realloc (render->text_image, 4 * width * height);
|
|
|
|
|
|
|
|
surface = cairo_image_surface_create_for_data (render->text_image,
|
|
|
|
CAIRO_FORMAT_ARGB32, width, height, width * 4);
|
|
|
|
cr = cairo_create (surface);
|
2009-08-06 18:47:33 +00:00
|
|
|
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
|
|
|
cairo_paint (cr);
|
|
|
|
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
2009-08-04 09:35:10 +00:00
|
|
|
|
|
|
|
/* set default color */
|
|
|
|
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
|
|
|
|
2009-08-06 18:47:33 +00:00
|
|
|
cairo_save (cr);
|
2009-08-04 09:35:10 +00:00
|
|
|
/* draw text */
|
|
|
|
pango_cairo_show_layout (cr, render->layout);
|
2009-08-06 18:47:33 +00:00
|
|
|
cairo_restore (cr);
|
2009-08-04 09:35:10 +00:00
|
|
|
|
|
|
|
/* composite shadow with offset */
|
|
|
|
cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
|
|
|
|
cairo_set_source_surface (cr, surface_shadow, 0.0, 0.0);
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
cairo_surface_destroy (surface_shadow);
|
|
|
|
cairo_surface_destroy (surface);
|
|
|
|
render->image_width = width;
|
|
|
|
render->image_height = height;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
2009-05-07 14:48:08 +00:00
|
|
|
static void
|
|
|
|
gst_text_render_check_argb (GstTextRender * render)
|
|
|
|
{
|
|
|
|
GstCaps *peer_caps;
|
|
|
|
peer_caps = gst_pad_get_allowed_caps (render->srcpad);
|
|
|
|
if (G_LIKELY (peer_caps)) {
|
|
|
|
guint i = 0, n = 0;
|
|
|
|
|
|
|
|
n = gst_caps_get_size (peer_caps);
|
|
|
|
GST_DEBUG_OBJECT (render, "peer allowed caps (%u structure(s)) are %"
|
|
|
|
GST_PTR_FORMAT, n, peer_caps);
|
|
|
|
|
2009-05-07 14:52:02 +00:00
|
|
|
/* Check if AYUV or ARGB is first */
|
2009-05-07 14:48:08 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2011-06-16 10:48:33 +00:00
|
|
|
GstStructure *s;
|
|
|
|
GstVideoFormat vformat;
|
2011-07-04 08:19:13 +00:00
|
|
|
const GstVideoFormatInfo *info;
|
2011-06-16 10:48:33 +00:00
|
|
|
const gchar *fmt;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (peer_caps, i);
|
|
|
|
if (!gst_structure_has_name (s, "video/x-raw"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fmt = gst_structure_get_string (s, "format");
|
|
|
|
if (fmt == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
vformat = gst_video_format_from_string (fmt);
|
2011-07-04 08:19:13 +00:00
|
|
|
info = gst_video_format_get_info (vformat);
|
|
|
|
if (info == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
render->use_ARGB = GST_VIDEO_FORMAT_INFO_HAS_ALPHA (info);
|
2009-05-07 14:48:08 +00:00
|
|
|
}
|
|
|
|
gst_caps_unref (peer_caps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
static gboolean
|
2011-06-07 09:55:36 +00:00
|
|
|
gst_text_render_src_setcaps (GstTextRender * render, GstCaps * caps)
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
{
|
|
|
|
GstStructure *structure;
|
2011-06-07 09:55:36 +00:00
|
|
|
gboolean ret;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
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);
|
|
|
|
|
2011-06-07 09:55:36 +00:00
|
|
|
GST_DEBUG_OBJECT (render, "Got caps %" GST_PTR_FORMAT, caps);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
if (width >= render->image_width && height >= render->image_height) {
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
render->width = width;
|
|
|
|
render->height = height;
|
|
|
|
}
|
|
|
|
|
2009-05-07 14:48:08 +00:00
|
|
|
gst_text_render_check_argb (render);
|
|
|
|
|
2012-06-08 13:51:06 +00:00
|
|
|
ret = gst_pad_set_caps (render->srcpad, caps);
|
2011-06-07 09:55:36 +00:00
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-03-11 18:04:41 +00:00
|
|
|
static GstCaps *
|
2011-11-10 10:02:12 +00:00
|
|
|
gst_text_render_fixate_caps (GstTextRender * render, GstCaps * caps)
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
{
|
2011-11-10 10:02:12 +00:00
|
|
|
GstStructure *s;
|
|
|
|
|
2012-03-11 18:04:41 +00:00
|
|
|
caps = gst_caps_truncate (caps);
|
|
|
|
|
|
|
|
caps = gst_caps_make_writable (caps);
|
2011-11-10 10:02:12 +00:00
|
|
|
s = gst_caps_get_structure (caps, 0);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Fixating caps %" GST_PTR_FORMAT, caps);
|
2011-05-26 08:43:51 +00:00
|
|
|
gst_structure_fixate_field_nearest_int (s, "width", MAX (render->image_width,
|
|
|
|
DEFAULT_RENDER_WIDTH));
|
|
|
|
gst_structure_fixate_field_nearest_int (s, "height",
|
|
|
|
MAX (render->image_height + render->ypad, DEFAULT_RENDER_HEIGHT));
|
2013-05-02 22:41:02 +00:00
|
|
|
caps = gst_caps_fixate (caps);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
GST_DEBUG ("Fixated to %" GST_PTR_FORMAT, caps);
|
2012-03-11 18:04:41 +00:00
|
|
|
|
|
|
|
return caps;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 08:37:38 +00:00
|
|
|
#define CAIRO_UNPREMULTIPLY(a,r,g,b) G_STMT_START { \
|
|
|
|
b = (a > 0) ? MIN ((b * 255 + a / 2) / a, 255) : 0; \
|
|
|
|
g = (a > 0) ? MIN ((g * 255 + a / 2) / a, 255) : 0; \
|
|
|
|
r = (a > 0) ? MIN ((r * 255 + a / 2) / a, 255) : 0; \
|
|
|
|
} G_STMT_END
|
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
static void
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_renderer_image_to_ayuv (GstTextRender * render, guchar * pixbuf,
|
|
|
|
int xpos, int ypos, int stride)
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
{
|
|
|
|
int y; /* text bitmap coordinates */
|
|
|
|
guchar *p, *bitp;
|
2009-08-04 09:35:10 +00:00
|
|
|
guchar a, r, g, b;
|
|
|
|
int width, height;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
width = render->image_width;
|
|
|
|
height = render->image_height;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2011-05-26 08:43:51 +00:00
|
|
|
for (y = 0; y < height && ypos + y < render->height; y++) {
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
int n;
|
2009-08-06 18:47:33 +00:00
|
|
|
p = pixbuf + (ypos + y) * stride + xpos * 4;
|
2011-05-26 08:43:51 +00:00
|
|
|
bitp = render->text_image + y * width * 4;
|
|
|
|
for (n = 0; n < width && n < render->width; n++) {
|
2009-08-06 07:13:14 +00:00
|
|
|
b = bitp[CAIRO_ARGB_B];
|
|
|
|
g = bitp[CAIRO_ARGB_G];
|
|
|
|
r = bitp[CAIRO_ARGB_R];
|
|
|
|
a = bitp[CAIRO_ARGB_A];
|
|
|
|
bitp += 4;
|
2009-08-04 09:35:10 +00:00
|
|
|
|
2009-10-01 08:37:38 +00:00
|
|
|
/* Cairo uses pre-multiplied ARGB, unpremultiply it */
|
|
|
|
CAIRO_UNPREMULTIPLY (a, r, g, b);
|
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
*p++ = a;
|
|
|
|
*p++ = CLAMP ((int) (((19595 * r) >> 16) + ((38470 * g) >> 16) +
|
|
|
|
((7471 * b) >> 16)), 0, 255);
|
|
|
|
*p++ = CLAMP ((int) (-((11059 * r) >> 16) - ((21709 * g) >> 16) +
|
|
|
|
((32768 * b) >> 16) + 128), 0, 255);
|
|
|
|
*p++ = CLAMP ((int) (((32768 * r) >> 16) - ((27439 * g) >> 16) -
|
|
|
|
((5329 * b) >> 16) + 128), 0, 255);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-07 14:48:08 +00:00
|
|
|
static void
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_renderer_image_to_argb (GstTextRender * render, guchar * pixbuf,
|
|
|
|
int xpos, int ypos, int stride)
|
2009-05-07 14:48:08 +00:00
|
|
|
{
|
2009-08-06 07:13:14 +00:00
|
|
|
int i, j;
|
2009-05-07 14:48:08 +00:00
|
|
|
guchar *p, *bitp;
|
2009-08-04 09:35:10 +00:00
|
|
|
int width, height;
|
2009-05-07 14:48:08 +00:00
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
width = render->image_width;
|
|
|
|
height = render->image_height;
|
2009-05-07 14:48:08 +00:00
|
|
|
|
2011-05-26 08:43:51 +00:00
|
|
|
for (i = 0; i < height && ypos + i < render->height; i++) {
|
2009-08-06 18:47:33 +00:00
|
|
|
p = pixbuf + (ypos + i) * stride + xpos * 4;
|
2011-05-26 08:43:51 +00:00
|
|
|
bitp = render->text_image + i * width * 4;
|
|
|
|
for (j = 0; j < width && j < render->width; j++) {
|
2009-08-06 07:13:14 +00:00
|
|
|
p[0] = bitp[CAIRO_ARGB_A];
|
|
|
|
p[1] = bitp[CAIRO_ARGB_R];
|
|
|
|
p[2] = bitp[CAIRO_ARGB_G];
|
|
|
|
p[3] = bitp[CAIRO_ARGB_B];
|
2009-08-06 18:47:33 +00:00
|
|
|
|
2009-10-01 08:37:38 +00:00
|
|
|
/* Cairo uses pre-multiplied ARGB, unpremultiply it */
|
|
|
|
CAIRO_UNPREMULTIPLY (p[0], p[1], p[2], p[3]);
|
|
|
|
|
2009-08-06 07:13:14 +00:00
|
|
|
bitp += 4;
|
|
|
|
p += 4;
|
|
|
|
}
|
2009-05-07 14:48:08 +00:00
|
|
|
}
|
|
|
|
}
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
2011-11-17 11:48:25 +00:00
|
|
|
gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
{
|
|
|
|
GstTextRender *render;
|
|
|
|
GstFlowReturn ret;
|
|
|
|
GstBuffer *outbuf;
|
2011-05-26 11:47:24 +00:00
|
|
|
GstCaps *caps = NULL, *padcaps;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2011-03-27 16:30:24 +00:00
|
|
|
guint8 *data;
|
|
|
|
gsize size;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
gint n;
|
2009-05-07 14:48:08 +00:00
|
|
|
gint xpos, ypos;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2011-11-17 11:48:25 +00:00
|
|
|
render = GST_TEXT_RENDER (parent);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (inbuf, &map, GST_MAP_READ);
|
|
|
|
data = map.data;
|
|
|
|
size = map.size;
|
2011-03-27 16:30:24 +00:00
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
/* somehow pango barfs over "\0" buffers... */
|
|
|
|
while (size > 0 &&
|
|
|
|
(data[size - 1] == '\r' ||
|
|
|
|
data[size - 1] == '\n' || data[size - 1] == '\0')) {
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* render text */
|
2011-08-09 14:39:31 +00:00
|
|
|
GST_DEBUG ("rendering '%*s'", (gint) size, data);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
pango_layout_set_markup (render->layout, (gchar *) data, size);
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_render_render_pangocairo (render);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (inbuf, &map);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2009-05-07 14:59:32 +00:00
|
|
|
gst_text_render_check_argb (render);
|
2009-05-07 14:48:08 +00:00
|
|
|
|
2011-11-15 15:48:15 +00:00
|
|
|
padcaps = gst_pad_query_caps (render->srcpad, NULL);
|
2011-11-15 16:17:53 +00:00
|
|
|
caps = gst_pad_peer_query_caps (render->srcpad, padcaps);
|
2011-05-26 08:48:05 +00:00
|
|
|
gst_caps_unref (padcaps);
|
|
|
|
|
|
|
|
if (!caps || gst_caps_is_empty (caps)) {
|
|
|
|
GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
2009-05-07 14:48:08 +00:00
|
|
|
}
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2012-03-11 18:04:41 +00:00
|
|
|
caps = gst_text_render_fixate_caps (render, caps);
|
2011-05-26 08:48:05 +00:00
|
|
|
|
2011-06-07 09:55:36 +00:00
|
|
|
if (!gst_text_render_src_setcaps (render, caps)) {
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2009-05-07 14:48:08 +00:00
|
|
|
GST_DEBUG ("Allocating buffer WxH = %dx%d", render->width, render->height);
|
2011-04-29 11:28:17 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (render->width * render->height * 4);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2011-03-27 16:30:24 +00:00
|
|
|
gst_buffer_copy_into (outbuf, inbuf, GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
|
2012-01-20 15:11:54 +00:00
|
|
|
|
|
|
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
|
|
|
data = map.data;
|
|
|
|
size = map.size;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
2009-05-07 15:38:40 +00:00
|
|
|
if (render->use_ARGB) {
|
2009-08-06 07:13:14 +00:00
|
|
|
memset (data, 0, render->width * render->height * 4);
|
2009-05-07 15:38:40 +00:00
|
|
|
} else {
|
|
|
|
for (n = 0; n < render->width * render->height; n++) {
|
|
|
|
data[n * 4] = data[n * 4 + 1] = 0;
|
|
|
|
data[n * 4 + 2] = data[n * 4 + 3] = 128;
|
|
|
|
}
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
2009-05-07 14:48:08 +00:00
|
|
|
switch (render->halign) {
|
|
|
|
case GST_TEXT_RENDER_HALIGN_LEFT:
|
|
|
|
xpos = render->xpad;
|
|
|
|
break;
|
|
|
|
case GST_TEXT_RENDER_HALIGN_CENTER:
|
2009-08-04 09:35:10 +00:00
|
|
|
xpos = (render->width - render->image_width) / 2;
|
2009-05-07 14:48:08 +00:00
|
|
|
break;
|
|
|
|
case GST_TEXT_RENDER_HALIGN_RIGHT:
|
2009-08-04 09:35:10 +00:00
|
|
|
xpos = render->width - render->image_width - render->xpad;
|
2009-05-07 14:48:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
xpos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (render->valign) {
|
|
|
|
case GST_TEXT_RENDER_VALIGN_BOTTOM:
|
2009-08-04 09:35:10 +00:00
|
|
|
ypos = render->height - render->image_height - render->ypad;
|
2009-05-07 14:48:08 +00:00
|
|
|
break;
|
|
|
|
case GST_TEXT_RENDER_VALIGN_BASELINE:
|
2009-08-04 09:35:10 +00:00
|
|
|
ypos = render->height - (render->image_height + render->ypad);
|
2009-05-07 14:48:08 +00:00
|
|
|
break;
|
|
|
|
case GST_TEXT_RENDER_VALIGN_TOP:
|
|
|
|
ypos = render->ypad;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ypos = render->ypad;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
if (render->text_image) {
|
2009-05-07 14:48:08 +00:00
|
|
|
if (render->use_ARGB) {
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_renderer_image_to_argb (render, data, xpos, ypos,
|
|
|
|
render->width * 4);
|
2009-05-07 14:48:08 +00:00
|
|
|
} else {
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_renderer_image_to_ayuv (render, data, xpos, ypos,
|
|
|
|
render->width * 4);
|
2009-05-07 14:48:08 +00:00
|
|
|
}
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
}
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuf, &map);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
ret = gst_pad_push (render->srcpad, outbuf);
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (caps)
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
gst_buffer_unref (inbuf);
|
2011-11-17 11:48:25 +00:00
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_text_render_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstTextRender *render = GST_TEXT_RENDER (object);
|
|
|
|
|
2009-08-04 09:35:10 +00:00
|
|
|
g_free (render->text_image);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
|
|
|
|
if (render->layout)
|
|
|
|
g_object_unref (render->layout);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-19 12:11:32 +00:00
|
|
|
gst_text_render_init (GstTextRender * render)
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
{
|
2006-03-09 15:05:03 +00:00
|
|
|
GstPadTemplate *template;
|
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
/* sink */
|
2006-03-09 15:05:03 +00:00
|
|
|
template = gst_static_pad_template_get (&sink_template_factory);
|
|
|
|
render->sinkpad = gst_pad_new_from_template (template, "sink");
|
|
|
|
gst_object_unref (template);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
gst_pad_set_chain_function (render->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_text_render_chain));
|
|
|
|
gst_element_add_pad (GST_ELEMENT (render), render->sinkpad);
|
|
|
|
|
|
|
|
/* source */
|
2006-03-09 15:05:03 +00:00
|
|
|
template = gst_static_pad_template_get (&src_template_factory);
|
|
|
|
render->srcpad = gst_pad_new_from_template (template, "src");
|
|
|
|
gst_object_unref (template);
|
2009-05-07 14:48:08 +00:00
|
|
|
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (render), render->srcpad);
|
|
|
|
|
2009-05-07 14:48:08 +00:00
|
|
|
render->line_align = DEFAULT_PROP_LINE_ALIGNMENT;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
render->layout =
|
|
|
|
pango_layout_new (GST_TEXT_RENDER_GET_CLASS (render)->pango_context);
|
2009-05-07 14:48:08 +00:00
|
|
|
pango_layout_set_alignment (render->layout,
|
|
|
|
(PangoAlignment) render->line_align);
|
|
|
|
|
|
|
|
render->halign = DEFAULT_PROP_HALIGNMENT;
|
|
|
|
render->valign = DEFAULT_PROP_VALIGNMENT;
|
|
|
|
render->xpad = DEFAULT_PROP_XPAD;
|
|
|
|
render->ypad = DEFAULT_PROP_YPAD;
|
|
|
|
|
|
|
|
render->width = DEFAULT_RENDER_WIDTH;
|
|
|
|
render->height = DEFAULT_RENDER_HEIGHT;
|
|
|
|
|
|
|
|
render->use_ARGB = FALSE;
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2009-05-07 14:48:08 +00:00
|
|
|
case PROP_VALIGNMENT:
|
|
|
|
render->valign = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case PROP_HALIGNMENT:
|
|
|
|
render->halign = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case PROP_LINE_ALIGNMENT:
|
|
|
|
render->line_align = g_value_get_enum (value);
|
|
|
|
pango_layout_set_alignment (render->layout,
|
|
|
|
(PangoAlignment) render->line_align);
|
|
|
|
break;
|
|
|
|
case PROP_XPAD:
|
|
|
|
render->xpad = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_YPAD:
|
|
|
|
render->ypad = g_value_get_int (value);
|
|
|
|
break;
|
2009-08-04 09:45:01 +00:00
|
|
|
case PROP_FONT_DESC:
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
{
|
|
|
|
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);
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_render_adjust_values_with_fontdesc (render, desc);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
pango_font_description_free (desc);
|
2009-08-04 09:35:10 +00:00
|
|
|
gst_text_render_render_pangocairo (render);
|
ext/pango/gsttextrender.*: Add missing files.
Original commit message from CVS:
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
(gst_text_render_class_init), (resize_bitmap),
(gst_text_render_render_text), (gst_text_render_setcaps),
(gst_text_render_fixate_caps), (gst_text_renderer_bitmap_to_ayuv),
(gst_text_render_chain), (gst_text_render_finalize),
(gst_text_render_init), (gst_text_render_set_property):
* ext/pango/gsttextrender.h:
Add missing files.
2005-11-30 14:53:29 +00:00
|
|
|
GST_OBJECT_UNLOCK (render);
|
|
|
|
} else {
|
|
|
|
GST_WARNING ("font description parse failed: %s",
|
|
|
|
g_value_get_string (value));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-07 14:48:08 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_text_render_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstTextRender *render = GST_TEXT_RENDER (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_VALIGNMENT:
|
|
|
|
g_value_set_enum (value, render->valign);
|
|
|
|
break;
|
|
|
|
case PROP_HALIGNMENT:
|
|
|
|
g_value_set_enum (value, render->halign);
|
|
|
|
break;
|
|
|
|
case PROP_LINE_ALIGNMENT:
|
|
|
|
g_value_set_enum (value, render->line_align);
|
|
|
|
break;
|
|
|
|
case PROP_XPAD:
|
|
|
|
g_value_set_int (value, render->xpad);
|
|
|
|
break;
|
|
|
|
case PROP_YPAD:
|
|
|
|
g_value_set_int (value, render->ypad);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|