summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-07-05 13:03:10 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-07-05 13:04:31 +0200
commitaa2309e54ad8123b37e6463a712d69b6acfdbec4 (patch)
tree3006dd8d19e1d66f79f49f24341875e953621a05
parent964ea9eccb66f4bee4d79f980859f00288931220 (diff)
event: Add format and position to the segment-done event
-rw-r--r--docs/gst/gstreamer-sections.txt1
-rw-r--r--gst/gstevent.c43
-rw-r--r--gst/gstevent.h3
-rw-r--r--gst/gstquark.c2
-rw-r--r--gst/gstquark.h3
-rw-r--r--libs/gst/base/gstbaseparse.c3
-rw-r--r--libs/gst/base/gstbasesink.c4
-rw-r--r--libs/gst/base/gstbasesrc.c2
-rw-r--r--win32/common/libgstreamer.def2
9 files changed, 54 insertions, 9 deletions
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
index 1110b7b26..22f4667d4 100644
--- a/docs/gst/gstreamer-sections.txt
+++ b/docs/gst/gstreamer-sections.txt
@@ -1028,6 +1028,7 @@ gst_event_new_toc_select
gst_event_parse_toc_select
gst_event_new_segment_done
+gst_event_parse_segment_done
<SUBSECTION Standard>
GstEventClass
GST_EVENT
diff --git a/gst/gstevent.c b/gst/gstevent.c
index 980747dc5..d07c8140c 100644
--- a/gst/gstevent.c
+++ b/gst/gstevent.c
@@ -1739,7 +1739,9 @@ gst_event_parse_toc_select (GstEvent * event, gchar ** uid)
/**
* gst_event_new_segment_done:
-
+ * @format: The format of the position being done
+ * @position: The position of the segment being done
+ *
* Create a new segment-done event. This event is sent by elements that
* finish playback of a segment as a result of a segment seek.
*
@@ -1748,13 +1750,48 @@ gst_event_parse_toc_select (GstEvent * event, gchar ** uid)
* Since: 0.11.0
*/
GstEvent *
-gst_event_new_segment_done (void)
+gst_event_new_segment_done (GstFormat format, gint64 position)
{
GstEvent *event;
+ GstStructure *structure;
GST_CAT_INFO (GST_CAT_EVENT, "creating segment-done event");
- event = gst_event_new_custom (GST_EVENT_SEGMENT_DONE, NULL);
+ structure = gst_structure_new_id (GST_QUARK (EVENT_SEGMENT_DONE),
+ GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
+ GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
+
+ event = gst_event_new_custom (GST_EVENT_SEGMENT_DONE, structure);
return event;
}
+
+/**
+ * gst_event_parse_segment_done:
+ * @event: A valid #GstEvent of type GST_EVENT_SEGMENT_DONE.
+ * @format: (out): Result location for the format, or NULL
+ * @position: (out): Result location for the position, or NULL
+ *
+ * Extracts the position and format from the segment done message.
+ *
+ */
+void
+gst_event_parse_segment_done (GstEvent * event, GstFormat * format,
+ gint64 * position)
+{
+ const GstStructure *structure;
+ const GValue *val;
+
+ g_return_if_fail (event != NULL);
+ g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT_DONE);
+
+ structure = gst_event_get_structure (event);
+
+ val = gst_structure_id_get_value (structure, GST_QUARK (FORMAT));
+ if (format != NULL)
+ *format = g_value_get_enum (val);
+
+ val = gst_structure_id_get_value (structure, GST_QUARK (POSITION));
+ if (position != NULL)
+ *position = g_value_get_int64 (val);
+}
diff --git a/gst/gstevent.h b/gst/gstevent.h
index aa7c94bb4..be85cdf6f 100644
--- a/gst/gstevent.h
+++ b/gst/gstevent.h
@@ -577,7 +577,8 @@ GstEvent* gst_event_new_toc_select (const gchar *uid) G_GNUC_MALLOC
void gst_event_parse_toc_select (GstEvent *event, gchar **uid);
/* segment-done event */
-GstEvent* gst_event_new_segment_done (void) G_GNUC_MALLOC;
+GstEvent* gst_event_new_segment_done (GstFormat format, gint64 position) G_GNUC_MALLOC;
+void gst_event_parse_segment_done (GstEvent *event, GstFormat *format, gint64 *position);
G_END_DECLS
diff --git a/gst/gstquark.c b/gst/gstquark.c
index b2654f913..42da13026 100644
--- a/gst/gstquark.c
+++ b/gst/gstquark.c
@@ -63,7 +63,7 @@ static const gchar *_quark_strings[] = {
GST_ELEMENT_METADATA_AUTHOR, "toc", "toc-entry", "updated", "extend-uid",
"uid", "tags", "sub-entries", "info", "GstMessageTag", "GstEventTag",
"GstMessageResetTime",
- "GstMessageToc", "GstEventToc"
+ "GstMessageToc", "GstEventToc", "GstEventSegmentDone"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
diff --git a/gst/gstquark.h b/gst/gstquark.h
index 45a5d9b2b..06423d75d 100644
--- a/gst/gstquark.h
+++ b/gst/gstquark.h
@@ -184,7 +184,8 @@ typedef enum _GstQuarkId
GST_QUARK_MESSAGE_RESET_TIME = 155,
GST_QUARK_MESSAGE_TOC = 156,
GST_QUARK_EVENT_TOC = 157,
- GST_QUARK_MAX = 158
+ GST_QUARK_EVENT_SEGMENT_DONE = 158,
+ GST_QUARK_MAX = 159
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
index 6dcaf4e61..5f2c7fd5d 100644
--- a/libs/gst/base/gstbaseparse.c
+++ b/libs/gst/base/gstbaseparse.c
@@ -2923,7 +2923,8 @@ pause:
(GST_ELEMENT_CAST (parse),
gst_message_new_segment_done (GST_OBJECT_CAST (parse),
GST_FORMAT_TIME, stop));
- gst_pad_push_event (parse->srcpad, gst_event_new_segment_done ());
+ gst_pad_push_event (parse->srcpad,
+ gst_event_new_segment_done (GST_FORMAT_TIME, stop));
} else {
/* If we STILL have zero frames processed, fire an error */
if (parse->priv->framecount == 0) {
diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c
index bc146063f..1db5f42a3 100644
--- a/libs/gst/base/gstbasesink.c
+++ b/libs/gst/base/gstbasesink.c
@@ -3751,7 +3751,9 @@ paused:
gst_element_post_message (GST_ELEMENT_CAST (basesink),
gst_message_new_segment_done (GST_OBJECT_CAST (basesink),
basesink->segment.format, basesink->segment.position));
- gst_base_sink_event (pad, parent, gst_event_new_segment_done ());
+ gst_base_sink_event (pad, parent,
+ gst_event_new_segment_done (basesink->segment.format,
+ basesink->segment.position));
} else {
gst_base_sink_event (pad, parent, gst_event_new_eos ());
}
diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c
index 4532c0edf..2129cc004 100644
--- a/libs/gst/base/gstbasesrc.c
+++ b/libs/gst/base/gstbasesrc.c
@@ -2718,7 +2718,7 @@ pause:
format, position);
gst_message_set_seqnum (message, src->priv->seqnum);
gst_element_post_message (GST_ELEMENT_CAST (src), message);
- event = gst_event_new_segment_done ();
+ event = gst_event_new_segment_done (format, position);
gst_event_set_seqnum (event, src->priv->seqnum);
gst_pad_push_event (pad, event);
} else {
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index ce80eae90..7f95539b9 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -432,6 +432,7 @@ EXPORTS
gst_event_new_reconfigure
gst_event_new_seek
gst_event_new_segment
+ gst_event_new_segment_done
gst_event_new_sink_message
gst_event_new_step
gst_event_new_stream_config
@@ -448,6 +449,7 @@ EXPORTS
gst_event_parse_qos
gst_event_parse_seek
gst_event_parse_segment
+ gst_event_parse_segment_done
gst_event_parse_sink_message
gst_event_parse_step
gst_event_parse_stream_config