cairooverlay
cairooverlay renders an overlay using a application provided render function.
The full example can be found in tests/examples/cairo/cairo_overlay.c
Example code
 #include <gst/gst.h>
 #include <gst/video/video.h>
 ...
 typedef struct {
   gboolean valid;
   int width;
   int height;
 } CairoOverlayState;
 ...
 static void
 prepare_overlay (GstElement * overlay, GstCaps * caps, gpointer user_data)
 {
   CairoOverlayState *state = (CairoOverlayState *)user_data;
   gst_video_format_parse_caps (caps, NULL, &state->width, &state->height);
   state->valid = TRUE;
 }
 static void
 draw_overlay (GstElement * overlay, cairo_t * cr, guint64 timestamp,
   guint64 duration, gpointer user_data)
 {
   CairoOverlayState *s = (CairoOverlayState *)user_data;
   double scale;
   if (!s->valid)
     return;
   scale = 2*(((timestamp/(int)1e7) % 70)+30)/100.0;
   cairo_translate(cr, s->width/2, (s->height/2)-30);
   cairo_scale (cr, scale, scale);
   cairo_move_to (cr, 0, 0);
   cairo_curve_to (cr, 0,-30, -50,-30, -50,0);
   cairo_curve_to (cr, -50,30, 0,35, 0,60 );
   cairo_curve_to (cr, 0,35, 50,30, 50,0 ); *
   cairo_curve_to (cr, 50,-30, 0,-30, 0,0 );
   cairo_set_source_rgba (cr, 0.9, 0.0, 0.1, 0.7);
   cairo_fill (cr);
 }
 ...
 cairo_overlay = gst_element_factory_make ("cairooverlay", "overlay");
 g_signal_connect (cairo_overlay, "draw", G_CALLBACK (draw_overlay),
   overlay_state);
 g_signal_connect (cairo_overlay, "caps-changed",
   G_CALLBACK (prepare_overlay), overlay_state);
 ...
Hierarchy
GObject ╰──GInitiallyUnowned ╰──GstObject ╰──GstElement ╰──GstBaseTransform ╰──cairooverlay
Factory details
Authors: – Jon Nordby 
Classification: – Filter/Editor/Video
Rank – none
Plugin – cairo
Package – GStreamer Good Plug-ins
Pad Templates
sink
        video/x-raw:
         format: { BGRx, BGRA, RGB16 }
          width: [ 1, 2147483647 ]
         height: [ 1, 2147483647 ]
      framerate: [ 0/1, 2147483647/1 ]
src
        video/x-raw:
         format: { BGRx, BGRA, RGB16 }
          width: [ 1, 2147483647 ]
         height: [ 1, 2147483647 ]
      framerate: [ 0/1, 2147483647/1 ]
Signals
caps-changed
caps_changed_callback (GstElement * overlay, GstCaps * caps, gpointer udata)
def caps_changed_callback (overlay, caps, udata):
    #python callback for the 'caps-changed' signal
function caps_changed_callback(overlay: GstElement * overlay, caps: GstCaps * caps, udata: gpointer udata): {
    // javascript callback for the 'caps-changed' signal
}
This signal is emitted when the caps of the element has changed.
Parameters:
overlay
				–
	Overlay element emitting the signal.
caps
				–
	The GstCaps of the element.
udata
				–
	Flags:
draw
draw_callback (GstElement * overlay, CairoContext * cr, guint64 timestamp, guint64 duration, gpointer udata)
def draw_callback (overlay, cr, timestamp, duration, udata):
    #python callback for the 'draw' signal
function draw_callback(overlay: GstElement * overlay, cr: CairoContext * cr, timestamp: guint64 timestamp, duration: guint64 duration, udata: gpointer udata): {
    // javascript callback for the 'draw' signal
}
This signal is emitted when the overlay should be drawn.
Parameters:
overlay
				–
	Overlay element emitting the signal.
cr
				–
	Cairo context to draw to.
timestamp
				–
	Timestamp (see GstClockTime) of the current buffer.
duration
				–
	Duration (see GstClockTime) of the current buffer.
udata
				–
	Flags:
Properties
draw-on-transparent-surface
“draw-on-transparent-surface” gboolean
Let the draw signal work on a transparent surface and blend the results with the video at a later time
Flags : Read / Write
Default value : false
The results of the search are