* the sink. */
changed = FALSE;
sinkpad = NULL;
+
+ /* store the selector for the pad */
+ g_object_set_data (G_OBJECT (pad), "playbin2.select", select);
}
GST_SOURCE_GROUP_UNLOCK (group);
"pad %s:%s removed from group %p", GST_DEBUG_PAD_NAME (pad), group);
GST_SOURCE_GROUP_LOCK (group);
+
+ if ((select = g_object_get_data (G_OBJECT (pad), "playbin2.select"))) {
+ g_assert (select->selector == NULL);
+ g_assert (select->srcpad == pad);
+ gst_object_unref (pad);
+ select->srcpad = NULL;
+ goto exit;
+ }
+
/* get the selector sinkpad */
if (!(peer = g_object_get_data (G_OBJECT (pad), "playbin.sinkpad")))
goto not_linked;
/* remove the pad from the array */
g_ptr_array_remove (select->channels, peer);
GST_DEBUG_OBJECT (playbin, "pad %p removed from array", peer);
+
+ if (!select->channels->len && select->selector) {
+ GST_DEBUG_OBJECT (playbin, "all selector sinkpads removed");
+ GST_DEBUG_OBJECT (playbin, "removing selector %p", select->selector);
+ gst_object_unref (select->srcpad);
+ select->srcpad = NULL;
+ gst_element_set_state (select->selector, GST_STATE_NULL);
+ gst_bin_remove (GST_BIN_CAST (playbin), select->selector);
+ select->selector = NULL;
+ }
}
/* unlink the pad now (can fail, the pad is unlinked before it's removed) */
gst_object_unref (peer);
gst_object_unref (selector);
+exit:
GST_SOURCE_GROUP_UNLOCK (group);
return;
GST_DEBUG_OBJECT (playbin, "requesting new sink pad %d", select->type);
select->sinkpad =
gst_play_sink_request_pad (playbin->playsink, select->type);
-
+ } else if (select->srcpad && select->sinkpad) {
+ GST_DEBUG_OBJECT (playbin, "refreshing new sink pad %d", select->type);
+ gst_play_sink_refresh_pad (playbin->playsink, select->sinkpad,
+ select->type);
+ } else if (select->sinkpad && select->srcpad == NULL) {
+ GST_DEBUG_OBJECT (playbin, "releasing sink pad %d", select->type);
+ gst_play_sink_release_pad (playbin->playsink, select->sinkpad);
+ select->sinkpad = NULL;
+ }
+ if (select->sinkpad && select->srcpad &&
+ !gst_pad_is_linked (select->srcpad)) {
res = gst_pad_link (select->srcpad, select->sinkpad);
GST_DEBUG_OBJECT (playbin, "linked type %s, result: %d",
select->media_list[0], res);
}
}
+void
+gst_play_sink_refresh_pad (GstPlaySink * playsink, GstPad * pad,
+ GstPlaySinkType type)
+{
+ GST_DEBUG_OBJECT (playsink, "refresh pad %" GST_PTR_FORMAT, pad);
+
+ GST_PLAY_SINK_LOCK (playsink);
+ if (pad == playsink->video_pad) {
+ if (type != GST_PLAY_SINK_TYPE_VIDEO_RAW &&
+ type != GST_PLAY_SINK_TYPE_VIDEO)
+ goto wrong_type;
+ } else if (pad == playsink->audio_pad) {
+ if (type != GST_PLAY_SINK_TYPE_AUDIO_RAW &&
+ type != GST_PLAY_SINK_TYPE_AUDIO)
+ goto wrong_type;
+ } else if (pad == playsink->text_pad) {
+ if (type != GST_PLAY_SINK_TYPE_TEXT)
+ goto wrong_type;
+ }
+
+ if (type != GST_PLAY_SINK_TYPE_FLUSHING) {
+ GstPad *blockpad =
+ GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (pad)));
+
+ gst_pad_set_blocked_async (blockpad, TRUE, sinkpad_blocked_cb, playsink);
+ PENDING_FLAG_SET (playsink, type);
+ gst_object_unref (blockpad);
+ }
+ GST_PLAY_SINK_UNLOCK (playsink);
+
+ return;
+
+ /* ERRORS */
+wrong_type:
+ {
+ GST_WARNING_OBJECT (playsink, "wrong type %d for pad %" GST_PTR_FORMAT,
+ pad);
+ GST_PLAY_SINK_UNLOCK (playsink);
+ return;
+ }
+}
+
/**
* gst_play_sink_request_pad
* @playsink: a #GstPlaySink
return res;
}
+
static GstPad *
gst_play_sink_request_new_pad (GstElement * element, GstPadTemplate * templ,
const gchar * name, const GstCaps * caps)