# HG changeset patch # User renatofilho # Date 1184710629 -3600 # Node ID 357b301e2d23f8d92e571b66d6a3b276a86633f2 # Parent e42706ada2313b48da2321d548a75bbb05544f63 [svn r794] -fixed volume property for audio sinks elements; - Created property parse-metadata for enable parse files metadata diff -r e42706ada231 -r 357b301e2d23 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 Tue Jul 17 23:17:09 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); } diff -r e42706ada231 -r 357b301e2d23 gst-gmyth/playbinmaemo/gstplaybinmaemo.h --- a/gst-gmyth/playbinmaemo/gstplaybinmaemo.h Sat Jul 14 17:20:54 2007 +0100 +++ b/gst-gmyth/playbinmaemo/gstplaybinmaemo.h Tue Jul 17 23:17:09 2007 +0100 @@ -46,11 +46,13 @@ guint64 queue_size; guint64 queue_min_threshold; gboolean is_stream; + gboolean parse_metadata; glong xid; guint volume; /* currently loaded media */ gboolean need_rebuild; + gboolean has_metadata; gchar *uri; GstElement *source; GstElement *decoder;