summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <ystreet00@gmail.com>2014-06-25 12:00:34 +1000
committerMatthew Waters <ystreet00@gmail.com>2014-06-25 12:00:34 +1000
commitc37ace184428e3096f57ccd89b67434eab632e6e (patch)
tree4828d06d15ac1f9212e4da41e519c2c57052caaa
parent4c02c4f0044d702e0a7a56cab9380d23e5637f95 (diff)
glvideomixer: bas output width/height on the pad properties
Allows automatic negotiation of the size in the following case: gst-launch-1.0 glvideomixer name=m sink_0::xpos=0 sink_1::xpos=320 ! glimagesink \ videotestsrc ! m. \ videotestsrc pattern=1 ! m. https://bugzilla.gnome.org/show_bug.cgi?id=731878
-rw-r--r--ext/gl/gstglvideomixer.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/ext/gl/gstglvideomixer.c b/ext/gl/gstglvideomixer.c
index 1d0299cf0..7b3904e64 100644
--- a/ext/gl/gstglvideomixer.c
+++ b/ext/gl/gstglvideomixer.c
@@ -60,6 +60,7 @@ static void gst_gl_video_mixer_set_property (GObject * object, guint prop_id,
static void gst_gl_video_mixer_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
+static gboolean _update_info (GstVideoAggregator * vagg, GstVideoInfo * info);
static void gst_gl_video_mixer_reset (GstGLMixer * mixer);
static gboolean gst_gl_video_mixer_init_shader (GstGLMixer * mixer,
GstCaps * outcaps);
@@ -249,6 +250,7 @@ gst_gl_video_mixer_class_init (GstGLVideoMixerClass * klass)
GObjectClass *gobject_class;
GstElementClass *element_class;
GstAggregatorClass *agg_class = (GstAggregatorClass *) klass;
+ GstVideoAggregatorClass *vagg_class = (GstVideoAggregatorClass *) klass;
gobject_class = (GObjectClass *) klass;
element_class = GST_ELEMENT_CLASS (klass);
@@ -265,8 +267,9 @@ gst_gl_video_mixer_class_init (GstGLVideoMixerClass * klass)
GST_GL_MIXER_CLASS (klass)->process_textures =
gst_gl_video_mixer_process_textures;
- agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD;
+ vagg_class->update_info = _update_info;
+ agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD;
}
static void
@@ -298,6 +301,52 @@ gst_gl_video_mixer_get_property (GObject * object, guint prop_id,
}
}
+static gboolean
+_update_info (GstVideoAggregator * vagg, GstVideoInfo * info)
+{
+ GList *l;
+ gint best_width = -1, best_height = -1;
+ gboolean ret = FALSE;
+
+ GST_OBJECT_LOCK (vagg);
+ for (l = GST_ELEMENT (vagg)->sinkpads; l; l = l->next) {
+ GstVideoAggregatorPad *vaggpad = l->data;
+ GstGLVideoMixerPad *mixer_pad = GST_GL_VIDEO_MIXER_PAD (vaggpad);
+ gint this_width, this_height;
+ gint width, height;
+
+ if (mixer_pad->width > 0)
+ width = mixer_pad->width;
+ else
+ width = GST_VIDEO_INFO_WIDTH (&vaggpad->info);
+
+ if (mixer_pad->height > 0)
+ height = mixer_pad->height;
+ else
+ height = GST_VIDEO_INFO_HEIGHT (&vaggpad->info);
+
+ if (width == 0 || height == 0)
+ continue;
+
+ this_width = width + MAX (mixer_pad->xpos, 0);
+ this_height = height + MAX (mixer_pad->ypos, 0);
+
+ if (best_width < this_width)
+ best_width = this_width;
+ if (best_height < this_height)
+ best_height = this_height;
+ }
+ GST_OBJECT_UNLOCK (vagg);
+
+ if (best_width > 0 && best_height > 0) {
+ gst_video_info_set_format (info, GST_VIDEO_INFO_FORMAT (info),
+ best_width, best_height);
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
static void
gst_gl_video_mixer_reset (GstGLMixer * mixer)
{