diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2012-04-19 16:19:32 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2013-09-13 16:33:02 +0200 |
commit | 508e105d644bb17b6532caab6337b821085b847b (patch) | |
tree | 822cb3ff6323049d034dac19dfc21eb1ecf5d078 | |
parent | b5bd0ad35223b44bdbd5dc0f80c921ff60bce9eb (diff) | |
download | gst-plugins-good-508e105d644bb17b6532caab6337b821085b847b.tar.gz gst-plugins-good-508e105d644bb17b6532caab6337b821085b847b.tar.xz |
v4l2: handle propose_allocation in gstv4l2object
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | sys/v4l2/gstv4l2object.c | 61 | ||||
-rw-r--r-- | sys/v4l2/gstv4l2object.h | 2 | ||||
-rw-r--r-- | sys/v4l2/gstv4l2sink.c | 54 |
3 files changed, 64 insertions, 53 deletions
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index f3985d40c..d31d945da 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -46,6 +46,7 @@ #include "gst/gst-i18n-plugin.h" #include <gst/video/video.h> +#include <gst/video/gstvideometa.h> /* videodev2.h is not versioned and we can't easily check for the presence * of enum values at compile time, but the V4L2_CAP_VIDEO_OUTPUT_OVERLAY define @@ -2669,3 +2670,63 @@ invalid_buffer: return FALSE; } } + +gboolean +gst_v4l2_object_propose_allocation (GstV4l2Object * v4l2object, + GstQuery * query) +{ + GstBufferPool *pool; + guint size = 0; + GstCaps *caps; + gboolean need_pool; + + gst_query_parse_allocation (query, &caps, &need_pool); + + if (caps == NULL) + goto no_caps; + + if ((pool = v4l2object->pool)) + gst_object_ref (pool); + + if (pool != NULL) { + GstCaps *pcaps; + GstStructure *config; + + /* we had a pool, check caps */ + config = gst_buffer_pool_get_config (pool); + gst_buffer_pool_config_get_params (config, &pcaps, &size, NULL, NULL); + + GST_DEBUG_OBJECT (v4l2object->element, + "we had a pool with caps %" GST_PTR_FORMAT, pcaps); + if (!gst_caps_is_equal (caps, pcaps)) { + gst_structure_free (config); + gst_object_unref (pool); + goto different_caps; + } + gst_structure_free (config); + } + /* we need at least 2 buffers to operate */ + gst_query_add_allocation_pool (query, pool, size, 2, 0); + + /* we also support various metadata */ + gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); + gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE, NULL); + + if (pool) + gst_object_unref (pool); + + return TRUE; + + /* ERRORS */ +no_caps: + { + GST_DEBUG_OBJECT (v4l2object->element, "no caps specified"); + return FALSE; + } +different_caps: + { + /* different caps, we can't use this pool */ + GST_DEBUG_OBJECT (v4l2object->element, "pool has different caps"); + return FALSE; + } +} diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h index 2505f4796..762a965b3 100644 --- a/sys/v4l2/gstv4l2object.h +++ b/sys/v4l2/gstv4l2object.h @@ -245,6 +245,8 @@ gboolean gst_v4l2_object_stop (GstV4l2Object *v4l2object); gboolean gst_v4l2_object_copy (GstV4l2Object * v4l2object, GstBuffer * dest, GstBuffer *src); +gboolean gst_v4l2_object_propose_allocation (GstV4l2Object * v4l2object, + GstQuery * query); #define GST_IMPLEMENT_V4L2_PROBE_METHODS(Type_Class, interface_as_function) \ \ diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c index dbc41a7ca..7b8af47fe 100644 --- a/sys/v4l2/gstv4l2sink.c +++ b/sys/v4l2/gstv4l2sink.c @@ -623,60 +623,8 @@ gst_v4l2sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) { GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink); GstV4l2Object *obj = v4l2sink->v4l2object; - GstBufferPool *pool; - guint size = 0; - GstCaps *caps; - gboolean need_pool; - gst_query_parse_allocation (query, &caps, &need_pool); - - if (caps == NULL) - goto no_caps; - - if ((pool = obj->pool)) - gst_object_ref (pool); - - if (pool != NULL) { - GstCaps *pcaps; - GstStructure *config; - - /* we had a pool, check caps */ - config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_get_params (config, &pcaps, &size, NULL, NULL); - - GST_DEBUG_OBJECT (v4l2sink, - "we had a pool with caps %" GST_PTR_FORMAT, pcaps); - if (!gst_caps_is_equal (caps, pcaps)) { - gst_structure_free (config); - gst_object_unref (pool); - goto different_caps; - } - gst_structure_free (config); - } - /* we need at least 2 buffers to operate */ - gst_query_add_allocation_pool (query, pool, size, 2, 0); - - /* we also support various metadata */ - gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); - gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE, NULL); - - if (pool) - gst_object_unref (pool); - - return TRUE; - - /* ERRORS */ -no_caps: - { - GST_DEBUG_OBJECT (v4l2sink, "no caps specified"); - return FALSE; - } -different_caps: - { - /* different caps, we can't use this pool */ - GST_DEBUG_OBJECT (v4l2sink, "pool has different caps"); - return FALSE; - } + return gst_v4l2_object_propose_allocation (obj, query); } /* called after A/V sync to render frame */ |