From 4970367850896eca6e2a7611224b9b8462390490 Mon Sep 17 00:00:00 2001 From: Alex Badea Date: Fri, 11 Jun 2010 22:32:34 +0300 Subject: [PATCH] Add: gst-play-event Silent-proof media player --- configure.ac | 8 ++++++ debian/control | 4 ++- src/Makefile.am | 6 ++++- src/gst-play-event.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/gst-play-event.c diff --git a/configure.ac b/configure.ac index 57fb79b..95eb48c 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,14 @@ PKG_CHECK_MODULES(HAL, [hal]) AC_SUBST(HAL_CFLAGS) AC_SUBST(HAL_LIBS) +PKG_CHECK_MODULES(GST, [gstreamer-0.10]) +AC_SUBST(GST_CFLAGS) +AC_SUBST(GST_LIBS) + +PKG_CHECK_MODULES(PA, [pulsecore]) +AC_SUBST(PA_CFLAGS) +AC_SUBST(PA_LIBS) + AC_OUTPUT([ Makefile src/Makefile diff --git a/debian/control b/debian/control index 19976b0..9da5c35 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,9 @@ Source: espeaktime Section: user/multimedia Priority: extra Maintainer: Alex Badea -Build-Depends: debhelper (>= 5), libglib2.0-dev, libdbus-glib-1-dev, libhal-dev, mce-dev (>= 1.8.10) +Build-Depends: debhelper (>= 5), + libglib2.0-dev, libdbus-glib-1-dev, libhal-dev, mce-dev (>= 1.8.10), + pulseaudio-dev, libgstreamer0.10-dev Standards-Version: 3.7.2 Package: espeaktime-daemon diff --git a/src/Makefile.am b/src/Makefile.am index 86908a2..0e0d50d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,10 @@ bin_SCRIPTS = espeaktime-now.sh -bin_PROGRAMS = espeaktimed +bin_PROGRAMS = espeaktimed gst-play-event espeaktimed_SOURCES = daemon.c espeaktimed_CFLAGS = $(GLIB_CFLAGS) $(DBUS_CFLAGS) $(MCE_CFLAGS) $(HAL_CFLAGS) espeaktimed_LDADD = $(GLIB_LIBS) $(DBUS_LIBS) $(MCE_LIBS) $(HAL_LIBS) +gst_play_event_SOURCES = gst-play-event.c +gst_play_event_CFLAGS = $(GST_CFLAGS) $(PA_CFLAGS) +gst_play_event_LDADD = $(GST_LIBS) $(PA_LIBS) + diff --git a/src/gst-play-event.c b/src/gst-play-event.c new file mode 100644 index 0000000..47265c3 --- /dev/null +++ b/src/gst-play-event.c @@ -0,0 +1,72 @@ +/* + * Play media file via gstreamer, optionally setting pulseaudio + * properties on it. Inspired by qwerty12's code from: + * http://talk.maemo.org/showthread.php?t=50266&page=2 + */ + +#include +#include +#include + +static GMainLoop *loop; +static GstElement *sound_player, *pulsesink; + +static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) +{ + GMainLoop *loop = data; + gchar *debug; + GError *error; + + switch (GST_MESSAGE_TYPE(msg)) { + case GST_MESSAGE_EOS: + g_main_loop_quit(loop); + break; + case GST_MESSAGE_ERROR: + gst_message_parse_error(msg, &error, &debug); + g_free (debug); + + g_printerr("Error: %s\n", error->message); + g_error_free(error); + g_main_loop_quit(loop); + break; + default: + break; + } + + return TRUE; +} + +int main(int argc, char *argv[]) +{ + GstBus *bus; + pa_proplist *proplist = NULL; + + if (argc < 2) { + g_printerr("Usage: %s []\n", argv[0]); + return 1; + } + + gst_init(&argc, &argv); + loop = g_main_loop_new(NULL, FALSE); + + if (argc > 2) { + proplist = pa_proplist_new(); + pa_proplist_sets(proplist, PA_PROP_EVENT_ID, argv[2]); + pa_proplist_sets(proplist, "module-stream-restore.id", "x-maemo-applet-profiles"); + } + + sound_player = gst_element_factory_make("playbin2", "eSpeakTime"); + pulsesink = gst_element_factory_make("pulsesink", NULL); + if (proplist) + g_object_set(G_OBJECT(pulsesink), "proplist", proplist, NULL); + + bus = gst_pipeline_get_bus(GST_PIPELINE(sound_player)); + gst_bus_add_watch(bus, bus_call, loop); + gst_object_unref(bus); + + g_object_set(sound_player, "audio-sink", pulsesink, "uri", argv[1], NULL); + gst_element_set_state(sound_player, GST_STATE_PLAYING); + + g_main_loop_run(loop); + return 0; +} -- 1.7.9.5