mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
aggregator: add simple support for caps handling
Modelled off the videoaggregator caps handling as that seems the most mature aggregtor-using implementation that has caps handling there is. https://bugzilla.gnome.org/show_bug.cgi?id=776931
This commit is contained in:
parent
178bbc253d
commit
ffe51f38fc
4 changed files with 26 additions and 57 deletions
|
@ -108,11 +108,14 @@ gst_gl_base_mixer_pad_set_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_negotiated_caps (GstVideoAggregator * vagg, GstCaps * caps)
|
_negotiated_caps (GstAggregator * agg, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstGLBaseMixer *mix = GST_GL_BASE_MIXER (vagg);
|
GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg);
|
||||||
|
|
||||||
return gst_gl_base_mixer_do_bufferpool (mix, caps);
|
if (!gst_gl_base_mixer_do_bufferpool (mix, caps))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return GST_AGGREGATOR_CLASS (parent_class)->negotiated_src_caps (agg, caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -324,9 +327,6 @@ gst_gl_base_mixer_class_init (GstGLBaseMixerClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *element_class;
|
GstElementClass *element_class;
|
||||||
|
|
||||||
GstVideoAggregatorClass *videoaggregator_class =
|
|
||||||
(GstVideoAggregatorClass *) klass;
|
|
||||||
GstAggregatorClass *agg_class = (GstAggregatorClass *) klass;
|
GstAggregatorClass *agg_class = (GstAggregatorClass *) klass;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glmixer", 0, "opengl mixer");
|
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glmixer", 0, "opengl mixer");
|
||||||
|
@ -350,8 +350,7 @@ gst_gl_base_mixer_class_init (GstGLBaseMixerClass * klass)
|
||||||
agg_class->src_activate = gst_gl_base_mixer_src_activate_mode;
|
agg_class->src_activate = gst_gl_base_mixer_src_activate_mode;
|
||||||
agg_class->stop = gst_gl_base_mixer_stop;
|
agg_class->stop = gst_gl_base_mixer_stop;
|
||||||
agg_class->start = gst_gl_base_mixer_start;
|
agg_class->start = gst_gl_base_mixer_start;
|
||||||
|
agg_class->negotiated_src_caps = _negotiated_caps;
|
||||||
videoaggregator_class->negotiated_caps = _negotiated_caps;
|
|
||||||
|
|
||||||
klass->propose_allocation = _default_propose_allocation;
|
klass->propose_allocation = _default_propose_allocation;
|
||||||
|
|
||||||
|
|
|
@ -96,16 +96,16 @@ gst_gl_mixer_pad_set_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_negotiated_caps (GstVideoAggregator * vagg, GstCaps * caps)
|
_negotiated_caps (GstAggregator * agg, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstGLMixer *mix = GST_GL_MIXER (vagg);
|
GstGLMixer *mix = GST_GL_MIXER (agg);
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
mix->priv->negotiated = TRUE;
|
mix->priv->negotiated = TRUE;
|
||||||
|
|
||||||
gst_caps_replace (&mix->out_caps, caps);
|
gst_caps_replace (&mix->out_caps, caps);
|
||||||
|
|
||||||
ret = GST_VIDEO_AGGREGATOR_CLASS (parent_class)->negotiated_caps (vagg, caps);
|
ret = GST_AGGREGATOR_CLASS (parent_class)->negotiated_src_caps (agg, caps);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -215,29 +215,6 @@ gst_gl_mixer_pad_sink_acceptcaps (GstPad * pad, GstGLMixer * mix,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copies the given caps */
|
|
||||||
static GstCaps *
|
|
||||||
_update_caps (GstVideoAggregator * vagg, GstCaps * caps, GstCaps * filter)
|
|
||||||
{
|
|
||||||
GstCaps *tmp;
|
|
||||||
guint i, n;
|
|
||||||
|
|
||||||
if (filter) {
|
|
||||||
tmp = gst_caps_intersect (caps, filter);
|
|
||||||
tmp = gst_caps_make_writable (tmp);
|
|
||||||
} else {
|
|
||||||
tmp = gst_caps_copy (caps);
|
|
||||||
}
|
|
||||||
|
|
||||||
n = gst_caps_get_size (tmp);
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
gst_caps_set_features (tmp, i,
|
|
||||||
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY));
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_gl_mixer_pad_sink_getcaps (GstPad * pad, GstGLMixer * mix, GstCaps * filter)
|
gst_gl_mixer_pad_sink_getcaps (GstPad * pad, GstGLMixer * mix, GstCaps * filter)
|
||||||
{
|
{
|
||||||
|
@ -391,11 +368,10 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass)
|
||||||
agg_class->src_query = gst_gl_mixer_src_query;
|
agg_class->src_query = gst_gl_mixer_src_query;
|
||||||
agg_class->stop = gst_gl_mixer_stop;
|
agg_class->stop = gst_gl_mixer_stop;
|
||||||
agg_class->start = gst_gl_mixer_start;
|
agg_class->start = gst_gl_mixer_start;
|
||||||
|
agg_class->negotiated_src_caps = _negotiated_caps;
|
||||||
|
|
||||||
videoaggregator_class->aggregate_frames = gst_gl_mixer_aggregate_frames;
|
videoaggregator_class->aggregate_frames = gst_gl_mixer_aggregate_frames;
|
||||||
videoaggregator_class->get_output_buffer = gst_gl_mixer_get_output_buffer;
|
videoaggregator_class->get_output_buffer = gst_gl_mixer_get_output_buffer;
|
||||||
videoaggregator_class->negotiated_caps = _negotiated_caps;
|
|
||||||
videoaggregator_class->update_caps = _update_caps;
|
|
||||||
videoaggregator_class->find_best_format = _find_best_format;
|
videoaggregator_class->find_best_format = _find_best_format;
|
||||||
|
|
||||||
mix_class->propose_allocation = gst_gl_mixer_propose_allocation;
|
mix_class->propose_allocation = gst_gl_mixer_propose_allocation;
|
||||||
|
|
|
@ -81,10 +81,8 @@ gst_gl_stereo_mix_pad_init (GstGLStereoMixPad * pad)
|
||||||
#define gst_gl_stereo_mix_parent_class parent_class
|
#define gst_gl_stereo_mix_parent_class parent_class
|
||||||
G_DEFINE_TYPE (GstGLStereoMix, gst_gl_stereo_mix, GST_TYPE_GL_MIXER);
|
G_DEFINE_TYPE (GstGLStereoMix, gst_gl_stereo_mix, GST_TYPE_GL_MIXER);
|
||||||
|
|
||||||
static GstCaps *_update_caps (GstVideoAggregator * vagg, GstCaps * caps,
|
static GstCaps *_update_caps (GstVideoAggregator * vagg, GstCaps * caps);
|
||||||
GstCaps * filter);
|
static gboolean _negotiated_caps (GstAggregator * aggregator, GstCaps * caps);
|
||||||
static gboolean _negotiated_caps (GstVideoAggregator * videoaggregator,
|
|
||||||
GstCaps * caps);
|
|
||||||
gboolean gst_gl_stereo_mix_make_output (GstGLStereoMix * mix);
|
gboolean gst_gl_stereo_mix_make_output (GstGLStereoMix * mix);
|
||||||
static gboolean gst_gl_stereo_mix_process_frames (GstGLStereoMix * mixer);
|
static gboolean gst_gl_stereo_mix_process_frames (GstGLStereoMix * mixer);
|
||||||
|
|
||||||
|
@ -188,10 +186,10 @@ gst_gl_stereo_mix_class_init (GstGLStereoMixClass * klass)
|
||||||
agg_class->stop = gst_gl_stereo_mix_stop;
|
agg_class->stop = gst_gl_stereo_mix_stop;
|
||||||
agg_class->start = gst_gl_stereo_mix_start;
|
agg_class->start = gst_gl_stereo_mix_start;
|
||||||
agg_class->src_query = gst_gl_stereo_mix_src_query;
|
agg_class->src_query = gst_gl_stereo_mix_src_query;
|
||||||
|
agg_class->negotiated_src_caps = _negotiated_caps;
|
||||||
|
|
||||||
videoaggregator_class->aggregate_frames = gst_gl_stereo_mix_aggregate_frames;
|
videoaggregator_class->aggregate_frames = gst_gl_stereo_mix_aggregate_frames;
|
||||||
videoaggregator_class->update_caps = _update_caps;
|
videoaggregator_class->update_caps = _update_caps;
|
||||||
videoaggregator_class->negotiated_caps = _negotiated_caps;
|
|
||||||
videoaggregator_class->get_output_buffer =
|
videoaggregator_class->get_output_buffer =
|
||||||
gst_gl_stereo_mix_get_output_buffer;
|
gst_gl_stereo_mix_get_output_buffer;
|
||||||
|
|
||||||
|
@ -470,7 +468,7 @@ get_converted_caps (GstGLStereoMix * mix, GstCaps * caps)
|
||||||
|
|
||||||
/* Return the possible output caps based on inputs and downstream prefs */
|
/* Return the possible output caps based on inputs and downstream prefs */
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
_update_caps (GstVideoAggregator * vagg, GstCaps * caps, GstCaps * filter)
|
_update_caps (GstVideoAggregator * vagg, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstGLStereoMix *mix = GST_GL_STEREO_MIX (vagg);
|
GstGLStereoMix *mix = GST_GL_STEREO_MIX (vagg);
|
||||||
GList *l;
|
GList *l;
|
||||||
|
@ -563,16 +561,16 @@ _update_caps (GstVideoAggregator * vagg, GstCaps * caps, GstCaps * filter)
|
||||||
|
|
||||||
/* Called after videoaggregator fixates our caps */
|
/* Called after videoaggregator fixates our caps */
|
||||||
static gboolean
|
static gboolean
|
||||||
_negotiated_caps (GstVideoAggregator * vagg, GstCaps * caps)
|
_negotiated_caps (GstAggregator * agg, GstCaps * caps)
|
||||||
{
|
{
|
||||||
|
GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg);
|
||||||
GstGLStereoMix *mix = GST_GL_STEREO_MIX (vagg);
|
GstGLStereoMix *mix = GST_GL_STEREO_MIX (vagg);
|
||||||
GstCaps *in_caps;
|
GstCaps *in_caps;
|
||||||
|
|
||||||
GST_LOG_OBJECT (mix, "Configured output caps %" GST_PTR_FORMAT, caps);
|
GST_LOG_OBJECT (mix, "Configured output caps %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
if (GST_VIDEO_AGGREGATOR_CLASS (parent_class)->negotiated_caps)
|
if (GST_AGGREGATOR_CLASS (parent_class)->negotiated_src_caps)
|
||||||
if (!GST_VIDEO_AGGREGATOR_CLASS (parent_class)->negotiated_caps (vagg,
|
if (!GST_AGGREGATOR_CLASS (parent_class)->negotiated_src_caps (agg, caps))
|
||||||
caps))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Update the glview_convert output */
|
/* Update the glview_convert output */
|
||||||
|
|
|
@ -453,9 +453,8 @@ 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,
|
static void gst_gl_video_mixer_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstCaps *_update_caps (GstVideoAggregator * vagg, GstCaps * caps,
|
static GstCaps *_update_caps (GstVideoAggregator * vagg, GstCaps * caps);
|
||||||
GstCaps * filter);
|
static GstCaps *_fixate_caps (GstAggregator * agg, GstCaps * caps);
|
||||||
static GstCaps *_fixate_caps (GstVideoAggregator * vagg, GstCaps * caps);
|
|
||||||
static gboolean gst_gl_video_mixer_propose_allocation (GstGLBaseMixer *
|
static gboolean gst_gl_video_mixer_propose_allocation (GstGLBaseMixer *
|
||||||
base_mix, GstGLBaseMixerPad * base_pad, GstQuery * decide_query,
|
base_mix, GstGLBaseMixerPad * base_pad, GstQuery * decide_query,
|
||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
|
@ -874,9 +873,9 @@ gst_gl_video_mixer_class_init (GstGLVideoMixerClass * klass)
|
||||||
gst_gl_video_mixer_process_textures;
|
gst_gl_video_mixer_process_textures;
|
||||||
|
|
||||||
vagg_class->update_caps = _update_caps;
|
vagg_class->update_caps = _update_caps;
|
||||||
vagg_class->fixate_caps = _fixate_caps;
|
|
||||||
|
|
||||||
agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD;
|
agg_class->sinkpads_type = GST_TYPE_GL_VIDEO_MIXER_PAD;
|
||||||
|
agg_class->fixate_src_caps = _fixate_caps;
|
||||||
|
|
||||||
mix_class->propose_allocation = gst_gl_video_mixer_propose_allocation;
|
mix_class->propose_allocation = gst_gl_video_mixer_propose_allocation;
|
||||||
|
|
||||||
|
@ -986,7 +985,7 @@ _mixer_pad_get_output_size (GstGLVideoMixer * mix,
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
_update_caps (GstVideoAggregator * vagg, GstCaps * caps, GstCaps * filter)
|
_update_caps (GstVideoAggregator * vagg, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstCaps *ret;
|
GstCaps *ret;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
@ -1014,18 +1013,15 @@ _update_caps (GstVideoAggregator * vagg, GstCaps * caps, GstCaps * filter)
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (vagg);
|
GST_OBJECT_UNLOCK (vagg);
|
||||||
|
|
||||||
if (filter) {
|
ret = gst_caps_ref (caps);
|
||||||
ret = gst_caps_intersect (caps, filter);
|
|
||||||
} else {
|
|
||||||
ret = gst_caps_ref (caps);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
_fixate_caps (GstVideoAggregator * vagg, GstCaps * caps)
|
_fixate_caps (GstAggregator * agg, GstCaps * caps)
|
||||||
{
|
{
|
||||||
|
GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg);
|
||||||
GstGLVideoMixer *mix = GST_GL_VIDEO_MIXER (vagg);
|
GstGLVideoMixer *mix = GST_GL_VIDEO_MIXER (vagg);
|
||||||
gint best_width = 0, best_height = 0;
|
gint best_width = 0, best_height = 0;
|
||||||
gint best_fps_n = 0, best_fps_d = 0;
|
gint best_fps_n = 0, best_fps_d = 0;
|
||||||
|
|
Loading…
Reference in a new issue