1.1 --- a/gst-gmyth/decodebin2/gstdecodebin2.c Thu Aug 02 14:49:26 2007 +0100
1.2 +++ b/gst-gmyth/decodebin2/gstdecodebin2.c Thu Aug 02 14:58:15 2007 +0100
1.3 @@ -450,9 +450,11 @@
1.4 }
1.5
1.6 /* only select elements with autoplugging rank */
1.7 +#if 0
1.8 rank = gst_plugin_feature_get_rank (feature);
1.9 if (rank < GST_RANK_MARGINAL)
1.10 return FALSE;
1.11 +#endif
1.12
1.13 return TRUE;
1.14 }
2.1 --- a/gst-gmyth/playbinmaemo/gstplaybinmaemo.c Thu Aug 02 14:49:26 2007 +0100
2.2 +++ b/gst-gmyth/playbinmaemo/gstplaybinmaemo.c Thu Aug 02 14:58:15 2007 +0100
2.3 @@ -95,10 +95,9 @@
2.4 gpointer user_data);
2.5 static void queue_sink_overrun_cb (GstElement* queue,
2.6 gpointer user_data);
2.7 -
2.8 -
2.9 -
2.10 -
2.11 +static gboolean add_element (GstPlayBinMaemo *pbm,
2.12 + GstElement *child);
2.13 +static void clear_elements (GstPlayBinMaemo *pbm);
2.14
2.15 GST_BOILERPLATE(GstPlayBinMaemo, gst_play_bin_maemo, GstPipeline, GST_TYPE_PIPELINE)
2.16
2.17 @@ -191,6 +190,7 @@
2.18 static void
2.19 gst_play_bin_maemo_finalize (GObject * object)
2.20 {
2.21 + clear_elements (GST_PLAY_BIN_MAEMO (object));
2.22 G_OBJECT_CLASS (parent_class)->finalize (object);
2.23 }
2.24
2.25 @@ -248,8 +248,7 @@
2.26 if (IS_BLACKLISTED_URI (play_bin_maemo->uri))
2.27 goto uri_blacklisted;
2.28
2.29 - source = gst_element_make_from_uri (GST_URI_SRC, play_bin_maemo->uri,
2.30 - "source");
2.31 + source = gst_element_make_from_uri (GST_URI_SRC, play_bin_maemo->uri, "source");
2.32 if (!source)
2.33 goto no_source;
2.34
2.35 @@ -312,76 +311,32 @@
2.36 }
2.37
2.38 static void
2.39 -remove_source (GstPlayBinMaemo *pbm)
2.40 -{
2.41 - GstElement *source = pbm->source;
2.42 -
2.43 - if (source) {
2.44 - GST_DEBUG_OBJECT (pbm, "removing old src element");
2.45 - gst_element_set_state (source, GST_STATE_NULL);
2.46 - gst_bin_remove (GST_BIN_CAST (pbm), source);
2.47 - pbm->source = NULL;
2.48 - }
2.49 -}
2.50 -
2.51 -static void
2.52 -remove_decoders (GstPlayBinMaemo *pbm)
2.53 -{
2.54 - if (pbm->queue != NULL) {
2.55 - gst_element_set_state (pbm->queue, GST_STATE_NULL);
2.56 - gst_bin_remove (GST_BIN_CAST (pbm), pbm->queue);
2.57 - pbm->queue = NULL;
2.58 - }
2.59 -
2.60 - if (pbm->decoder != NULL) {
2.61 - gst_element_set_state (pbm->decoder, GST_STATE_NULL);
2.62 - gst_bin_remove (GST_BIN_CAST (pbm), pbm->decoder);
2.63 - pbm->decoder = NULL;
2.64 - }
2.65 -}
2.66 -
2.67 -static void
2.68 -remove_sinks (GstPlayBinMaemo *pbm)
2.69 -{
2.70 - GSList *walk;
2.71 -
2.72 - for(walk=pbm->sinks; walk != NULL; walk = walk->next) {
2.73 - GstElement *element = (GstElement *) walk->data;
2.74 -
2.75 - gst_element_set_state (element, GST_STATE_NULL);
2.76 - gst_bin_remove (GST_BIN_CAST (pbm), element);
2.77 - }
2.78 -
2.79 - g_slist_free (pbm->sinks);
2.80 - pbm->sinks = NULL;
2.81 -}
2.82 -
2.83 -static void
2.84 prepare_elements (GstPlayBinMaemo *pbm)
2.85 {
2.86 - if (pbm->decoder == NULL) {
2.87 - pbm->decoder = gst_element_factory_make ("decodebin2", "decode");
2.88 - gst_bin_add (GST_BIN (pbm), pbm->decoder);
2.89 - g_signal_connect (G_OBJECT (pbm->decoder),
2.90 - "autoplug-continue",
2.91 - G_CALLBACK (autoplug_continue_cb),
2.92 - pbm);
2.93 - g_signal_connect (G_OBJECT (pbm->decoder),
2.94 - "unknown-type",
2.95 - G_CALLBACK (unknown_type_cb),
2.96 - pbm);
2.97 - g_signal_connect (G_OBJECT (pbm->decoder),
2.98 - "new-decoded-pad",
2.99 - G_CALLBACK (new_decoded_pad_cb),
2.100 - pbm);
2.101 - }
2.102 + GstElement *decoder;
2.103 + GstElement *queue;
2.104
2.105 - if (pbm->queue == NULL) {
2.106 - pbm->queue = gst_element_factory_make ("queue", NULL);
2.107 - gst_bin_add (GST_BIN (pbm), pbm->queue);
2.108 - }
2.109 + decoder = gst_element_factory_make ("decodebin2", "decode");
2.110 + add_element (pbm, decoder);
2.111 + g_signal_connect (G_OBJECT (decoder),
2.112 + "autoplug-continue",
2.113 + G_CALLBACK (autoplug_continue_cb),
2.114 + pbm);
2.115
2.116 - if (gst_element_link_many (pbm->source, pbm->queue, pbm->decoder, NULL) == FALSE) {
2.117 + g_signal_connect (G_OBJECT (decoder),
2.118 + "unknown-type",
2.119 + G_CALLBACK (unknown_type_cb),
2.120 + pbm);
2.121 +
2.122 + g_signal_connect (G_OBJECT (decoder),
2.123 + "new-decoded-pad",
2.124 + G_CALLBACK (new_decoded_pad_cb),
2.125 + pbm);
2.126 +
2.127 + queue = gst_element_factory_make ("queue", NULL);
2.128 + add_element (pbm, queue);
2.129 +
2.130 + if (gst_element_link_many (pbm->source, queue, decoder, NULL) == FALSE) {
2.131 g_warning ("FAIL TO LINK SRC WITH DECODEBIN2");
2.132 }
2.133 }
2.134 @@ -389,26 +344,25 @@
2.135 static gboolean
2.136 setup_source (GstPlayBinMaemo *pbm)
2.137 {
2.138 + GstIterator *childs;
2.139 + GstState state;
2.140 +
2.141 if (!pbm->need_rebuild)
2.142 return TRUE;
2.143
2.144 + clear_elements (pbm);
2.145 +
2.146 GST_DEBUG_OBJECT (pbm, "setup source");
2.147
2.148 pbm->has_metadata = FALSE;
2.149
2.150 - /* delete old src */
2.151 - remove_source (pbm);
2.152 -
2.153 /* create and configure an element that can handle the uri */
2.154 if (!(pbm->source = gen_source_element (pbm)))
2.155 goto no_source;
2.156
2.157
2.158 - gst_bin_add (GST_BIN_CAST (pbm), pbm->source);
2.159 + add_element (pbm, pbm->source);
2.160
2.161 - remove_decoders (pbm);
2.162 -
2.163 - remove_sinks (pbm);
2.164
2.165 #if 0
2.166 if (verify_src_have_sink (pbm)) {
2.167 @@ -460,7 +414,7 @@
2.168 }
2.169 case ARG_VOLUME:
2.170 {
2.171 - guint volume;
2.172 + guint volume = 0;
2.173 volume = g_value_get_uint (value);
2.174 if (volume != 0) {
2.175 volume = (guint) (65535 * volume / 10);
2.176 @@ -476,7 +430,8 @@
2.177 {
2.178 long xid;
2.179 xid = g_value_get_long (value);
2.180 - if (play_bin_maemo->xid != xid) {
2.181 + if (play_bin_maemo->xid != xid)
2.182 + {
2.183 play_bin_maemo->xid = xid;
2.184 update_xid (play_bin_maemo);
2.185 }
2.186 @@ -509,8 +464,14 @@
2.187 g_value_set_object (value, play_bin_maemo->source);
2.188 break;
2.189 case ARG_VOLUME:
2.190 - g_value_set_uint (value, play_bin_maemo->volume);
2.191 + {
2.192 + guint volume = 0;
2.193 + if (play_bin_maemo->volume > 0) {
2.194 + volume = 10 * play_bin_maemo->volume / 65535;
2.195 + }
2.196 + g_value_set_uint (value, volume);
2.197 break;
2.198 + }
2.199 case ARG_XID:
2.200 g_value_set_long (value, play_bin_maemo->xid);
2.201 break;
2.202 @@ -553,8 +514,7 @@
2.203 case GST_STATE_CHANGE_PAUSED_TO_READY:
2.204 case GST_STATE_CHANGE_READY_TO_NULL:
2.205 play_bin_maemo->need_rebuild = TRUE;
2.206 - remove_decoders (play_bin_maemo);
2.207 - remove_source (play_bin_maemo);
2.208 + clear_elements (play_bin_maemo);
2.209 break;
2.210 default:
2.211 break;
2.212 @@ -719,47 +679,93 @@
2.213 static GstElement*
2.214 create_element (GstPlayBinMaemo *pbm, GstElementFactory *factory)
2.215 {
2.216 - GstElement *ret = NULL;
2.217 + GstElement *queue;
2.218 + GstElement *bin = NULL;
2.219 GstElement *element;
2.220 + GstPad *pad;
2.221
2.222 element = gst_element_factory_create (factory, NULL);
2.223 if (element == NULL)
2.224 return NULL;
2.225
2.226 +
2.227 + bin = gst_bin_new (NULL);
2.228 +
2.229 + queue = gst_element_factory_make ("queue", NULL);
2.230 + gst_bin_add (GST_BIN (bin), queue);
2.231 +
2.232 if (strstr (gst_element_factory_get_klass (factory), "Sink/Video") != NULL) {
2.233 + GstElement *colorspace;
2.234 +
2.235 + colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL);
2.236 +
2.237 + gst_bin_add (GST_BIN (bin), colorspace);
2.238 + if (gst_element_link (queue, colorspace) == FALSE) {
2.239 + GST_WARNING_OBJECT (pbm, "Fail to link queue and colorspace");
2.240 + gst_element_set_state (colorspace, GST_STATE_NULL);
2.241 + gst_object_unref (colorspace);
2.242 + goto error;
2.243 + }
2.244 +
2.245 + gst_bin_add (GST_BIN (bin), element);
2.246 + if (gst_element_link (colorspace, element) == FALSE) {
2.247 + GST_WARNING_OBJECT (pbm, "Fail to link colorspace and sink video: %s", GST_ELEMENT_NAME (element));
2.248 + gst_element_set_state (colorspace, GST_STATE_NULL);
2.249 + gst_object_unref (colorspace);
2.250 + goto error;
2.251 + }
2.252 +
2.253 + pbm->sink_video = element;
2.254 update_xid (pbm);
2.255 - pbm->sink_video = element;
2.256 - ret = element;
2.257 +
2.258 } else if (strstr (gst_element_factory_get_klass (factory), "Sink/Audio") != NULL) {
2.259 GParamSpec *vol_spec;
2.260 + GstElement *prev;
2.261
2.262 + prev = queue;
2.263 vol_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume");
2.264 if (vol_spec == NULL) {
2.265 - GstElement *bin;
2.266 GstElement *volume;
2.267
2.268 bin = gst_bin_new (NULL);
2.269 volume = gst_element_factory_make ("volume", "volume");
2.270 gst_bin_add (GST_BIN (bin), volume);
2.271 - gst_bin_add (GST_BIN (bin), element);
2.272 - if (gst_element_link (volume, element) == FALSE) {
2.273 - GST_WARNING_OBJECT (pbm, "Fail to link volume and sink audio: %s", GST_ELEMENT_NAME (element));
2.274 - gst_element_set_state (bin, GST_STATE_NULL);
2.275 - gst_object_unref (bin);
2.276 - return NULL;
2.277 + if (gst_element_link (queue, volume) == FALSE) {
2.278 + GST_WARNING_OBJECT (pbm, "Fail to link queue and volume");
2.279 + gst_element_set_state (volume, GST_STATE_NULL);
2.280 + gst_object_unref (volume);
2.281 + goto error;
2.282 }
2.283 - pbm->volume_element = volume;
2.284 - ret = bin;
2.285 - } else {
2.286 - ret = element;
2.287 - pbm->volume_element = element;
2.288 +
2.289 + prev = volume;
2.290 g_param_spec_unref (vol_spec);
2.291 }
2.292
2.293 + gst_bin_add (GST_BIN (bin), element);
2.294 + if (gst_element_link (prev, element) == FALSE) {
2.295 + GST_WARNING_OBJECT (pbm, "Fail to link volume and sink audio: %s", GST_ELEMENT_NAME (element));
2.296 + if (prev != queue) {
2.297 + gst_element_set_state (prev, GST_STATE_NULL);
2.298 + gst_object_unref (prev);
2.299 + }
2.300 + goto error;
2.301 + }
2.302 +
2.303 + pbm->volume_element = (prev != queue) ? prev : element;
2.304 update_volume (pbm);
2.305 }
2.306
2.307 - return ret;
2.308 + pad = gst_element_get_pad (queue, "sink");
2.309 + gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad));
2.310 + gst_object_unref (pad);
2.311 +
2.312 + return bin;
2.313 +error:
2.314 +
2.315 + gst_element_set_state (bin, GST_STATE_NULL);
2.316 + gst_object_unref (bin);
2.317 +
2.318 + return NULL;
2.319 }
2.320
2.321 static void
2.322 @@ -798,10 +804,13 @@
2.323 if ((element = create_element (pbm, factory)) == NULL) {
2.324 GST_WARNING_OBJECT (pbm, "Could not create an element from %s",
2.325 gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
2.326 + g_debug ("Could not create an element from %s",
2.327 + gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
2.328 +
2.329 continue;
2.330 }
2.331
2.332 - if (!(gst_bin_add (GST_BIN (user_data), element))) {
2.333 + if (!(add_element (GST_PLAY_BIN_MAEMO (user_data), element))) {
2.334 GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY", GST_ELEMENT_NAME (element));
2.335 gst_object_unref (element);
2.336 continue;
2.337 @@ -817,6 +826,7 @@
2.338
2.339 if (!(sinkpad = find_sink_pad (element))) {
2.340 GST_WARNING_OBJECT (pbm, "Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element));
2.341 + g_debug ("Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element));
2.342 gst_object_unref (element);
2.343 continue;
2.344 }
2.345 @@ -838,8 +848,6 @@
2.346 continue;
2.347 }
2.348
2.349 -
2.350 - pbm->sinks = g_slist_append (pbm->sinks, element);
2.351 linked = TRUE;
2.352 break;
2.353 }
2.354 @@ -874,14 +882,51 @@
2.355 (pbm->xid != -1) &&
2.356 (GST_IS_X_OVERLAY (pbm->sink_video))) {
2.357
2.358 + Display *display;
2.359 g_object_set (G_OBJECT (pbm->sink_video),
2.360 "force-aspect-ratio", TRUE, NULL);
2.361 + display = XOpenDisplay(NULL);
2.362 + XMapRaised(display, pbm->xid);
2.363 + XSync (display, FALSE);
2.364 +
2.365 gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (pbm->sink_video),
2.366 pbm->xid);
2.367 }
2.368 }
2.369
2.370 static gboolean
2.371 +add_element (GstPlayBinMaemo *pbm,
2.372 + GstElement *child)
2.373 +{
2.374 + if (gst_bin_add (GST_BIN (pbm), child)) {
2.375 + pbm->elements = g_list_append (pbm->elements, child);
2.376 + return TRUE;
2.377 + }
2.378 + return FALSE;
2.379 +}
2.380 +
2.381 +static void
2.382 +clear_elements (GstPlayBinMaemo *pbm)
2.383 +{
2.384 + GList *walk;
2.385 +
2.386 + walk = pbm->elements;
2.387 +
2.388 + for (; walk != NULL; walk = walk->next) {
2.389 + GstElement *e = GST_ELEMENT (walk->data);
2.390 +
2.391 + gst_element_set_state (e, GST_STATE_NULL);
2.392 + gst_bin_remove (GST_BIN (pbm), e);
2.393 + }
2.394 +
2.395 + g_list_free (pbm->elements);
2.396 + pbm->elements = NULL;
2.397 + pbm->source = NULL;
2.398 + pbm->volume_element = NULL;
2.399 + pbm->sink_video = NULL;
2.400 +}
2.401 +
2.402 +static gboolean
2.403 plugin_init(GstPlugin * plugin)
2.404 {
2.405 #ifdef ENABLE_NLS
3.1 --- a/gst-gmyth/playbinmaemo/gstplaybinmaemo.h Thu Aug 02 14:49:26 2007 +0100
3.2 +++ b/gst-gmyth/playbinmaemo/gstplaybinmaemo.h Thu Aug 02 14:58:15 2007 +0100
3.3 @@ -54,12 +54,10 @@
3.4 gboolean need_rebuild;
3.5 gboolean has_metadata;
3.6 gchar *uri;
3.7 + GstElement *volume_element;
3.8 GstElement *source;
3.9 - GstElement *decoder;
3.10 - GstElement *queue;
3.11 - GstElement *volume_element;
3.12 GstElement *sink_video;
3.13 - GSList *sinks;
3.14 + GList *elements;
3.15 GList *factories;
3.16 };
3.17