From a32d944a3853e955a349c828fad53c2eb22ba497 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 11 Mar 2012 19:06:37 +0100 Subject: [PATCH] fix for caps api changes --- ext/aalib/gstaasink.c | 10 +++++--- ext/gdk_pixbuf/pixbufscale.c | 2 +- ext/jpeg/gstjpegdec.c | 2 +- ext/jpeg/gstjpegenc.c | 2 +- ext/pulse/pulsesrc.c | 5 ++-- gst/goom/gstgoom.c | 2 +- gst/goom2k1/gstgoom.c | 3 +-- gst/rtp/gstrtph263ppay.c | 48 +++++++++++++++++++----------------- gst/rtp/gstrtph264pay.c | 2 +- gst/videomixer/videomixer2.c | 2 +- sys/v4l2/gstv4l2src.c | 15 ++++++----- sys/ximage/gstximagesrc.c | 10 +++++--- 12 files changed, 57 insertions(+), 46 deletions(-) diff --git a/ext/aalib/gstaasink.c b/ext/aalib/gstaasink.c index be41619ff2..5ba829a750 100644 --- a/ext/aalib/gstaasink.c +++ b/ext/aalib/gstaasink.c @@ -72,7 +72,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420")) ); -static void gst_aasink_fixate (GstBaseSink * bsink, GstCaps * caps); +static GstCaps *gst_aasink_fixate (GstBaseSink * bsink, GstCaps * caps); static gboolean gst_aasink_setcaps (GstBaseSink * bsink, GstCaps * caps); static void gst_aasink_get_times (GstBaseSink * bsink, GstBuffer * buffer, GstClockTime * start, GstClockTime * end); @@ -227,18 +227,22 @@ gst_aasink_class_init (GstAASinkClass * klass) gstvideosink_class->show_frame = GST_DEBUG_FUNCPTR (gst_aasink_show_frame); } -static void +static GstCaps * gst_aasink_fixate (GstBaseSink * bsink, GstCaps * caps) { GstStructure *structure; + caps = gst_caps_make_writable (caps); + structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", 320); gst_structure_fixate_field_nearest_int (structure, "height", 240); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); - GST_BASE_SINK_CLASS (parent_class)->fixate (bsink, caps); + caps = GST_BASE_SINK_CLASS (parent_class)->fixate (bsink, caps); + + return caps; } static gboolean diff --git a/ext/gdk_pixbuf/pixbufscale.c b/ext/gdk_pixbuf/pixbufscale.c index 35af64e6dd..0738388065 100644 --- a/ext/gdk_pixbuf/pixbufscale.c +++ b/ext/gdk_pixbuf/pixbufscale.c @@ -270,8 +270,8 @@ gst_pixbufscale_fixate_caps (GstBaseTransform * base, GstPadDirection direction, GstStructure *ins, *outs; const GValue *from_par, *to_par; + othercaps = gst_caps_truncate (othercaps); othercaps = gst_caps_make_writable (othercaps); - gst_caps_truncate (othercaps); GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT " based on caps %" GST_PTR_FORMAT, othercaps, caps); diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index a723f352dd..8e7b9f78ba 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -1271,7 +1271,7 @@ gst_jpeg_dec_negotiate (GstJpegDec * dec, gint width, gint height, gint clrspc) gst_caps_unref (caps); caps = gst_caps_copy_nth (allowed_caps, i); /* sigh, ds and _parse_caps need fixed caps for parsing, fixate */ - gst_caps_fixate (caps); + caps = gst_caps_fixate (caps); GST_LOG_OBJECT (dec, "checking caps %" GST_PTR_FORMAT, caps); if (!gst_video_info_from_caps (&tmpinfo, caps)) diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index bb0767f0e8..3814bbb13b 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -334,7 +334,7 @@ gst_jpegenc_getcaps (GstPad * pad, GstCaps * filter) if ((val = gst_structure_get_value (s, "framerate"))) gst_structure_set_value (structure, "framerate", val); - gst_caps_merge_structure (caps, structure); + caps = gst_caps_merge_structure (caps, structure); } } diff --git a/ext/pulse/pulsesrc.c b/ext/pulse/pulsesrc.c index 5b1d576c4e..be790c75f6 100644 --- a/ext/pulse/pulsesrc.c +++ b/ext/pulse/pulsesrc.c @@ -1294,12 +1294,11 @@ gst_pulsesrc_negotiate (GstBaseSrc * basesrc) } if (caps) { /* take first (and best, since they are sorted) possibility */ - caps = gst_caps_make_writable (caps); - gst_caps_truncate (caps); + caps = gst_caps_truncate (caps); /* now fixate */ if (!gst_caps_is_empty (caps)) { - GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, caps); + caps = GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, caps); GST_DEBUG_OBJECT (basesrc, "fixated to: %" GST_PTR_FORMAT, caps); if (gst_caps_is_any (caps)) { diff --git a/gst/goom/gstgoom.c b/gst/goom/gstgoom.c index f467739bfb..7351503864 100644 --- a/gst/goom/gstgoom.c +++ b/gst/goom/gstgoom.c @@ -271,7 +271,7 @@ gst_goom_src_negotiate (GstGoom * goom) if (gst_caps_is_empty (target)) goto no_format; - gst_caps_truncate (target); + target = gst_caps_truncate (target); } else { target = templ; } diff --git a/gst/goom2k1/gstgoom.c b/gst/goom2k1/gstgoom.c index ae78d976d9..ee01a2aa10 100644 --- a/gst/goom2k1/gstgoom.c +++ b/gst/goom2k1/gstgoom.c @@ -268,8 +268,7 @@ gst_goom_src_negotiate (GstGoom * goom) if (gst_caps_is_empty (target)) goto no_format; - target = gst_caps_make_writable (target); - gst_caps_truncate (target); + target = gst_caps_truncate (target); } else { target = gst_caps_copy (templ); } diff --git a/gst/rtp/gstrtph263ppay.c b/gst/rtp/gstrtph263ppay.c index b029a3e9aa..7333bed62b 100644 --- a/gst/rtp/gstrtph263ppay.c +++ b/gst/rtp/gstrtph263ppay.c @@ -206,16 +206,16 @@ gst_rtp_h263p_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) return res; } -static void +static GstCaps * caps_append (GstCaps * caps, GstStructure * in_s, guint x, guint y, guint mpi) { GstStructure *s; if (!in_s) - return; + return caps; if (mpi < 1 || mpi > 32) - return; + return caps; s = gst_structure_copy (in_s); @@ -224,7 +224,9 @@ caps_append (GstCaps * caps, GstStructure * in_s, guint x, guint y, guint mpi) "height", GST_TYPE_INT_RANGE, 1, y, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30000, 1001 * mpi, NULL); - gst_caps_merge_structure (caps, s); + caps = gst_caps_merge_structure (caps, s); + + return caps; } @@ -383,7 +385,7 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, "width", GST_TYPE_INT_RANGE, 1, 176, "height", GST_TYPE_INT_RANGE, 1, 144, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30000, 2002, NULL); - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); } else if (level <= 20) { GstStructure *s_copy = gst_structure_copy (new_s); @@ -391,20 +393,20 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, "width", GST_TYPE_INT_RANGE, 1, 352, "height", GST_TYPE_INT_RANGE, 1, 288, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30000, 2002, NULL); - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); gst_structure_set (s_copy, "width", GST_TYPE_INT_RANGE, 1, 176, "height", GST_TYPE_INT_RANGE, 1, 144, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30000, 1001, NULL); - gst_caps_merge_structure (caps, s_copy); + caps = gst_caps_merge_structure (caps, s_copy); } else if (level <= 40) { gst_structure_set (new_s, "width", GST_TYPE_INT_RANGE, 1, 352, "height", GST_TYPE_INT_RANGE, 1, 288, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30000, 1001, NULL); - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); } else if (level <= 50) { GstStructure *s_copy = gst_structure_copy (new_s); @@ -412,13 +414,13 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, "width", GST_TYPE_INT_RANGE, 1, 352, "height", GST_TYPE_INT_RANGE, 1, 288, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 50, 1, NULL); - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); gst_structure_set (s_copy, "width", GST_TYPE_INT_RANGE, 1, 352, "height", GST_TYPE_INT_RANGE, 1, 240, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 60000, 1001, NULL); - gst_caps_merge_structure (caps, s_copy); + caps = gst_caps_merge_structure (caps, s_copy); } else if (level <= 60) { GstStructure *s_copy = gst_structure_copy (new_s); @@ -426,13 +428,13 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, "width", GST_TYPE_INT_RANGE, 1, 720, "height", GST_TYPE_INT_RANGE, 1, 288, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 50, 1, NULL); - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); gst_structure_set (s_copy, "width", GST_TYPE_INT_RANGE, 1, 720, "height", GST_TYPE_INT_RANGE, 1, 240, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 60000, 1001, NULL); - gst_caps_merge_structure (caps, s_copy); + caps = gst_caps_merge_structure (caps, s_copy); } else if (level <= 70) { GstStructure *s_copy = gst_structure_copy (new_s); @@ -440,15 +442,15 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, "width", GST_TYPE_INT_RANGE, 1, 720, "height", GST_TYPE_INT_RANGE, 1, 576, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 50, 1, NULL); - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); gst_structure_set (s_copy, "width", GST_TYPE_INT_RANGE, 1, 720, "height", GST_TYPE_INT_RANGE, 1, 480, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 60000, 1001, NULL); - gst_caps_merge_structure (caps, s_copy); + caps = gst_caps_merge_structure (caps, s_copy); } else { - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); } } else { @@ -460,7 +462,7 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, GST_DEBUG_OBJECT (rtph263ppay, "No profile or level specified" " for H263-2000, defaulting to baseline H263"); - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); } } else { gboolean f = FALSE, i = FALSE, j = FALSE, t = FALSE; @@ -523,7 +525,7 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, unsigned int xmax, ymax, mpi; if (sscanf (str, "%u,%u,%u", &xmax, &ymax, &mpi) == 3) { if (xmax % 4 && ymax % 4 && mpi >= 1 && mpi <= 32) { - caps_append (caps, new_s, xmax, ymax, mpi); + caps = caps_append (caps, new_s, xmax, ymax, mpi); added = TRUE; } else { GST_WARNING_OBJECT (rtph263ppay, "Invalid custom framesize/MPI" @@ -538,42 +540,42 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, str = gst_structure_get_string (s, "16cif"); if (str) { int mpi = atoi (str); - caps_append (caps, new_s, 1408, 1152, mpi); + caps = caps_append (caps, new_s, 1408, 1152, mpi); added = TRUE; } str = gst_structure_get_string (s, "4cif"); if (str) { int mpi = atoi (str); - caps_append (caps, new_s, 704, 576, mpi); + caps = caps_append (caps, new_s, 704, 576, mpi); added = TRUE; } str = gst_structure_get_string (s, "cif"); if (str) { int mpi = atoi (str); - caps_append (caps, new_s, 352, 288, mpi); + caps = caps_append (caps, new_s, 352, 288, mpi); added = TRUE; } str = gst_structure_get_string (s, "qcif"); if (str) { int mpi = atoi (str); - caps_append (caps, new_s, 176, 144, mpi); + caps = caps_append (caps, new_s, 176, 144, mpi); added = TRUE; } str = gst_structure_get_string (s, "sqcif"); if (str) { int mpi = atoi (str); - caps_append (caps, new_s, 128, 96, mpi); + caps = caps_append (caps, new_s, 128, 96, mpi); added = TRUE; } if (added) gst_structure_free (new_s); else - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); } } diff --git a/gst/rtp/gstrtph264pay.c b/gst/rtp/gstrtph264pay.c index 93ddf7990a..14dc6a6972 100644 --- a/gst/rtp/gstrtph264pay.c +++ b/gst/rtp/gstrtph264pay.c @@ -370,7 +370,7 @@ gst_rtp_h264_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad, "profile", G_TYPE_STRING, "constrained-baseline", NULL); } - gst_caps_merge_structure (caps, new_s); + caps = gst_caps_merge_structure (caps, new_s); } icaps = gst_caps_intersect (caps, template_caps); diff --git a/gst/videomixer/videomixer2.c b/gst/videomixer/videomixer2.c index ec8273a52f..e4bcc127e9 100644 --- a/gst/videomixer/videomixer2.c +++ b/gst/videomixer/videomixer2.c @@ -256,7 +256,7 @@ gst_videomixer2_update_src_caps (GstVideoMixer2 * mix) goto done; } - gst_caps_truncate (caps); + caps = gst_caps_truncate (caps); s = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (s, "width", best_width); gst_structure_fixate_field_nearest_int (s, "height", best_height); diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index 5722bdea84..7f04f92cf1 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -122,7 +122,7 @@ static gboolean gst_v4l2src_query (GstBaseSrc * bsrc, GstQuery * query); static gboolean gst_v4l2src_decide_allocation (GstBaseSrc * src, GstQuery * query); static GstFlowReturn gst_v4l2src_fill (GstPushSrc * src, GstBuffer * out); -static void gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps); +static GstCaps *gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps); static gboolean gst_v4l2src_negotiate (GstBaseSrc * basesrc); static void gst_v4l2src_set_property (GObject * object, guint prop_id, @@ -280,7 +280,7 @@ gst_v4l2src_get_property (GObject * object, } /* this function is a bit of a last resort */ -static void +static GstCaps * gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps) { GstStructure *structure; @@ -288,6 +288,8 @@ gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps) GST_DEBUG_OBJECT (basesrc, "fixating caps %" GST_PTR_FORMAT, caps); + caps = gst_caps_make_writable (caps); + for (i = 0; i < gst_caps_get_size (caps); ++i) { structure = gst_caps_get_structure (caps, i); @@ -302,7 +304,9 @@ gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps) GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, caps); - GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, caps); + caps = GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, caps); + + return caps; } @@ -395,12 +399,11 @@ gst_v4l2src_negotiate (GstBaseSrc * basesrc) if (peercaps) gst_caps_unref (peercaps); if (caps) { - caps = gst_caps_make_writable (caps); - gst_caps_truncate (caps); + caps = gst_caps_truncate (caps); /* now fixate */ if (!gst_caps_is_empty (caps)) { - gst_v4l2src_fixate (basesrc, caps); + caps = gst_v4l2src_fixate (basesrc, caps); GST_DEBUG_OBJECT (basesrc, "fixated to: %" GST_PTR_FORMAT, caps); LOG_CAPS (basesrc, caps); diff --git a/sys/ximage/gstximagesrc.c b/sys/ximage/gstximagesrc.c index 51b46d7c01..eee74d420b 100644 --- a/sys/ximage/gstximagesrc.c +++ b/sys/ximage/gstximagesrc.c @@ -81,7 +81,7 @@ enum #define gst_ximage_src_parent_class parent_class G_DEFINE_TYPE (GstXImageSrc, gst_ximage_src, GST_TYPE_PUSH_SRC); -static void gst_ximage_src_fixate (GstBaseSrc * bsrc, GstCaps * caps); +static GstCaps *gst_ximage_src_fixate (GstBaseSrc * bsrc, GstCaps * caps); static void gst_ximage_src_clear_bufpool (GstXImageSrc * ximagesrc); /* Called when a buffer is returned from the pipeline */ @@ -1115,18 +1115,22 @@ gst_ximage_src_set_caps (GstBaseSrc * bs, GstCaps * caps) return TRUE; } -static void +static GstCaps * gst_ximage_src_fixate (GstBaseSrc * bsrc, GstCaps * caps) { gint i; GstStructure *structure; + caps = gst_caps_make_writable (caps); + for (i = 0; i < gst_caps_get_size (caps); ++i) { structure = gst_caps_get_structure (caps, i); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 25, 1); } - GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps); + caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps); + + return caps; } static void