# HG changeset patch # User leo_sobral # Date 1187215615 -3600 # Node ID a87c760e0dfa3bcd8827794e3890cc5874b8a0a1 # Parent 4b2192319f5668f7b3424dfc6504bec2e1fb1c30 [svn r811] - Fixed indentation to 2 spaces diff -r 4b2192319f56 -r a87c760e0dfa gst-gmyth/playbinmaemo/gstplaybinmaemo.c --- a/gst-gmyth/playbinmaemo/gstplaybinmaemo.c Wed Aug 15 20:52:44 2007 +0100 +++ b/gst-gmyth/playbinmaemo/gstplaybinmaemo.c Wed Aug 15 23:06:55 2007 +0100 @@ -306,52 +306,51 @@ static void prepare_elements (GstPlayBinMaemo *pbm) { - GstElement *decoder; - GstElement *queue; + GstElement *decoder; + GstElement *queue; - decoder = gst_element_factory_make ("decodebin2", "decode"); - add_element (pbm, decoder); - g_signal_connect (G_OBJECT (decoder), - "autoplug-continue", - G_CALLBACK (autoplug_continue_cb), - pbm); + decoder = gst_element_factory_make ("decodebin2", "decode"); + add_element (pbm, decoder); + g_signal_connect (G_OBJECT (decoder), + "autoplug-continue", + G_CALLBACK (autoplug_continue_cb), + pbm); - g_signal_connect (G_OBJECT (decoder), - "unknown-type", - G_CALLBACK (unknown_type_cb), - pbm); + g_signal_connect (G_OBJECT (decoder), + "unknown-type", + G_CALLBACK (unknown_type_cb), + pbm); - g_signal_connect (G_OBJECT (decoder), - "new-decoded-pad", - G_CALLBACK (new_decoded_pad_cb), - pbm); + g_signal_connect (G_OBJECT (decoder), + "new-decoded-pad", + G_CALLBACK (new_decoded_pad_cb), + pbm); - queue = gst_element_factory_make ("queue", NULL); - add_element (pbm, queue); + queue = gst_element_factory_make ("queue", NULL); + add_element (pbm, queue); - if (gst_element_link_many (pbm->source, queue, decoder, NULL) == FALSE) { - g_warning ("FAIL TO LINK SRC WITH DECODEBIN2"); - } + if (gst_element_link_many (pbm->source, queue, decoder, NULL) == FALSE) { + g_warning ("FAIL TO LINK SRC WITH DECODEBIN2"); + } } static gboolean setup_source (GstPlayBinMaemo *pbm) { - if (!pbm->need_rebuild) - return TRUE; + if (!pbm->need_rebuild) + return TRUE; - clear_elements (pbm); + clear_elements (pbm); - GST_DEBUG_OBJECT (pbm, "setup source"); + GST_DEBUG_OBJECT (pbm, "setup source"); - pbm->has_metadata = FALSE; + pbm->has_metadata = FALSE; - /* create and configure an element that can handle the uri */ - if (!(pbm->source = gen_source_element (pbm))) - goto no_source; + /* create and configure an element that can handle the uri */ + if (!(pbm->source = gen_source_element (pbm))) + goto no_source; - - add_element (pbm, pbm->source); + add_element (pbm, pbm->source); #if 0 @@ -361,12 +360,12 @@ } #endif - prepare_elements (pbm); + prepare_elements (pbm); - return TRUE; + return TRUE; no_source: - return FALSE; + return FALSE; } static void @@ -458,14 +457,14 @@ g_value_set_object (value, play_bin_maemo->source); break; case ARG_VOLUME: - { + { gdouble volume = 0; if (play_bin_maemo->volume > 0) { volume = play_bin_maemo->volume / 65535; } g_value_set_double (value, volume); break; - } + } case ARG_XID: g_value_set_long (value, play_bin_maemo->xid); break; @@ -528,23 +527,23 @@ factory_filter_sinks (GstPluginFeature *feature, GstPlayBinMaemo *pbm) { - guint rank; - const gchar *klass; + guint rank; + const gchar *klass; - if (!GST_IS_ELEMENT_FACTORY (feature)) - return FALSE; + if (!GST_IS_ELEMENT_FACTORY (feature)) + return FALSE; - klass = gst_element_factory_get_klass (GST_ELEMENT_FACTORY (feature)); + klass = gst_element_factory_get_klass (GST_ELEMENT_FACTORY (feature)); - if ((strstr (klass, "Sink/Video") == NULL) && (strstr (klass, "Sink/Audio") == NULL)) - return FALSE; + if ((strstr (klass, "Sink/Video") == NULL) && (strstr (klass, "Sink/Audio") == NULL)) + return FALSE; - g_debug ("Filtered: %s", gst_element_factory_get_longname ((GST_ELEMENT_FACTORY (feature)))); - rank = gst_plugin_feature_get_rank (feature); - if (rank < GST_RANK_MARGINAL) - return FALSE; + g_debug ("Filtered: %s", gst_element_factory_get_longname ((GST_ELEMENT_FACTORY (feature)))); + rank = gst_plugin_feature_get_rank (feature); + if (rank < GST_RANK_MARGINAL) + return FALSE; - return TRUE; + return TRUE; } static gint @@ -650,7 +649,7 @@ GstCaps *caps, gpointer user_data) { - g_debug ("unknown_type_cb: %s", gst_caps_to_string (caps)); + g_debug ("unknown_type_cb: %s", gst_caps_to_string (caps)); } static GstPad * @@ -673,93 +672,93 @@ static GstElement* create_element (GstPlayBinMaemo *pbm, GstElementFactory *factory) { - GstElement *queue; - GstElement *bin = NULL; - GstElement *element; - GstPad *pad; + GstElement *queue; + GstElement *bin = NULL; + GstElement *element; + GstPad *pad; - element = gst_element_factory_create (factory, NULL); - if (element == NULL) - return NULL; + element = gst_element_factory_create (factory, NULL); + if (element == NULL) + return NULL; - bin = gst_bin_new (NULL); + bin = gst_bin_new (NULL); - queue = gst_element_factory_make ("queue", NULL); - gst_bin_add (GST_BIN (bin), queue); + queue = gst_element_factory_make ("queue", NULL); + gst_bin_add (GST_BIN (bin), queue); - if (strstr (gst_element_factory_get_klass (factory), "Sink/Video") != NULL) { - GstElement *colorspace; + if (strstr (gst_element_factory_get_klass (factory), "Sink/Video") != NULL) { + GstElement *colorspace; - colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL); + colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL); - gst_bin_add (GST_BIN (bin), colorspace); - if (gst_element_link (queue, colorspace) == FALSE) { - GST_WARNING_OBJECT (pbm, "Fail to link queue and colorspace"); - gst_element_set_state (colorspace, GST_STATE_NULL); - gst_object_unref (colorspace); - goto error; - } - - gst_bin_add (GST_BIN (bin), element); - if (gst_element_link (colorspace, element) == FALSE) { - GST_WARNING_OBJECT (pbm, "Fail to link colorspace and sink video: %s", GST_ELEMENT_NAME (element)); - gst_element_set_state (colorspace, GST_STATE_NULL); - gst_object_unref (colorspace); - goto error; - } - - pbm->sink_video = element; - update_xid (pbm); - - } else if (strstr (gst_element_factory_get_klass (factory), "Sink/Audio") != NULL) { - GParamSpec *vol_spec; - GstElement *prev; - - prev = queue; - vol_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume"); - if (vol_spec == NULL) { - GstElement *volume; - - bin = gst_bin_new (NULL); - volume = gst_element_factory_make ("volume", "volume"); - gst_bin_add (GST_BIN (bin), volume); - if (gst_element_link (queue, volume) == FALSE) { - GST_WARNING_OBJECT (pbm, "Fail to link queue and volume"); - gst_element_set_state (volume, GST_STATE_NULL); - gst_object_unref (volume); - goto error; - } - - prev = volume; - g_param_spec_unref (vol_spec); - } - - gst_bin_add (GST_BIN (bin), element); - if (gst_element_link (prev, element) == FALSE) { - GST_WARNING_OBJECT (pbm, "Fail to link volume and sink audio: %s", GST_ELEMENT_NAME (element)); - if (prev != queue) { - gst_element_set_state (prev, GST_STATE_NULL); - gst_object_unref (prev); - } - goto error; - } - - pbm->volume_element = (prev != queue) ? prev : element; - update_volume (pbm); + gst_bin_add (GST_BIN (bin), colorspace); + if (gst_element_link (queue, colorspace) == FALSE) { + GST_WARNING_OBJECT (pbm, "Fail to link queue and colorspace"); + gst_element_set_state (colorspace, GST_STATE_NULL); + gst_object_unref (colorspace); + goto error; } - pad = gst_element_get_pad (queue, "sink"); - gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad)); - gst_object_unref (pad); + gst_bin_add (GST_BIN (bin), element); + if (gst_element_link (colorspace, element) == FALSE) { + GST_WARNING_OBJECT (pbm, "Fail to link colorspace and sink video: %s", GST_ELEMENT_NAME (element)); + gst_element_set_state (colorspace, GST_STATE_NULL); + gst_object_unref (colorspace); + goto error; + } - return bin; + pbm->video_sink = element; + update_xid (pbm); + + } else if (strstr (gst_element_factory_get_klass (factory), "Sink/Audio") != NULL) { + GParamSpec *vol_spec; + GstElement *prev; + + prev = queue; + vol_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume"); + if (vol_spec == NULL) { + GstElement *volume; + + bin = gst_bin_new (NULL); + volume = gst_element_factory_make ("volume", "volume"); + gst_bin_add (GST_BIN (bin), volume); + if (gst_element_link (queue, volume) == FALSE) { + GST_WARNING_OBJECT (pbm, "Fail to link queue and volume"); + gst_element_set_state (volume, GST_STATE_NULL); + gst_object_unref (volume); + goto error; + } + + prev = volume; + g_param_spec_unref (vol_spec); + } + + gst_bin_add (GST_BIN (bin), element); + if (gst_element_link (prev, element) == FALSE) { + GST_WARNING_OBJECT (pbm, "Fail to link volume and sink audio: %s", GST_ELEMENT_NAME (element)); + if (prev != queue) { + gst_element_set_state (prev, GST_STATE_NULL); + gst_object_unref (prev); + } + goto error; + } + + pbm->volume_element = (prev != queue) ? prev : element; + update_volume (pbm); + } + + pad = gst_element_get_pad (queue, "sink"); + gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad)); + gst_object_unref (pad); + + return bin; error: - gst_element_set_state (bin, GST_STATE_NULL); - gst_object_unref (bin); + gst_element_set_state (bin, GST_STATE_NULL); + gst_object_unref (bin); - return NULL; + return NULL; } static void @@ -768,172 +767,172 @@ gboolean arg, gpointer user_data) { - GList *comp = NULL; - GList *walk; - GstCaps *caps; - gboolean linked; - GstPlayBinMaemo *pbm; + GList *comp = NULL; + GList *walk; + GstCaps *caps; + gboolean linked; + GstPlayBinMaemo *pbm; - pbm = GST_PLAY_BIN_MAEMO (user_data); - caps = gst_pad_get_caps (pad); + pbm = GST_PLAY_BIN_MAEMO (user_data); + caps = gst_pad_get_caps (pad); - g_debug ("new_decoded_pad_cb: %s", gst_caps_to_string (caps)); + g_debug ("new_decoded_pad_cb: %s", gst_caps_to_string (caps)); - comp = find_compatibles (GST_PLAY_BIN_MAEMO (user_data), caps); + comp = find_compatibles (GST_PLAY_BIN_MAEMO (user_data), caps); - if (comp == NULL) { - g_warning ("flow error: dont find comaptible"); - return; + if (comp == NULL) { + g_warning ("flow error: dont find comaptible"); + return; + } + + GST_PAD_STREAM_LOCK (pad); + + linked = FALSE; + for (walk=comp; walk != NULL; walk = walk->next) { + GstElementFactory *factory = (GstElementFactory *) walk->data; + GstElement *element; + GstPad *sinkpad = NULL; + + if ((element = create_element (pbm, factory)) == NULL) { + GST_WARNING_OBJECT (pbm, "Could not create an element from %s", + gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); + g_debug ("Could not create an element from %s", + gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); + + continue; } - GST_PAD_STREAM_LOCK (pad); - - linked = FALSE; - for (walk=comp; walk != NULL; walk = walk->next) { - GstElementFactory *factory = (GstElementFactory *) walk->data; - GstElement *element; - GstPad *sinkpad = NULL; - - if ((element = create_element (pbm, factory)) == NULL) { - GST_WARNING_OBJECT (pbm, "Could not create an element from %s", - gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); - g_debug ("Could not create an element from %s", - gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); - - continue; - } - - if (!(add_element (GST_PLAY_BIN_MAEMO (user_data), element))) { - GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY", GST_ELEMENT_NAME (element)); - gst_object_unref (element); - continue; - } - - if ((gst_element_set_state (element, GST_STATE_READY)) - == GST_STATE_CHANGE_FAILURE) { - gst_element_set_state (element, GST_STATE_NULL); - gst_object_unref (sinkpad); - gst_bin_remove (GST_BIN (user_data), element); - continue; - } - - if (!(sinkpad = find_sink_pad (element))) { - GST_WARNING_OBJECT (pbm, "Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element)); - g_debug ("Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element)); - gst_object_unref (element); - continue; - } - - - if ((gst_pad_link (pad, sinkpad)) != GST_PAD_LINK_OK) { - GST_WARNING_OBJECT (pbm, "Link failed on pad %s:%s", GST_DEBUG_PAD_NAME (sinkpad)); - gst_element_set_state (element, GST_STATE_NULL); - gst_object_unref (sinkpad); - gst_bin_remove (GST_BIN (user_data), element); - continue; - } - - gst_object_unref (sinkpad); - - if ((gst_element_set_state (element, GST_STATE_PAUSED)) == GST_STATE_CHANGE_FAILURE) { - gst_element_set_state (element, GST_STATE_NULL); - gst_bin_remove (GST_BIN (user_data), element); - continue; - } - - linked = TRUE; - break; + if (!(add_element (GST_PLAY_BIN_MAEMO (user_data), element))) { + GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY", GST_ELEMENT_NAME (element)); + gst_object_unref (element); + continue; } - g_list_free (comp); - if (linked == FALSE) { - g_warning ("GstFlow ERROR"); + if ((gst_element_set_state (element, GST_STATE_READY)) + == GST_STATE_CHANGE_FAILURE) { + gst_element_set_state (element, GST_STATE_NULL); + gst_object_unref (sinkpad); + gst_bin_remove (GST_BIN (user_data), element); + continue; } - GST_PAD_STREAM_UNLOCK (pad); + + if (!(sinkpad = find_sink_pad (element))) { + GST_WARNING_OBJECT (pbm, "Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element)); + g_debug ("Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element)); + gst_object_unref (element); + continue; + } + + + if ((gst_pad_link (pad, sinkpad)) != GST_PAD_LINK_OK) { + GST_WARNING_OBJECT (pbm, "Link failed on pad %s:%s", GST_DEBUG_PAD_NAME (sinkpad)); + gst_element_set_state (element, GST_STATE_NULL); + gst_object_unref (sinkpad); + gst_bin_remove (GST_BIN (user_data), element); + continue; + } + + gst_object_unref (sinkpad); + + if ((gst_element_set_state (element, GST_STATE_PAUSED)) == GST_STATE_CHANGE_FAILURE) { + gst_element_set_state (element, GST_STATE_NULL); + gst_bin_remove (GST_BIN (user_data), element); + continue; + } + + linked = TRUE; + break; + } + + g_list_free (comp); + if (linked == FALSE) { + g_warning ("GstFlow ERROR"); + } + GST_PAD_STREAM_UNLOCK (pad); } static void update_volume (GstPlayBinMaemo *pbm) { - if (pbm->volume_element != NULL) { - if (pbm->volume > 0) { - g_object_set (G_OBJECT (pbm->volume_element), - "volume", pbm->volume, - NULL); - } else { - g_object_set (G_OBJECT (pbm->volume_element), - "mute", TRUE, - NULL); - } + if (pbm->volume_element != NULL) { + if (pbm->volume > 0) { + g_object_set (G_OBJECT (pbm->volume_element), + "volume", pbm->volume, + NULL); + } else { + g_object_set (G_OBJECT (pbm->volume_element), + "mute", TRUE, + NULL); } + } } static void update_xid (GstPlayBinMaemo *pbm) { - if ((pbm->sink_video != NULL) && - (pbm->xid != -1) && - (GST_IS_X_OVERLAY (pbm->sink_video))) { + if ((pbm->video_sink != NULL) && + (pbm->xid != -1) && + (GST_IS_X_OVERLAY (pbm->video_sink))) { - Display *display; - g_object_set (G_OBJECT (pbm->sink_video), - "force-aspect-ratio", TRUE, NULL); - display = XOpenDisplay(NULL); - XMapRaised(display, pbm->xid); - XSync (display, FALSE); + Display *display; + g_object_set (G_OBJECT (pbm->video_sink), + "force-aspect-ratio", TRUE, NULL); + display = XOpenDisplay(NULL); + XMapRaised(display, pbm->xid); + XSync (display, FALSE); - gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (pbm->sink_video), - pbm->xid); - } + gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (pbm->video_sink), + pbm->xid); + } } static gboolean add_element (GstPlayBinMaemo *pbm, GstElement *child) { - if (gst_bin_add (GST_BIN (pbm), child)) { - pbm->elements = g_list_append (pbm->elements, child); - return TRUE; - } - return FALSE; + if (gst_bin_add (GST_BIN (pbm), child)) { + pbm->elements = g_list_append (pbm->elements, child); + return TRUE; + } + return FALSE; } static void clear_elements (GstPlayBinMaemo *pbm) { - GList *walk; + GList *walk; - walk = pbm->elements; + walk = pbm->elements; - for (; walk != NULL; walk = walk->next) { - GstElement *e = GST_ELEMENT (walk->data); + for (; walk != NULL; walk = walk->next) { + GstElement *e = GST_ELEMENT (walk->data); - gst_element_set_state (e, GST_STATE_NULL); - gst_bin_remove (GST_BIN (pbm), e); - } + gst_element_set_state (e, GST_STATE_NULL); + gst_bin_remove (GST_BIN (pbm), e); + } - g_list_free (pbm->elements); - pbm->elements = NULL; - pbm->source = NULL; - pbm->volume_element = NULL; - pbm->sink_video = NULL; + g_list_free (pbm->elements); + pbm->elements = NULL; + pbm->source = NULL; + pbm->volume_element = NULL; + pbm->video_sink = NULL; } static gboolean plugin_init(GstPlugin * plugin) { #ifdef ENABLE_NLS - setlocale(LC_ALL, ""); - bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); #endif /* ENABLE_NLS */ - if (!gst_element_register(plugin, "playbinmaemo", GST_RANK_SECONDARY, - GST_TYPE_PLAY_BIN_MAEMO)) { - return FALSE; - } + if (!gst_element_register(plugin, "playbinmaemo", GST_RANK_SECONDARY, + GST_TYPE_PLAY_BIN_MAEMO)) { + return FALSE; + } - return TRUE; + return TRUE; } GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,