add parent to pad functions

This commit is contained in:
Wim Taymans 2011-11-17 12:49:33 +01:00
parent 319de2e96a
commit 152e090891
6 changed files with 60 additions and 67 deletions

View file

@ -228,10 +228,13 @@ static void gst_ffmpegdec_finalize (GObject * object);
static gboolean gst_ffmpegdec_src_query (GstPad * pad, GstObject * parent,
GstQuery * query);
static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstObject * parent,
GstEvent * event);
static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event);
static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstBuffer * buf);
static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event);
static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstObject * parent,
GstBuffer * buf);
static GstStateChangeReturn gst_ffmpegdec_change_state (GstElement * element,
GstStateChange transition);
@ -539,12 +542,12 @@ gst_ffmpegdec_read_qos (GstFFMpegDec * ffmpegdec, gdouble * proportion,
}
static gboolean
gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event)
gst_ffmpegdec_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstFFMpegDec *ffmpegdec;
gboolean res;
ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
ffmpegdec = (GstFFMpegDec *) parent;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_QOS:
@ -569,8 +572,6 @@ gst_ffmpegdec_src_event (GstPad * pad, GstEvent * event)
break;
}
gst_object_unref (ffmpegdec);
return res;
}
@ -2475,12 +2476,12 @@ gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
}
static gboolean
gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event)
gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstFFMpegDec *ffmpegdec;
gboolean ret = FALSE;
ffmpegdec = (GstFFMpegDec *) gst_pad_get_parent (pad);
ffmpegdec = (GstFFMpegDec *) parent;
GST_DEBUG_OBJECT (ffmpegdec, "Handling %s event",
GST_EVENT_TYPE_NAME (event));
@ -2584,7 +2585,6 @@ gst_ffmpegdec_sink_event (GstPad * pad, GstEvent * event)
ret = gst_pad_push_event (ffmpegdec->srcpad, event);
done:
gst_object_unref (ffmpegdec);
return ret;
@ -2604,7 +2604,7 @@ invalid_format:
}
static GstFlowReturn
gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
{
GstFFMpegDec *ffmpegdec;
GstFFMpegDecClass *oclass;
@ -2620,7 +2620,7 @@ gst_ffmpegdec_chain (GstPad * pad, GstBuffer * inbuf)
const GstTSInfo *in_info;
const GstTSInfo *dec_info;
ffmpegdec = (GstFFMpegDec *) (GST_PAD_PARENT (pad));
ffmpegdec = (GstFFMpegDec *) parent;
if (G_UNLIKELY (!ffmpegdec->opened))
goto not_negotiated;

View file

@ -137,7 +137,7 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
G_DEFINE_TYPE (GstFFMpegDeinterlace, gst_ffmpegdeinterlace, GST_TYPE_ELEMENT);
static GstFlowReturn gst_ffmpegdeinterlace_chain (GstPad * pad,
GstBuffer * inbuf);
GstObject * parent, GstBuffer * inbuf);
static void
gst_ffmpegdeinterlace_class_init (GstFFMpegDeinterlaceClass * klass)
@ -230,10 +230,10 @@ gst_ffmpegdeinterlace_sink_setcaps (GstPad * pad, GstCaps * caps)
}
static gboolean
gst_ffmpegdeinterlace_sink_event (GstPad * pad, GstEvent * event)
gst_ffmpegdeinterlace_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event)
{
GstFFMpegDeinterlace *deinterlace =
GST_FFMPEGDEINTERLACE (gst_pad_get_parent (pad));
GstFFMpegDeinterlace *deinterlace = GST_FFMPEGDEINTERLACE (parent);
gboolean ret = FALSE;
switch (GST_EVENT_TYPE (event)) {
@ -251,8 +251,6 @@ gst_ffmpegdeinterlace_sink_event (GstPad * pad, GstEvent * event)
break;
}
gst_object_unref (deinterlace);
return ret;
}
@ -280,10 +278,10 @@ gst_ffmpegdeinterlace_init (GstFFMpegDeinterlace * deinterlace)
}
static GstFlowReturn
gst_ffmpegdeinterlace_chain (GstPad * pad, GstBuffer * inbuf)
gst_ffmpegdeinterlace_chain (GstPad * pad, GstObject * parent,
GstBuffer * inbuf)
{
GstFFMpegDeinterlace *deinterlace =
GST_FFMPEGDEINTERLACE (gst_pad_get_parent (pad));
GstFFMpegDeinterlace *deinterlace = GST_FFMPEGDEINTERLACE (parent);
GstBuffer *outbuf = NULL;
GstFlowReturn result;
guint8 *from_data, *to_data;

View file

@ -120,8 +120,10 @@ static void gst_ffmpegdemux_base_init (GstFFMpegDemuxClass * klass);
static void gst_ffmpegdemux_init (GstFFMpegDemux * demux);
static void gst_ffmpegdemux_finalize (GObject * object);
static gboolean gst_ffmpegdemux_sink_event (GstPad * sinkpad, GstEvent * event);
static GstFlowReturn gst_ffmpegdemux_chain (GstPad * sinkpad, GstBuffer * buf);
static gboolean gst_ffmpegdemux_sink_event (GstPad * sinkpad,
GstObject * parent, GstEvent * event);
static GstFlowReturn gst_ffmpegdemux_chain (GstPad * sinkpad,
GstObject * parent, GstBuffer * buf);
static void gst_ffmpegdemux_loop (GstFFMpegDemux * demux);
static gboolean gst_ffmpegdemux_sink_activate (GstPad * sinkpad);
@ -649,7 +651,7 @@ no_format:
}
static gboolean
gst_ffmpegdemux_src_event (GstPad * pad, GstEvent * event)
gst_ffmpegdemux_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstFFMpegDemux *demux;
GstFFStream *stream;
@ -658,7 +660,7 @@ gst_ffmpegdemux_src_event (GstPad * pad, GstEvent * event)
if (!(stream = gst_pad_get_element_private (pad)))
return FALSE;
demux = (GstFFMpegDemux *) gst_pad_get_parent (pad);
demux = (GstFFMpegDemux *) parent;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
@ -676,8 +678,6 @@ gst_ffmpegdemux_src_event (GstPad * pad, GstEvent * event)
break;
}
gst_object_unref (demux);
return res;
}
@ -1548,13 +1548,14 @@ no_buffer:
static gboolean
gst_ffmpegdemux_sink_event (GstPad * sinkpad, GstEvent * event)
gst_ffmpegdemux_sink_event (GstPad * sinkpad, GstObject * parent,
GstEvent * event)
{
GstFFMpegDemux *demux;
GstFFMpegPipe *ffpipe;
gboolean result = TRUE;
demux = (GstFFMpegDemux *) (GST_PAD_PARENT (sinkpad));
demux = (GstFFMpegDemux *) parent;
ffpipe = &(demux->ffpipe);
GST_LOG_OBJECT (demux, "event: %" GST_PTR_FORMAT, event);
@ -1562,7 +1563,7 @@ gst_ffmpegdemux_sink_event (GstPad * sinkpad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
/* forward event */
gst_pad_event_default (sinkpad, event);
gst_pad_event_default (sinkpad, parent, event);
/* now unblock the chain function */
GST_FFMPEG_PIPE_MUTEX_LOCK (ffpipe);
@ -1577,7 +1578,7 @@ gst_ffmpegdemux_sink_event (GstPad * sinkpad, GstEvent * event)
goto done;
case GST_EVENT_FLUSH_STOP:
/* forward event */
gst_pad_event_default (sinkpad, event);
gst_pad_event_default (sinkpad, parent, event);
GST_OBJECT_LOCK (demux);
g_list_foreach (demux->cached_events, (GFunc) gst_mini_object_unref,
@ -1626,7 +1627,7 @@ gst_ffmpegdemux_sink_event (GstPad * sinkpad, GstEvent * event)
break;
}
result = gst_pad_event_default (sinkpad, event);
result = gst_pad_event_default (sinkpad, parent, event);
done:
@ -1634,12 +1635,12 @@ done:
}
static GstFlowReturn
gst_ffmpegdemux_chain (GstPad * sinkpad, GstBuffer * buffer)
gst_ffmpegdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * buffer)
{
GstFFMpegDemux *demux;
GstFFMpegPipe *ffpipe;
demux = (GstFFMpegDemux *) (GST_PAD_PARENT (sinkpad));
demux = (GstFFMpegDemux *) parent;
ffpipe = &demux->ffpipe;
GST_FFMPEG_PIPE_MUTEX_LOCK (ffpipe);

View file

@ -100,11 +100,13 @@ static gboolean gst_ffmpegenc_setcaps (GstFFMpegEnc * ffmpegenc,
GstCaps * caps);
static GstCaps *gst_ffmpegenc_getcaps (GstPad * pad, GstCaps * filter);
static GstFlowReturn gst_ffmpegenc_chain_video (GstPad * pad,
GstBuffer * buffer);
GstObject * parent, GstBuffer * buffer);
static GstFlowReturn gst_ffmpegenc_chain_audio (GstPad * pad,
GstBuffer * buffer);
static gboolean gst_ffmpegenc_event_sink (GstPad * pad, GstEvent * event);
static gboolean gst_ffmpegenc_event_src (GstPad * pad, GstEvent * event);
GstObject * parent, GstBuffer * buffer);
static gboolean gst_ffmpegenc_event_sink (GstPad * pad, GstObject * parent,
GstEvent * event);
static gboolean gst_ffmpegenc_event_src (GstPad * pad, GstObject * parent,
GstEvent * event);
static gboolean gst_ffmpegenc_query_sink (GstPad * pad, GstObject * parent,
GstQuery * query);
@ -771,9 +773,9 @@ ffmpegenc_setup_working_buf (GstFFMpegEnc * ffmpegenc)
}
static GstFlowReturn
gst_ffmpegenc_chain_video (GstPad * pad, GstBuffer * inbuf)
gst_ffmpegenc_chain_video (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
{
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (GST_PAD_PARENT (pad));
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) parent;
GstBuffer *outbuf;
guint8 *data;
gsize size;
@ -923,7 +925,7 @@ gst_ffmpegenc_encode_audio (GstFFMpegEnc * ffmpegenc, guint8 * audio_in,
}
static GstFlowReturn
gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer * inbuf)
gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
{
GstFFMpegEnc *ffmpegenc;
GstFFMpegEncClass *oclass;
@ -936,7 +938,7 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer * inbuf)
gboolean discont;
guint8 *in_data;
ffmpegenc = (GstFFMpegEnc *) (GST_OBJECT_PARENT (pad));
ffmpegenc = (GstFFMpegEnc *) parent;
oclass = (GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
if (G_UNLIKELY (!ffmpegenc->opened))
@ -1166,9 +1168,9 @@ flush:
}
static gboolean
gst_ffmpegenc_event_sink (GstPad * pad, GstEvent * event)
gst_ffmpegenc_event_sink (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (GST_PAD_PARENT (pad));
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) parent;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
@ -1204,9 +1206,9 @@ gst_ffmpegenc_event_sink (GstPad * pad, GstEvent * event)
}
static gboolean
gst_ffmpegenc_event_src (GstPad * pad, GstEvent * event)
gst_ffmpegenc_event_src (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (GST_PAD_PARENT (pad));
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) parent;
gboolean forward = TRUE;
switch (GST_EVENT_TYPE (event)) {

View file

@ -117,7 +117,8 @@ static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
gpointer user_data);
static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event);
static gboolean gst_ffmpegmux_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event);
static GstStateChangeReturn gst_ffmpegmux_change_state (GstElement * element,
GstStateChange transition);
@ -508,9 +509,9 @@ not_accepted:
static gboolean
gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
gst_ffmpegmux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) gst_pad_get_parent (pad);
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) parent;
gboolean res = TRUE;
switch (GST_EVENT_TYPE (event)) {
@ -535,10 +536,9 @@ gst_ffmpegmux_sink_event (GstPad * pad, GstEvent * event)
}
/* chaining up to collectpads default event function */
res = ffmpegmux->event_function (pad, event);
res = ffmpegmux->event_function (pad, parent, event);
beach:
gst_object_unref (ffmpegmux);
return res;
}

