summaryrefslogtreecommitdiffstats
path: root/ext/directfb/dfb-example.c
diff options
context:
space:
mode:
authorJulien Moutte <julien@moutte.net>2005-11-05 23:36:20 +0000
committerJulien Moutte <julien@moutte.net>2005-11-05 23:36:20 +0000
commit72e3851f87ed6e0f07ba74afb7e260f5bfe8def8 (patch)
treede44c4b366f5f7c303466228f800a91a9db7634d /ext/directfb/dfb-example.c
parent0adb034b32d93e761f38dae2e4485c1095e1a786 (diff)
downloadgst-plugins-bad-72e3851f87ed6e0f07ba74afb7e260f5bfe8def8.tar.gz
gst-plugins-bad-72e3851f87ed6e0f07ba74afb7e260f5bfe8def8.tar.bz2
gst-plugins-bad-72e3851f87ed6e0f07ba74afb7e260f5bfe8def8.zip
ext/directfb/Makefile.am: Add the example application.
Original commit message from CVS: 2005-11-06 Julien MOUTTE <julien@moutte.net> * ext/directfb/Makefile.am: Add the example application. * ext/directfb/dfb-example.c: (get_me_out), (main): Here is an example application that runs videotestsrc for 20 seconds. It's included in the documentation. * ext/directfb/dfbvideosink.c: (gst_dfbvideosink_enum_layers), (gst_dfbvideosink_setup), (gst_dfbvideosink_can_blit_from_format), (gst_dfbvideosink_getcaps), (gst_dfbvideosink_buffer_alloc): More fixes, calculate new size of the buffer when renegotiating. This completely breaks ffmpegcolorspace but i need to discuss that with Wim on monday. Add documentation.
Diffstat (limited to 'ext/directfb/dfb-example.c')
-rw-r--r--ext/directfb/dfb-example.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/ext/directfb/dfb-example.c b/ext/directfb/dfb-example.c
new file mode 100644
index 00000000..3f455c92
--- /dev/null
+++ b/ext/directfb/dfb-example.c
@@ -0,0 +1,78 @@
+
+#include <directfb.h>
+#include <gst/gst.h>
+
+static IDirectFB *dfb = NULL;
+static IDirectFBSurface *primary = NULL;
+static GMainLoop *loop;
+
+#define DFBCHECK(x...) \
+ { \
+ DFBResult err = x; \
+ \
+ if (err != DFB_OK) \
+ { \
+ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
+ DirectFBErrorFatal( #x, err ); \
+ } \
+ }
+
+static gboolean
+get_me_out (gpointer data)
+{
+ g_main_loop_quit (loop);
+ return FALSE;
+}
+
+int
+main (int argc, char *argv[])
+{
+ DFBSurfaceDescription dsc;
+ GstElement *pipeline, *src, *sink;
+
+ /* Init both GStreamer and DirectFB */
+ DFBCHECK (DirectFBInit (&argc, &argv));
+ gst_init (&argc, &argv);
+
+ /* Creates DirectFB main context and set it to fullscreen layout */
+ DFBCHECK (DirectFBCreate (&dfb));
+ DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
+
+ /* We want a double buffered primary surface */
+ dsc.flags = DSDESC_CAPS;
+ dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
+
+ DFBCHECK (dfb->CreateSurface (dfb, &dsc, &primary));
+
+ /* Creating our pipeline : videotestsrc ! dfbvideosink */
+ pipeline = gst_pipeline_new (NULL);
+ g_assert (pipeline);
+ src = gst_element_factory_make ("videotestsrc", NULL);
+ g_assert (src);
+ sink = gst_element_factory_make ("dfbvideosink", NULL);
+ g_assert (sink);
+ /* That's the interesting part, giving the primary surface to dfbvideosink */
+ g_object_set (sink, "surface", primary, NULL);
+
+ /* Adding elements to the pipeline */
+ gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
+ g_assert (gst_element_link (src, sink));
+
+ /* Let's play ! */
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ /* we need to run a GLib main loop to get out of here */
+ loop = g_main_loop_new (NULL, FALSE);
+ /* Get us out after 20 seconds */
+ g_timeout_add (20000, get_me_out, NULL);
+ g_main_loop_run (loop);
+
+ /* Release elements and stop playback */
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+
+ /* Release DirectFB context and surface */
+ primary->Release (primary);
+ dfb->Release (dfb);
+
+ return 0;
+}