manpagez: man pages & more
html files: gst-plugins-good-plugins-1.0
Home | html | info | man

cairooverlay

cairooverlay

Signals

void caps-changed  
void draw  

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GstObject
            ╰── GstElement
                ╰── GstBaseTransform
                    ╰── GstVideoFilter
                        ╰── GstCairoOverlay

Description

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#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);
...

Synopsis

Element Information

plugin

cairo

author

Jon Nordby <jononor@gmail.com>

class

Filter/Editor/Video

Element Pads

name

sink

direction

sink

presence

always

details

video/x-raw, format=(string){ BGRx, BGRA, RGB16 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

name

src

direction

source

presence

always

details

video/x-raw, format=(string){ BGRx, BGRA, RGB16 }, width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ], framerate=(fraction)[ 0/1, 2147483647/1 ]

Functions

Types and Values

struct GstCairoOverlay

struct GstCairoOverlay;

Signal Details

The “caps-changed” signal

void
user_function (GstCairoOverlay *overlay,
               GstCaps         *caps,
               gpointer         user_data)

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.

 

user_data

user data set when the signal handler was connected.

 

The “draw” signal

void
user_function (GstCairoOverlay *overlay,
               CairoContext    *cr,
               guint64          timestamp,
               guint64          duration,
               gpointer         user_data)

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.

 

user_data

user data set when the signal handler was connected.

 
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.