From 5e606a84514469d9d2c4c1e4fa6cca1ed61b18c3 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 1 Jul 2005 17:13:02 +0000 Subject: [PATCH] ext/theora/theoradec.c (theora_dec_src_getcaps): Implement a getcaps to do explicit caps. Needs to be done in all dec... Original commit message from CVS: 2005-07-01 Andy Wingo * ext/theora/theoradec.c (theora_dec_src_getcaps): Implement a getcaps to do explicit caps. Needs to be done in all decoders, possibly via a base class. * configure.ac (GST_PLUGIN_LDFLAGS): Add videoscale. * ext/ogg/gstoggdemux.c (gst_ogg_pad_typefind): No need to set caps on the sink pad, just rely on the pad template. Also, setting ANY caps on a pad is not valid because the caps are not fixed. * sys/ximage/ximagesink.c (gst_ximagesink_buffer_alloc): Set the caps on the buffer, and get the width from the desired_caps if they're set. (gst_ximagesink_renegotiate_size): Implement via setting the desired_caps on the ximagesink. (gst_ximagesink_setcaps): Only reset the width of the player if it wasn't already set. Not sure if this is right. (gst_ximagesink_show_frame): Memcpy only for normal buffers. * sys/ximage/ximagesink.h (desired_caps): New field, is the caps that the user wants. NULL unless the window has been resized. * gst/volume/gstvolume.c (volume_transform): Adapt to basetransform refcount changes. --- ChangeLog | 27 ++++++++++++++++ configure.ac | 2 ++ docs/libs/tmpl/gstcolorbalance.sgml | 9 ++++++ docs/libs/tmpl/gstmixer.sgml | 6 ---- ext/ogg/gstoggdemux.c | 5 --- ext/theora/theoradec.c | 17 ++++++++++ gst/volume/gstvolume.c | 2 +- sys/ximage/ximagesink.c | 63 ++++++++++++++++++++----------------- sys/ximage/ximagesink.h | 2 ++ 9 files changed, 92 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index a6d9fae..7191a45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,32 @@ 2005-07-01 Andy Wingo + * ext/theora/theoradec.c (theora_dec_src_getcaps): Implement a + getcaps to do explicit caps. Needs to be done in all decoders, + possibly via a base class. + + * configure.ac (GST_PLUGIN_LDFLAGS): Add videoscale. + + * ext/ogg/gstoggdemux.c (gst_ogg_pad_typefind): No need to set + caps on the sink pad, just rely on the pad template. Also, setting + ANY caps on a pad is not valid because the caps are not fixed. + + * sys/ximage/ximagesink.c (gst_ximagesink_buffer_alloc): Set the + caps on the buffer, and get the width from the desired_caps if + they're set. + (gst_ximagesink_renegotiate_size): Implement via setting the + desired_caps on the ximagesink. + (gst_ximagesink_setcaps): Only reset the width of the player if it + wasn't already set. Not sure if this is right. + (gst_ximagesink_show_frame): Memcpy only for normal buffers. + + * sys/ximage/ximagesink.h (desired_caps): New field, is the caps + that the user wants. NULL unless the window has been resized. + + * gst/volume/gstvolume.c (volume_transform): Adapt to + basetransform refcount changes. + +2005-07-01 Andy Wingo + * gst/videoscale/gstvideoscale.c: * gst/videoscale/gstvideoscale.h: Clean up, port to 0.9. Derives from BaseTransform, implements a transform_caps. Removed dead code diff --git a/configure.ac b/configure.ac index 3bb8ec2..d0869fb 100644 --- a/configure.ac +++ b/configure.ac @@ -378,6 +378,7 @@ GST_PLUGINS_ALL="\ typefind \ videotestsrc \ videorate \ + videoscale \ volume \ " @@ -885,6 +886,7 @@ gst/subparse/Makefile gst/typefind/Makefile gst/videotestsrc/Makefile gst/videorate/Makefile +gst/videoscale/Makefile gst/volume/Makefile sys/Makefile sys/ximage/Makefile diff --git a/docs/libs/tmpl/gstcolorbalance.sgml b/docs/libs/tmpl/gstcolorbalance.sgml index 3d401d8..5953b69 100644 --- a/docs/libs/tmpl/gstcolorbalance.sgml +++ b/docs/libs/tmpl/gstcolorbalance.sgml @@ -20,6 +20,15 @@ interface for elements that provide color balance operations + + + + + +@gstcolorbalance: the object which received the signal. +@arg1: +@arg2: + diff --git a/docs/libs/tmpl/gstmixer.sgml b/docs/libs/tmpl/gstmixer.sgml index a70333a..da7e32d 100644 --- a/docs/libs/tmpl/gstmixer.sgml +++ b/docs/libs/tmpl/gstmixer.sgml @@ -45,18 +45,12 @@ gstmixer -@parent: -@values: -@_gst_reserved: -@parent: -@label: -@flags: diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index d1b0d87..2fd7816 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -557,8 +557,6 @@ gst_ogg_pad_typefind (GstOggPad * pad, ogg_packet * packet) gst_element_factory_create (GST_ELEMENT_FACTORY (factories->data), NULL); if (element) { - GstCaps *any; - /* this is ours */ gst_object_ref (element); gst_object_sink (GST_OBJECT (element)); @@ -572,9 +570,6 @@ gst_ogg_pad_typefind (GstOggPad * pad, ogg_packet * packet) gst_pad_set_chain_function (pad->elem_out, gst_ogg_pad_internal_chain); gst_pad_set_element_private (pad->elem_out, pad); - any = gst_caps_new_any (); - gst_pad_set_caps (pad->elem_out, any); - gst_caps_unref (any); gst_pad_set_active (pad->elem_out, TRUE); /* and this pad may not be named src.. */ diff --git a/ext/theora/theoradec.c b/ext/theora/theoradec.c index 4aee286..fedc3db 100644 --- a/ext/theora/theoradec.c +++ b/ext/theora/theoradec.c @@ -123,6 +123,7 @@ static gboolean theora_dec_sink_convert (GstPad * pad, GstFormat src_format, gint64 src_value, GstFormat * dest_format, gint64 * dest_value); static gboolean theora_dec_sink_query (GstPad * pad, GstQuery * query); +static GstCaps *theora_dec_src_getcaps (GstPad * pad); #if 0 static const GstFormat *theora_get_formats (GstPad * pad); @@ -178,6 +179,7 @@ gst_theora_dec_init (GstTheoraDec * dec) dec->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&theora_dec_src_factory), "src"); + gst_pad_set_getcaps_function (dec->srcpad, theora_dec_src_getcaps); gst_pad_set_event_function (dec->srcpad, theora_dec_src_event); gst_pad_set_query_type_function (dec->srcpad, theora_get_query_types); gst_pad_set_query_function (dec->srcpad, theora_dec_src_query); @@ -563,6 +565,21 @@ error: return res; } +static GstCaps * +theora_dec_src_getcaps (GstPad * pad) +{ + GstCaps *caps; + + GST_LOCK (pad); + caps = GST_PAD_CAPS (pad); + GST_UNLOCK (pad); + + if (caps) + return gst_caps_ref (caps); + else + return gst_caps_ref (gst_pad_get_pad_template_caps (pad)); +} + static gboolean theora_dec_sink_event (GstPad * pad, GstEvent * event) { diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c index af3dce1..1ed7f36 100644 --- a/gst/volume/gstvolume.c +++ b/gst/volume/gstvolume.c @@ -346,7 +346,7 @@ volume_transform (GstBaseTransform * base, GstBuffer * inbuf, } } - *outbuf = gst_buffer_make_writable (gst_buffer_ref (inbuf)); + *outbuf = gst_buffer_make_writable (inbuf); filter->process (filter, GST_BUFFER_TIMESTAMP (*outbuf), GST_BUFFER_DATA (*outbuf), GST_BUFFER_SIZE (*outbuf)); diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index 0983a53..047e6dc 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -623,12 +623,6 @@ gst_ximagesink_renegotiate_size (GstXImageSink * ximagesink) if (ximagesink->xwindow->width <= 1 || ximagesink->xwindow->height <= 1) return; - /* FIXME */ -#if 0 - if (GST_PAD_IS_NEGOTIATING (GST_VIDEOSINK_PAD (ximagesink)) || - !gst_pad_is_negotiated (GST_VIDEOSINK_PAD (ximagesink))) - return; - /* Window got resized or moved. We do caps negotiation again to get video scaler to fit that new size only if size of the window differs from our size. */ @@ -658,27 +652,21 @@ gst_ximagesink_renegotiate_size (GstXImageSink * ximagesink) nom, den, NULL); } - r = gst_pad_try_set_caps (GST_VIDEOSINK_PAD (ximagesink), caps); - - if ((r == GST_PAD_LINK_OK) || (r == GST_PAD_LINK_DONE)) { - /* Renegotiation succeeded, we update our size and image */ + if (gst_pad_peer_accept_caps (GST_VIDEOSINK_PAD (ximagesink), caps)) { + gst_caps_replace (&ximagesink->desired_caps, caps); GST_VIDEOSINK_WIDTH (ximagesink) = ximagesink->xwindow->width; GST_VIDEOSINK_HEIGHT (ximagesink) = ximagesink->xwindow->height; - if ((ximagesink->ximage) && - ((GST_VIDEOSINK_WIDTH (ximagesink) != ximagesink->ximage->width) || - (GST_VIDEOSINK_HEIGHT (ximagesink) != - ximagesink->ximage->height))) { - /* We renew our ximage only if size changed */ + if (ximagesink->ximage) { GST_DEBUG_OBJECT (ximagesink, "destroying and recreating our ximage"); gst_ximagesink_ximage_destroy (ximagesink, ximagesink->ximage); ximagesink->ximage = NULL; } } else { ximagesink->sw_scaling_failed = TRUE; + gst_caps_unref (caps); } } -#endif } /* This function handles XEvents that might be in the queue. It generates @@ -1060,7 +1048,7 @@ static gboolean gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps) { GstXImageSink *ximagesink; - gboolean ret; + gboolean ret = TRUE; GstStructure *structure; const GValue *par; @@ -1074,10 +1062,12 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps) GST_PTR_FORMAT, ximagesink->xcontext->caps, caps); structure = gst_caps_get_structure (caps, 0); - ret = gst_structure_get_int (structure, "width", - &(GST_VIDEOSINK_WIDTH (ximagesink))); - ret &= gst_structure_get_int (structure, "height", - &(GST_VIDEOSINK_HEIGHT (ximagesink))); + if (GST_VIDEOSINK_WIDTH (ximagesink) == 0) { + ret &= gst_structure_get_int (structure, "width", + &(GST_VIDEOSINK_WIDTH (ximagesink))); + ret &= gst_structure_get_int (structure, "height", + &(GST_VIDEOSINK_HEIGHT (ximagesink))); + } ret &= gst_structure_get_double (structure, "framerate", &ximagesink->framerate); if (!ret) @@ -1250,12 +1240,11 @@ gst_ximagesink_show_frame (GstBaseSink * bsink, GstBuffer * buf) ("Failed creating an XImage in ximagesink chain function.")); return GST_FLOW_ERROR; } + memcpy (ximagesink->ximage->ximage->data, + GST_BUFFER_DATA (buf), + MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size)); + gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage); } - - memcpy (ximagesink->ximage->ximage->data, - GST_BUFFER_DATA (buf), - MIN (GST_BUFFER_SIZE (buf), ximagesink->ximage->size)); - gst_ximagesink_ximage_put (ximagesink, ximagesink->ximage); } gst_ximagesink_handle_xevents (ximagesink); @@ -1307,7 +1296,7 @@ gst_ximagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, /* FIXME, we should just parse the caps, and provide a buffer in this format, * we should not just reconfigure ourselves yet */ - if (caps && caps != GST_PAD_CAPS (GST_VIDEOSINK_PAD (ximagesink))) { + if (caps && !GST_PAD_CAPS (GST_VIDEOSINK_PAD (ximagesink))) { if (!gst_ximagesink_setcaps (bsink, caps)) { return GST_FLOW_NOT_NEGOTIATED; } @@ -1341,9 +1330,25 @@ gst_ximagesink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, if (!ximage) { /* We found no suitable image in the pool. Creating... */ + gint height, width; + + if (ximagesink->desired_caps) { + GstStructure *s = gst_caps_get_structure (ximagesink->desired_caps, 0); + + gst_structure_get_int (s, "width", &width); + gst_structure_get_int (s, "height", &height); + } else { + width = GST_VIDEOSINK_WIDTH (ximagesink); + height = GST_VIDEOSINK_HEIGHT (ximagesink); + } + GST_DEBUG_OBJECT (ximagesink, "no usable image in pool, creating ximage"); - ximage = gst_ximagesink_ximage_new (ximagesink, - GST_VIDEOSINK_WIDTH (ximagesink), GST_VIDEOSINK_HEIGHT (ximagesink)); + ximage = gst_ximagesink_ximage_new (ximagesink, width, height); + + if (ximagesink->desired_caps) + gst_buffer_set_caps (GST_BUFFER (ximage), ximagesink->desired_caps); + else + gst_buffer_set_caps (GST_BUFFER (ximage), caps); } *buf = GST_BUFFER (ximage); diff --git a/sys/ximage/ximagesink.h b/sys/ximage/ximagesink.h index 4b2652f..84b7dc0 100644 --- a/sys/ximage/ximagesink.h +++ b/sys/ximage/ximagesink.h @@ -121,6 +121,8 @@ struct _GstXImageSink { GstXImageBuffer *ximage; GstXImageBuffer *cur_image; + GstCaps *desired_caps; + gdouble framerate; GMutex *x_lock; GMutex *stream_lock; -- 2.7.4