[maemo-commits] [maemo-commits] r17982 - projects/haf/trunk/hildon-welcome/src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Apr 2 13:13:02 EEST 2009
- Previous message: [maemo-commits] r17981 - in projects/haf/trunk/libmatchbox2: . matchbox/comp-mgr
- Next message: [maemo-commits] r17983 - in projects/haf/trunk/libmatchbox2: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: schulhof Date: 2009-04-02 13:13:02 +0300 (Thu, 02 Apr 2009) New Revision: 17982 Modified: projects/haf/trunk/hildon-welcome/src/tmp.c Log: Modified: projects/haf/trunk/hildon-welcome/src/tmp.c =================================================================== --- projects/haf/trunk/hildon-welcome/src/tmp.c 2009-04-02 10:10:07 UTC (rev 17981) +++ projects/haf/trunk/hildon-welcome/src/tmp.c 2009-04-02 10:13:02 UTC (rev 17982) @@ -1,39 +1,58 @@ +/** + * cc -g -Wall -O0 `pkg-config --cflags --libs gstreamer-0.10 gstreamer-plugins-base-0.10 gstreamer-interfaces-0.10 xcomposite` tmp.c -o play + * ./play /usr/share/sounds/ui-wake_up_tune.wav /usr/share/sounds/call-ringtone01.wav + * ./play /usr/share/hildon-welcome/media/Hands-v32-h264.avi /usr/share/hildon-welcome/media/Hands-v32-h264.avi + **/ + #include <stdlib.h> #include <gst/gst.h> +#include <gst/interfaces/xoverlay.h> +#include <X11/Xlib.h> +#include <X11/extensions/Xcomposite.h> +//#define HAVE_VIDEO + +#ifdef HAVE_VIDEO #define VIDEO_SINK 0 +#endif /* HAVE_VIDEO */ #define AUDIO_SINK 1 static void -video_no_more_pads(GstElement *src, GstElement *sinks[2]) +no_more_pads(GstElement *src, GstElement *sinks[2]) { +#ifdef HAVE_VIDEO gst_element_link(src, sinks[VIDEO_SINK]); +#endif /* HAVE_VIDEO */ gst_element_link(src, sinks[AUDIO_SINK]); + + GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(g_object_get_data(G_OBJECT(sinks[AUDIO_SINK]), "pipeline")), GST_DEBUG_GRAPH_SHOW_ALL, "playdetails"); } static GstElement * -create_bin(char *fname, GstElement *sinks[2]) +create_bin(char *fname, GstElement *sinks[2], GstElement *pipeline) { static int counter = 0; char *name = NULL; GstElement *bin, *filesrc, *decodebin2; - name = g_strdup_printf("audio-bin%d", counter++); + name = g_strdup_printf("bin%d", counter++); bin = gst_bin_new(name); g_free(name); filesrc = gst_element_factory_make("filesrc", NULL); g_object_set(G_OBJECT(filesrc), "location", fname, NULL); decodebin2 = gst_element_factory_make("decodebin2", NULL); - g_signal_connect(G_OBJECT(decodebin2), "no-more-pads", (GCallback)video_no_more_pads, sinks); + g_signal_connect(G_OBJECT(decodebin2), "no-more-pads", (GCallback)no_more_pads, sinks); gst_bin_add_many(GST_BIN(bin), filesrc, decodebin2, NULL); gst_element_link(filesrc, decodebin2); + g_object_set_data(G_OBJECT(sinks[AUDIO_SINK]), "pipeline", pipeline); + return bin; } static void -play_file(GstElement *pipeline, char *audio, GstElement *sinks[2]) +play_file(GstElement *pipeline, char *audio, Window dst_window, GstElement *sinks[2]) { GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); @@ -44,7 +63,7 @@ GstMessage *msg = NULL; GstElement *new_bin = NULL; - new_bin = create_bin(audio, sinks); + new_bin = create_bin(audio, sinks, pipeline); gst_bin_add(GST_BIN(pipeline), new_bin); gst_element_set_state(pipeline, GST_STATE_PAUSED); gst_element_send_event(pipeline, @@ -58,6 +77,19 @@ if (!msg) break; switch (GST_MESSAGE_TYPE(msg)) { + case GST_MESSAGE_STATE_CHANGED: + if (GST_OBJECT(pipeline) == GST_MESSAGE_SRC(msg)) + { + GstState oldstate, newstate, pending; + gst_message_parse_state_changed(msg, &oldstate, &newstate, &pending); + g_debug("wait_for_eos: %s state-changed: old = %s, new = %s, pending = %s\n", + gst_element_get_name(GST_ELEMENT(GST_MESSAGE_SRC(msg))), + gst_element_state_get_name(oldstate), + gst_element_state_get_name(newstate), + gst_element_state_get_name(pending)); + } + break; + case GST_MESSAGE_ERROR: { GError *err = NULL; @@ -74,11 +106,17 @@ debug = NULL;; } /* fall through */ + case GST_MESSAGE_EOS: case GST_MESSAGE_SEGMENT_DONE: - g_print("play_file: SEGMENT_DONE\n"); + g_print("play_file: Exiting loop: %s\n", GST_MESSAGE_TYPE_NAME(msg)); keep_looping = FALSE; break; + case GST_MESSAGE_ELEMENT: + if (gst_structure_has_name(msg->structure, "prepare-xwindow-id")) + gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(GST_MESSAGE_SRC(msg)), dst_window); + break; + default: break; } @@ -104,20 +142,34 @@ int Nix; GstElement *pipeline = NULL, *sinks[2]; gst_init(&argc, &argv); + Display *display; + Window dst_window = 0, xcomposite_window = 0; + if (!(display = XOpenDisplay(NULL))) + g_error("main: Failed to open display\n"); + if ((dst_window = DefaultRootWindow(display)) == 0) + g_error("main: Failed to obtain root window\n"); + if ((xcomposite_window = XCompositeGetOverlayWindow(display, dst_window)) != 0) + dst_window = xcomposite_window; + if (argc > 1) if ((pipeline = gst_pipeline_new("sequence-player"))) { sinks[AUDIO_SINK] = gst_element_factory_make("autoaudiosink", NULL); + gst_bin_add(GST_BIN(pipeline), sinks[AUDIO_SINK]); +#ifdef HAVE_VIDEO sinks[VIDEO_SINK] = gst_element_factory_make("autovideosink", NULL); - gst_bin_add(GST_BIN(pipeline), sinks[AUDIO_SINK]); gst_bin_add(GST_BIN(pipeline), sinks[VIDEO_SINK]); +#endif /* HAVE_VIDEO */ for (Nix = 1 ; Nix < argc ; Nix++) - play_file(pipeline, argv[Nix], sinks); + play_file(pipeline, argv[Nix], dst_window, sinks); gst_element_set_state(pipeline, GST_STATE_NULL); gst_object_unref(pipeline); } + if (xcomposite_window) + XCompositeReleaseOverlayWindow(display, xcomposite_window); + XCloseDisplay(display); gst_deinit(); return 0; }
- Previous message: [maemo-commits] r17981 - in projects/haf/trunk/libmatchbox2: . matchbox/comp-mgr
- Next message: [maemo-commits] r17983 - in projects/haf/trunk/libmatchbox2: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]