overlaycompositor: Show the full example instead of a stripped down version

This commit is contained in:
Thibault Saunier 2019-05-29 14:41:10 -04:00
parent 3645c0c4cb
commit 1d2994ce64

View file

@ -23,99 +23,9 @@
* The overlaycomposition element renders an overlay using an application * The overlaycomposition element renders an overlay using an application
* provided draw function. * provided draw function.
* *
* A more interesting example can be found at * ## Example code
* https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/tests/examples/overlaycomposition/overlaycomposition.c
* *
* <refsect2> * {{ ../../tests/examples/overlaycomposition/overlaycomposition.c[23:316] }}
* <title>Example code</title>
* |[
*
* #include &lt;gst/gst.h&gt;
* #include &lt;gst/video/video.h&gt;
*
* ...
*
* 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 (&amp;s-&gt;info, caps))
* s-&gt;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-&gt;valid)
* return NULL;
*
* gst_video_info_set_format (&amp;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(&amp;info),
* GST_VIDEO_INFO_WIDTH(&amp;info),
* GST_VIDEO_INFO_HEIGHT(&amp;info));
*
* gst_video_frame_map (&amp;frame, &amp;info, buffer, GST_MAP_WRITE);
*
* // Overlay a half-transparent blue 16x16 rectangle in the middle
* // of the frame
* data = GST_VIDEO_FRAME_PLANE_DATA(&amp;frame, 0);
* for (y = 0; y < 16; y++) {
* guint8 *line = &amp;data[y * GST_VIDEO_FRAME_PLANE_STRIDE (&amp;frame, 0)];
* for (x = 0; x < 16; x++) {
* guint8 *pixel = &amp;line[x * 4];
*
* pixel[0] = 255;
* pixel[1] = 0;
* pixel[2] = 0;
* pixel[3] = 127;
* }
* }
*
* gst_video_frame_unmap (&amp;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 (&quot;overlaycomposition&quot;, &quot;overlay&quot;);
*
* g_signal_connect (overlay, &quot;draw&quot;, G_CALLBACK (draw_overlay),
* overlay_state);
* g_signal_connect (overlay, &quot;caps-changed&quot;,
* G_CALLBACK (prepare_overlay), overlay_state);
* ...
*
* ]|
* </refsect2>
*/ */
#if HAVE_CONFIG_H #if HAVE_CONFIG_H