static void gst_vaapi_surface_destroy (GstVaapiSurface * surface) { GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface); VASurfaceID surface_id; VAStatus status; surface_id = GST_VAAPI_OBJECT_ID (surface); GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id)); gst_vaapi_surface_destroy_subpictures (surface); gst_vaapi_surface_set_parent_context (surface, NULL); if (surface_id != VA_INVALID_SURFACE) { GST_VAAPI_DISPLAY_LOCK (display); status = vaDestroySurfaces (GST_VAAPI_DISPLAY_VADISPLAY (display), &surface_id, 1); GST_VAAPI_DISPLAY_UNLOCK (display); if (!vaapi_check_status (status, "vaDestroySurfaces()")) g_warning ("failed to destroy surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id)); GST_VAAPI_OBJECT_ID (surface) = VA_INVALID_SURFACE; } gst_vaapi_buffer_proxy_replace (&surface->extbuf_proxy, NULL); }
/** * gst_vaapi_surface_set_subpictures_from_composition: * @surface: a #GstVaapiSurface * @compostion: a #GstVideoOverlayCompositon * @propagate_context: a flag specifying whether to apply composition * to the parent context, if any * * Helper to update the subpictures from #GstVideoOverlayCompositon. Sending * a NULL composition will clear all the current subpictures. Note that this * method will clear existing subpictures. * * Return value: %TRUE on success */ gboolean gst_vaapi_surface_set_subpictures_from_composition( GstVaapiSurface *surface, GstVideoOverlayComposition *composition, gboolean propagate_context ) { GstVaapiDisplay *display; guint n, nb_rectangles; g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), FALSE); if (propagate_context) { GstVaapiContext * const context = surface->priv->parent_context; if (context) return gst_vaapi_context_apply_composition(context, composition); } display = GST_VAAPI_OBJECT_DISPLAY(surface); if (!display) return FALSE; /* Clear current subpictures */ gst_vaapi_surface_destroy_subpictures(surface); if (!composition) return TRUE; nb_rectangles = gst_video_overlay_composition_n_rectangles (composition); /* Overlay all the rectangles cantained in the overlay composition */ for (n = 0; n < nb_rectangles; ++n) { GstVideoOverlayRectangle *rect; GstVaapiRectangle sub_rect; GstVaapiSubpicture *subpicture; rect = gst_video_overlay_composition_get_rectangle (composition, n); subpicture = gst_vaapi_subpicture_new_from_overlay_rectangle (display, rect); gst_video_overlay_rectangle_get_render_rectangle (rect, (gint *)&sub_rect.x, (gint *)&sub_rect.y, &sub_rect.width, &sub_rect.height); if (!gst_vaapi_surface_associate_subpicture (surface, subpicture, NULL, &sub_rect)) { GST_WARNING ("could not render overlay rectangle %p", rect); g_object_unref (subpicture); return FALSE; } g_object_unref (subpicture); } return TRUE; }