diff --git a/docs/pwg/advanced-allocation.xml b/docs/pwg/advanced-allocation.xml index f368e7d380..a8c34be9d0 100644 --- a/docs/pwg/advanced-allocation.xml +++ b/docs/pwg/advanced-allocation.xml @@ -720,7 +720,63 @@ gst_buffer_add_my_example_meta (GstBuffer *buffer, ALLOCATION query example - WRITEME + Below is an example of the ALLOCATION query. + + + +#include +#include + + GstCaps *caps; + GstQuery *query; + GstStructure *structure; + GstBufferPool *pool; + GstStructure *config; + guint size, min, max; + +[...] + + /* find a pool for the negotiated caps now */ + query = gst_query_new_allocation (caps, TRUE); + + if (!gst_pad_peer_query (scope->srcpad, query)) { + /* query failed, not a problem, we use the query defaults */ + } + + if (gst_query_get_n_allocation_pools (query) > 0) { + /* we got configuration from our peer, parse them */ + gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); + } else { + pool = NULL; + size = 0; + min = max = 0; + } + + if (pool == NULL) { + /* we did not get a pool, make one ourselves then */ + pool = gst_video_buffer_pool_new (); + } + + config = gst_buffer_pool_get_config (pool); + gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); + gst_buffer_pool_config_set_params (config, caps, size, min, max); + gst_buffer_pool_set_config (pool, config); + + /* and activate */ + gst_buffer_pool_set_active (pool, TRUE); + +[...] +]]> + + + This particular implementation will make a custom + GstVideoBufferPool object that is specialized + in allocating video buffers. You can also enable the pool to + put GstVideoMeta metadata on the buffers from + the pool doing + gst_buffer_pool_config_add_option (config, + GST_BUFFER_POOL_OPTION_VIDEO_META). @@ -745,6 +801,11 @@ gst_buffer_add_my_example_meta (GstBuffer *buffer, + + Implementors of these methods should modify the given + GstQuery object by updating the pool options + and allocation options. +