View file

@ -171,7 +171,7 @@ static gboolean gst_ffmpegscale_set_caps (GstBaseTransform * trans,
static GstFlowReturn gst_ffmpegscale_transform (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer * outbuf);
static gboolean gst_ffmpegscale_handle_src_event (GstPad * pad,
static gboolean gst_ffmpegscale_src_event (GstBaseTransform * trans,
GstEvent * event);
static void
@ -208,6 +208,7 @@ gst_ffmpegscale_class_init (GstFFMpegScaleClass * klass)
GST_DEBUG_FUNCPTR (gst_ffmpegscale_get_unit_size);
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_ffmpegscale_set_caps);
trans_class->transform = GST_DEBUG_FUNCPTR (gst_ffmpegscale_transform);
trans_class->src_event = GST_DEBUG_FUNCPTR (gst_ffmpegscale_src_event);
trans_class->passthrough_on_same_caps = TRUE;
}
@ -215,10 +216,6 @@ gst_ffmpegscale_class_init (GstFFMpegScaleClass * klass)
static void
gst_ffmpegscale_init (GstFFMpegScale * scale)
{
GstBaseTransform *trans = GST_BASE_TRANSFORM (scale);
gst_pad_set_event_function (trans->srcpad, gst_ffmpegscale_handle_src_event);
scale->method = DEFAULT_PROP_METHOD;
scale->ctx = NULL;
scale->in_pixfmt = PIX_FMT_NONE;
@ -649,21 +646,20 @@ invalid_buffer:
}
static gboolean
gst_ffmpegscale_handle_src_event (GstPad * pad, GstEvent * event)
gst_ffmpegscale_src_event (GstBaseTransform * trans, GstEvent * event)
{
GstFFMpegScale *scale;
GstStructure *structure;
gdouble pointer;
gboolean res;
scale = GST_FFMPEGSCALE (gst_pad_get_parent (pad));
scale = GST_FFMPEGSCALE (trans);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:
event =
GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event)));
event = gst_event_make_writable (event);
structure = (GstStructure *) gst_event_get_structure (event);
structure = gst_event_writable_structure (event);
if (gst_structure_get_double (structure, "pointer_x", &pointer)) {
gst_structure_set (structure,
"pointer_x", G_TYPE_DOUBLE,
@ -679,9 +675,7 @@ gst_ffmpegscale_handle_src_event (GstPad * pad, GstEvent * event)
break;
}
res = gst_pad_event_default (pad, event);
gst_object_unref (scale);
res = GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans, event);
return res;
}
@ -777,9 +771,7 @@ plugin_init (GstPlugin * plugin)
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"ffvideoscale",
"videoscaling element (" FFMPEG_SOURCE ")",
plugin_init,
PACKAGE_VERSION,
"videoscaling element (" FFMPEG_SOURCE ")", plugin_init, PACKAGE_VERSION,
#ifdef GST_FFMPEG_ENABLE_LGPL
"LGPL",
#else