From: Olivier CrĂȘte Date: Fri, 11 Jun 2010 00:14:01 +0000 (-0400) Subject: videomaxrate: Use basetransform correctly X-Git-Tag: 1.19.3~507^2~16776 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed74d385bc003a7fa7f1fa6a2631db7e53e745fe;p=platform%2Fupstream%2Fgstreamer.git videomaxrate: Use basetransform correctly --- diff --git a/gst/videomaxrate/videomaxrate.c b/gst/videomaxrate/videomaxrate.c index 2fc2cba159..7d56d151f6 100644 --- a/gst/videomaxrate/videomaxrate.c +++ b/gst/videomaxrate/videomaxrate.c @@ -44,7 +44,9 @@ static GstStaticPadTemplate gst_video_max_rate_sink_template = GST_STATIC_CAPS ("video/x-raw-yuv; video/x-raw-rgb") ); -static gboolean gst_video_max_rate_sink_event (GstPad * pad, GstEvent * event); +static gboolean gst_video_max_rate_start (GstBaseTransform * trans); +static gboolean gst_video_max_rate_sink_event (GstBaseTransform * trans, + GstEvent * event); static GstCaps *gst_video_max_rate_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps); static gboolean gst_video_max_rate_set_caps (GstBaseTransform * trans, @@ -81,42 +83,53 @@ gst_video_max_rate_class_init (GstVideoMaxRateClass * klass) base_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_max_rate_set_caps); base_class->transform_ip = GST_DEBUG_FUNCPTR (gst_video_max_rate_transform_ip); + base_class->event = GST_DEBUG_FUNCPTR (gst_video_max_rate_sink_event); + base_class->start = GST_DEBUG_FUNCPTR (gst_video_max_rate_start); } static void -gst_video_max_rate_init (GstVideoMaxRate * videomaxrate, - GstVideoMaxRateClass * gclass) +gst_video_max_rate_reset (GstVideoMaxRate * videomaxrate) { videomaxrate->last_ts = GST_CLOCK_TIME_NONE; videomaxrate->average = 0; +} + +static void +gst_video_max_rate_init (GstVideoMaxRate * videomaxrate, + GstVideoMaxRateClass * gclass) +{ + gst_video_max_rate_reset (videomaxrate); videomaxrate->wanted_diff = 0; gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (videomaxrate), TRUE); + gst_base_transform_set_in_place (GST_BASE_TRANSFORM (videomaxrate), TRUE); +} + +static gboolean +gst_video_max_rate_start (GstBaseTransform * trans) +{ + GstVideoMaxRate *videomaxrate = GST_VIDEO_MAX_RATE (trans); + + gst_video_max_rate_reset (videomaxrate); - gst_pad_set_event_function (GST_BASE_TRANSFORM_SINK_PAD (videomaxrate), - GST_DEBUG_FUNCPTR (gst_video_max_rate_sink_event)); + return TRUE; } gboolean -gst_video_max_rate_sink_event (GstPad * pad, GstEvent * event) +gst_video_max_rate_sink_event (GstBaseTransform * trans, GstEvent * event) { - GstVideoMaxRate *videomaxrate = GST_VIDEO_MAX_RATE (gst_pad_get_parent (pad)); - gboolean ret; + GstVideoMaxRate *videomaxrate = GST_VIDEO_MAX_RATE (trans); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_NEWSEGMENT: case GST_EVENT_FLUSH_STOP: - videomaxrate->last_ts = GST_CLOCK_TIME_NONE; - videomaxrate->average = 0; + gst_video_max_rate_reset (videomaxrate); break; default: break; } - ret = gst_pad_push_event (GST_BASE_TRANSFORM_SRC_PAD (videomaxrate), event); - - gst_object_unref (videomaxrate); - return ret; + return TRUE; } GstCaps * @@ -159,8 +172,8 @@ gst_video_max_rate_set_caps (GstBaseTransform * trans, GstCaps * incaps, denominator, numerator); else videomaxrate->wanted_diff = 0; - videomaxrate->last_ts = GST_CLOCK_TIME_NONE; - videomaxrate->average = 0; + + gst_video_max_rate_reset (videomaxrate); return TRUE; }