diff options
Diffstat (limited to 'gst/videoflip')
-rw-r--r-- | gst/videoflip/gstvideoflip.c | 166 | ||||
-rw-r--r-- | gst/videoflip/videoflip.c | 36 | ||||
-rw-r--r-- | gst/videoflip/videoflip.h | 4 |
3 files changed, 77 insertions, 129 deletions
diff --git a/gst/videoflip/gstvideoflip.c b/gst/videoflip/gstvideoflip.c index 7d65cac5..0f20f47b 100644 --- a/gst/videoflip/gstvideoflip.c +++ b/gst/videoflip/gstvideoflip.c @@ -57,6 +57,7 @@ static void gst_videoflip_get_property (GObject *object, guint prop_id, GValue static void gst_videoflip_chain (GstPad *pad, GstData *_data); static GstCaps * gst_videoflip_get_capslist(void); + static GstElementClass *parent_class = NULL; #define GST_TYPE_VIDEOFLIP_METHOD (gst_videoflip_method_get_type()) @@ -86,38 +87,28 @@ gst_videoflip_method_get_type(void) static GstPadTemplate * gst_videoflip_src_template_factory(void) { - static GstPadTemplate *templ = NULL; - - if(!templ){ - /* well, actually RGB too, but since there's no RGB format anyway */ - GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv", - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); + /* well, actually RGB too, but since there's no RGB format anyway */ + GstCaps *caps = gst_caps_from_string ("video/x-raw-yuv, " + "width = (int) [ 0, MAX ], " + "height = (int) [ 0, MAX ], " + "framerate = (double) [ 0, MAX ]"); - caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ()); + caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ()); - templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps); - } - return templ; + return gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps); } static GstPadTemplate * gst_videoflip_sink_template_factory(void) { - static GstPadTemplate *templ = NULL; - - if(!templ){ - GstCaps *caps = GST_CAPS_NEW("sink","video/x-raw-yuv", - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); + GstCaps *caps = gst_caps_from_string ("video/x-raw-yuv, " + "width = (int) [ 0, MAX ], " + "height = (int) [ 0, MAX ], " + "framerate = (double) [ 0, MAX ]"); - caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ()); + caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ()); - templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps); - } - return templ; + return gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps); } GType @@ -149,8 +140,10 @@ gst_videoflip_base_init (gpointer g_class) gst_element_class_set_details (element_class, &videoflip_details); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (gst_videoflip_sink_template_factory)); - gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (gst_videoflip_src_template_factory)); + gst_element_class_add_pad_template (element_class, + gst_videoflip_sink_template_factory ()); + gst_element_class_add_pad_template (element_class, + gst_videoflip_src_template_factory ()); } static void gst_videoflip_class_init (GstVideoflipClass *klass) @@ -176,34 +169,30 @@ gst_videoflip_class_init (GstVideoflipClass *klass) static GstCaps * gst_videoflip_get_capslist(void) { - static GstCaps *capslist = NULL; GstCaps *caps; + GstStructure *structure; int i; - if (capslist){ - gst_caps_ref(capslist); - return capslist; - } - + caps = gst_caps_new_empty (); for(i=0;i<videoflip_n_formats;i++){ - caps = videoflip_get_caps(videoflip_formats + i); - capslist = gst_caps_append(capslist, caps); + structure = videoflip_get_cap (videoflip_formats + i); + gst_caps_append_structure (caps, structure); } - gst_caps_ref(capslist); - return capslist; + return caps; } static GstCaps * -gst_videoflip_sink_getcaps (GstPad *pad, GstCaps *caps) +gst_videoflip_sink_getcaps (GstPad *pad) { GstVideoflip *videoflip; GstCaps *capslist = NULL; GstCaps *peercaps; GstCaps *sizecaps; + GstCaps *caps; int i; - GST_DEBUG ("gst_videoflip_src_link"); + GST_DEBUG ("gst_videoflip_sink_getcaps"); videoflip = GST_VIDEOFLIP (gst_pad_get_parent (pad)); /* get list of peer's caps */ @@ -218,111 +207,70 @@ gst_videoflip_sink_getcaps (GstPad *pad, GstCaps *caps) /* Look through our list of caps and find those that match with * the peer's formats. Create a list of them. */ for(i=0;i<videoflip_n_formats;i++){ - GstCaps *fromcaps = videoflip_get_caps(videoflip_formats + i); + GstCaps *fromcaps = gst_caps_new_full(videoflip_get_cap( + videoflip_formats + i), NULL); if(gst_caps_is_always_compatible(fromcaps, peercaps)){ - capslist = gst_caps_append(capslist, fromcaps); + gst_caps_append(capslist, fromcaps); } - gst_caps_unref (fromcaps); } - gst_caps_unref (peercaps); + gst_caps_free (peercaps); - sizecaps = GST_CAPS_NEW("videoflip_size","video/x-raw-yuv", - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT), - "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)); + sizecaps = gst_caps_from_string ("video/x-raw-yuv, " + "width = (int) [ 0, MAX ], " + "height = (int) [ 0, MAX ], " + "framerate = (double) [ 0, MAX ]"); - caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ()); - gst_caps_unref (sizecaps); + caps = gst_caps_intersect(capslist, sizecaps); + gst_caps_free (sizecaps); return caps; } static GstPadLinkReturn -gst_videoflip_src_link (GstPad *pad, GstCaps *caps) +gst_videoflip_src_link (GstPad *pad, const GstCaps *caps) { GstVideoflip *videoflip; - GstPadLinkReturn ret; - GstCaps *peercaps; + GstStructure *structure; + gboolean ret; GST_DEBUG ("gst_videoflip_src_link"); videoflip = GST_VIDEOFLIP (gst_pad_get_parent (pad)); - - if (!GST_CAPS_IS_FIXED (caps)) { - return GST_PAD_LINK_DELAYED; - } - - gst_caps_debug(caps,"ack"); + + structure = gst_caps_get_structure (caps, 0); videoflip->format = videoflip_find_by_caps (caps); g_return_val_if_fail(videoflip->format, GST_PAD_LINK_REFUSED); - gst_caps_get_int (caps, "width", &videoflip->to_width); - gst_caps_get_int (caps, "height", &videoflip->to_height); - - GST_DEBUG ("width %d height %d",videoflip->to_width,videoflip->to_height); + ret = gst_structure_get_int (structure, "width", &videoflip->to_width); + ret &= gst_structure_get_int (structure, "height", &videoflip->to_height); - peercaps = gst_caps_copy(caps); + if (!ret) return GST_PAD_LINK_REFUSED; - gst_caps_set(peercaps, "width", GST_PROPS_INT_RANGE (0, G_MAXINT)); - gst_caps_set(peercaps, "height", GST_PROPS_INT_RANGE (0, G_MAXINT)); - - ret = gst_pad_try_set_caps (videoflip->srcpad, peercaps); - - gst_caps_unref(peercaps); - - if(ret==GST_PAD_LINK_OK){ - caps = gst_pad_get_caps (videoflip->srcpad); - - gst_caps_get_int (caps, "width", &videoflip->from_width); - gst_caps_get_int (caps, "height", &videoflip->from_height); - gst_videoflip_setup(videoflip); - } - - return ret; + return GST_PAD_LINK_OK; } static GstPadLinkReturn -gst_videoflip_sink_link (GstPad *pad, GstCaps *caps) +gst_videoflip_sink_link (GstPad *pad, const GstCaps *caps) { GstVideoflip *videoflip; - GstPadLinkReturn ret; - GstCaps *peercaps; + GstStructure *structure; + gboolean ret; - GST_DEBUG ("gst_videoflip_src_link"); + GST_DEBUG ("gst_videoflip_sink_link"); videoflip = GST_VIDEOFLIP (gst_pad_get_parent (pad)); - - if (!GST_CAPS_IS_FIXED (caps)) { - return GST_PAD_LINK_DELAYED; - } + + structure = gst_caps_get_structure (caps, 0); videoflip->format = videoflip_find_by_caps (caps); - gst_caps_debug(caps,"ack"); g_return_val_if_fail(videoflip->format, GST_PAD_LINK_REFUSED); - gst_caps_get_int (caps, "width", &videoflip->from_width); - gst_caps_get_int (caps, "height", &videoflip->from_height); - - gst_videoflip_setup(videoflip); - - peercaps = gst_caps_copy(caps); - - gst_caps_set(peercaps, "width", GST_PROPS_INT (videoflip->to_width)); - gst_caps_set(peercaps, "height", GST_PROPS_INT (videoflip->to_height)); + ret = gst_structure_get_int (structure, "width", &videoflip->from_width); + ret &= gst_structure_get_int (structure, "height", &videoflip->from_height); - ret = gst_pad_try_set_caps (videoflip->srcpad, peercaps); - - gst_caps_unref(peercaps); - - if(ret==GST_PAD_LINK_OK){ - caps = gst_pad_get_caps (videoflip->srcpad); - - gst_caps_get_int (caps, "width", &videoflip->to_width); - gst_caps_get_int (caps, "height", &videoflip->to_height); - gst_videoflip_setup(videoflip); - } + if (!ret) return GST_PAD_LINK_REFUSED; - return ret; + return GST_PAD_LINK_OK; } static void @@ -330,7 +278,7 @@ gst_videoflip_init (GstVideoflip *videoflip) { GST_DEBUG ("gst_videoflip_init"); videoflip->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (gst_videoflip_sink_template_factory), + gst_videoflip_sink_template_factory(), "sink"); gst_element_add_pad(GST_ELEMENT(videoflip),videoflip->sinkpad); gst_pad_set_chain_function(videoflip->sinkpad,gst_videoflip_chain); @@ -338,7 +286,7 @@ gst_videoflip_init (GstVideoflip *videoflip) gst_pad_set_getcaps_function(videoflip->sinkpad,gst_videoflip_sink_getcaps); videoflip->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (gst_videoflip_src_template_factory), + gst_videoflip_src_template_factory(), "src"); gst_element_add_pad(GST_ELEMENT(videoflip),videoflip->srcpad); gst_pad_set_link_function(videoflip->srcpad,gst_videoflip_src_link); diff --git a/gst/videoflip/videoflip.c b/gst/videoflip/videoflip.c index f108ea62..7956165d 100644 --- a/gst/videoflip/videoflip.c +++ b/gst/videoflip/videoflip.c @@ -43,11 +43,11 @@ struct videoflip_format_struct videoflip_formats[] = { int videoflip_n_formats = sizeof(videoflip_formats)/sizeof(videoflip_formats[0]); -GstCaps * -videoflip_get_caps(struct videoflip_format_struct *format) +GstStructure * +videoflip_get_cap(struct videoflip_format_struct *format) { unsigned int fourcc; - GstCaps *caps; + GstStructure *structure; if(format->scale==NULL) return NULL; @@ -55,40 +55,40 @@ videoflip_get_caps(struct videoflip_format_struct *format) fourcc = GST_MAKE_FOURCC(format->fourcc[0],format->fourcc[1],format->fourcc[2],format->fourcc[3]); if(format->bpp){ - caps = GST_CAPS_NEW ("videoflip", "video/x-raw-rgb", - "depth", GST_PROPS_INT(format->bpp), - "bpp", GST_PROPS_INT(format->depth), - "endianness", GST_PROPS_INT(format->endianness), - "red_mask", GST_PROPS_INT(format->red_mask), - "green_mask", GST_PROPS_INT(format->green_mask), - "blue_mask", GST_PROPS_INT(format->blue_mask)); + structure = gst_structure_new("video/x-raw-rgb", + "depth", G_TYPE_INT, format->bpp, + "bpp", G_TYPE_INT, format->depth, + "endianness", G_TYPE_INT, format->endianness, + "red_mask", G_TYPE_INT, format->red_mask, + "green_mask", G_TYPE_INT, format->green_mask, + "blue_mask", G_TYPE_INT, format->blue_mask, NULL); }else{ - caps = GST_CAPS_NEW ("videoflip", "video/x-raw-yuv", - "format", GST_PROPS_FOURCC (fourcc)); + structure = gst_structure_new("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, fourcc, NULL); } - return caps; + return structure; } struct videoflip_format_struct * -videoflip_find_by_caps(GstCaps *caps) +videoflip_find_by_caps(const GstCaps *caps) { int i; - GST_DEBUG ("finding %p",caps); + GST_DEBUG ("finding %p", caps); g_return_val_if_fail(caps != NULL, NULL); for (i = 0; i < videoflip_n_formats; i++){ GstCaps *c; - c = videoflip_get_caps(videoflip_formats + i); + c = gst_caps_new_full (videoflip_get_cap (videoflip_formats + i), NULL); if(c){ if(gst_caps_is_always_compatible(caps, c)){ - gst_caps_unref(c); + gst_caps_free(c); return videoflip_formats + i; } - gst_caps_unref(c); + gst_caps_free(c); } } diff --git a/gst/videoflip/videoflip.h b/gst/videoflip/videoflip.h index e61cbffe..e912fe98 100644 --- a/gst/videoflip/videoflip.h +++ b/gst/videoflip/videoflip.h @@ -37,9 +37,9 @@ struct videoflip_format_struct { extern struct videoflip_format_struct videoflip_formats[]; extern int videoflip_n_formats; -GstCaps *videoflip_get_caps(struct videoflip_format_struct *format); +GstStructure *videoflip_get_cap(struct videoflip_format_struct *format); -struct videoflip_format_struct *videoflip_find_by_caps(GstCaps *caps); +struct videoflip_format_struct *videoflip_find_by_caps(const GstCaps *caps); #endif |