gsttextoverlay.c 3.7 KB
Newer Older
1 2 3
/* GStreamer
 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
 * Copyright (C) <2003> David Schleef <ds@schleef.org>
4
 * Copyright (C) <2006> Julien Moutte <julien@moutte.net>
5
 * Copyright (C) <2006> Zeeshan Ali <zeeshan.ali@nokia.com>
6
 * Copyright (C) <2006-2008> Tim-Philipp Müller <tim centricular net>
7
 * Copyright (C) <2009> Young-Ho Cha <ganadist@gmail.com>
8
 * Copyright (C) <2011> Sebastian Dröge <sebastian.droege@collabora.co.uk>
9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * 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
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
22 23
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
24
 */
25

26 27
/**
 * SECTION:element-textoverlay
28
 * @title: textoverlay
29
 * @see_also: #GstTextRender, #GstTextOverlay, #GstTimeOverlay, #GstSubParse
30 31 32 33 34 35 36
 *
 * This plugin renders text on top of a video stream. This can be either
 * static text or text from buffers received on the text sink pad, e.g.
 * as produced by the subparse element. If the text sink pad is not linked,
 * the text set via the "text" property will be rendered. If the text sink
 * pad is linked, text will be rendered as it is received on that pad,
 * honouring and matching the buffer timestamps of both input streams.
37
 *
38 39
 * The text can contain newline characters and text wrapping is enabled by
 * default.
40
 *
41
 * ## Example launch lines
42
 * |[
43
 * gst-launch-1.0 -v videotestsrc ! textoverlay text="Room A" valignment=top halignment=left font-desc="Sans, 72" ! autovideosink
44 45
 * ]|
 * Here is a simple pipeline that displays a static text in the top left
46
 * corner of the video picture
47
 * |[
48
 * gst-launch-1.0 -v filesrc location=subtitles.srt ! subparse ! txt.   videotestsrc ! timeoverlay ! textoverlay name=txt shaded-background=yes ! autovideosink
49 50
 * ]|
 * Here is another pipeline that displays subtitles from an .srt subtitle
51 52
 * file, centered at the bottom of the picture and with a rectangular shading
 * around the text in the background:
53
 *
54
 * If you do not have such a subtitle file, create one looking like this
55
 * in a text editor:
56
 * |[
57 58 59
 * 1
 * 00:00:03,000 --> 00:00:05,000
 * Hello? (3-5s)
60
 *
61 62
 * 2
 * 00:00:08,000 --> 00:00:13,000
63
 * Yes, this is a subtitle. Don&apos;t
64
 * you like it? (8-13s)
65
 *
66 67 68
 * 3
 * 00:00:18,826 --> 00:01:02,886
 * Uh? What are you talking about?
69
 * I don&apos;t understand  (18-62s)
70
 * ]|
71
 *
72 73
 */

74
#ifdef HAVE_CONFIG_H
75
#include "config.h"
76 77
#endif

78
#include <gsttextoverlay.h>
David Schleef's avatar
David Schleef committed
79 80

static GstStaticPadTemplate text_sink_template_factory =
81
GST_STATIC_PAD_TEMPLATE ("text_sink",
David Schleef's avatar
David Schleef committed
82 83
    GST_PAD_SINK,
    GST_PAD_ALWAYS,
84
    GST_STATIC_CAPS ("text/x-raw, format = { pango-markup, utf8 }")
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
85 86
    );

87
G_DEFINE_TYPE (GstTextOverlay, gst_text_overlay, GST_TYPE_BASE_TEXT_OVERLAY);
88

89
static void
90
gst_text_overlay_class_init (GstTextOverlayClass * klass)
Iain Holmes's avatar
Iain Holmes committed
91
{
92
  GstElementClass *element_class = (GstElementClass *) klass;
Iain Holmes's avatar
Iain Holmes committed
93

94 95
  gst_element_class_add_static_pad_template (element_class,
      &text_sink_template_factory);
96

97
  gst_element_class_set_static_metadata (element_class, "Text overlay",
98 99 100
      "Filter/Editor/Video",
      "Adds text strings on top of a video buffer",
      "David Schleef <ds@schleef.org>, " "Zeeshan Ali <zeeshan.ali@nokia.com>");
101 102
}

103
static void
104
gst_text_overlay_init (GstTextOverlay * overlay)
105
{
106
}