From b55427f75474a04d3e95cef63933ef12f44f6bdd Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 4 Jan 2004 09:55:16 +0000 Subject: ext/xvid/gstxviddec.c: Implement src_getcaps() so proper size caps is negotiated. Original commit message from CVS: 2004-01-04 Ronald Bultje * ext/xvid/gstxviddec.c: (gst_xviddec_init), (gst_xviddec_src_getcaps), (gst_xviddec_src_link), (gst_xviddec_sink_link): Implement src_getcaps() so proper size caps is negotiated. --- ChangeLog | 7 +++++++ ext/xvid/gstxviddec.c | 46 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c425f8f3..d6c23d8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-01-04 Ronald Bultje + + * ext/xvid/gstxviddec.c: (gst_xviddec_init), + (gst_xviddec_src_getcaps), (gst_xviddec_src_link), + (gst_xviddec_sink_link): + Implement src_getcaps() so proper size caps is negotiated. + 2004-01-04 Ronald Bultje * ext/flac/gstflacdec.c: (gst_flacdec_loop): diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c index 37abbed5..0766c3ef 100644 --- a/ext/xvid/gstxviddec.c +++ b/ext/xvid/gstxviddec.c @@ -87,6 +87,8 @@ static GstPadLinkReturn static GstPadLinkReturn gst_xviddec_src_link (GstPad *pad, const GstCaps *vscapslist); +static GstCaps * + gst_xviddec_src_getcaps (GstPad *pad); static GstElementStateReturn gst_xviddec_change_state (GstElement *element); @@ -164,6 +166,7 @@ gst_xviddec_init (GstXvidDec *xviddec) "src"); gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->srcpad); + gst_pad_set_getcaps_function (xviddec->srcpad, gst_xviddec_src_getcaps); gst_pad_set_link_function(xviddec->srcpad, gst_xviddec_src_link); /* size, etc. */ @@ -271,10 +274,41 @@ gst_xviddec_chain (GstPad *pad, gst_buffer_unref(buf); } -/* - * This function allows multiple structures because it - * can be called from sink_link(). - */ +static GstCaps * +gst_xviddec_src_getcaps (GstPad *pad) +{ + GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad)); + GstCaps *caps; + gint csp[] = { + XVID_CSP_I420, + XVID_CSP_YV12, + XVID_CSP_YUY2, + XVID_CSP_UYVY, + XVID_CSP_YVYU, + XVID_CSP_BGRA, + XVID_CSP_ABGR, + XVID_CSP_RGBA, + XVID_CSP_ARGB, + XVID_CSP_BGR, + XVID_CSP_RGB555, + XVID_CSP_RGB565, + 0 + }, i; + + if (!GST_PAD_CAPS (xviddec->sinkpad)) { + GstPadTemplate *templ = gst_static_pad_template_get (&src_template); + return gst_caps_copy (gst_pad_template_get_caps (templ)); + } + + caps = gst_caps_new_empty (); + for (i = 0; csp[i] != 0; i++) { + GstCaps *one = gst_xvid_csp_to_caps (csp[i], xviddec->width, + xviddec->height, xviddec->fps); + gst_caps_append (caps, one); + } + + return caps; +} static GstPadLinkReturn gst_xviddec_src_link (GstPad *pad, @@ -290,7 +324,7 @@ gst_xviddec_src_link (GstPad *pad, if (xviddec->handle) { gst_xviddec_unset(xviddec); } - +g_print ("out: %s\n", gst_caps_to_string (vscaps)); xviddec->csp = gst_xvid_structure_to_csp (structure, xviddec->width, &xviddec->stride, &xviddec->bpp); @@ -323,7 +357,7 @@ gst_xviddec_sink_link (GstPad *pad, gst_structure_get_int(structure, "width", &xviddec->width); gst_structure_get_int(structure, "height", &xviddec->height); gst_structure_get_double(structure, "framerate", &xviddec->fps); - +g_print ("in: %dx%d\n", xviddec->width, xviddec->height); /* re-nego? or just await src nego? */ if (GST_PAD_CAPS(xviddec->srcpad)) { GstPadLinkReturn ret; -- cgit v1.2.1