mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-25 16:48:11 +00:00
Add passthru. Remove height/width parameters. Fix caps negotiation to automatically work with ranges in the output.
Original commit message from CVS: Add passthru. Remove height/width parameters. Fix caps negotiation to automatically work with ranges in the output.
This commit is contained in:
parent
a5755233e8
commit
6511cd71bb
2 changed files with 40 additions and 50 deletions
|
@ -46,8 +46,6 @@ enum {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_WIDTH,
|
|
||||||
ARG_HEIGHT,
|
|
||||||
ARG_METHOD,
|
ARG_METHOD,
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
@ -112,12 +110,6 @@ gst_videoscale_class_init (GstVideoscaleClass *klass)
|
||||||
gobject_class = (GObjectClass*)klass;
|
gobject_class = (GObjectClass*)klass;
|
||||||
gstelement_class = (GstElementClass*)klass;
|
gstelement_class = (GstElementClass*)klass;
|
||||||
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDTH,
|
|
||||||
g_param_spec_int("width","width","width",
|
|
||||||
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HEIGHT,
|
|
||||||
g_param_spec_int("height","height","height",
|
|
||||||
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
|
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_METHOD,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_METHOD,
|
||||||
g_param_spec_enum("method","method","method",
|
g_param_spec_enum("method","method","method",
|
||||||
GST_TYPE_VIDEOSCALE_METHOD,0,G_PARAM_READWRITE)); /* CHECKME! */
|
GST_TYPE_VIDEOSCALE_METHOD,0,G_PARAM_READWRITE)); /* CHECKME! */
|
||||||
|
@ -290,6 +282,8 @@ gst_videoscale_src_link (GstPad *pad, GstCaps *caps)
|
||||||
gst_caps_set(peercaps, "width", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
gst_caps_set(peercaps, "width", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
||||||
gst_caps_set(peercaps, "height", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
gst_caps_set(peercaps, "height", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
||||||
|
|
||||||
|
g_print("setting caps to %s\n", gst_caps_to_string(peercaps));
|
||||||
|
|
||||||
ret = gst_pad_try_set_caps (videoscale->srcpad, peercaps);
|
ret = gst_pad_try_set_caps (videoscale->srcpad, peercaps);
|
||||||
|
|
||||||
gst_caps_unref(peercaps);
|
gst_caps_unref(peercaps);
|
||||||
|
@ -311,43 +305,57 @@ gst_videoscale_sink_link (GstPad *pad, GstCaps *caps)
|
||||||
GstVideoscale *videoscale;
|
GstVideoscale *videoscale;
|
||||||
GstPadLinkReturn ret;
|
GstPadLinkReturn ret;
|
||||||
GstCaps *peercaps;
|
GstCaps *peercaps;
|
||||||
|
GstCaps *srccaps;
|
||||||
|
GstCaps *caps1;
|
||||||
|
|
||||||
GST_DEBUG ("gst_videoscale_src_link");
|
GST_DEBUG ("gst_videoscale_sink_link");
|
||||||
videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
|
videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
if (!GST_CAPS_IS_FIXED (caps)) {
|
if (!GST_CAPS_IS_FIXED (caps)) {
|
||||||
return GST_PAD_LINK_DELAYED;
|
return GST_PAD_LINK_DELAYED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
videoscale->format = videoscale_find_by_caps (caps);
|
videoscale->format = videoscale_find_by_caps (caps);
|
||||||
gst_caps_debug(caps,"ack");
|
|
||||||
g_return_val_if_fail(videoscale->format, GST_PAD_LINK_REFUSED);
|
g_return_val_if_fail(videoscale->format, GST_PAD_LINK_REFUSED);
|
||||||
|
|
||||||
|
ret = gst_pad_try_set_caps (videoscale->srcpad, gst_caps_copy(caps));
|
||||||
|
if (ret == GST_PAD_LINK_OK || ret == GST_PAD_LINK_DONE) {
|
||||||
|
videoscale->passthru = TRUE;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
videoscale->passthru = FALSE;
|
||||||
|
|
||||||
|
srccaps = gst_caps_copy(caps);
|
||||||
|
gst_caps_set(srccaps, "width", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
||||||
|
gst_caps_set(srccaps, "height", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
||||||
|
|
||||||
|
peercaps = gst_pad_get_allowed_caps(videoscale->srcpad);
|
||||||
|
|
||||||
|
caps1 = gst_caps_intersect(peercaps, srccaps);
|
||||||
|
|
||||||
|
if (!GST_CAPS_IS_FIXED (caps1)) {
|
||||||
|
/* FIXME */
|
||||||
|
return GST_PAD_LINK_DELAYED;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_print("setting caps to %s\n", gst_caps_to_string(caps1));
|
||||||
|
|
||||||
|
ret = gst_pad_try_set_caps (videoscale->srcpad, caps1);
|
||||||
|
if (ret != GST_PAD_LINK_OK && ret != GST_PAD_LINK_DONE) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_caps_get_int (caps1, "width", &videoscale->to_width);
|
||||||
|
gst_caps_get_int (caps1, "height", &videoscale->to_height);
|
||||||
|
|
||||||
gst_caps_get_int (caps, "width", &videoscale->from_width);
|
gst_caps_get_int (caps, "width", &videoscale->from_width);
|
||||||
gst_caps_get_int (caps, "height", &videoscale->from_height);
|
gst_caps_get_int (caps, "height", &videoscale->from_height);
|
||||||
|
gst_caps_get_float (caps, "framerate", &videoscale->framerate);
|
||||||
|
|
||||||
peercaps = gst_caps_copy(caps);
|
|
||||||
|
|
||||||
if(videoscale->force_size){
|
|
||||||
gst_caps_set(peercaps, "width", GST_PROPS_INT (videoscale->forced_width));
|
|
||||||
gst_caps_set(peercaps, "height", GST_PROPS_INT (videoscale->forced_height));
|
|
||||||
}else{
|
|
||||||
gst_caps_set(peercaps, "width", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
|
||||||
gst_caps_set(peercaps, "height", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gst_pad_try_set_caps (videoscale->srcpad, peercaps);
|
|
||||||
|
|
||||||
gst_caps_unref(peercaps);
|
|
||||||
|
|
||||||
if(ret==GST_PAD_LINK_OK){
|
|
||||||
caps = gst_pad_get_caps (videoscale->srcpad);
|
caps = gst_pad_get_caps (videoscale->srcpad);
|
||||||
|
|
||||||
gst_caps_get_int (caps, "width", &videoscale->to_width);
|
|
||||||
gst_caps_get_int (caps, "height", &videoscale->to_height);
|
|
||||||
gst_videoscale_setup(videoscale);
|
gst_videoscale_setup(videoscale);
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +380,6 @@ gst_videoscale_init (GstVideoscale *videoscale)
|
||||||
gst_pad_set_getcaps_function(videoscale->srcpad,gst_videoscale_getcaps);
|
gst_pad_set_getcaps_function(videoscale->srcpad,gst_videoscale_getcaps);
|
||||||
|
|
||||||
videoscale->inited = FALSE;
|
videoscale->inited = FALSE;
|
||||||
videoscale->force_size = FALSE;
|
|
||||||
|
|
||||||
videoscale->method = GST_VIDEOSCALE_NEAREST;
|
videoscale->method = GST_VIDEOSCALE_NEAREST;
|
||||||
/*videoscale->method = GST_VIDEOSCALE_BILINEAR; */
|
/*videoscale->method = GST_VIDEOSCALE_BILINEAR; */
|
||||||
|
@ -448,14 +455,6 @@ gst_videoscale_set_property (GObject *object, guint prop_id, const GValue *value
|
||||||
|
|
||||||
GST_DEBUG ("gst_videoscale_set_property");
|
GST_DEBUG ("gst_videoscale_set_property");
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_WIDTH:
|
|
||||||
src->forced_width = g_value_get_int (value);
|
|
||||||
src->force_size = TRUE;
|
|
||||||
break;
|
|
||||||
case ARG_HEIGHT:
|
|
||||||
src->forced_height = g_value_get_int (value);
|
|
||||||
src->force_size = TRUE;
|
|
||||||
break;
|
|
||||||
case ARG_METHOD:
|
case ARG_METHOD:
|
||||||
src->method = g_value_get_enum (value);
|
src->method = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
|
@ -474,12 +473,6 @@ gst_videoscale_get_property (GObject *object, guint prop_id, GValue *value, GPar
|
||||||
src = GST_VIDEOSCALE(object);
|
src = GST_VIDEOSCALE(object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_WIDTH:
|
|
||||||
g_value_set_int (value, src->forced_width);
|
|
||||||
break;
|
|
||||||
case ARG_HEIGHT:
|
|
||||||
g_value_set_int (value, src->forced_height);
|
|
||||||
break;
|
|
||||||
case ARG_METHOD:
|
case ARG_METHOD:
|
||||||
g_value_set_enum (value, src->method);
|
g_value_set_enum (value, src->method);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -57,10 +57,6 @@ struct _GstVideoscale {
|
||||||
|
|
||||||
GstPad *sinkpad,*srcpad;
|
GstPad *sinkpad,*srcpad;
|
||||||
|
|
||||||
gboolean force_size;
|
|
||||||
gint forced_width;
|
|
||||||
gint forced_height;
|
|
||||||
|
|
||||||
/* video state */
|
/* video state */
|
||||||
gboolean inited;
|
gboolean inited;
|
||||||
struct videoscale_format_struct *format;
|
struct videoscale_format_struct *format;
|
||||||
|
@ -69,6 +65,7 @@ struct _GstVideoscale {
|
||||||
gint from_width;
|
gint from_width;
|
||||||
gint from_height;
|
gint from_height;
|
||||||
gboolean passthru;
|
gboolean passthru;
|
||||||
|
float framerate;
|
||||||
|
|
||||||
GstVideoScaleMethod method;
|
GstVideoScaleMethod method;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue