rtph264pay: avoid double buffer unmap on error
[platform/upstream/gstreamer.git] / gst / videomixer / videomixer2.h
1 /* Generic video mixer plugin
2  * Copyright (C) 2008 Wim Taymans <wim@fluendo.com>
3  * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
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 #ifndef __GST_VIDEO_MIXER2_H__
22 #define __GST_VIDEO_MIXER2_H__
23
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26
27 #include "blend.h"
28 #include <gst/base/gstcollectpads.h>
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_VIDEO_MIXER2 (gst_videomixer2_get_type())
33 #define GST_VIDEO_MIXER2(obj) \
34         (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_MIXER2, GstVideoMixer2))
35 #define GST_VIDEO_MIXER2_CLASS(klass) \
36         (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_MIXER2, GstVideoMixer2Class))
37 #define GST_IS_VIDEO_MIXER2(obj) \
38         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_MIXER2))
39 #define GST_IS_VIDEO_MIXER2_CLASS(klass) \
40         (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_MIXER2))
41
42 typedef struct _GstVideoMixer2 GstVideoMixer2;
43 typedef struct _GstVideoMixer2Class GstVideoMixer2Class;
44
45 /**
46  * GstVideoMixer2Background:
47  * @VIDEO_MIXER2_BACKGROUND_CHECKER: checker pattern background
48  * @VIDEO_MIXER2_BACKGROUND_BLACK: solid color black background
49  * @VIDEO_MIXER2_BACKGROUND_WHITE: solid color white background
50  * @VIDEO_MIXER2_BACKGROUND_TRANSPARENT: background is left transparent and layers are composited using "A OVER B" composition rules. This is only applicable to AYUV and ARGB (and variants) as it preserves the alpha channel and allows for further mixing.
51  *
52  * The different backgrounds videomixer can blend over.
53  */
54 typedef enum
55 {
56   VIDEO_MIXER2_BACKGROUND_CHECKER,
57   VIDEO_MIXER2_BACKGROUND_BLACK,
58   VIDEO_MIXER2_BACKGROUND_WHITE,
59   VIDEO_MIXER2_BACKGROUND_TRANSPARENT,
60 }
61 GstVideoMixer2Background;
62
63 /**
64  * GstVideoMixer2:
65  *
66  * The opaque #GstVideoMixer2 structure.
67  */
68 struct _GstVideoMixer2
69 {
70   GstElement element;
71
72   /* < private > */
73
74   /* pad */
75   GstPad *srcpad;
76
77   /* Lock to prevent the state to change while blending */
78   GMutex lock;
79
80   /* Lock to prevent two src setcaps from happening at the same time  */
81   GMutex setcaps_lock;
82
83   /* Sink pads using Collect Pads 2*/
84   GstCollectPads *collect;
85
86   /* sinkpads, a GSList of GstVideoMixer2Pads */
87   GSList *sinkpads;
88   gint numpads;
89   /* Next available sinkpad index */
90   guint next_sinkpad;
91
92   /* Output caps */
93   GstVideoInfo info;
94
95   /* current caps */
96   GstCaps *current_caps;
97   gboolean send_caps;
98
99   gboolean newseg_pending;
100   gboolean flush_stop_pending;
101
102   GstVideoMixer2Background background;
103
104   /* Current downstream segment */
105   GstSegment segment;
106   GstClockTime ts_offset;
107   guint64 nframes;
108
109   /* QoS stuff */
110   gdouble proportion;
111   GstClockTime earliest_time;
112   guint64 qos_processed, qos_dropped;
113
114   BlendFunction blend, overlay;
115   FillCheckerFunction fill_checker;
116   FillColorFunction fill_color;
117
118   gboolean send_stream_start;
119 };
120
121 struct _GstVideoMixer2Class
122 {
123   GstElementClass parent_class;
124 };
125
126 GType gst_videomixer2_get_type (void);
127
128 G_END_DECLS
129 #endif /* __GST_VIDEO_MIXER2_H__ */