summaryrefslogtreecommitdiff
path: root/tests/examples
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2013-01-01 11:52:09 +0000
committerTim-Philipp Müller <tim@centricular.net>2013-01-01 11:52:09 +0000
commit08702be68f2745ff331324bb65482e4bfc80da6a (patch)
tree6d0c3cca36f8a76fa00276c619755ed6d5b67fcb /tests/examples
parent1a073355bce618a298fbf728f9d07ae7922a1af7 (diff)
cairo: port cairooverlay to 0.11
The other elements are not that interesting now that we're using pangocairo in the pango plugin, and should probably just be removed.
Diffstat (limited to 'tests/examples')
-rw-r--r--tests/examples/Makefile.am2
-rw-r--r--tests/examples/cairo/Makefile.am2
-rw-r--r--tests/examples/cairo/cairo_overlay.c26
3 files changed, 19 insertions, 11 deletions
diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am
index 50a972516..b613a640d 100644
--- a/tests/examples/Makefile.am
+++ b/tests/examples/Makefile.am
@@ -4,7 +4,7 @@ else
JACK_DIR=
endif
-if USE_CAIRO_GOBJECT
+if USE_CAIRO
CAIRO_DIR=cairo
else
CAIRO_DIR=
diff --git a/tests/examples/cairo/Makefile.am b/tests/examples/cairo/Makefile.am
index 9bc47179b..2e833cc30 100644
--- a/tests/examples/cairo/Makefile.am
+++ b/tests/examples/cairo/Makefile.am
@@ -1,6 +1,4 @@
-if USE_CAIRO_GOBJECT
noinst_PROGRAMS = cairo_overlay
-endif
cairo_overlay_SOURCES = cairo_overlay.c
cairo_overlay_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(CAIRO_CFLAGS)
diff --git a/tests/examples/cairo/cairo_overlay.c b/tests/examples/cairo/cairo_overlay.c
index 1b26b549e..9e9f71afa 100644
--- a/tests/examples/cairo/cairo_overlay.c
+++ b/tests/examples/cairo/cairo_overlay.c
@@ -69,8 +69,7 @@ on_message (GstBus * bus, GstMessage * message, gpointer user_data)
typedef struct
{
gboolean valid;
- int width;
- int height;
+ GstVideoInfo vinfo;
} CairoOverlayState;
/* Store the information from the caps that we are interested in. */
@@ -79,8 +78,7 @@ 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;
+ state->valid = gst_video_info_from_caps (&state->vinfo, caps);
}
/* Draw the overlay.
@@ -91,12 +89,18 @@ draw_overlay (GstElement * overlay, cairo_t * cr, guint64 timestamp,
{
CairoOverlayState *s = (CairoOverlayState *) user_data;
double scale;
+ int width, height;
if (!s->valid)
return;
+ width = GST_VIDEO_INFO_WIDTH (&s->vinfo);
+ height = GST_VIDEO_INFO_HEIGHT (&s->vinfo);
+
scale = 2 * (((timestamp / (int) 1e7) % 70) + 30) / 100.0;
- cairo_translate (cr, s->width / 2, (s->height / 2) - 30);
+ cairo_translate (cr, width / 2, (height / 2) - 30);
+
+ /* FIXME: this assumes a pixel-aspect-ratio of 1/1 */
cairo_scale (cr, scale, scale);
cairo_move_to (cr, 0, 0);
@@ -122,7 +126,9 @@ setup_gst_pipeline (CairoOverlayState * overlay_state)
adaptor1 = gst_element_factory_make ("videoconvert", "adaptor1");
cairo_overlay = gst_element_factory_make ("cairooverlay", "overlay");
adaptor2 = gst_element_factory_make ("videoconvert", "adaptor2");
- sink = gst_element_factory_make ("autovideosink", "sink");
+ sink = gst_element_factory_make ("ximagesink", "sink");
+ if (sink == NULL)
+ sink = gst_element_factory_make ("autovideosink", "sink");
/* If failing, the element could not be created */
g_assert (cairo_overlay);
@@ -150,12 +156,15 @@ main (int argc, char **argv)
GMainLoop *loop;
GstElement *pipeline;
GstBus *bus;
- CairoOverlayState overlay_state = { FALSE, 0, 0 };
+ CairoOverlayState *overlay_state;
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
- pipeline = setup_gst_pipeline (&overlay_state);
+ /* allocate on heap for pedagogical reasons, makes code easier to transfer */
+ overlay_state = g_new0 (CairoOverlayState, 1);
+
+ pipeline = setup_gst_pipeline (overlay_state);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_signal_watch (bus);
@@ -168,5 +177,6 @@ main (int argc, char **argv)
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
+ g_free (overlay_state);
return 0;
}