1/* GStreamer video sink base class
2 * Copyright (C) <2003> Julien Moutte <julien@moutte.net>
3 * Copyright (C) <2009> Tim-Philipp Müller <tim centricular net>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21/* FIXME 0.11: turn this into a proper base class */
22
23#ifndef __GST_VIDEO_SINK_H__
24#define __GST_VIDEO_SINK_H__
25
26#include <gst/gst.h>
27#include <gst/base/gstbasesink.h>
28#include <gst/video/video-prelude.h>
29
30G_BEGIN_DECLS
31
32#define GST_TYPE_VIDEO_SINK (gst_video_sink_get_type())
33#define GST_VIDEO_SINK(obj) \
34 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VIDEO_SINK, GstVideoSink))
35#define GST_VIDEO_SINK_CLASS(klass) \
36 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VIDEO_SINK, GstVideoSinkClass))
37#define GST_IS_VIDEO_SINK(obj) \
38 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VIDEO_SINK))
39#define GST_IS_VIDEO_SINK_CLASS(klass) \
40 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VIDEO_SINK))
41#define GST_VIDEO_SINK_GET_CLASS(klass) \
42 (G_TYPE_INSTANCE_GET_CLASS ((klass), GST_TYPE_VIDEO_SINK, GstVideoSinkClass))
43
44/**
45 * GST_VIDEO_SINK_CAST:
46 * @obj: a #GstVideoSink or derived object
47 *
48 * Cast @obj to a #GstVideoSink without runtime type check.
49 */
50#define GST_VIDEO_SINK_CAST(obj) ((GstVideoSink *) (obj))
51
52/**
53 * GST_VIDEO_SINK_PAD:
54 * @obj: a #GstVideoSink
55 *
56 * Get the sink #GstPad of @obj.
57 */
58#define GST_VIDEO_SINK_PAD(obj) GST_BASE_SINK_PAD(obj)
59
60#define GST_VIDEO_SINK_WIDTH(obj) (GST_VIDEO_SINK_CAST (obj)->width)
61#define GST_VIDEO_SINK_HEIGHT(obj) (GST_VIDEO_SINK_CAST (obj)->height)
62
63typedef struct _GstVideoSink GstVideoSink;
64typedef struct _GstVideoSinkClass GstVideoSinkClass;
65typedef struct _GstVideoRectangle GstVideoRectangle;
66typedef struct _GstVideoSinkPrivate GstVideoSinkPrivate;
67
68/**
69 * GstVideoRectangle:
70 * @x: X coordinate of rectangle's top-left point
71 * @y: Y coordinate of rectangle's top-left point
72 * @w: width of the rectangle
73 * @h: height of the rectangle
74 *
75 * Helper structure representing a rectangular area.
76 */
77struct _GstVideoRectangle {
78 gint x;
79 gint y;
80 gint w;
81 gint h;
82};
83
84/**
85 * GstVideoSink:
86 * @height: video height (derived class needs to set this)
87 * @width: video width (derived class needs to set this)
88 *
89 * The video sink instance structure. Derived video sinks should set the
90 * @height and @width members.
91 */
92struct _GstVideoSink {
93 GstBaseSink element; /* FIXME 0.11: this should not be called 'element' */
94
95 /*< public >*/
96 gint width, height;
97
98 /*< private >*/
99 GstVideoSinkPrivate *priv;
100
101 gpointer _gst_reserved[GST_PADDING];
102};
103
104/**
105 * GstVideoSinkClass:
106 * @parent_class: the parent class structure
107 * @show_frame: render a video frame. Maps to #GstBaseSinkClass.render() and
108 * #GstBaseSinkClass.preroll() vfuncs. Rendering during preroll will be
109 * suppressed if the #GstVideoSink:show-preroll-frame property is set to
110 * %FALSE.
111 *
112 * The video sink class structure. Derived classes should override the
113 * @show_frame virtual function.
114 */
115struct _GstVideoSinkClass {
116 GstBaseSinkClass parent_class;
117
118 GstFlowReturn (*show_frame) (GstVideoSink *video_sink, GstBuffer *buf);
119
120 /*< private >*/
121 gpointer _gst_reserved[GST_PADDING];
122};
123
124GST_VIDEO_API
125GType gst_video_sink_get_type (void);
126
127GST_VIDEO_API
128void gst_video_sink_center_rect (GstVideoRectangle src, GstVideoRectangle dst,
129 GstVideoRectangle *result, gboolean scaling);
130
131#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
132G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoSink, gst_object_unref)
133#endif
134
135G_END_DECLS
136
137#endif /* __GST_VIDEO_SINK_H__ */
138