diff options
-rw-r--r-- | gst/smooth/gstsmooth.c | 47 | ||||
-rw-r--r-- | gst/smpte/gstsmpte.c | 83 | ||||
-rw-r--r-- | gst/smpte/gstsmpte.h | 2 | ||||
-rw-r--r-- | gst/speed/gstspeed.c | 104 | ||||
-rw-r--r-- | gst/vbidec/gstvbidec.c | 28 | ||||
-rw-r--r-- | gst/videocrop/gstvideocrop.c | 71 | ||||
-rw-r--r-- | gst/videodrop/gstvideodrop.c | 99 |
7 files changed, 173 insertions, 261 deletions
diff --git a/gst/smooth/gstsmooth.c b/gst/smooth/gstsmooth.c index 4455c74f..be41e88e 100644 --- a/gst/smooth/gstsmooth.c +++ b/gst/smooth/gstsmooth.c @@ -47,29 +47,25 @@ enum { ARG_LUM_ONLY }; -GST_PAD_TEMPLATE_FACTORY (smooth_src_factory, +static GstStaticPadTemplate gst_smooth_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "smooth_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); -GST_PAD_TEMPLATE_FACTORY (smooth_sink_factory, +static GstStaticPadTemplate gst_smooth_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "smooth_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); static void gst_smooth_class_init (GstSmoothClass *klass); static void gst_smooth_base_init (GstSmoothClass *klass); @@ -113,9 +109,9 @@ gst_smooth_base_init (GstSmoothClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smooth_sink_factory)); + gst_static_pad_template_get (&gst_smooth_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smooth_src_factory)); + gst_static_pad_template_get (&gst_smooth_src_template)); gst_element_class_set_details (element_class, &smooth_details); } @@ -146,17 +142,19 @@ gst_smooth_class_init (GstSmoothClass *klass) } static GstPadLinkReturn -gst_smooth_sinkconnect (GstPad *pad, GstCaps *caps) +gst_smooth_link (GstPad *pad, const GstCaps2 *caps) { GstSmooth *filter; + GstStructure *structure; + gboolean ret; filter = GST_SMOOTH (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + structure = gst_caps2_get_nth_cap (caps, 0); + ret = gst_structure_get_int (structure, "width", &filter->width); + ret &= gst_structure_get_int (structure, "height", &filter->height); - gst_caps_get_int (caps, "width", &filter->width); - gst_caps_get_int (caps, "height", &filter->height); + if (!ret) return GST_PAD_LINK_REFUSED; return gst_pad_try_set_caps (filter->srcpad, caps); } @@ -165,13 +163,14 @@ static void gst_smooth_init (GstSmooth *smooth) { smooth->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smooth_sink_factory), "sink"); - gst_pad_set_link_function (smooth->sinkpad, gst_smooth_sinkconnect); + gst_static_pad_template_get (&gst_smooth_sink_template), "sink"); + gst_pad_set_link_function (smooth->sinkpad, gst_smooth_link); gst_pad_set_chain_function (smooth->sinkpad, gst_smooth_chain); gst_element_add_pad (GST_ELEMENT (smooth), smooth->sinkpad); smooth->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smooth_src_factory), "src"); + gst_static_pad_template_get (&gst_smooth_sink_template), "src"); + gst_pad_set_link_function (smooth->srcpad, gst_smooth_link); gst_element_add_pad (GST_ELEMENT (smooth), smooth->srcpad); smooth->active = TRUE; diff --git a/gst/smpte/gstsmpte.c b/gst/smpte/gstsmpte.c index de485105..a318bdc3 100644 --- a/gst/smpte/gstsmpte.c +++ b/gst/smpte/gstsmpte.c @@ -33,41 +33,35 @@ static GstElementDetails smpte_details = { "Wim Taymans <wim.taymans@chello.be>" }; -GST_PAD_TEMPLATE_FACTORY (smpte_src_factory, +static GstStaticPadTemplate gst_smpte_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "smpte_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); -GST_PAD_TEMPLATE_FACTORY (smpte_sink1_factory, +static GstStaticPadTemplate gst_smpte_sink1_template = +GST_STATIC_PAD_TEMPLATE ( "sink1", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "smpte_sink1", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); -GST_PAD_TEMPLATE_FACTORY (smpte_sink2_factory, +static GstStaticPadTemplate gst_smpte_sink2_template = +GST_STATIC_PAD_TEMPLATE ( "sink2", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "smpte_sink2", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) + GST_STATIC_CAPS ( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("I420") ) -) +); /* SMPTE signals and args */ @@ -158,11 +152,11 @@ gst_smpte_base_init (GstSMPTEClass *klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smpte_sink1_factory)); + gst_static_pad_template_get(&gst_smpte_sink1_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smpte_sink2_factory)); + gst_static_pad_template_get(&gst_smpte_sink2_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (smpte_src_factory)); + gst_static_pad_template_get(&gst_smpte_src_template)); gst_element_class_set_details (element_class, &smpte_details); } @@ -236,40 +230,42 @@ gst_smpte_update_mask (GstSMPTE *smpte, gint type, gint depth, gint width, gint } static gboolean -gst_smpte_sinkconnect (GstPad *pad, GstCaps *caps) +gst_smpte_sinkconnect (GstPad *pad, const GstCaps2 *caps) { GstSMPTE *smpte; + GstStructure *structure; + gboolean ret; smpte = GST_SMPTE (gst_pad_get_parent (pad)); - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + structure = gst_caps2_get_nth_cap (caps, 0); - gst_caps_get_int (caps, "width", &smpte->width); - gst_caps_get_int (caps, "height", &smpte->height); - gst_caps_get_float (caps, "framerate", &smpte->fps); + ret = gst_structure_get_int (structure, "width", &smpte->width); + ret &= gst_structure_get_int (structure, "height", &smpte->height); + ret &= gst_structure_get_double (structure, "framerate", &smpte->fps); + if (!ret) return GST_PAD_LINK_REFUSED; gst_smpte_update_mask (smpte, smpte->type, smpte->depth, smpte->width, smpte->height); /* forward to the next plugin */ - return gst_pad_try_set_caps(smpte->srcpad, gst_caps_copy_1(caps)); + return gst_pad_try_set_caps(smpte->srcpad, caps); } static void gst_smpte_init (GstSMPTE *smpte) { smpte->sinkpad1 = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smpte_sink1_factory), "sink1"); + gst_static_pad_template_get(&gst_smpte_sink1_template), "sink1"); gst_pad_set_link_function (smpte->sinkpad1, gst_smpte_sinkconnect); gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad1); smpte->sinkpad2 = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smpte_sink2_factory), "sink2"); + gst_static_pad_template_get(&gst_smpte_sink2_template), "sink2"); gst_pad_set_link_function (smpte->sinkpad2, gst_smpte_sinkconnect); gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad2); smpte->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (smpte_src_factory), "src"); + gst_static_pad_template_get(&gst_smpte_src_template), "src"); gst_element_add_pad (GST_ELEMENT (smpte), smpte->srcpad); gst_element_set_loop_function (GST_ELEMENT (smpte), gst_smpte_loop); @@ -366,16 +362,15 @@ gst_smpte_loop (GstElement *element) outbuf = gst_buffer_new_and_alloc (smpte->width * smpte->height * 3); if (!GST_PAD_CAPS (smpte->srcpad)) { - if (!gst_pad_try_set_caps (smpte->srcpad, - GST_CAPS_NEW ( - "smpte_srccaps", - "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT (smpte->width), - "height", GST_PROPS_INT (smpte->height), - "framerate", GST_PROPS_FLOAT (smpte->fps) - ))) - { + GstCaps2 *caps; + caps = gst_caps2_copy (gst_static_caps2_get ( + &gst_smpte_src_template.static_caps)); + gst_caps2_set_simple (caps, + "width", G_TYPE_INT, smpte->width, + "height", G_TYPE_INT, smpte->height, + "framerate", G_TYPE_DOUBLE, smpte->fps, NULL); + + if (!gst_pad_try_set_caps (smpte->srcpad, caps)) { gst_element_error (element, "cannot set caps"); return; } diff --git a/gst/smpte/gstsmpte.h b/gst/smpte/gstsmpte.h index c51d4fbe..40844209 100644 --- a/gst/smpte/gstsmpte.h +++ b/gst/smpte/gstsmpte.h @@ -44,7 +44,7 @@ struct _GstSMPTE { gint format; gint width; gint height; - gfloat fps; + gdouble fps; gint duration; gint position; diff --git a/gst/speed/gstspeed.c b/gst/speed/gstspeed.c index a8894075..a8fa40f7 100644 --- a/gst/speed/gstspeed.c +++ b/gst/speed/gstspeed.c @@ -55,39 +55,27 @@ enum { ARG_SPEED }; -static GstPadTemplate* -speed_sink_factory (void) -{ - static GstPadTemplate *template = NULL; - - if (!template) { - template = gst_pad_template_new - ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS), - gst_caps_new ("sink_float", "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS)), - NULL); - } - return template; -} +static GstStaticPadTemplate gst_speed_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " + GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS + ) +); -static GstPadTemplate* -speed_src_factory (void) -{ - static GstPadTemplate *template = NULL; - - if (!template) - template = gst_pad_template_new - ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float", - GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS), - gst_caps_new ("src_int", "audio/x-raw-int", - GST_AUDIO_INT_PAD_TEMPLATE_PROPS)), - NULL); - - return template; -} +static GstStaticPadTemplate gst_speed_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( + GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; " + GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS + ) +); static GstBufferPool* speed_sink_get_bufferpool (GstPad *pad) @@ -106,7 +94,7 @@ static void speed_init (GstSpeed *filter); static void speed_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void speed_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static gboolean speed_parse_caps (GstSpeed *filter, GstCaps *caps); +static gboolean speed_parse_caps (GstSpeed *filter, const GstCaps2 *caps); static void speed_loop (GstElement *element); @@ -114,7 +102,7 @@ static GstElementClass *parent_class = NULL; /*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */ static GstPadLinkReturn -speed_link (GstPad *pad, GstCaps *caps) +speed_link (GstPad *pad, const GstCaps2 *caps) { GstSpeed *filter; GstPad *otherpad; @@ -124,41 +112,41 @@ speed_link (GstPad *pad, GstCaps *caps) g_return_val_if_fail (GST_IS_SPEED (filter), GST_PAD_LINK_REFUSED); otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad); - if (GST_CAPS_IS_FIXED (caps)) { - if (! speed_parse_caps (filter, caps)) return GST_PAD_LINK_REFUSED; + if (! speed_parse_caps (filter, caps)) return GST_PAD_LINK_REFUSED; - return gst_pad_try_set_caps(otherpad, caps); - } - - return GST_PAD_LINK_DELAYED; + return gst_pad_try_set_caps(otherpad, caps); } static gboolean -speed_parse_caps (GstSpeed *filter, GstCaps *caps) +speed_parse_caps (GstSpeed *filter, const GstCaps2 *caps) { const gchar *mimetype; + GstStructure *structure; + gboolean ret; g_return_val_if_fail(filter != NULL, FALSE); g_return_val_if_fail(caps != NULL, FALSE); - gst_caps_get_int (caps, "rate", &filter->rate); - gst_caps_get_int (caps, "channels", &filter->channels); - gst_caps_get_int (caps, "width", &filter->width); - gst_caps_get_int (caps, "endianness", &filter->endianness); - gst_caps_get_int (caps, "buffer-frames", &filter->buffer_frames); + structure = gst_caps2_get_nth_cap (caps, 0); + + ret = gst_structure_get_int (structure, "rate", &filter->rate); + ret &= gst_structure_get_int (structure, "channels", &filter->channels); + ret &= gst_structure_get_int (structure, "width", &filter->width); + ret &= gst_structure_get_int (structure, "endianness", &filter->endianness); + ret &= gst_structure_get_int (structure, "buffer-frames", &filter->buffer_frames); - mimetype = gst_caps_get_mime (caps); + mimetype = gst_structure_get_name (structure); - if (! strncmp(mimetype, "audio/x-raw-int", 15)) { + if (strcmp(mimetype, "audio/x-raw-int") == 0) { filter->format = GST_SPEED_FORMAT_INT; - gst_caps_get_int (caps, "depth", &filter->depth); - gst_caps_get_boolean (caps, "signed", &filter->is_signed); - } else if (! strncmp(mimetype, "audio/x-raw-float", 17)) { + ret &= gst_structure_get_int (structure, "depth", &filter->depth); + ret &= gst_structure_get_boolean (structure, "signed", &filter->is_signed); + } else if (strcmp(mimetype, "audio/x-raw-float") == 0) { filter->format = GST_SPEED_FORMAT_FLOAT; } else { return FALSE; } - return TRUE; + return ret; } @@ -190,8 +178,10 @@ speed_base_init (gpointer g_class) gst_element_class_set_details (element_class, &speed_details); - gst_element_class_add_pad_template (element_class, speed_src_factory ()); - gst_element_class_add_pad_template (element_class, speed_sink_factory ()); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_speed_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_speed_sink_template)); } static void speed_class_init (GstSpeedClass *klass) @@ -211,12 +201,14 @@ speed_class_init (GstSpeedClass *klass) static void speed_init (GstSpeed *filter) { - filter->sinkpad = gst_pad_new_from_template(speed_sink_factory (), "sink"); + filter->sinkpad = gst_pad_new_from_template( + gst_static_pad_template_get (&gst_speed_sink_template), "sink"); gst_pad_set_link_function(filter->sinkpad, speed_link); gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad); gst_pad_set_bufferpool_function (filter->sinkpad, speed_sink_get_bufferpool); - filter->srcpad = gst_pad_new_from_template(speed_src_factory (), "src"); + filter->srcpad = gst_pad_new_from_template( + gst_static_pad_template_get (&gst_speed_src_template), "src"); gst_pad_set_link_function(filter->srcpad, speed_link); gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad); diff --git a/gst/vbidec/gstvbidec.c b/gst/vbidec/gstvbidec.c index f3c68534..c5c0bd6d 100644 --- a/gst/vbidec/gstvbidec.c +++ b/gst/vbidec/gstvbidec.c @@ -82,26 +82,20 @@ enum { ARG_DVD_INPUT }; -GST_PAD_TEMPLATE_FACTORY (sink_template_factory, +static GstStaticPadTemplate gst_vbidec_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "vbidec_sink", - "application/octet-stream", - NULL - ) + GST_STATIC_CAPS2_ANY ); -GST_PAD_TEMPLATE_FACTORY (src_template_factory, +static GstStaticPadTemplate gst_vbidec_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "vbidec_src", - "text/plain", - NULL - ) + GST_STATIC_CAPS ( "text/plain" ) ); @@ -171,8 +165,10 @@ gst_vbidec_base_init (gpointer g_class) gst_element_class_set_details (element_class, &gst_vbidec_details); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_template_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_template_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_vbidec_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_vbidec_sink_template)); } static void gst_vbidec_class_init(GstVBIDecClass *klass) @@ -204,12 +200,12 @@ gst_vbidec_init (GstVBIDec *vbidec) { /* create the sink and src pads */ vbidec->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_template_factory), "sink"); + gst_static_pad_template_get (&gst_vbidec_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (vbidec), vbidec->sinkpad); gst_pad_set_chain_function (vbidec->sinkpad, GST_DEBUG_FUNCPTR (gst_vbidec_chain)); vbidec->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_template_factory), "src"); + gst_static_pad_template_get (&gst_vbidec_src_template), "src"); gst_element_add_pad (GST_ELEMENT (vbidec), vbidec->srcpad); vbidec->vbiscreen = vbiscreen_new(0, 0, 1.0, 0, (void *)vbidec); diff --git a/gst/videocrop/gstvideocrop.c b/gst/videocrop/gstvideocrop.c index d96a6c53..acb049cd 100644 --- a/gst/videocrop/gstvideocrop.c +++ b/gst/videocrop/gstvideocrop.c @@ -48,7 +48,7 @@ struct _GstVideoCrop { /* caps */ gint width, height; - gfloat fps; + gdouble fps; gint crop_left, crop_right, crop_top, crop_bottom; }; @@ -80,29 +80,21 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY (video_crop_src_template_factory, +static GstStaticPadTemplate gst_video_crop_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_new ( - "video_crop_src", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420")) +); -GST_PAD_TEMPLATE_FACTORY (video_crop_sink_template_factory, +static GstStaticPadTemplate gst_video_crop_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_new ( - "video_crop_sink", - "video/x-raw-yuv", - GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) - ) -) + GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420")) +); static void gst_video_crop_base_init (gpointer g_class); @@ -115,7 +107,7 @@ static void gst_video_crop_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static GstPadLinkReturn - gst_video_crop_sink_connect (GstPad *pad, GstCaps *caps); + gst_video_crop_sink_link (GstPad *pad, const GstCaps2 *caps); static void gst_video_crop_chain (GstPad *pad, GstData *_data); static GstElementStateReturn @@ -155,9 +147,9 @@ gst_video_crop_base_init (gpointer g_class) gst_element_class_set_details (element_class, &gst_video_crop_details); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (video_crop_sink_template_factory)); + gst_static_pad_template_get (&gst_video_crop_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (video_crop_src_template_factory)); + gst_static_pad_template_get (&gst_video_crop_src_template)); } static void gst_video_crop_class_init (GstVideoCropClass *klass) @@ -194,13 +186,13 @@ gst_video_crop_init (GstVideoCrop *video_crop) { /* create the sink and src pads */ video_crop->sinkpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET (video_crop_sink_template_factory), "sink"); + gst_static_pad_template_get (&gst_video_crop_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (video_crop), video_crop->sinkpad); - gst_pad_set_chain_function (video_crop->sinkpad, GST_DEBUG_FUNCPTR (gst_video_crop_chain)); - gst_pad_set_link_function (video_crop->sinkpad, GST_DEBUG_FUNCPTR (gst_video_crop_sink_connect)); + gst_pad_set_chain_function (video_crop->sinkpad, gst_video_crop_chain); + gst_pad_set_link_function (video_crop->sinkpad, gst_video_crop_sink_link); video_crop->srcpad = gst_pad_new_from_template( - GST_PAD_TEMPLATE_GET (video_crop_src_template_factory), "src"); + gst_static_pad_template_get (&gst_video_crop_src_template), "src"); gst_element_add_pad (GST_ELEMENT (video_crop), video_crop->srcpad); video_crop->crop_right = 0; @@ -270,19 +262,18 @@ gst_video_crop_get_property (GObject *object, guint prop_id, GValue *value, GPar } static GstPadLinkReturn -gst_video_crop_sink_connect (GstPad *pad, GstCaps *caps) +gst_video_crop_sink_link (GstPad *pad, const GstCaps2 *caps) { GstVideoCrop *video_crop; - - /* we are not going to act on variable caps */ - if (!GST_CAPS_IS_FIXED (caps)) - return GST_PAD_LINK_DELAYED; + GstStructure *structure; + gboolean ret; video_crop = GST_VIDEO_CROP (gst_pad_get_parent (pad)); + structure = gst_caps2_get_nth_cap (caps, 0); - gst_caps_get_int (caps, "width", &video_crop->width); - gst_caps_get_int (caps, "height", &video_crop->height); - gst_caps_get_float (caps, "framerate", &video_crop->fps); + ret = gst_structure_get_int (structure, "width", &video_crop->width); + ret &= gst_structure_get_int (structure, "height", &video_crop->height); + ret &= gst_structure_get_double (structure, "framerate", &video_crop->fps); return GST_PAD_LINK_OK; } @@ -380,22 +371,6 @@ gst_video_crop_chain (GstPad *pad, GstData *_data) new_height = video_crop->height - (video_crop->crop_top + video_crop->crop_bottom); - if (GST_PAD_CAPS (video_crop->srcpad) == NULL) { - if (gst_pad_try_set_caps (video_crop->srcpad, - GST_CAPS_NEW ( - "video_crop_caps", - "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - "width", GST_PROPS_INT (new_width), - "height", GST_PROPS_INT (new_height), - "framerate", GST_PROPS_FLOAT (video_crop->fps) - )) <= 0) - { - gst_element_error (GST_ELEMENT (video_crop), "could not negotiate pads"); - return; - } - } - outbuf = gst_buffer_new_and_alloc ((new_width * new_height * 3) / 2); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer); diff --git a/gst/videodrop/gstvideodrop.c b/gst/videodrop/gstvideodrop.c index 3de45574..bf837126 100644 --- a/gst/videodrop/gstvideodrop.c +++ b/gst/videodrop/gstvideodrop.c @@ -22,6 +22,7 @@ #endif #include <gstvideodrop.h> +#include <gst/video/video.h> /* elementfactory information */ static GstElementDetails videodrop_details = GST_ELEMENT_DETAILS ( @@ -42,45 +43,25 @@ enum { /* FILL ME */ }; -GST_PAD_TEMPLATE_FACTORY(src_template, +static GstStaticPadTemplate gst_videodrop_src_template = +GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW( - "framedropper_yuv", - "video/x-raw-yuv", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('U','Y','V','Y')) - ) + GST_STATIC_CAPS( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("{ YUY2, I420, YV12, YUYV, UYVY }") ) -) +); -GST_PAD_TEMPLATE_FACTORY(sink_template, +static GstStaticPadTemplate gst_videodrop_sink_template = +GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW( - "framedropper_yuv", - "video/x-raw-yuv", - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','V')), - GST_PROPS_FOURCC (GST_MAKE_FOURCC ('U','Y','V','Y')) - ) + GST_STATIC_CAPS( + GST_VIDEO_YUV_PAD_TEMPLATE_CAPS("{ YUY2, I420, YV12, YUYV, UYVY }") ) -) +); static void gst_videodrop_base_init (gpointer g_class); static void gst_videodrop_class_init (GstVideodropClass *klass); @@ -124,9 +105,9 @@ gst_videodrop_base_init (gpointer g_class) gst_element_class_set_details (element_class, &videodrop_details); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_template)); + gst_static_pad_template_get (&gst_videodrop_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_template)); + gst_static_pad_template_get (&gst_videodrop_src_template)); } static void gst_videodrop_class_init (GstVideodropClass *klass) @@ -140,52 +121,27 @@ gst_videodrop_class_init (GstVideodropClass *klass) min, max) static GstPadLinkReturn -gst_videodrop_link (GstPad *pad, GstCaps *caps) +gst_videodrop_link (GstPad *pad, const GstCaps2 *caps) { GstVideodrop *videodrop; - GstPadLinkReturn ret; - GstCaps *peercaps; + GstStructure *structure; + gboolean ret; + double fps; videodrop = GST_VIDEODROP (gst_pad_get_parent (pad)); - videodrop->inited = FALSE; - - if (!GST_CAPS_IS_FIXED (caps)) { - return GST_PAD_LINK_DELAYED; - } + structure = gst_caps2_get_nth_cap (caps, 0); + ret = gst_structure_get_double (structure, "framerate", &fps); - gst_caps_get_float (caps, "framerate", &videodrop->from_fps); + if (!ret) return GST_PAD_LINK_REFUSED; - /* calc output fps */ - peercaps = gst_pad_get_allowed_caps (videodrop->srcpad); - if (gst_caps_has_fixed_property (peercaps, "framerate")) { - gst_caps_get_float (peercaps, "framerate", &videodrop->to_fps); + if (pad == videodrop->srcpad) { + videodrop->to_fps = fps; } else { - gfloat min, max; - gst_caps_get_float_range (peercaps, "framerate", &min, &max); - if (videodrop->from_fps >= min && - videodrop->from_fps <= max) { - videodrop->to_fps = videodrop->from_fps; - } else { - videodrop->to_fps = max; - } - } - gst_caps_unref (peercaps); - - GST_DEBUG ("%f -> %f fps", - videodrop->from_fps, videodrop->to_fps); - - peercaps = gst_caps_copy (caps); - - peercaps->properties = gst_caps_set (peercaps, "framerate", - GST_PROPS_FLOAT (videodrop->to_fps)); - - if ((ret = gst_pad_try_set_caps (videodrop->srcpad, peercaps)) > 0) { - videodrop->inited = TRUE; - videodrop->total = videodrop->pass = 0; + videodrop->from_fps = fps; } - return ret; + return GST_PAD_LINK_OK; } static void @@ -193,16 +149,15 @@ gst_videodrop_init (GstVideodrop *videodrop) { GST_DEBUG ("gst_videodrop_init"); videodrop->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (sink_template), - "sink"); + gst_static_pad_template_get (&gst_videodrop_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (videodrop), videodrop->sinkpad); gst_pad_set_chain_function (videodrop->sinkpad, gst_videodrop_chain); gst_pad_set_link_function (videodrop->sinkpad, gst_videodrop_link); videodrop->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (src_template), - "src"); + gst_static_pad_template_get (&gst_videodrop_src_template), "src"); gst_element_add_pad (GST_ELEMENT(videodrop), videodrop->srcpad); + gst_pad_set_link_function (videodrop->srcpad, gst_videodrop_link); videodrop->inited = FALSE; videodrop->total = videodrop->pass = 0; |