* The overlaycomposition element renders an overlay using an application
* provided draw function.
*
- * A more interesting example can be found at
- * https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/tests/examples/overlaycomposition/overlaycomposition.c
+ * ## Example code
*
- * <refsect2>
- * <title>Example code</title>
- * |[
- *
- * #include <gst/gst.h>
- * #include <gst/video/video.h>
- *
- * ...
- *
- * typedef struct {
- * gboolean valid;
- * GstVideoInfo info;
- * } OverlayState;
- *
- * ...
- *
- * static void
- * prepare_overlay (GstElement * overlay, GstCaps * caps, gint window_width,
- * gint window_height, gpointer user_data)
- * {
- * OverlayState *s = (OverlayState *)user_data;
- *
- * if (gst_video_info_from_caps (&s->info, caps))
- * s->valid = TRUE;
- * }
- *
- * static GstVideoOverlayComposition *
- * draw_overlay (GstElement * overlay, GstSample * sample, gpointer user_data)
- * {
- * OverlayState *s = (OverlayState *)user_data;
- * GstBuffer *buffer;
- * GstVideoOverlayRectangle *rect;
- * GstVideoOverlayComposition *comp;
- * GstVideoInfo info;
- * GstVideoFrame frame;
- * gint x, y;
- * guint8 *data;
- *
- * if (!s->valid)
- * return NULL;
- *
- * gst_video_info_set_format (&info, GST_VIDEO_FORMAT_BGRA, 16, 16);
- * buffer = gst_buffer_new_and_alloc (info.size);
- * gst_buffer_add_video_meta (buffer, GST_VIDEO_FRAME_FLAG_NONE,
- * GST_VIDEO_INFO_FORMAT(&info),
- * GST_VIDEO_INFO_WIDTH(&info),
- * GST_VIDEO_INFO_HEIGHT(&info));
- *
- * gst_video_frame_map (&frame, &info, buffer, GST_MAP_WRITE);
- *
- * // Overlay a half-transparent blue 16x16 rectangle in the middle
- * // of the frame
- * data = GST_VIDEO_FRAME_PLANE_DATA(&frame, 0);
- * for (y = 0; y < 16; y++) {
- * guint8 *line = &data[y * GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0)];
- * for (x = 0; x < 16; x++) {
- * guint8 *pixel = &line[x * 4];
- *
- * pixel[0] = 255;
- * pixel[1] = 0;
- * pixel[2] = 0;
- * pixel[3] = 127;
- * }
- * }
- *
- * gst_video_frame_unmap (&frame);
- * rect = gst_video_overlay_rectangle_new_raw (buffer,
- * s->info.width / 2 - 8,
- * s->info.height / 2 - 8,
- * 16, 16,
- * GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE);
- * comp = gst_video_overlay_composition_new (rect);
- * gst_video_overlay_rectangle_unref (rect);
- * gst_buffer_unref (buffer);
- *
- * return comp;
- * }
- *
- * ...
- *
- * overlay = gst_element_factory_make ("overlaycomposition", "overlay");
- *
- * g_signal_connect (overlay, "draw", G_CALLBACK (draw_overlay),
- * overlay_state);
- * g_signal_connect (overlay, "caps-changed",
- * G_CALLBACK (prepare_overlay), overlay_state);
- * ...
- *
- * ]|
- * </refsect2>
+ * {{ ../../tests/examples/overlaycomposition/overlaycomposition.c[23:316] }}
*/
#if HAVE_CONFIG_H