+#if GST_CHECK_VERSION(1,0,0)
+static gboolean
+gst_vaapisink_propose_allocation(GstBaseSink *base_sink, GstQuery *query)
+{
+ GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
+ GstCaps *caps = NULL;
+ gboolean need_pool;
+
+ gst_query_parse_allocation(query, &caps, &need_pool);
+
+ if (need_pool) {
+ if (!caps)
+ goto error_no_caps;
+ if (!gst_vaapisink_ensure_video_buffer_pool(sink, caps))
+ return FALSE;
+ gst_query_add_allocation_pool(query, sink->video_buffer_pool,
+ sink->video_buffer_size, 0, 0);
+ }
+
+ gst_query_add_allocation_meta(query,
+ GST_VAAPI_VIDEO_META_API_TYPE, NULL);
+ 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);
+ gst_query_add_allocation_meta(query,
+ GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL);
+ return TRUE;
+
+ /* ERRORS */
+error_no_caps:
+ {
+ GST_ERROR("no caps specified");
+ return FALSE;
+ }
+}
+#else
+static GstFlowReturn
+gst_vaapisink_buffer_alloc(
+ GstBaseSink *base_sink,
+ guint64 offset,
+ guint size,
+ GstCaps *caps,
+ GstBuffer **pbuf
+)
+{
+ GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
+ GstVideoInfo vi;
+ GstBuffer *buf;
+
+ *pbuf = NULL;
+
+ if (!sink->use_video_raw) {
+ /* Note: this code path is rarely used but for raw YUV formats
+ from custom pipeline. Otherwise, GstBaseSink::set_caps() is
+ called first, and GstBaseSink::buffer_alloc() is not called
+ in VA surface format mode */
+ if (!gst_video_info_from_caps(&vi, caps))
+ return GST_FLOW_NOT_SUPPORTED;
+ if (!GST_VIDEO_INFO_IS_YUV(&vi))
+ return GST_FLOW_OK;
+ }
+
+ if (!gst_vaapi_uploader_ensure_display(sink->uploader, sink->display))
+ return GST_FLOW_NOT_SUPPORTED;
+ if (!gst_vaapi_uploader_ensure_caps(sink->uploader, caps, NULL))
+ return GST_FLOW_NOT_SUPPORTED;
+
+ buf = gst_vaapi_uploader_get_buffer(sink->uploader);
+ if (!buf) {
+ GST_WARNING("failed to allocate resources for raw YUV buffer");
+ return GST_FLOW_NOT_SUPPORTED;
+ }
+
+ *pbuf = buf;
+ return GST_FLOW_OK;
+}
+#endif
+