gst-gmyth/playbinmaemo/gstplaybinmaemo.c
branchtrunk
changeset 791 cdafc5e948b8
parent 787 e42706ada231
child 792 a6ac25bf88a7
     1.1 --- a/gst-gmyth/playbinmaemo/gstplaybinmaemo.c	Sat Jul 14 17:20:54 2007 +0100
     1.2 +++ b/gst-gmyth/playbinmaemo/gstplaybinmaemo.c	Thu Aug 02 14:49:26 2007 +0100
     1.3 @@ -47,6 +47,7 @@
     1.4    ARG_QUEUE_MIN_THRESHOLD,
     1.5    ARG_SOURCE,
     1.6    ARG_VOLUME,
     1.7 +  ARG_PARSE_METADATA,
     1.8    ARG_XID
     1.9  };
    1.10  
    1.11 @@ -142,6 +143,11 @@
    1.12        g_param_spec_object ("source", "Source", "Source element",
    1.13            GST_TYPE_ELEMENT, G_PARAM_READABLE));
    1.14  
    1.15 +  g_object_class_install_property (gobject_klass, ARG_PARSE_METADATA,
    1.16 +      g_param_spec_boolean ("parse-metadata", "Parse Metadata", "Parse metadata info",
    1.17 +          TRUE, G_PARAM_READWRITE));
    1.18 +
    1.19 +
    1.20    GST_DEBUG_CATEGORY_INIT (gst_play_bin_maemo_debug, "playbinmaemo", 0,
    1.21        "playbinmaemo");
    1.22  
    1.23 @@ -162,6 +168,7 @@
    1.24  
    1.25    play_bin_maemo->volume = DEFAULT_VOLUME * 65535 / 10;
    1.26    play_bin_maemo->xid = DEFAULT_XID;
    1.27 +  play_bin_maemo->parse_metadata = TRUE;
    1.28  
    1.29    factories = gst_default_registry_feature_filter ((GstPluginFeatureFilter) factory_filter_sinks,
    1.30                                                     FALSE, play_bin_maemo);
    1.31 @@ -387,6 +394,8 @@
    1.32  
    1.33      GST_DEBUG_OBJECT (pbm, "setup source");
    1.34  
    1.35 +    pbm->has_metadata = FALSE;
    1.36 +
    1.37      /* delete old src */
    1.38      remove_source (pbm);
    1.39  
    1.40 @@ -473,6 +482,9 @@
    1.41        }
    1.42        break;
    1.43      }
    1.44 +    case ARG_PARSE_METADATA:
    1.45 +        play_bin_maemo->parse_metadata = g_value_get_boolean (value);
    1.46 +        break;
    1.47      default:
    1.48        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    1.49        break;
    1.50 @@ -502,6 +514,9 @@
    1.51      case ARG_XID:
    1.52        g_value_set_long (value, play_bin_maemo->xid);
    1.53        break;
    1.54 +    case ARG_PARSE_METADATA:
    1.55 +      g_value_set_boolean (value, play_bin_maemo->parse_metadata);
    1.56 +      break;
    1.57      default:
    1.58        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    1.59        break;
    1.60 @@ -649,6 +664,22 @@
    1.61  {
    1.62      GList *comp = NULL;
    1.63      gboolean ret = TRUE;
    1.64 +    GstPlayBinMaemo *pbm;
    1.65 +
    1.66 +    pbm = GST_PLAY_BIN_MAEMO (user_data);
    1.67 +
    1.68 +    //TODO: fix this for work with all metada elements
    1.69 +    if (pbm->parse_metadata) {
    1.70 +        gchar *caps_str = gst_caps_to_string (caps);
    1.71 +        if ((strstr (caps_str, "id3") != NULL) &&
    1.72 +            (pbm->has_metadata == FALSE)) {
    1.73 +
    1.74 +            g_free (caps_str);
    1.75 +            pbm->has_metadata = TRUE;
    1.76 +            return ret;
    1.77 +        }
    1.78 +        g_free (caps_str);
    1.79 +    }
    1.80  
    1.81      comp = find_compatibles (GST_PLAY_BIN_MAEMO (user_data), caps);
    1.82      if (comp != NULL) {
    1.83 @@ -685,6 +716,52 @@
    1.84    return pad;
    1.85  }
    1.86  
    1.87 +static GstElement*
    1.88 +create_element (GstPlayBinMaemo *pbm, GstElementFactory *factory)
    1.89 +{
    1.90 +    GstElement *ret = NULL;
    1.91 +    GstElement *element;
    1.92 +
    1.93 +    element = gst_element_factory_create (factory, NULL);
    1.94 +    if (element == NULL)
    1.95 +        return NULL;
    1.96 +
    1.97 +    if (strstr (gst_element_factory_get_klass (factory), "Sink/Video") != NULL) {
    1.98 +        update_xid (pbm);
    1.99 +        pbm->sink_video = element;
   1.100 +        ret = element;
   1.101 +    } else if (strstr (gst_element_factory_get_klass (factory), "Sink/Audio") != NULL) {
   1.102 +        GParamSpec *vol_spec;
   1.103 +
   1.104 +        vol_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume");
   1.105 +        if (vol_spec == NULL) {
   1.106 +            GstElement *bin;
   1.107 +            GstElement *volume;
   1.108 +
   1.109 +            bin = gst_bin_new (NULL);
   1.110 +            volume = gst_element_factory_make ("volume", "volume");
   1.111 +            gst_bin_add (GST_BIN (bin), volume);
   1.112 +            gst_bin_add (GST_BIN (bin), element);
   1.113 +            if (gst_element_link (volume, element) == FALSE) {
   1.114 +                GST_WARNING_OBJECT (pbm, "Fail to link volume and sink audio: %s", GST_ELEMENT_NAME (element));
   1.115 +                gst_element_set_state (bin, GST_STATE_NULL);
   1.116 +                gst_object_unref (bin);
   1.117 +                return NULL;
   1.118 +            }
   1.119 +            pbm->volume_element = volume;
   1.120 +            ret = bin;
   1.121 +        } else {
   1.122 +            ret = element;
   1.123 +            pbm->volume_element = element;
   1.124 +            g_param_spec_unref (vol_spec);
   1.125 +        }
   1.126 +
   1.127 +        update_volume (pbm);
   1.128 +    }
   1.129 +
   1.130 +    return ret;
   1.131 +}
   1.132 +
   1.133  static void
   1.134  new_decoded_pad_cb (GstElement *object,
   1.135                      GstPad* pad,
   1.136 @@ -718,23 +795,14 @@
   1.137          GstElement *element;
   1.138          GstPad *sinkpad;
   1.139  
   1.140 -        if ((element = gst_element_factory_create (factory, NULL)) == NULL) {
   1.141 +        if ((element = create_element (pbm, factory)) == NULL) {
   1.142              GST_WARNING_OBJECT (pbm, "Could not create an element from %s",
   1.143                  gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
   1.144              continue;
   1.145          }
   1.146  
   1.147 -        if (strstr (gst_element_factory_get_klass (factory), "Sink/Video") != NULL) {
   1.148 -            pbm->sink_video = element;
   1.149 -            update_xid (pbm);
   1.150 -        } else if (strstr (gst_element_factory_get_klass (factory), "Sink/Audio") != NULL) {
   1.151 -            pbm->volume_element = element;
   1.152 -            update_volume (pbm);
   1.153 -        }
   1.154 -
   1.155          if (!(gst_bin_add (GST_BIN (user_data), element))) {
   1.156 -            GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY",
   1.157 -                GST_ELEMENT_NAME (element));
   1.158 +            GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY", GST_ELEMENT_NAME (element));
   1.159              gst_object_unref (element);
   1.160              continue;
   1.161          }
   1.162 @@ -755,8 +823,7 @@
   1.163  
   1.164  
   1.165          if ((gst_pad_link (pad, sinkpad)) != GST_PAD_LINK_OK) {
   1.166 -            GST_WARNING_OBJECT (pbm, "Link failed on pad %s:%s",
   1.167 -                GST_DEBUG_PAD_NAME (sinkpad));
   1.168 +            GST_WARNING_OBJECT (pbm, "Link failed on pad %s:%s", GST_DEBUG_PAD_NAME (sinkpad));
   1.169              gst_element_set_state (element, GST_STATE_NULL);
   1.170              gst_object_unref (sinkpad);
   1.171              gst_bin_remove (GST_BIN (user_data), element);
   1.172 @@ -806,12 +873,9 @@
   1.173      if ((pbm->sink_video != NULL) &&
   1.174          (pbm->xid != -1) &&
   1.175          (GST_IS_X_OVERLAY (pbm->sink_video))) {
   1.176 -        XGCValues values;
   1.177 -        Display *disp;
   1.178 +
   1.179          g_object_set (G_OBJECT (pbm->sink_video),
   1.180                        "force-aspect-ratio", TRUE, NULL);
   1.181 -        g_debug ("Update XID to %ld", pbm->xid);
   1.182 -
   1.183          gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (pbm->sink_video),
   1.184                                        pbm->xid);
   1.185      }