static gboolean gst_play_sink_convert_bin_sink_setcaps (GstPlaySinkConvertBin * self, GstCaps * caps) { GstStructure *s; const gchar *name; gboolean reconfigure = FALSE; gboolean raw; GST_DEBUG_OBJECT (self, "setcaps"); GST_PLAY_SINK_CONVERT_BIN_LOCK (self); s = gst_caps_get_structure (caps, 0); name = gst_structure_get_name (s); if (self->audio) { raw = g_str_equal (name, "audio/x-raw"); } else { raw = g_str_equal (name, "video/x-raw"); } GST_DEBUG_OBJECT (self, "raw %d, self->raw %d, blocked %d", raw, self->raw, gst_pad_is_blocked (self->sink_proxypad)); if (raw) { if (!gst_pad_is_blocked (self->sink_proxypad)) { GstPad *target = gst_ghost_pad_get_target (GST_GHOST_PAD (self->sinkpad)); if (!self->raw || (target && !gst_pad_query_accept_caps (target, caps))) { if (!self->raw) GST_DEBUG_OBJECT (self, "Changing caps from non-raw to raw"); else GST_DEBUG_OBJECT (self, "Changing caps in an incompatible way"); reconfigure = TRUE; block_proxypad (self); } if (target) gst_object_unref (target); } } else { if (self->raw && !gst_pad_is_blocked (self->sink_proxypad)) { GST_DEBUG_OBJECT (self, "Changing caps from raw to non-raw"); reconfigure = TRUE; block_proxypad (self); } } /* Otherwise the setcaps below fails */ if (reconfigure) { gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->sinkpad), NULL); gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->srcpad), NULL); } GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self); GST_DEBUG_OBJECT (self, "Setting sink caps %" GST_PTR_FORMAT, caps); return TRUE; }
/** * Process a pad for connecting or disconnecting, it should be always called * whint the agnostic lock hold. * * @self: The #KmsAgnosticBin2 owner of the pad * @pad: The pad to be processed */ static gboolean kms_agnostic_bin2_process_pad (KmsAgnosticBin2 * self, GstPad * pad) { GstPad *peer = NULL; if (!GST_OBJECT_FLAG_IS_SET (pad, KMS_AGNOSTIC_PAD_STARTED)) { return FALSE; } if (!self->priv->started) { return FALSE; } GST_DEBUG_OBJECT (self, "Processing pad: %" GST_PTR_FORMAT, pad); if (pad == NULL) { return FALSE; } peer = gst_pad_get_peer (pad); if (peer != NULL) { GstPad *target = gst_ghost_pad_get_target (GST_GHOST_PAD (pad)); if (target) { GstCaps *caps = gst_pad_get_current_caps (pad); if (caps != NULL) { gboolean accepted; accepted = gst_pad_query_accept_caps (peer, caps); gst_caps_unref (caps); if (accepted) { GST_DEBUG_OBJECT (self, "No need to reconfigure pad %" GST_PTR_FORMAT, pad); g_object_unref (target); g_object_unref (peer); return FALSE; } remove_target_pad (pad); } g_object_unref (target); } kms_agnostic_bin2_link_pad (self, pad, peer); } return TRUE; }