2005-04-23 23:29:47 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
* 2005 Wim Taymans <wim@fluendo.com>
|
|
|
|
* 2005 David Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
docs/: Correct fixxrefs options.
Original commit message from CVS:
* docs/gst/Makefile.am:
* docs/libs/Makefile.am:
Correct fixxrefs options.
* docs/plugins/Makefile.am:
* docs/plugins/gstreamer-plugins-docs.sgml:
* docs/plugins/gstreamer-plugins-sections.txt:
* plugins/elements/Makefile.am:
* plugins/elements/gstcapsfilter.c (gst_capsfilter_details):
* plugins/elements/gstcapsfilter.h (__GST_CAPSFILTER_H__,
GST_TYPE_CAPSFILTER, GST_CAPSFILTER, GST_CAPSFILTER_CLASS,
GST_IS_CAPSFILTER, GST_IS_CAPSFILTER_CLASS, GstCapsFilter,
GstCapsFilterClass, _GstCapsFilter, trans, filter_caps,
_GstCapsFilterClass, trans_class):
* plugins/elements/gstelements.c (name, rank, type, _elements):
* plugins/elements/gstidentity.c
(gst_identity_check_imperfect_timestamp,
gst_identity_check_imperfect_offset):
Document capsfilter and add doc-blurb to identity.
2007-05-06 18:27:25 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-capsfilter
|
|
|
|
* @short_description: pass data though unmodified, but enforces format limmits
|
|
|
|
*
|
|
|
|
* The element does not modify data as such, but can enforce limmitations on the
|
|
|
|
* data format.
|
|
|
|
*/
|
2005-04-23 23:29:47 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2005-08-04 19:40:43 +00:00
|
|
|
#include "config.h"
|
2005-04-23 23:29:47 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-29 18:00:15 +00:00
|
|
|
#include "../../gst/gst-i18n-lib.h"
|
docs/: Correct fixxrefs options.
Original commit message from CVS:
* docs/gst/Makefile.am:
* docs/libs/Makefile.am:
Correct fixxrefs options.
* docs/plugins/Makefile.am:
* docs/plugins/gstreamer-plugins-docs.sgml:
* docs/plugins/gstreamer-plugins-sections.txt:
* plugins/elements/Makefile.am:
* plugins/elements/gstcapsfilter.c (gst_capsfilter_details):
* plugins/elements/gstcapsfilter.h (__GST_CAPSFILTER_H__,
GST_TYPE_CAPSFILTER, GST_CAPSFILTER, GST_CAPSFILTER_CLASS,
GST_IS_CAPSFILTER, GST_IS_CAPSFILTER_CLASS, GstCapsFilter,
GstCapsFilterClass, _GstCapsFilter, trans, filter_caps,
_GstCapsFilterClass, trans_class):
* plugins/elements/gstelements.c (name, rank, type, _elements):
* plugins/elements/gstidentity.c
(gst_identity_check_imperfect_timestamp,
gst_identity_check_imperfect_offset):
Document capsfilter and add doc-blurb to identity.
2007-05-06 18:27:25 +00:00
|
|
|
#include "gstcapsfilter.h"
|
2005-08-04 19:40:43 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_FILTER_CAPS
|
|
|
|
};
|
|
|
|
|
2005-04-23 23:29:47 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2005-08-04 19:40:43 +00:00
|
|
|
|
2005-04-23 23:29:47 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_capsfilter_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_capsfilter_debug
|
|
|
|
|
|
|
|
#define _do_init(bla) \
|
2005-08-04 19:40:43 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_capsfilter_debug, "capsfilter", 0, \
|
|
|
|
"capsfilter element");
|
|
|
|
|
|
|
|
GST_BOILERPLATE_FULL (GstCapsFilter, gst_capsfilter, GstBaseTransform,
|
|
|
|
GST_TYPE_BASE_TRANSFORM, _do_init);
|
2005-04-23 23:29:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void gst_capsfilter_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_capsfilter_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2005-08-04 19:40:43 +00:00
|
|
|
static void gst_capsfilter_dispose (GObject * object);
|
|
|
|
static GstCaps *gst_capsfilter_transform_caps (GstBaseTransform * base,
|
2005-08-24 13:33:21 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps);
|
2005-08-04 19:40:43 +00:00
|
|
|
static GstFlowReturn gst_capsfilter_transform_ip (GstBaseTransform * base,
|
|
|
|
GstBuffer * buf);
|
2005-09-09 23:45:15 +00:00
|
|
|
static GstFlowReturn gst_capsfilter_prepare_buf (GstBaseTransform * trans,
|
|
|
|
GstBuffer * input, gint size, GstCaps * caps, GstBuffer ** buf);
|
2007-07-24 12:32:31 +00:00
|
|
|
static gboolean gst_capsfilter_transform_size (GstBaseTransform * trans,
|
|
|
|
GstPadDirection direction, GstCaps * caps, guint size,
|
|
|
|
GstCaps * othercaps, guint * othersize);
|
2005-04-23 23:29:47 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_capsfilter_base_init (gpointer g_class)
|
|
|
|
{
|
2007-06-21 14:29:05 +00:00
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
gst_element_class_set_details_simple (gstelement_class,
|
|
|
|
"CapsFilter",
|
|
|
|
"Generic",
|
|
|
|
"Pass data without modification, limiting formats",
|
|
|
|
"David Schleef <ds@schleef.org>");
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
2005-04-23 23:29:47 +00:00
|
|
|
gst_static_pad_template_get (&srctemplate));
|
2007-06-21 14:29:05 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
2005-04-23 23:29:47 +00:00
|
|
|
gst_static_pad_template_get (&sinktemplate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_capsfilter_class_init (GstCapsFilterClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2005-08-04 19:40:43 +00:00
|
|
|
GstBaseTransformClass *trans_class;
|
2005-04-23 23:29:47 +00:00
|
|
|
|
2006-05-11 18:10:34 +00:00
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
2005-08-04 19:40:43 +00:00
|
|
|
gobject_class->set_property = gst_capsfilter_set_property;
|
|
|
|
gobject_class->get_property = gst_capsfilter_get_property;
|
|
|
|
gobject_class->dispose = gst_capsfilter_dispose;
|
2005-04-23 23:29:47 +00:00
|
|
|
|
2006-05-11 18:10:34 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_FILTER_CAPS,
|
2005-09-29 12:37:38 +00:00
|
|
|
g_param_spec_boxed ("caps", _("Filter caps"),
|
2007-06-27 11:24:08 +00:00
|
|
|
_("Restrict the possible allowed capabilities (NULL means ANY). "
|
|
|
|
"Setting this property takes a reference to the supplied GstCaps "
|
|
|
|
"object."), GST_TYPE_CAPS, G_PARAM_READWRITE));
|
2005-04-23 23:29:47 +00:00
|
|
|
|
2006-05-11 18:10:34 +00:00
|
|
|
trans_class = GST_BASE_TRANSFORM_CLASS (klass);
|
2005-08-04 19:40:43 +00:00
|
|
|
trans_class->transform_caps = gst_capsfilter_transform_caps;
|
|
|
|
trans_class->transform_ip = gst_capsfilter_transform_ip;
|
2005-09-09 23:45:15 +00:00
|
|
|
trans_class->prepare_output_buffer = gst_capsfilter_prepare_buf;
|
2007-07-24 12:32:31 +00:00
|
|
|
trans_class->transform_size = gst_capsfilter_transform_size;
|
2005-04-23 23:29:47 +00:00
|
|
|
}
|
|
|
|
|
2005-08-04 19:40:43 +00:00
|
|
|
static void
|
2005-08-28 17:45:58 +00:00
|
|
|
gst_capsfilter_init (GstCapsFilter * filter, GstCapsFilterClass * g_class)
|
2005-04-23 23:29:47 +00:00
|
|
|
{
|
2005-08-04 19:40:43 +00:00
|
|
|
filter->filter_caps = gst_caps_new_any ();
|
2005-04-23 23:29:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_capsfilter_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2005-08-04 19:40:43 +00:00
|
|
|
GstCapsFilter *capsfilter = GST_CAPSFILTER (object);
|
2005-04-23 23:29:47 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2005-06-02 15:45:16 +00:00
|
|
|
case PROP_FILTER_CAPS:{
|
2005-08-07 13:37:08 +00:00
|
|
|
GstCaps *new_caps;
|
2005-06-16 17:50:16 +00:00
|
|
|
GstCaps *old_caps;
|
2005-11-28 14:02:54 +00:00
|
|
|
const GstCaps *new_caps_val = gst_value_get_caps (value);
|
2005-06-02 15:45:16 +00:00
|
|
|
|
2005-08-07 13:37:08 +00:00
|
|
|
if (new_caps_val == NULL) {
|
2005-06-16 17:50:16 +00:00
|
|
|
new_caps = gst_caps_new_any ();
|
2005-08-07 13:37:08 +00:00
|
|
|
} else {
|
2007-06-27 11:24:08 +00:00
|
|
|
new_caps = (GstCaps *) new_caps_val;
|
|
|
|
gst_caps_ref (new_caps);
|
2005-06-16 17:50:16 +00:00
|
|
|
}
|
2005-06-02 15:45:16 +00:00
|
|
|
|
2005-06-16 17:50:16 +00:00
|
|
|
old_caps = capsfilter->filter_caps;
|
2005-06-02 15:45:16 +00:00
|
|
|
capsfilter->filter_caps = new_caps;
|
2005-06-16 17:50:16 +00:00
|
|
|
gst_caps_unref (old_caps);
|
2005-06-02 15:45:16 +00:00
|
|
|
|
2005-11-28 14:02:54 +00:00
|
|
|
GST_DEBUG_OBJECT (capsfilter, "set new caps %" GST_PTR_FORMAT, new_caps);
|
|
|
|
|
2005-06-02 15:45:16 +00:00
|
|
|
/* FIXME: Need to activate these caps on the pads */
|
2005-04-23 23:29:47 +00:00
|
|
|
break;
|
2005-06-02 15:45:16 +00:00
|
|
|
}
|
2005-04-23 23:29:47 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_capsfilter_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
|
|
|
{
|
2005-08-04 19:40:43 +00:00
|
|
|
GstCapsFilter *capsfilter = GST_CAPSFILTER (object);
|
2005-04-23 23:29:47 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_FILTER_CAPS:
|
|
|
|
gst_value_set_caps (value, capsfilter->filter_caps);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-08-04 19:40:43 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_capsfilter_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
GstCapsFilter *filter = GST_CAPSFILTER (object);
|
|
|
|
|
|
|
|
gst_caps_replace (&filter->filter_caps, NULL);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstCaps *
|
2005-08-24 13:33:21 +00:00
|
|
|
gst_capsfilter_transform_caps (GstBaseTransform * base,
|
|
|
|
GstPadDirection direction, GstCaps * caps)
|
2005-08-04 19:40:43 +00:00
|
|
|
{
|
|
|
|
GstCapsFilter *capsfilter = GST_CAPSFILTER (base);
|
|
|
|
GstCaps *ret;
|
|
|
|
|
|
|
|
ret = gst_caps_intersect (caps, capsfilter->filter_caps);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-24 12:32:31 +00:00
|
|
|
static gboolean
|
|
|
|
gst_capsfilter_transform_size (GstBaseTransform * trans,
|
|
|
|
GstPadDirection direction, GstCaps * caps, guint size,
|
|
|
|
GstCaps * othercaps, guint * othersize)
|
|
|
|
{
|
|
|
|
/* return the same size */
|
|
|
|
*othersize = size;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-04 19:40:43 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_capsfilter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|
|
|
{
|
2005-09-09 23:45:15 +00:00
|
|
|
/* No actual work here. It's all done in the prepare output buffer
|
|
|
|
* func. */
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Output buffer preparation... if the buffer has no caps, and
|
|
|
|
* our allowed output caps is fixed, then give the caps to the
|
|
|
|
* buffer.
|
2005-10-15 15:30:24 +00:00
|
|
|
* This ensures that outgoing buffers have caps if we can, so
|
2005-09-09 23:45:15 +00:00
|
|
|
* that pipelines like:
|
2005-10-15 15:30:24 +00:00
|
|
|
* gst-launch filesrc location=rawsamples.raw !
|
2005-09-09 23:45:15 +00:00
|
|
|
* audio/x-raw-int,width=16,depth=16,rate=48000,channels=2,
|
|
|
|
* endianness=4321,signed='(boolean)'true ! alsasink
|
|
|
|
* will work.
|
|
|
|
*/
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
|
|
|
|
gint size, GstCaps * caps, GstBuffer ** buf)
|
|
|
|
{
|
|
|
|
if (GST_BUFFER_CAPS (input) != NULL) {
|
|
|
|
/* Output buffer already has caps */
|
2007-07-24 12:32:31 +00:00
|
|
|
GST_DEBUG_OBJECT (trans,
|
|
|
|
"Input buffer already has caps (implicitely fixed)");
|
|
|
|
/* FIXME : Move this behaviour to basetransform. The given caps are the ones
|
|
|
|
* of the source pad, therefore our outgoing buffers should always have
|
|
|
|
* those caps. */
|
|
|
|
gst_buffer_set_caps (input, caps);
|
2005-09-09 23:45:15 +00:00
|
|
|
gst_buffer_ref (input);
|
|
|
|
*buf = input;
|
|
|
|
} else {
|
|
|
|
/* Buffer has no caps. See if the output pad only supports fixed caps */
|
|
|
|
GstCaps *out_caps;
|
|
|
|
|
2005-10-21 15:13:08 +00:00
|
|
|
out_caps = GST_PAD_CAPS (trans->srcpad);
|
|
|
|
|
|
|
|
if (out_caps != NULL) {
|
|
|
|
gst_caps_ref (out_caps);
|
2005-09-09 23:45:15 +00:00
|
|
|
} else {
|
|
|
|
out_caps = gst_pad_get_allowed_caps (trans->srcpad);
|
|
|
|
g_return_val_if_fail (out_caps != NULL, GST_FLOW_ERROR);
|
|
|
|
}
|
|
|
|
|
2006-05-18 09:07:55 +00:00
|
|
|
out_caps = gst_caps_make_writable (out_caps);
|
|
|
|
gst_caps_do_simplify (out_caps);
|
|
|
|
|
2005-09-09 23:45:15 +00:00
|
|
|
if (gst_caps_is_fixed (out_caps) && !gst_caps_is_empty (out_caps)) {
|
|
|
|
GST_DEBUG_OBJECT (trans, "Have fixed output caps %"
|
|
|
|
GST_PTR_FORMAT " to apply to buffer with no caps", out_caps);
|
2006-01-17 12:14:20 +00:00
|
|
|
if (gst_buffer_is_metadata_writable (input)) {
|
2005-09-09 23:45:15 +00:00
|
|
|
gst_buffer_ref (input);
|
|
|
|
*buf = input;
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (trans, "Creating sub-buffer and setting caps");
|
|
|
|
*buf = gst_buffer_create_sub (input, 0, GST_BUFFER_SIZE (input));
|
|
|
|
}
|
2005-10-21 15:13:08 +00:00
|
|
|
GST_BUFFER_CAPS (*buf) = out_caps;
|
2005-09-09 23:45:15 +00:00
|
|
|
|
|
|
|
if (GST_PAD_CAPS (trans->srcpad) == NULL)
|
|
|
|
gst_pad_set_caps (trans->srcpad, out_caps);
|
|
|
|
} else {
|
2006-05-18 09:07:55 +00:00
|
|
|
GST_DEBUG_OBJECT (trans, "Have unfixed output caps %" GST_PTR_FORMAT,
|
|
|
|
out_caps);
|
2005-09-09 23:45:15 +00:00
|
|
|
gst_caps_unref (out_caps);
|
|
|
|
}
|
check/elements/identity.c: Make the error a little clearer when the test fails because identity made a copy of the bu...
Original commit message from CVS:
* check/elements/identity.c: (GST_START_TEST):
Make the error a little clearer when the test fails because
identity made a copy of the buffer.
* docs/gst/gstreamer-sections.txt:
New symbols in gstbasetransform.h
* gst/base/gstbasetransform.c: (gst_base_transform_class_init),
(gst_base_transform_init), (gst_base_transform_transform_size),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_default_prepare_buf),
(gst_base_transform_get_unit_size),
(gst_base_transform_buffer_alloc),
(gst_base_transform_handle_buffer), (gst_base_transform_chain),
(gst_base_transform_change_state),
(gst_base_transform_set_passthrough),
(gst_base_transform_set_in_place),
(gst_base_transform_is_in_place):
* gst/base/gstbasetransform.h:
Change BaseTransform to separate in_place operate from same_caps
output. in_place implies that the element can perform the transform
on incoming buffers in-place, even if the caps on the output are
different.
Sub-class elements can now implement special buffer allocation
methods for outgoing buffers if they wish to.
Big documentation addition.
* gst/elements/gstcapsfilter.c: (gst_capsfilter_transform_ip):
* gst/elements/gstelements.c:
Changes for basetransform modifications.
* gst/elements/Makefile.am:
* gst/elements/gstfdsrc.c: (gst_fdsrc_init), (gst_fdsrc_create):
Compile fix. Extra debug output.
2005-09-09 17:42:20 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 13:45:04 +00:00
|
|
|
return GST_FLOW_OK;
|
2005-08-04 19:40:43 +00:00
|
|
|
}
|