1 /* Generic video compositor 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_COMPOSITOR_H__ 22 #define __GST_COMPOSITOR_H__ 23 24 #include <gst/gst.h> 25 #include <gst/video/video.h> 26 #include <gst/video/gstvideoaggregator.h> 27 28 #include "blend.h" 29 30 G_BEGIN_DECLS 31 32 #define GST_TYPE_COMPOSITOR (gst_compositor_get_type()) 33 #define GST_COMPOSITOR(obj) \ 34 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_COMPOSITOR, GstCompositor)) 35 #define GST_COMPOSITOR_CLASS(klass) \ 36 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_COMPOSITOR, GstCompositorClass)) 37 #define GST_IS_COMPOSITOR(obj) \ 38 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COMPOSITOR)) 39 #define GST_IS_COMPOSITOR_CLASS(klass) \ 40 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COMPOSITOR)) 41 42 #define GST_TYPE_COMPOSITOR_PAD (gst_compositor_pad_get_type()) 43 #define GST_COMPOSITOR_PAD(obj) \ 44 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_COMPOSITOR_PAD, GstCompositorPad)) 45 #define GST_COMPOSITOR_PAD_CLASS(klass) \ 46 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_COMPOSITOR_PAD, GstCompositorPadClass)) 47 #define GST_IS_COMPOSITOR_PAD(obj) \ 48 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COMPOSITOR_PAD)) 49 #define GST_IS_COMPOSITOR_PAD_CLASS(klass) \ 50 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COMPOSITOR_PAD)) 51 52 typedef struct _GstCompositor GstCompositor; 53 typedef struct _GstCompositorClass GstCompositorClass; 54 55 typedef struct _GstCompositorPad GstCompositorPad; 56 typedef struct _GstCompositorPadClass GstCompositorPadClass; 57 58 /** 59 * GstCompositorBackground: 60 * @COMPOSITOR_BACKGROUND_CHECKER: checker pattern background 61 * @COMPOSITOR_BACKGROUND_BLACK: solid color black background 62 * @COMPOSITOR_BACKGROUND_WHITE: solid color white background 63 * @COMPOSITOR_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. 64 * 65 * The different backgrounds compositor can blend over. 66 */ 67 typedef enum 68 { 69 COMPOSITOR_BACKGROUND_CHECKER, 70 COMPOSITOR_BACKGROUND_BLACK, 71 COMPOSITOR_BACKGROUND_WHITE, 72 COMPOSITOR_BACKGROUND_TRANSPARENT, 73 } GstCompositorBackground; 74 75 /** 76 * GstCompositorOperator: 77 * @COMPOSITOR_OPERATOR_SOURCE: Copy the source over the destination, 78 * without the destination pixels. 79 * @COMPOSITOR_OPERATOR_OVER: Blend the source over the destination. 80 * @COMPOSITOR_OPERATOR_ADD: Similar to over but add the source and 81 * destination alpha. Requires output with alpha 82 * channel. 83 * 84 * The different blending operators that can be used by compositor. 85 * 86 * See https://www.cairographics.org/operators/ for some explanation and 87 * visualizations. 88 * 89 */ 90 typedef enum 91 { 92 COMPOSITOR_OPERATOR_SOURCE, 93 COMPOSITOR_OPERATOR_OVER, 94 COMPOSITOR_OPERATOR_ADD, 95 } GstCompositorOperator; 96 97 /** 98 * GstCompositor: 99 * 100 * The opaque #GstCompositor structure. 101 */ 102 struct _GstCompositor 103 { 104 GstVideoAggregator videoaggregator; 105 GstCompositorBackground background; 106 107 /* The 'blend' compositing function does not preserve the alpha value of the 108 * background, while 'overlay' does; i.e., COMPOSITOR_OPERATOR_ADD is the 109 * same as COMPOSITOR_OPERATOR_OVER when using the 'blend' BlendFunction. */ 110 BlendFunction blend, overlay; 111 FillCheckerFunction fill_checker; 112 FillColorFunction fill_color; 113 }; 114 115 struct _GstCompositorClass 116 { 117 GstVideoAggregatorClass parent_class; 118 }; 119 120 /** 121 * GstCompositorPad: 122 * 123 * The opaque #GstCompositorPad structure. 124 */ 125 struct _GstCompositorPad 126 { 127 GstVideoAggregatorConvertPad parent; 128 129 /* properties */ 130 gint xpos, ypos; 131 gint width, height; 132 gdouble alpha; 133 134 GstCompositorOperator op; 135 }; 136 137 struct _GstCompositorPadClass 138 { 139 GstVideoAggregatorConvertPadClass parent_class; 140 }; 141 142 GType gst_compositor_get_type (void); 143 GType gst_compositor_pad_get_type (void); 144 145 G_END_DECLS 146 #endif /* __GST_COMPOSITOR_H__ */ 147