mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
playsink: Add FLUSHING pad type
Make it possible to request a flushing pad from the playsink. We can eventually use these flushing pads to quickly terminate the dataflow when we are shutting down.
This commit is contained in:
parent
4d59aa3bc5
commit
747841e97c
2 changed files with 25 additions and 1 deletions
|
@ -134,6 +134,7 @@ struct _GstPlaySink
|
|||
gboolean mute;
|
||||
gchar *font_desc; /* font description */
|
||||
guint connection_speed; /* connection speed in bits/sec (0 = unknown) */
|
||||
gint count;
|
||||
};
|
||||
|
||||
struct _GstPlaySinkClass
|
||||
|
@ -1603,6 +1604,7 @@ gst_play_sink_request_pad (GstPlaySink * playsink, GstPlaySinkType type)
|
|||
GstPad *res = NULL;
|
||||
gboolean created = FALSE;
|
||||
gboolean raw = FALSE;
|
||||
gboolean activate = TRUE;
|
||||
|
||||
GST_DEBUG_OBJECT (playsink, "request pad type %d", type);
|
||||
|
||||
|
@ -1658,6 +1660,19 @@ gst_play_sink_request_pad (GstPlaySink * playsink, GstPlaySinkType type)
|
|||
}
|
||||
res = playsink->text_pad;
|
||||
break;
|
||||
case GST_PLAY_SINK_TYPE_FLUSHING:
|
||||
{
|
||||
gchar *padname;
|
||||
|
||||
/* we need a unique padname for the flushing pad. */
|
||||
padname = g_strdup_printf ("flushing_%d", playsink->count);
|
||||
res = gst_ghost_pad_new_no_target (padname, GST_PAD_SINK);
|
||||
g_free (padname);
|
||||
playsink->count++;
|
||||
activate = FALSE;
|
||||
created = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = NULL;
|
||||
break;
|
||||
|
@ -1665,8 +1680,12 @@ gst_play_sink_request_pad (GstPlaySink * playsink, GstPlaySinkType type)
|
|||
GST_PLAY_SINK_UNLOCK (playsink);
|
||||
|
||||
if (created && res) {
|
||||
/* we have to add the pad when it's active or we get an error when the
|
||||
* element is 'running' */
|
||||
gst_pad_set_active (res, TRUE);
|
||||
gst_element_add_pad (GST_ELEMENT_CAST (playsink), res);
|
||||
if (!activate)
|
||||
gst_pad_set_active (res, activate);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -1686,6 +1705,9 @@ gst_play_sink_release_pad (GstPlaySink * playsink, GstPad * pad)
|
|||
res = &playsink->audio_pad;
|
||||
} else if (pad == playsink->text_pad) {
|
||||
res = &playsink->text_pad;
|
||||
} else {
|
||||
/* try to release the given pad anyway, these could be the FLUSHING pads. */
|
||||
res = &pad;
|
||||
}
|
||||
GST_PLAY_SINK_UNLOCK (playsink);
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ G_BEGIN_DECLS
|
|||
* @GST_PLAY_SINK_TYPE_VIDEO_RAW: a raw video pad
|
||||
* @GST_PLAY_SINK_TYPE_TEXT: a raw text pad
|
||||
* @GST_PLAY_SINK_TYPE_LAST: the last type
|
||||
* @GST_PLAY_SINK_TYPE_FLUSHING: a flushing pad, used when shutting down
|
||||
*
|
||||
* Types of pads that can be requested from the sinks.
|
||||
*/
|
||||
|
@ -54,7 +55,8 @@ typedef enum {
|
|||
GST_PLAY_SINK_TYPE_VIDEO = 2,
|
||||
GST_PLAY_SINK_TYPE_VIDEO_RAW = 3,
|
||||
GST_PLAY_SINK_TYPE_TEXT = 4,
|
||||
GST_PLAY_SINK_TYPE_LAST = 5
|
||||
GST_PLAY_SINK_TYPE_LAST = 5,
|
||||
GST_PLAY_SINK_TYPE_FLUSHING = 6
|
||||
} GstPlaySinkType;
|
||||
|
||||
typedef struct _GstPlaySink GstPlaySink;
|
||||
|
|
Loading…
Reference in a new issue