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  <wingo@pobox.com>

* 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.
This commit is contained in:
Andy Wingo 2005-07-01 17:13:02 +00:00
parent 5f91e70f0b
commit 5e606a8451
9 changed files with 92 additions and 41 deletions

View file

@ -1,3 +1,30 @@
2005-07-01 Andy Wingo <wingo@pobox.com>
* 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 <wingo@pobox.com>
* gst/videoscale/gstvideoscale.c:

View file

@ -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

View file

@ -20,6 +20,15 @@ interface for elements that provide color balance operations
</para>
<!-- ##### SIGNAL GstColorBalance::value-changed ##### -->
<para>
</para>
@gstcolorbalance: the object which received the signal.
@arg1:
@arg2:
<!-- ##### STRUCT GstColorBalanceClass ##### -->
<para>

View file

@ -45,18 +45,12 @@ gstmixer
</para>
@parent:
@values:
@_gst_reserved:
<!-- ##### STRUCT GstMixerTrack ##### -->
<para>
</para>
@parent:
@label:
@flags:
<!-- ##### FUNCTION gst_mixer_list_tracks ##### -->
<para>

View file

@ -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.. */

View file

@ -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)
{

View file

@ -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));

View file

@ -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);

View file

@ -121,6 +121,8 @@ struct _GstXImageSink {
GstXImageBuffer *ximage;
GstXImageBuffer *cur_image;
GstCaps *desired_caps;
gdouble framerate;
GMutex *x_lock;
GMutex *stream_lock;