2010-07-26 14:07:15 +00:00
/* Generic video mixer plugin
* Copyright ( C ) 2008 Wim Taymans < wim @ fluendo . com >
* Copyright ( C ) 2010 Sebastian Dröge < sebastian . droege @ collabora . co . uk >
*
* 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
2012-11-04 00:07:18 +00:00
* Free Software Foundation , Inc . , 51 Franklin St , Fifth Floor ,
* Boston , MA 02110 - 1301 , USA .
2010-07-26 14:07:15 +00:00
*/
# ifndef __GST_VIDEO_MIXER2_H__
# define __GST_VIDEO_MIXER2_H__
# include <gst/gst.h>
# include <gst/video/video.h>
# include "blend.h"
2012-04-17 13:14:27 +00:00
# include <gst/base/gstcollectpads.h>
2010-07-26 14:07:15 +00:00
G_BEGIN_DECLS
# define GST_TYPE_VIDEO_MIXER2 (gst_videomixer2_get_type())
# define GST_VIDEO_MIXER2(obj) \
( G_TYPE_CHECK_INSTANCE_CAST ( ( obj ) , GST_TYPE_VIDEO_MIXER2 , GstVideoMixer2 ) )
# define GST_VIDEO_MIXER2_CLASS(klass) \
( G_TYPE_CHECK_CLASS_CAST ( ( klass ) , GST_TYPE_VIDEO_MIXER2 , GstVideoMixer2Class ) )
# define GST_IS_VIDEO_MIXER2(obj) \
( G_TYPE_CHECK_INSTANCE_TYPE ( ( obj ) , GST_TYPE_VIDEO_MIXER2 ) )
# define GST_IS_VIDEO_MIXER2_CLASS(klass) \
( G_TYPE_CHECK_CLASS_TYPE ( ( klass ) , GST_TYPE_VIDEO_MIXER2 ) )
typedef struct _GstVideoMixer2 GstVideoMixer2 ;
typedef struct _GstVideoMixer2Class GstVideoMixer2Class ;
/**
* GstVideoMixer2Background :
* @ VIDEO_MIXER2_BACKGROUND_CHECKER : checker pattern background
* @ VIDEO_MIXER2_BACKGROUND_BLACK : solid color black background
* @ VIDEO_MIXER2_BACKGROUND_WHITE : solid color white background
videomixer2: Add transparent background option for alpha channel formats
This option allows the videomixer2 element to output a valid alpha
channel when the inputs contain a valid alpha channel. This allows
mixing to occur in multiple stages serially.
The following pipeline shows an example of such a pipeline:
gst-launch videotestsrc background-color=0x000000 pattern=ball ! video/x-raw-yuv,format=\(fourcc\)AYUV ! videomixer2 background=transparent name=mix1 ! videomixer2 name=mix2 ! ffmpegcolorspace ! autovideosink videotestsrc ! video/x-raw-yuv,format=\(fourcc\)AYUV ! mix2.
The first videotestsrc in this pipeline creates a moving ball on a
transparent background. It is then passed to the first videomixer2.
Previously, this videomixer2 would have forced the alpha channel to
1.0 and given a background of checker, black, or white to the
stream. With this patch, however, you can now specify the background
as transparent, and the alpha channel of the input will be
preserved. This allows for further mixing downstream, as is shown in
the above pipeline where the a second videomixer2 is used to mix in a
background of an smpte videotestsrc. So the result is a ball hovering
over the smpte test source. This could, of course, have been
accomplished with a single mixer element, but staged mixing is useful
when it is not convenient to mix all video at once (e.g. a pipeline
where a foreground and background bin exist and are mixed at the final
output, but the foreground bin needs an internal mixer to create
transitions between clips).
Fixes bug #639994.
2011-01-19 19:07:17 +00:00
* @ 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 .
2010-07-26 14:07:15 +00:00
*
* The different backgrounds videomixer can blend over .
*/
typedef enum
{
VIDEO_MIXER2_BACKGROUND_CHECKER ,
VIDEO_MIXER2_BACKGROUND_BLACK ,
videomixer2: Add transparent background option for alpha channel formats
This option allows the videomixer2 element to output a valid alpha
channel when the inputs contain a valid alpha channel. This allows
mixing to occur in multiple stages serially.
The following pipeline shows an example of such a pipeline:
gst-launch videotestsrc background-color=0x000000 pattern=ball ! video/x-raw-yuv,format=\(fourcc\)AYUV ! videomixer2 background=transparent name=mix1 ! videomixer2 name=mix2 ! ffmpegcolorspace ! autovideosink videotestsrc ! video/x-raw-yuv,format=\(fourcc\)AYUV ! mix2.
The first videotestsrc in this pipeline creates a moving ball on a
transparent background. It is then passed to the first videomixer2.
Previously, this videomixer2 would have forced the alpha channel to
1.0 and given a background of checker, black, or white to the
stream. With this patch, however, you can now specify the background
as transparent, and the alpha channel of the input will be
preserved. This allows for further mixing downstream, as is shown in
the above pipeline where the a second videomixer2 is used to mix in a
background of an smpte videotestsrc. So the result is a ball hovering
over the smpte test source. This could, of course, have been
accomplished with a single mixer element, but staged mixing is useful
when it is not convenient to mix all video at once (e.g. a pipeline
where a foreground and background bin exist and are mixed at the final
output, but the foreground bin needs an internal mixer to create
transitions between clips).
Fixes bug #639994.
2011-01-19 19:07:17 +00:00
VIDEO_MIXER2_BACKGROUND_WHITE ,
VIDEO_MIXER2_BACKGROUND_TRANSPARENT ,
2010-07-26 14:07:15 +00:00
}
GstVideoMixer2Background ;
/**
* GstVideoMixer2 :
*
* The opaque # GstVideoMixer2 structure .
*/
struct _GstVideoMixer2
{
GstElement element ;
2010-09-02 09:19:06 +00:00
/* < private > */
2010-07-26 14:07:15 +00:00
/* pad */
GstPad * srcpad ;
/* Lock to prevent the state to change while blending */
2012-01-26 17:15:51 +00:00
GMutex lock ;
2012-09-13 00:10:00 +00:00
/* Lock to prevent two src setcaps from happening at the same time */
GMutex setcaps_lock ;
2010-07-26 14:07:15 +00:00
/* Sink pads using Collect Pads 2*/
2012-04-17 13:14:27 +00:00
GstCollectPads * collect ;
2010-07-26 14:07:15 +00:00
/* sinkpads, a GSList of GstVideoMixer2Pads */
GSList * sinkpads ;
gint numpads ;
/* Next available sinkpad index */
2012-05-01 17:58:03 +00:00
guint next_sinkpad ;
2010-07-26 14:07:15 +00:00
/* Output caps */
2012-01-25 17:40:03 +00:00
GstVideoInfo info ;
2010-07-26 14:07:15 +00:00
2013-05-18 18:36:39 +00:00
/* current caps */
GstCaps * current_caps ;
gboolean send_caps ;
2010-07-26 14:07:15 +00:00
gboolean newseg_pending ;
GstVideoMixer2Background background ;
/* Current downstream segment */
GstSegment segment ;
GstClockTime ts_offset ;
guint64 nframes ;
/* QoS stuff */
gdouble proportion ;
GstClockTime earliest_time ;
guint64 qos_processed , qos_dropped ;
videomixer2: Add transparent background option for alpha channel formats
This option allows the videomixer2 element to output a valid alpha
channel when the inputs contain a valid alpha channel. This allows
mixing to occur in multiple stages serially.
The following pipeline shows an example of such a pipeline:
gst-launch videotestsrc background-color=0x000000 pattern=ball ! video/x-raw-yuv,format=\(fourcc\)AYUV ! videomixer2 background=transparent name=mix1 ! videomixer2 name=mix2 ! ffmpegcolorspace ! autovideosink videotestsrc ! video/x-raw-yuv,format=\(fourcc\)AYUV ! mix2.
The first videotestsrc in this pipeline creates a moving ball on a
transparent background. It is then passed to the first videomixer2.
Previously, this videomixer2 would have forced the alpha channel to
1.0 and given a background of checker, black, or white to the
stream. With this patch, however, you can now specify the background
as transparent, and the alpha channel of the input will be
preserved. This allows for further mixing downstream, as is shown in
the above pipeline where the a second videomixer2 is used to mix in a
background of an smpte videotestsrc. So the result is a ball hovering
over the smpte test source. This could, of course, have been
accomplished with a single mixer element, but staged mixing is useful
when it is not convenient to mix all video at once (e.g. a pipeline
where a foreground and background bin exist and are mixed at the final
output, but the foreground bin needs an internal mixer to create
transitions between clips).
Fixes bug #639994.
2011-01-19 19:07:17 +00:00
BlendFunction blend , overlay ;
2010-07-26 14:07:15 +00:00
FillCheckerFunction fill_checker ;
FillColorFunction fill_color ;
2013-04-25 18:59:52 +00:00
gboolean send_stream_start ;
2013-09-14 01:27:09 +00:00
GstTagList * pending_tags ;
2010-07-26 14:07:15 +00:00
} ;
struct _GstVideoMixer2Class
{
GstElementClass parent_class ;
} ;
GType gst_videomixer2_get_type ( void ) ;
G_END_DECLS
# endif /* __GST_VIDEO_MIXER2_H__ */