diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2013-12-02 17:01:36 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2013-12-02 17:02:17 +0100 |
commit | 4b7bead2d41fdf3ed4786dd3ea865541ce219f51 (patch) | |
tree | d567824ccc79e776b9ebef734be94a4ecb0a85d1 | |
parent | 1ba3edf682c9c7a40833e60600baf6f82bdb0f96 (diff) | |
download | gstreamer-plugins-bad-4b7bead2d41fdf3ed4786dd3ea865541ce219f51.tar.gz |
openni2src: Use GstVideoInfo to create caps and don't leak them
-rw-r--r-- | ext/openni2/gstopenni2src.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/ext/openni2/gstopenni2src.cpp b/ext/openni2/gstopenni2src.cpp index f8ad4415a..6bfbead25 100644 --- a/ext/openni2/gstopenni2src.cpp +++ b/ext/openni2/gstopenni2src.cpp @@ -305,6 +305,8 @@ gst_openni2_src_get_caps (GstBaseSrc * src, GstCaps * filter) { GstOpenni2Src *ni2src; GstCaps *caps; + GstVideoInfo info; + GstVideoFormat format; ni2src = GST_OPENNI2_SRC (src); @@ -317,35 +319,25 @@ gst_openni2_src_get_caps (GstBaseSrc * src, GstCaps * filter) : gst_caps_ref (ni2src->gst_caps); } // If we are here, we need to compose the caps and return them. - caps = gst_caps_new_empty (); if (ni2src->colorpixfmt != openni::PIXEL_FORMAT_RGB888) - return caps; /* Uh oh, not RGB :? Not supported. */ + return gst_caps_new_empty (); /* Uh oh, not RGB :? Not supported. */ if (ni2src->depth.isValid () && ni2src->color.isValid () && ni2src->sourcetype == SOURCETYPE_BOTH) { - caps = gst_caps_new_simple ("video/x-raw", - "format", G_TYPE_STRING, "RGBA", - "framerate", GST_TYPE_FRACTION, ni2src->fps, 1, - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - "width", G_TYPE_INT, ni2src->width, - "height", G_TYPE_INT, ni2src->height, NULL); + format = GST_VIDEO_FORMAT_RGBA; } else if (ni2src->depth.isValid () && ni2src->sourcetype == SOURCETYPE_DEPTH) { - caps = gst_caps_new_simple ("video/x-raw", - "format", G_TYPE_STRING, "GRAY16_LE", - "framerate", GST_TYPE_FRACTION, ni2src->fps, 1, - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - "width", G_TYPE_INT, ni2src->width, - "height", G_TYPE_INT, ni2src->height, NULL); + format = GST_VIDEO_FORMAT_GRAY16_LE; } else if (ni2src->color.isValid () && ni2src->sourcetype == SOURCETYPE_COLOR) { - caps = gst_caps_new_simple ("video/x-raw", - "format", G_TYPE_STRING, "RGB", - "framerate", GST_TYPE_FRACTION, ni2src->fps, 1, - "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, - "width", G_TYPE_INT, ni2src->width, - "height", G_TYPE_INT, ni2src->height, NULL); + format = GST_VIDEO_FORMAT_RGB; } + + gst_video_info_set_format (&info, format, ni2src->width, ni2src->height); + info.fps_n = ni2src->fps; + info.fps_d = 1; + caps = gst_video_info_to_caps (&info); + GST_INFO_OBJECT (ni2src, "probed caps: %" GST_PTR_FORMAT, caps); - ni2src->gst_caps = gst_caps_ref (caps); + ni2src->gst_caps = caps; GST_OBJECT_UNLOCK (ni2src); return (filter) ? gst_caps_intersect_full (filter, ni2src->gst_caps, |