mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
pad: add gst_pad_get_stream_id() utility function
API: gst_pad_get_stream_id()
This commit is contained in:
parent
c015b70456
commit
c0926dc7cc
5 changed files with 54 additions and 0 deletions
|
@ -1772,6 +1772,8 @@ gst_pad_create_stream_id
|
||||||
gst_pad_create_stream_id_printf
|
gst_pad_create_stream_id_printf
|
||||||
gst_pad_create_stream_id_printf_valist
|
gst_pad_create_stream_id_printf_valist
|
||||||
|
|
||||||
|
gst_pad_get_stream_id
|
||||||
|
|
||||||
GstPadForwardFunction
|
GstPadForwardFunction
|
||||||
gst_pad_forward
|
gst_pad_forward
|
||||||
<SUBSECTION Core>
|
<SUBSECTION Core>
|
||||||
|
|
|
@ -3707,3 +3707,43 @@ gst_pad_create_stream_id (GstPad * pad, GstElement * parent,
|
||||||
{
|
{
|
||||||
return gst_pad_create_stream_id_printf (pad, parent, stream_id, NULL);
|
return gst_pad_create_stream_id_printf (pad, parent, stream_id, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_pad_get_stream_id:
|
||||||
|
* @pad: A source #GstPad
|
||||||
|
*
|
||||||
|
* Returns the current stream-id for the @pad, or %NULL if none has been
|
||||||
|
* set yet, i.e. the pad has not received a stream-start event yet.
|
||||||
|
*
|
||||||
|
* This is a convenience wrapper around gst_pad_get_sticky_event() and
|
||||||
|
* gst_event_parse_stream_start().
|
||||||
|
*
|
||||||
|
* The returned stream-id string should be treated as an opaque string, its
|
||||||
|
* contents should not be interpreted.
|
||||||
|
*
|
||||||
|
* Returns: a newly-allocated copy of the stream-idfor @pad, or %NULL.
|
||||||
|
* g_free() the returned string when no longer needed.
|
||||||
|
*
|
||||||
|
* Since: 1.2
|
||||||
|
*/
|
||||||
|
gchar *
|
||||||
|
gst_pad_get_stream_id (GstPad * pad)
|
||||||
|
{
|
||||||
|
const gchar *stream_id = NULL;
|
||||||
|
GstEvent *event;
|
||||||
|
gchar *ret = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||||
|
|
||||||
|
event = gst_pad_get_sticky_event (pad, GST_EVENT_STREAM_START, 0);
|
||||||
|
if (event != NULL) {
|
||||||
|
gst_event_parse_stream_start (event, &stream_id);
|
||||||
|
ret = g_strdup (stream_id);
|
||||||
|
gst_event_unref (event);
|
||||||
|
GST_LOG_OBJECT (pad, "pad has stream-id '%s'", ret);
|
||||||
|
} else {
|
||||||
|
GST_DEBUG_OBJECT (pad, "pad has not received a stream-start event yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -892,6 +892,8 @@ gchar * gst_pad_create_stream_id (GstPad * pad, Gs
|
||||||
gchar * gst_pad_create_stream_id_printf (GstPad * pad, GstElement * parent, const gchar *stream_id, ...);
|
gchar * gst_pad_create_stream_id_printf (GstPad * pad, GstElement * parent, const gchar *stream_id, ...);
|
||||||
gchar * gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent, const gchar *stream_id, va_list var_args);
|
gchar * gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent, const gchar *stream_id, va_list var_args);
|
||||||
|
|
||||||
|
gchar * gst_pad_get_stream_id (GstPad * pad);
|
||||||
|
|
||||||
/* bin functions */
|
/* bin functions */
|
||||||
void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
|
void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
|
||||||
void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
|
void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
|
@ -1479,15 +1479,24 @@ GST_START_TEST (test_sticky_events)
|
||||||
GstPad *srcpad, *sinkpad;
|
GstPad *srcpad, *sinkpad;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstSegment seg;
|
GstSegment seg;
|
||||||
|
gchar *id;
|
||||||
|
|
||||||
/* make unlinked srcpad */
|
/* make unlinked srcpad */
|
||||||
srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
||||||
fail_unless (srcpad != NULL);
|
fail_unless (srcpad != NULL);
|
||||||
gst_pad_set_active (srcpad, TRUE);
|
gst_pad_set_active (srcpad, TRUE);
|
||||||
|
|
||||||
|
/* test stream-start */
|
||||||
|
fail_unless (gst_pad_get_stream_id (srcpad) == NULL);
|
||||||
|
|
||||||
/* push an event, it should be sticky on the srcpad */
|
/* push an event, it should be sticky on the srcpad */
|
||||||
gst_pad_push_event (srcpad, gst_event_new_stream_start ("test"));
|
gst_pad_push_event (srcpad, gst_event_new_stream_start ("test"));
|
||||||
|
|
||||||
|
/* let's see if it stuck */
|
||||||
|
id = gst_pad_get_stream_id (srcpad);
|
||||||
|
fail_unless_equals_string (id, "test");
|
||||||
|
g_free (id);
|
||||||
|
|
||||||
/* make a caps event */
|
/* make a caps event */
|
||||||
caps = gst_caps_new_empty_simple ("foo/bar");
|
caps = gst_caps_new_empty_simple ("foo/bar");
|
||||||
gst_pad_push_event (srcpad, gst_event_new_caps (caps));
|
gst_pad_push_event (srcpad, gst_event_new_caps (caps));
|
||||||
|
|
|
@ -680,6 +680,7 @@ EXPORTS
|
||||||
gst_pad_get_peer
|
gst_pad_get_peer
|
||||||
gst_pad_get_range
|
gst_pad_get_range
|
||||||
gst_pad_get_sticky_event
|
gst_pad_get_sticky_event
|
||||||
|
gst_pad_get_stream_id
|
||||||
gst_pad_get_type
|
gst_pad_get_type
|
||||||
gst_pad_has_current_caps
|
gst_pad_has_current_caps
|
||||||
gst_pad_is_active
|
gst_pad_is_active
|
||||||
|
|
Loading…
Reference in a new issue