1 /* GStreamer
2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * 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 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
19 *
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24 */
25
26 /**
27 * SECTION:element-textoverlay
28 * @title: textoverlay
29 * @see_also: #GstTextRender, #GstTextOverlay, #GstTimeOverlay, #GstSubParse
30 *
31 * This plugin renders text on top of a video stream. This can be either
32 * static text or text from buffers received on the text sink pad, e.g.
33 * as produced by the subparse element. If the text sink pad is not linked,
34 * the text set via the "text" property will be rendered. If the text sink
35 * pad is linked, text will be rendered as it is received on that pad,
36 * honouring and matching the buffer timestamps of both input streams.
37 *
38 * The text can contain newline characters and text wrapping is enabled by
39 * 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 * file, centered at the bottom of the picture and with a rectangular shading
52 * 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 * 1
58 * 00:00:03,000 --> 00:00:05,000
59 * Hello? (3-5s)
60 *
61 * 2
62 * 00:00:08,000 --> 00:00:13,000
63 * Yes, this is a subtitle. Don't
64 * you like it? (8-13s)
65 *
66 * 3
67 * 00:00:18,826 --> 00:01:02,886
68 * Uh? What are you talking about?
69 * I don't understand (18-62s)
70 * ]|
71 *
72 */
73
74 #ifdef HAVE_CONFIG_H
75 #include "config.h"
76 #endif
77
78 #include "gsttextoverlay.h"
79 #include "gstpangoelements.h"
80
81 static GstStaticPadTemplate text_sink_template_factory =
82 GST_STATIC_PAD_TEMPLATE ("text_sink",
83 GST_PAD_SINK,
84 GST_PAD_ALWAYS,
85 GST_STATIC_CAPS ("text/x-raw, format = { pango-markup, utf8 }")
86 );
87
88 G_DEFINE_TYPE (GstTextOverlay, gst_text_overlay, GST_TYPE_BASE_TEXT_OVERLAY);
89 GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (textoverlay, "textoverlay",
90 GST_RANK_NONE, GST_TYPE_TEXT_OVERLAY, pango_element_init (plugin));
91
92 static void
gst_text_overlay_class_init(GstTextOverlayClass * klass)93 gst_text_overlay_class_init (GstTextOverlayClass * klass)
94 {
95 GstElementClass *element_class = (GstElementClass *) klass;
96
97 gst_element_class_add_static_pad_template (element_class,
98 &text_sink_template_factory);
99
100 gst_element_class_set_static_metadata (element_class, "Text overlay",
101 "Filter/Editor/Video",
102 "Adds text strings on top of a video buffer",
103 "David Schleef <ds@schleef.org>, " "Zeeshan Ali <zeeshan.ali@nokia.com>");
104 }
105
106 static void
gst_text_overlay_init(GstTextOverlay * overlay)107 gst_text_overlay_init (GstTextOverlay * overlay)
108 {
109 }
110