From e1fcd42a1917ae5a34486e9ae82a05a70173ba53 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 12 Mar 2015 13:57:28 +0100 Subject: [PATCH] examples: Move all examples to the root dir and create foldersdir per language + Add some markdown files to link between languages + Add a simple 'play timeline with one clip" example in C and python --- Makefile.am | 8 ++- bindings/python/Makefile.am | 4 -- bindings/python/examples/Makefile.am | 0 configure.ac | 4 +- {tests/examples => examples}/.gitignore | 0 examples/Makefile.am | 5 ++ {tests/examples => examples/c}/Makefile.am | 2 + {tests/examples => examples/c}/assets.c | 0 {tests/examples => examples/c}/concatenate.c | 0 {tests/examples => examples/c}/ges-ui.c | 0 {tests/examples => examples/c}/ges-ui.glade | 0 {tests/examples => examples/c}/multifilesrc.c | 0 {tests/examples => examples/c}/overlays.c | 0 examples/c/play_timeline_with_one_clip.c | 62 +++++++++++++++++++ {tests/examples => examples/c}/simple1.c | 0 {tests/examples => examples/c}/test1.c | 0 {tests/examples => examples/c}/test2.c | 0 {tests/examples => examples/c}/test3.c | 0 {tests/examples => examples/c}/test4.c | 0 {tests/examples => examples/c}/text_properties.c | 0 {tests/examples => examples/c}/thumbnails.c | 0 {tests/examples => examples/c}/transition.c | 0 examples/python/simple.py | 78 ++++++++++++++++++++++++ tests/Makefile.am | 10 +-- 24 files changed, 158 insertions(+), 15 deletions(-) delete mode 100644 bindings/python/examples/Makefile.am rename {tests/examples => examples}/.gitignore (100%) create mode 100644 examples/Makefile.am rename {tests/examples => examples/c}/Makefile.am (93%) rename {tests/examples => examples/c}/assets.c (100%) rename {tests/examples => examples/c}/concatenate.c (100%) rename {tests/examples => examples/c}/ges-ui.c (100%) rename {tests/examples => examples/c}/ges-ui.glade (100%) rename {tests/examples => examples/c}/multifilesrc.c (100%) rename {tests/examples => examples/c}/overlays.c (100%) create mode 100644 examples/c/play_timeline_with_one_clip.c rename {tests/examples => examples/c}/simple1.c (100%) rename {tests/examples => examples/c}/test1.c (100%) rename {tests/examples => examples/c}/test2.c (100%) rename {tests/examples => examples/c}/test3.c (100%) rename {tests/examples => examples/c}/test4.c (100%) rename {tests/examples => examples/c}/text_properties.c (100%) rename {tests/examples => examples/c}/thumbnails.c (100%) rename {tests/examples => examples/c}/transition.c (100%) create mode 100755 examples/python/simple.py diff --git a/Makefile.am b/Makefile.am index e33bfd2..979caa6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,12 @@ DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --with-bash-completion-dir=no -SUBDIRS = ges tests tools common m4 pkgconfig docs bindings plugins +if BUILD_EXAMPLES +EXAMPLES_SUBDIRS= examples +else +EXAMPLES_SUBDIRS= +endif + +SUBDIRS = ges tests tools common m4 pkgconfig docs bindings plugins $(EXAMPLES_SUBDIRS) DIST_SUBDIRS = $(SUBDIRS) diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am index 22bf444..14602de 100644 --- a/bindings/python/Makefile.am +++ b/bindings/python/Makefile.am @@ -1,5 +1 @@ SUBDIRS = gi - -if BUILD_EXAMPLES -SUBDIRS += examples -endif diff --git a/bindings/python/examples/Makefile.am b/bindings/python/examples/Makefile.am deleted file mode 100644 index e69de29..0000000 diff --git a/configure.ac b/configure.ac index 6e36dc6..77a38b1 100644 --- a/configure.ac +++ b/configure.ac @@ -460,7 +460,8 @@ ges/Makefile tests/Makefile tests/check/Makefile tests/benchmarks/Makefile -tests/examples/Makefile +examples/Makefile +examples/c/Makefile tests/validate/Makefile tests/validate/scenarios/Makefile tools/Makefile @@ -476,6 +477,5 @@ bindings/Makefile bindings/python/Makefile bindings/python/gi/Makefile bindings/python/gi/overrides/Makefile -bindings/python/examples/Makefile ) AC_OUTPUT diff --git a/tests/examples/.gitignore b/examples/.gitignore similarity index 100% rename from tests/examples/.gitignore rename to examples/.gitignore diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 0000000..a328175 --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = c + +AM_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS) +AM_LDFLAGS = -export-dynamic +LDADD = $(top_builddir)/ges/libges-@GST_API_VERSION@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) $(GTK_LIBS) diff --git a/tests/examples/Makefile.am b/examples/c/Makefile.am similarity index 93% rename from tests/examples/Makefile.am rename to examples/c/Makefile.am index 4d55a94..35c9d0e 100644 --- a/tests/examples/Makefile.am +++ b/examples/c/Makefile.am @@ -17,8 +17,10 @@ noinst_PROGRAMS = \ text_properties \ assets \ multifilesrc \ + play_timeline_with_one_clip \ $(graphical) AM_CFLAGS = -I$(top_srcdir) $(GST_PBUTILS_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS) AM_LDFLAGS = -export-dynamic LDADD = $(top_builddir)/ges/libges-@GST_API_VERSION@.la $(GST_PBUTILS_LIBS) $(GST_LIBS) $(GTK_LIBS) + diff --git a/tests/examples/assets.c b/examples/c/assets.c similarity index 100% rename from tests/examples/assets.c rename to examples/c/assets.c diff --git a/tests/examples/concatenate.c b/examples/c/concatenate.c similarity index 100% rename from tests/examples/concatenate.c rename to examples/c/concatenate.c diff --git a/tests/examples/ges-ui.c b/examples/c/ges-ui.c similarity index 100% rename from tests/examples/ges-ui.c rename to examples/c/ges-ui.c diff --git a/tests/examples/ges-ui.glade b/examples/c/ges-ui.glade similarity index 100% rename from tests/examples/ges-ui.glade rename to examples/c/ges-ui.glade diff --git a/tests/examples/multifilesrc.c b/examples/c/multifilesrc.c similarity index 100% rename from tests/examples/multifilesrc.c rename to examples/c/multifilesrc.c diff --git a/tests/examples/overlays.c b/examples/c/overlays.c similarity index 100% rename from tests/examples/overlays.c rename to examples/c/overlays.c diff --git a/examples/c/play_timeline_with_one_clip.c b/examples/c/play_timeline_with_one_clip.c new file mode 100644 index 0000000..745def4 --- /dev/null +++ b/examples/c/play_timeline_with_one_clip.c @@ -0,0 +1,62 @@ +/* This example can be found in the GStreamer Editing Services git repository in: + * examples/c/play_timeline_with_one_clip.c + */ +#include + +int +main (int argc, char **argv) +{ + GESLayer *layer; + GESTimeline *timeline; + + if (argc == 1) { + g_printerr ("Usage: play_timeline_with_one_clip file:///clip/uri\n"); + + return 1; + } + + gst_init (NULL, NULL); + ges_init (); + + timeline = ges_timeline_new_audio_video (); + layer = ges_timeline_append_layer (timeline); + + { + /* Add a clip with a duration of 5 seconds */ + GESClip *clip = GES_CLIP (ges_uri_clip_new (argv[1])); + + if (clip == NULL) { + g_printerr ("%s can not be used, make sure it is a supported media file", + argv[1]); + + return 1; + } + + g_object_set (clip, "duration", 5 * GST_SECOND, "start", 0, NULL); + ges_layer_add_clip (layer, clip); + } + + /* Commiting the timeline is always necessary for changes + * inside it to be taken into account by the Non Linear Engine */ + ges_timeline_commit (timeline); + + { + /* Play the timeline */ + GESPipeline *pipeline = ges_pipeline_new (); + GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + + ges_pipeline_set_timeline (pipeline, timeline); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); + + /* Simple way to just play the pipeline until EOS or an error pops on the bus */ + gst_bus_timed_pop_filtered (bus, 10 * GST_SECOND, + GST_MESSAGE_EOS | GST_MESSAGE_ERROR); + + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); + gst_object_unref (bus); + gst_object_unref (pipeline); + } + + + return 0; +} diff --git a/tests/examples/simple1.c b/examples/c/simple1.c similarity index 100% rename from tests/examples/simple1.c rename to examples/c/simple1.c diff --git a/tests/examples/test1.c b/examples/c/test1.c similarity index 100% rename from tests/examples/test1.c rename to examples/c/test1.c diff --git a/tests/examples/test2.c b/examples/c/test2.c similarity index 100% rename from tests/examples/test2.c rename to examples/c/test2.c diff --git a/tests/examples/test3.c b/examples/c/test3.c similarity index 100% rename from tests/examples/test3.c rename to examples/c/test3.c diff --git a/tests/examples/test4.c b/examples/c/test4.c similarity index 100% rename from tests/examples/test4.c rename to examples/c/test4.c diff --git a/tests/examples/text_properties.c b/examples/c/text_properties.c similarity index 100% rename from tests/examples/text_properties.c rename to examples/c/text_properties.c diff --git a/tests/examples/thumbnails.c b/examples/c/thumbnails.c similarity index 100% rename from tests/examples/thumbnails.c rename to examples/c/thumbnails.c diff --git a/tests/examples/transition.c b/examples/c/transition.c similarity index 100% rename from tests/examples/transition.c rename to examples/c/transition.c diff --git a/examples/python/simple.py b/examples/python/simple.py new file mode 100755 index 0000000..1de9f6e --- /dev/null +++ b/examples/python/simple.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +# +# GStreamer +# +# Copyright (C) 2013 Thibault Saunier