diff -r e42706ada231 -r cdafc5e948b8 gst-gmyth/playbinmaemo/gstplaybinmaemo.c --- a/gst-gmyth/playbinmaemo/gstplaybinmaemo.c Sat Jul 14 17:20:54 2007 +0100 +++ b/gst-gmyth/playbinmaemo/gstplaybinmaemo.c Thu Aug 02 14:49:26 2007 +0100 @@ -47,6 +47,7 @@ ARG_QUEUE_MIN_THRESHOLD, ARG_SOURCE, ARG_VOLUME, + ARG_PARSE_METADATA, ARG_XID }; @@ -142,6 +143,11 @@ g_param_spec_object ("source", "Source", "Source element", GST_TYPE_ELEMENT, G_PARAM_READABLE)); + g_object_class_install_property (gobject_klass, ARG_PARSE_METADATA, + g_param_spec_boolean ("parse-metadata", "Parse Metadata", "Parse metadata info", + TRUE, G_PARAM_READWRITE)); + + GST_DEBUG_CATEGORY_INIT (gst_play_bin_maemo_debug, "playbinmaemo", 0, "playbinmaemo"); @@ -162,6 +168,7 @@ play_bin_maemo->volume = DEFAULT_VOLUME * 65535 / 10; play_bin_maemo->xid = DEFAULT_XID; + play_bin_maemo->parse_metadata = TRUE; factories = gst_default_registry_feature_filter ((GstPluginFeatureFilter) factory_filter_sinks, FALSE, play_bin_maemo); @@ -387,6 +394,8 @@ GST_DEBUG_OBJECT (pbm, "setup source"); + pbm->has_metadata = FALSE; + /* delete old src */ remove_source (pbm); @@ -473,6 +482,9 @@ } break; } + case ARG_PARSE_METADATA: + play_bin_maemo->parse_metadata = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -502,6 +514,9 @@ case ARG_XID: g_value_set_long (value, play_bin_maemo->xid); break; + case ARG_PARSE_METADATA: + g_value_set_boolean (value, play_bin_maemo->parse_metadata); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -649,6 +664,22 @@ { GList *comp = NULL; gboolean ret = TRUE; + GstPlayBinMaemo *pbm; + + pbm = GST_PLAY_BIN_MAEMO (user_data); + + //TODO: fix this for work with all metada elements + if (pbm->parse_metadata) { + gchar *caps_str = gst_caps_to_string (caps); + if ((strstr (caps_str, "id3") != NULL) && + (pbm->has_metadata == FALSE)) { + + g_free (caps_str); + pbm->has_metadata = TRUE; + return ret; + } + g_free (caps_str); + } comp = find_compatibles (GST_PLAY_BIN_MAEMO (user_data), caps); if (comp != NULL) { @@ -685,6 +716,52 @@ return pad; } +static GstElement* +create_element (GstPlayBinMaemo *pbm, GstElementFactory *factory) +{ + GstElement *ret = NULL; + GstElement *element; + + element = gst_element_factory_create (factory, NULL); + if (element == NULL) + return NULL; + + if (strstr (gst_element_factory_get_klass (factory), "Sink/Video") != NULL) { + update_xid (pbm); + pbm->sink_video = element; + ret = element; + } else if (strstr (gst_element_factory_get_klass (factory), "Sink/Audio") != NULL) { + GParamSpec *vol_spec; + + vol_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume"); + if (vol_spec == NULL) { + GstElement *bin; + GstElement *volume; + + bin = gst_bin_new (NULL); + volume = gst_element_factory_make ("volume", "volume"); + gst_bin_add (GST_BIN (bin), volume); + gst_bin_add (GST_BIN (bin), element); + if (gst_element_link (volume, element) == FALSE) { + GST_WARNING_OBJECT (pbm, "Fail to link volume and sink audio: %s", GST_ELEMENT_NAME (element)); + gst_element_set_state (bin, GST_STATE_NULL); + gst_object_unref (bin); + return NULL; + } + pbm->volume_element = volume; + ret = bin; + } else { + ret = element; + pbm->volume_element = element; + g_param_spec_unref (vol_spec); + } + + update_volume (pbm); + } + + return ret; +} + static void new_decoded_pad_cb (GstElement *object, GstPad* pad, @@ -718,23 +795,14 @@ GstElement *element; GstPad *sinkpad; - if ((element = gst_element_factory_create (factory, NULL)) == 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))); continue; } - if (strstr (gst_element_factory_get_klass (factory), "Sink/Video") != NULL) { - pbm->sink_video = element; - update_xid (pbm); - } else if (strstr (gst_element_factory_get_klass (factory), "Sink/Audio") != NULL) { - pbm->volume_element = element; - update_volume (pbm); - } - if (!(gst_bin_add (GST_BIN (user_data), element))) { - GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY", - GST_ELEMENT_NAME (element)); + GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY", GST_ELEMENT_NAME (element)); gst_object_unref (element); continue; } @@ -755,8 +823,7 @@ 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_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); @@ -806,12 +873,9 @@ if ((pbm->sink_video != NULL) && (pbm->xid != -1) && (GST_IS_X_OVERLAY (pbm->sink_video))) { - XGCValues values; - Display *disp; + g_object_set (G_OBJECT (pbm->sink_video), "force-aspect-ratio", TRUE, NULL); - g_debug ("Update XID to %ld", pbm->xid); - gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (pbm->sink_video), pbm->xid); }