2010-12-15 20:45:38 +00:00
|
|
|
/* vim: set filetype=c: */
|
2010-04-14 23:32:34 +00:00
|
|
|
% ClassName
|
|
|
|
GstBaseTransform
|
|
|
|
% TYPE_CLASS_NAME
|
|
|
|
GST_TYPE_BASE_TRANSFORM
|
2010-12-15 03:03:09 +00:00
|
|
|
% pads
|
2013-03-15 06:57:06 +00:00
|
|
|
srcpad-simple
|
|
|
|
sinkpad-simple
|
2010-04-14 23:32:34 +00:00
|
|
|
% pkg-config
|
2013-02-06 20:35:36 +00:00
|
|
|
gstreamer-base-1.0
|
2010-04-14 23:32:34 +00:00
|
|
|
% includes
|
|
|
|
#include <gst/base/gstbasetransform.h>
|
|
|
|
% prototypes
|
2013-03-15 06:57:06 +00:00
|
|
|
static GstCaps *gst_replace_transform_caps (GstBaseTransform * trans,
|
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * filter);
|
|
|
|
static GstCaps *gst_replace_fixate_caps (GstBaseTransform * trans,
|
2010-04-14 23:32:34 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
2013-03-15 06:57:06 +00:00
|
|
|
static gboolean gst_replace_accept_caps (GstBaseTransform * trans,
|
|
|
|
GstPadDirection direction, GstCaps * caps);
|
|
|
|
static gboolean gst_replace_set_caps (GstBaseTransform * trans,
|
|
|
|
GstCaps * incaps, GstCaps * outcaps);
|
|
|
|
static gboolean gst_replace_query (GstBaseTransform * trans,
|
|
|
|
GstPadDirection direction, GstQuery * query);
|
|
|
|
static gboolean gst_replace_decide_allocation (GstBaseTransform * trans,
|
|
|
|
GstQuery * query);
|
|
|
|
static gboolean gst_replace_filter_meta (GstBaseTransform * trans,
|
|
|
|
GstQuery * query, GType api, const GstStructure * params);
|
|
|
|
static gboolean gst_replace_propose_allocation (GstBaseTransform * trans,
|
|
|
|
GstQuery * decide_query, GstQuery * query);
|
2013-02-06 20:35:36 +00:00
|
|
|
static gboolean gst_replace_transform_size (GstBaseTransform * trans,
|
2013-03-15 06:57:06 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps, gsize size, GstCaps * othercaps,
|
|
|
|
gsize * othersize);
|
2013-02-06 20:35:36 +00:00
|
|
|
static gboolean gst_replace_get_unit_size (GstBaseTransform * trans,
|
|
|
|
GstCaps * caps, gsize * size);
|
2010-04-14 23:32:34 +00:00
|
|
|
static gboolean gst_replace_start (GstBaseTransform * trans);
|
|
|
|
static gboolean gst_replace_stop (GstBaseTransform * trans);
|
2013-02-06 20:35:36 +00:00
|
|
|
static gboolean gst_replace_sink_event (GstBaseTransform * trans,
|
|
|
|
GstEvent * event);
|
|
|
|
static gboolean gst_replace_src_event (GstBaseTransform * trans,
|
|
|
|
GstEvent * event);
|
2013-03-15 06:57:06 +00:00
|
|
|
static GstFlowReturn gst_replace_prepare_output_buffer (GstBaseTransform *
|
|
|
|
trans, GstBuffer * input, GstBuffer ** outbuf);
|
|
|
|
static gboolean gst_replace_copy_metadata (GstBaseTransform * trans,
|
|
|
|
GstBuffer * input, GstBuffer * outbuf);
|
|
|
|
static gboolean gst_replace_transform_meta (GstBaseTransform * trans,
|
|
|
|
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf);
|
|
|
|
static void gst_replace_before_transform (GstBaseTransform * trans,
|
|
|
|
GstBuffer * buffer);
|
|
|
|
static GstFlowReturn gst_replace_transform (GstBaseTransform * trans,
|
|
|
|
GstBuffer * inbuf, GstBuffer * outbuf);
|
|
|
|
static GstFlowReturn gst_replace_transform_ip (GstBaseTransform * trans,
|
|
|
|
GstBuffer * buf);
|
2010-04-14 23:32:34 +00:00
|
|
|
% declare-class
|
|
|
|
GstBaseTransformClass *base_transform_class = GST_BASE_TRANSFORM_CLASS (klass);
|
|
|
|
% set-methods
|
|
|
|
base_transform_class->transform_caps = GST_DEBUG_FUNCPTR (gst_replace_transform_caps);
|
|
|
|
base_transform_class->fixate_caps = GST_DEBUG_FUNCPTR (gst_replace_fixate_caps);
|
2013-02-06 20:35:36 +00:00
|
|
|
base_transform_class->accept_caps = GST_DEBUG_FUNCPTR (gst_replace_accept_caps);
|
|
|
|
base_transform_class->set_caps = GST_DEBUG_FUNCPTR (gst_replace_set_caps);
|
|
|
|
base_transform_class->query = GST_DEBUG_FUNCPTR (gst_replace_query);
|
|
|
|
base_transform_class->decide_allocation = GST_DEBUG_FUNCPTR (gst_replace_decide_allocation);
|
|
|
|
base_transform_class->filter_meta = GST_DEBUG_FUNCPTR (gst_replace_filter_meta);
|
|
|
|
base_transform_class->propose_allocation = GST_DEBUG_FUNCPTR (gst_replace_propose_allocation);
|
2010-04-14 23:32:34 +00:00
|
|
|
base_transform_class->transform_size = GST_DEBUG_FUNCPTR (gst_replace_transform_size);
|
|
|
|
base_transform_class->get_unit_size = GST_DEBUG_FUNCPTR (gst_replace_get_unit_size);
|
|
|
|
base_transform_class->start = GST_DEBUG_FUNCPTR (gst_replace_start);
|
|
|
|
base_transform_class->stop = GST_DEBUG_FUNCPTR (gst_replace_stop);
|
2013-02-06 20:35:36 +00:00
|
|
|
base_transform_class->sink_event = GST_DEBUG_FUNCPTR (gst_replace_sink_event);
|
2010-04-14 23:32:34 +00:00
|
|
|
base_transform_class->src_event = GST_DEBUG_FUNCPTR (gst_replace_src_event);
|
2013-02-06 20:35:36 +00:00
|
|
|
base_transform_class->prepare_output_buffer = GST_DEBUG_FUNCPTR (gst_replace_prepare_output_buffer);
|
|
|
|
base_transform_class->copy_metadata = GST_DEBUG_FUNCPTR (gst_replace_copy_metadata);
|
|
|
|
base_transform_class->transform_meta = GST_DEBUG_FUNCPTR (gst_replace_transform_meta);
|
2010-04-14 23:32:34 +00:00
|
|
|
base_transform_class->before_transform = GST_DEBUG_FUNCPTR (gst_replace_before_transform);
|
2013-02-06 20:35:36 +00:00
|
|
|
base_transform_class->transform = GST_DEBUG_FUNCPTR (gst_replace_transform);
|
|
|
|
base_transform_class->transform_ip = GST_DEBUG_FUNCPTR (gst_replace_transform_ip);
|
2010-04-14 23:32:34 +00:00
|
|
|
% methods
|
|
|
|
static GstCaps *
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_transform_caps (GstBaseTransform * trans, GstPadDirection direction,
|
|
|
|
GstCaps * caps, GstCaps * filter)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "transform_caps");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-02-06 20:35:36 +00:00
|
|
|
static GstCaps *
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_fixate_caps (GstBaseTransform * trans, GstPadDirection direction,
|
|
|
|
GstCaps * caps, GstCaps * othercaps)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "fixate_caps");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-02-06 20:35:36 +00:00
|
|
|
return NULL;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_accept_caps (GstBaseTransform * trans, GstPadDirection direction,
|
|
|
|
GstCaps * caps)
|
2013-02-06 20:35:36 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "accept_caps");
|
|
|
|
|
2013-02-06 20:35:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_replace_set_caps (GstBaseTransform * trans, GstCaps * incaps,
|
|
|
|
GstCaps * outcaps)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "set_caps");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_query (GstBaseTransform * trans, GstPadDirection direction,
|
|
|
|
GstQuery * query)
|
2013-02-06 20:35:36 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "query");
|
2013-02-06 20:35:36 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
/* decide allocation query for output buffers */
|
2013-02-06 20:35:36 +00:00
|
|
|
static gboolean
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_decide_allocation (GstBaseTransform * trans, GstQuery * query)
|
2013-02-06 20:35:36 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "decide_allocation");
|
2013-02-06 20:35:36 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_filter_meta (GstBaseTransform * trans, GstQuery * query, GType api,
|
|
|
|
const GstStructure * params)
|
2013-02-06 20:35:36 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "filter_meta");
|
2013-02-06 20:35:36 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
/* propose allocation query parameters for input buffers */
|
2013-02-06 20:35:36 +00:00
|
|
|
static gboolean
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_propose_allocation (GstBaseTransform * trans,
|
|
|
|
GstQuery * decide_query, GstQuery * query)
|
2013-02-06 20:35:36 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "propose_allocation");
|
2013-02-06 20:35:36 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
/* transform size */
|
2013-02-06 20:35:36 +00:00
|
|
|
static gboolean
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_transform_size (GstBaseTransform * trans, GstPadDirection direction,
|
2013-02-06 20:35:36 +00:00
|
|
|
GstCaps * caps, gsize size, GstCaps * othercaps, gsize * othersize)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
GST_DEBUG_OBJECT (replace, "transform_size");
|
|
|
|
|
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-02-06 20:35:36 +00:00
|
|
|
gst_replace_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
|
|
|
gsize * size)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
GST_DEBUG_OBJECT (replace, "get_unit_size");
|
|
|
|
|
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
/* states */
|
2010-04-14 23:32:34 +00:00
|
|
|
static gboolean
|
|
|
|
gst_replace_start (GstBaseTransform * trans)
|
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "start");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_replace_stop (GstBaseTransform * trans)
|
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "stop");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
/* sink and src pad event handlers */
|
2010-04-14 23:32:34 +00:00
|
|
|
static gboolean
|
2013-02-06 20:35:36 +00:00
|
|
|
gst_replace_sink_event (GstBaseTransform * trans, GstEvent * event)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "sink_event");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
2013-02-06 20:35:36 +00:00
|
|
|
static gboolean
|
|
|
|
gst_replace_src_event (GstBaseTransform * trans, GstEvent * event)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "src_event");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_prepare_output_buffer (GstBaseTransform * trans, GstBuffer * input,
|
|
|
|
GstBuffer ** outbuf)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "prepare_output_buffer");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
return GST_FLOW_OK;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
/* metadata */
|
2013-02-06 20:35:36 +00:00
|
|
|
static gboolean
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_copy_metadata (GstBaseTransform * trans, GstBuffer * input,
|
|
|
|
GstBuffer * outbuf)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "copy_metadata");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-02-06 20:35:36 +00:00
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-03-15 06:57:06 +00:00
|
|
|
gst_replace_transform_meta (GstBaseTransform * trans, GstBuffer * outbuf,
|
|
|
|
GstMeta * meta, GstBuffer * inbuf)
|
2010-04-14 23:32:34 +00:00
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "transform_meta");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
2013-02-06 20:35:36 +00:00
|
|
|
return TRUE;
|
2010-04-14 23:32:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_replace_before_transform (GstBaseTransform * trans, GstBuffer * buffer)
|
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "before_transform");
|
2010-04-14 23:32:34 +00:00
|
|
|
|
|
|
|
}
|
2013-02-06 20:35:36 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
/* transform */
|
2013-02-06 20:35:36 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_replace_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|
|
|
GstBuffer * outbuf)
|
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (replace, "transform");
|
2013-02-06 20:35:36 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
return GST_FLOW_OK;
|
2013-02-06 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_replace_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
|
|
|
{
|
2013-03-15 06:57:06 +00:00
|
|
|
GstReplace *replace = GST_REPLACE (trans);
|
2013-02-06 20:35:36 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
GST_DEBUG_OBJECT (replace, "transform_ip");
|
2013-02-06 20:35:36 +00:00
|
|
|
|
2013-03-15 06:57:06 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2010-04-14 23:32:34 +00:00
|
|
|
% end
|