2013-07-09 13:31:15 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
* 2009 Nokia Corporation
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-04-07 19:02:48 +00:00
|
|
|
* SECTION:gesvideosource
|
2017-03-08 21:13:48 +00:00
|
|
|
* @title: GESVideoSource
|
2013-07-09 13:31:15 +00:00
|
|
|
* @short_description: Base Class for video sources
|
2014-10-30 11:36:57 +00:00
|
|
|
*
|
2017-03-13 12:30:39 +00:00
|
|
|
* # Children Properties:
|
2017-03-08 21:13:48 +00:00
|
|
|
* You can use the following children properties through the
|
|
|
|
* #ges_track_element_set_child_property and alike set of methods:
|
2017-03-13 12:30:39 +00:00
|
|
|
*
|
2014-10-30 11:36:57 +00:00
|
|
|
* <informaltable frame="none">
|
|
|
|
* <tgroup cols="3">
|
|
|
|
* <colspec colname="properties_type" colwidth="150px"/>
|
|
|
|
* <colspec colname="properties_name" colwidth="200px"/>
|
|
|
|
* <colspec colname="properties_flags" colwidth="400px"/>
|
|
|
|
* <tbody>
|
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="gdouble"><type>double</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--alpha">alpha</link></entry>
|
|
|
|
* <entry>The desired alpha for the stream.</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="gint"><type>gint</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--posx">posx</link></entry>
|
|
|
|
* <entry>The desired x position for the stream.</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="gint"><type>gint</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--posy">posy</link></entry>
|
|
|
|
* <entry>The desired y position for the stream</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="guint"><type>guint</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--zorder">zorder</link></entry>
|
|
|
|
* <entry>The desired z order for the stream</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="gint"><type>gint</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--width">width</link></entry>
|
|
|
|
* <entry>The desired width for that source. Set to 0 if size is not mandatory, will be set to width of the current track.</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="gint"><type>gint</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--height">height</link></entry>
|
|
|
|
* <entry>The desired height for that source. Set to 0 if size is not mandatory, will be set to height of the current track.</entry>
|
|
|
|
* </row>
|
2016-04-29 13:29:00 +00:00
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="GstDeinterlaceModes"><type>GstDeinterlaceModes</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--deinterlace-mode">deinterlace-mode</link></entry>
|
|
|
|
* <entry>Deinterlace Mode</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="GstDeinterlaceFields"><type>GstDeinterlaceFields</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--deinterlace-fields">deinterlace-fields</link></entry>
|
|
|
|
* <entry>Fields to use for deinterlacing</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry role="property_type"><link linkend="GstDeinterlaceFieldLayout"><type>GstDeinterlaceFieldLayout</type></link></entry>
|
|
|
|
* <entry role="property_name"><link linkend="GESVideoSource--deinterlace-tff">deinterlace-tff</link></entry>
|
|
|
|
* <entry>Deinterlace top field first</entry>
|
|
|
|
* </row>
|
2014-10-30 11:36:57 +00:00
|
|
|
* </tbody>
|
|
|
|
* </tgroup>
|
|
|
|
* </informaltable>
|
2013-07-09 13:31:15 +00:00
|
|
|
*/
|
|
|
|
|
2014-01-15 18:12:08 +00:00
|
|
|
#include <gst/pbutils/missing-plugins.h>
|
|
|
|
|
2013-07-09 13:31:15 +00:00
|
|
|
#include "ges-internal.h"
|
|
|
|
#include "ges/ges-meta-container.h"
|
|
|
|
#include "ges-track-element.h"
|
|
|
|
#include "ges-video-source.h"
|
|
|
|
#include "ges-layer.h"
|
2016-04-13 09:31:05 +00:00
|
|
|
#include "gstframepositioner.h"
|
2013-07-09 13:31:15 +00:00
|
|
|
|
2015-08-27 14:28:42 +00:00
|
|
|
#define parent_class ges_video_source_parent_class
|
2013-09-04 00:50:54 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (GESVideoSource, ges_video_source, GES_TYPE_SOURCE);
|
2013-07-09 13:31:15 +00:00
|
|
|
|
|
|
|
struct _GESVideoSourcePrivate
|
|
|
|
{
|
2016-04-13 09:31:05 +00:00
|
|
|
GstFramePositioner *positioner;
|
2013-08-21 09:32:45 +00:00
|
|
|
GstElement *capsfilter;
|
2013-07-09 13:31:15 +00:00
|
|
|
};
|
|
|
|
|
2013-09-01 16:19:32 +00:00
|
|
|
/* TrackElement VMethods */
|
|
|
|
|
2015-08-27 14:28:42 +00:00
|
|
|
static gboolean
|
|
|
|
_set_priority (GESTimelineElement * element, guint32 priority)
|
2013-09-01 16:19:32 +00:00
|
|
|
{
|
2015-08-27 14:28:42 +00:00
|
|
|
gboolean res;
|
|
|
|
GESVideoSource *self = GES_VIDEO_SOURCE (element);
|
2013-07-09 13:31:15 +00:00
|
|
|
|
2015-08-27 14:28:42 +00:00
|
|
|
res = GES_TIMELINE_ELEMENT_CLASS (parent_class)->set_priority (element,
|
|
|
|
priority);
|
2013-07-09 13:31:15 +00:00
|
|
|
|
2016-04-13 09:31:05 +00:00
|
|
|
if (res && self->priv->positioner)
|
|
|
|
g_object_set (self->priv->positioner, "zorder", G_MAXUINT - priority, NULL);
|
2013-07-09 13:31:15 +00:00
|
|
|
|
2015-08-27 14:28:42 +00:00
|
|
|
return res;
|
2013-07-09 13:31:15 +00:00
|
|
|
}
|
|
|
|
|
2014-01-15 18:12:08 +00:00
|
|
|
static void
|
|
|
|
post_missing_element_message (GstElement * element, const gchar * name)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
|
|
|
|
msg = gst_missing_element_message_new (element, name);
|
|
|
|
gst_element_post_message (element, msg);
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:31:15 +00:00
|
|
|
static GstElement *
|
|
|
|
ges_video_source_create_element (GESTrackElement * trksrc)
|
|
|
|
{
|
|
|
|
GstElement *topbin;
|
|
|
|
GstElement *sub_element;
|
2014-05-15 17:37:05 +00:00
|
|
|
GstElement *queue = gst_element_factory_make ("queue", NULL);
|
2013-07-09 13:31:15 +00:00
|
|
|
GESVideoSourceClass *source_class = GES_VIDEO_SOURCE_GET_CLASS (trksrc);
|
|
|
|
GESVideoSource *self;
|
2016-04-13 09:31:05 +00:00
|
|
|
GstElement *positioner, *videoscale, *videorate, *capsfilter, *videoconvert,
|
2014-01-15 18:12:08 +00:00
|
|
|
*deinterlace;
|
2016-04-29 13:29:00 +00:00
|
|
|
const gchar *positioner_props[] =
|
|
|
|
{ "alpha", "posx", "posy", "width", "height", NULL };
|
|
|
|
const gchar *deinterlace_props[] = { "mode", "fields", "tff", NULL };
|
2013-07-09 13:31:15 +00:00
|
|
|
|
|
|
|
if (!source_class->create_source)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
sub_element = source_class->create_source (trksrc);
|
|
|
|
|
|
|
|
self = (GESVideoSource *) trksrc;
|
|
|
|
|
2016-04-13 09:31:05 +00:00
|
|
|
/* That positioner will add metadata to buffers according to its
|
2013-07-09 13:31:15 +00:00
|
|
|
properties, acting like a proxy for our smart-mixer dynamic pads. */
|
2016-04-13 09:31:05 +00:00
|
|
|
positioner = gst_element_factory_make ("framepositioner", "frame_tagger");
|
|
|
|
g_object_set (positioner, "zorder",
|
2015-09-02 15:58:33 +00:00
|
|
|
G_MAXUINT - GES_TIMELINE_ELEMENT_PRIORITY (self), NULL);
|
2013-07-09 13:31:15 +00:00
|
|
|
|
2013-08-21 09:32:45 +00:00
|
|
|
videoscale =
|
|
|
|
gst_element_factory_make ("videoscale", "track-element-videoscale");
|
2014-01-15 18:12:08 +00:00
|
|
|
videoconvert =
|
|
|
|
gst_element_factory_make ("videoconvert", "track-element-videoconvert");
|
2013-09-04 23:03:51 +00:00
|
|
|
videorate = gst_element_factory_make ("videorate", "track-element-videorate");
|
2014-01-15 18:12:08 +00:00
|
|
|
deinterlace = gst_element_factory_make ("deinterlace", "deinterlace");
|
2013-08-21 09:32:45 +00:00
|
|
|
capsfilter =
|
|
|
|
gst_element_factory_make ("capsfilter", "track-element-capsfilter");
|
|
|
|
|
2016-04-13 09:31:05 +00:00
|
|
|
ges_frame_positioner_set_source_and_filter (GST_FRAME_POSITIONNER
|
|
|
|
(positioner), trksrc, capsfilter);
|
2013-08-21 09:32:45 +00:00
|
|
|
|
2016-04-29 13:29:00 +00:00
|
|
|
ges_track_element_add_children_props (trksrc, positioner, NULL, NULL,
|
|
|
|
positioner_props);
|
2014-01-15 18:12:08 +00:00
|
|
|
|
|
|
|
if (deinterlace == NULL) {
|
|
|
|
post_missing_element_message (sub_element, "deinterlace");
|
|
|
|
|
|
|
|
GST_ELEMENT_WARNING (sub_element, CORE, MISSING_PLUGIN,
|
|
|
|
("Missing element '%s' - check your GStreamer installation.",
|
|
|
|
"deinterlace"), ("deinterlacing won't work"));
|
|
|
|
topbin =
|
2014-05-15 17:37:05 +00:00
|
|
|
ges_source_create_topbin ("videosrcbin", sub_element, queue,
|
2016-04-13 09:31:05 +00:00
|
|
|
videoconvert, positioner, videoscale, videorate, capsfilter, NULL);
|
2014-01-15 18:12:08 +00:00
|
|
|
} else {
|
2016-04-29 13:29:00 +00:00
|
|
|
ges_track_element_add_children_props (trksrc, deinterlace, NULL, NULL,
|
|
|
|
deinterlace_props);
|
2014-01-15 18:12:08 +00:00
|
|
|
topbin =
|
2014-05-15 17:37:05 +00:00
|
|
|
ges_source_create_topbin ("videosrcbin", sub_element, queue,
|
2016-04-13 09:31:05 +00:00
|
|
|
videoconvert, deinterlace, positioner, videoscale, videorate,
|
2014-05-15 17:37:05 +00:00
|
|
|
capsfilter, NULL);
|
2014-01-15 18:12:08 +00:00
|
|
|
}
|
|
|
|
|
2016-04-13 09:31:05 +00:00
|
|
|
self->priv->positioner = GST_FRAME_POSITIONNER (positioner);
|
2016-08-02 20:42:20 +00:00
|
|
|
self->priv->positioner->scale_in_compositor =
|
|
|
|
!GES_VIDEO_SOURCE_GET_CLASS (self)->ABI.abi.disable_scale_in_compositor;
|
2013-08-21 09:32:45 +00:00
|
|
|
self->priv->capsfilter = capsfilter;
|
|
|
|
|
2013-07-09 13:31:15 +00:00
|
|
|
return topbin;
|
|
|
|
}
|
|
|
|
|
2016-04-29 13:29:00 +00:00
|
|
|
static gboolean
|
|
|
|
_lookup_child (GESTimelineElement * object,
|
|
|
|
const gchar * prop_name, GObject ** element, GParamSpec ** pspec)
|
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
gchar *clean_name;
|
|
|
|
|
|
|
|
if (!g_strcmp0 (prop_name, "deinterlace-fields"))
|
|
|
|
clean_name = g_strdup ("GstDeinterlace::fields");
|
|
|
|
else if (!g_strcmp0 (prop_name, "deinterlace-mode"))
|
|
|
|
clean_name = g_strdup ("GstDeinterlace::mode");
|
|
|
|
else if (!g_strcmp0 (prop_name, "deinterlace-tff"))
|
|
|
|
clean_name = g_strdup ("GstDeinterlace::tff");
|
|
|
|
else if (!g_strcmp0 (prop_name, "tff") ||
|
|
|
|
!g_strcmp0 (prop_name, "fields") || !g_strcmp0 (prop_name, "mode")) {
|
|
|
|
GST_DEBUG_OBJECT (object, "Not allowed to use GstDeinterlace %s"
|
|
|
|
" property without prefixing its name", prop_name);
|
|
|
|
return FALSE;
|
|
|
|
} else
|
|
|
|
clean_name = g_strdup (prop_name);
|
|
|
|
|
|
|
|
res =
|
|
|
|
GES_TIMELINE_ELEMENT_CLASS (ges_video_source_parent_class)->lookup_child
|
|
|
|
(object, clean_name, element, pspec);
|
|
|
|
|
|
|
|
g_free (clean_name);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:31:15 +00:00
|
|
|
static void
|
|
|
|
ges_video_source_class_init (GESVideoSourceClass * klass)
|
|
|
|
{
|
2016-04-29 13:29:00 +00:00
|
|
|
GESTrackElementClass *track_element_class = GES_TRACK_ELEMENT_CLASS (klass);
|
2013-09-01 16:19:32 +00:00
|
|
|
GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
|
2013-07-09 13:31:15 +00:00
|
|
|
GESVideoSourceClass *video_source_class = GES_VIDEO_SOURCE_CLASS (klass);
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (GESVideoSourcePrivate));
|
|
|
|
|
2015-08-27 14:28:42 +00:00
|
|
|
element_class->set_priority = _set_priority;
|
2016-04-29 13:29:00 +00:00
|
|
|
element_class->lookup_child = _lookup_child;
|
2015-08-27 14:28:42 +00:00
|
|
|
|
2016-04-29 13:29:00 +00:00
|
|
|
track_element_class->nleobject_factorytype = "nlesource";
|
|
|
|
track_element_class->create_element = ges_video_source_create_element;
|
2013-07-09 13:31:15 +00:00
|
|
|
video_source_class->create_source = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ges_video_source_init (GESVideoSource * self)
|
|
|
|
{
|
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
|
|
|
GES_TYPE_VIDEO_SOURCE, GESVideoSourcePrivate);
|
2016-04-13 09:31:05 +00:00
|
|
|
self->priv->positioner = NULL;
|
2013-08-21 09:32:45 +00:00
|
|
|
self->priv->capsfilter = NULL;
|
2013-07-09 13:31:15 +00:00
|
|
|
}
|