}
/**
- * gst_event_get_segment:
- * @event: The event
- *
- * Get the segment from @event. The segment remains valid as long as @event remains
- * valid.
+ * gst_event_parse_segment:
+ * @event: The event to parse
+ * @segment: (out) (transfer none): a pointer to a #GstSegment
*
- * Returns: the #GstSegment. The segment stays valid for as long as @event is
- * valid.
+ * Parses a segment @event and stores the result in the given @segment location.
+ * @segment remains valid only until the @event is freed. Don't modify the segment
+ * and make a copy if you want to modify it or store it for later use.
*/
-const GstSegment *
-gst_event_get_segment (GstEvent * event)
+void
+gst_event_parse_segment (GstEvent * event, const GstSegment ** segment)
{
GstStructure *structure;
- GstSegment *segment;
-
- g_return_val_if_fail (GST_IS_EVENT (event), NULL);
- g_return_val_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT, NULL);
- structure = GST_EVENT_STRUCTURE (event);
- segment = g_value_get_boxed (gst_structure_id_get_value (structure,
- GST_QUARK (SEGMENT)));
+ g_return_if_fail (GST_IS_EVENT (event));
+ g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
- return segment;
+ if (segment) {
+ structure = GST_EVENT_STRUCTURE (event);
+ *segment = g_value_get_boxed (gst_structure_id_get_value (structure,
+ GST_QUARK (SEGMENT)));
+ }
}
/**
- * gst_event_parse_segment:
+ * gst_event_copy_segment:
* @event: The event to parse
- * @segment: a #GstSegment
+ * @segment: a pointer to a #GstSegment
*
- * Copy the segment values from @event into @segment.
+ * Parses a segment @event and copies the #GstSegment into the location
+ * given by @segment.
*/
void
-gst_event_parse_segment (GstEvent * event, GstSegment * segment)
+gst_event_copy_segment (GstEvent * event, GstSegment * segment)
{
const GstSegment *src;
- g_return_if_fail (segment != NULL);
-
- src = gst_event_get_segment (event);
- g_return_if_fail (src != NULL);
+ g_return_if_fail (GST_IS_EVENT (event));
+ g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
- gst_segment_copy_into (src, segment);
+ if (segment) {
+ gst_event_parse_segment (event, &src);
+ gst_segment_copy_into (src, segment);
+ }
}
/**
/* segment event */
GstEvent* gst_event_new_segment (GstSegment *segment);
-const GstSegment *
- gst_event_get_segment (GstEvent *event);
-void gst_event_parse_segment (GstEvent *event, GstSegment *segment);
+void gst_event_parse_segment (GstEvent *event, const GstSegment **segment);
+void gst_event_copy_segment (GstEvent *event, GstSegment *segment);
/* tag event */
GstEvent* gst_event_new_tag (GstTagList *taglist);
gboolean update;
#endif
- in_segment = gst_event_get_segment (event);
+ gst_event_parse_segment (event, &in_segment);
gst_segment_init (&out_segment, GST_FORMAT_TIME);
GST_DEBUG_OBJECT (parse, "segment %" GST_SEGMENT_FORMAT, in_segment);
GST_OBJECT_LOCK (basesink);
/* the newsegment event is needed to bring the buffer timestamps to the
* stream time and to drop samples outside of the playback segment. */
- gst_event_parse_segment (event, segment);
+ gst_event_copy_segment (event, segment);
GST_DEBUG_OBJECT (basesink, "configured SEGMENT %" GST_SEGMENT_FORMAT,
segment);
GST_OBJECT_UNLOCK (basesink);
}
case GST_EVENT_SEGMENT:
{
- gst_event_parse_segment (event, &trans->segment);
+ gst_event_copy_segment (event, &trans->segment);
trans->have_segment = TRUE;
GST_DEBUG_OBJECT (trans, "received SEGMENT %" GST_SEGMENT_FORMAT,
}
case GST_EVENT_SEGMENT:
{
- gst_event_parse_segment (event, &data->segment);
+ gst_event_copy_segment (event, &data->segment);
GST_DEBUG_OBJECT (data->pad, "got newsegment %" GST_SEGMENT_FORMAT,
&data->segment);
switch (type) {
case GST_EVENT_SEGMENT:
{
- GstSegment segment;
+ const GstSegment *segment;
gst_event_parse_segment (event, &segment);
- if (segment.format == GST_FORMAT_BYTES) {
+ if (segment->format == GST_FORMAT_BYTES) {
/* only try to seek and fail when we are going to a different
* position */
- if (fdsink->current_pos != segment.start) {
+ if (fdsink->current_pos != segment->start) {
/* FIXME, the seek should be performed on the pos field, start/stop are
* just boundaries for valid bytes offsets. We should also fill the file
* with zeroes if the new position extends the current EOF (sparse streams
* and segment accumulation). */
- if (!gst_fd_sink_do_seek (fdsink, (guint64) segment.start))
+ if (!gst_fd_sink_do_seek (fdsink, (guint64) segment->start))
goto seek_failed;
}
} else {
GST_DEBUG_OBJECT (fdsink,
- "Ignored SEGMENT event of format %u (%s)", (guint) segment.format,
- gst_format_get_name (segment.format));
+ "Ignored SEGMENT event of format %u (%s)", (guint) segment->format,
+ gst_format_get_name (segment->format));
}
break;
}
switch (type) {
case GST_EVENT_SEGMENT:
{
- GstSegment segment;
+ const GstSegment *segment;
gst_event_parse_segment (event, &segment);
- if (segment.format == GST_FORMAT_BYTES) {
+ if (segment->format == GST_FORMAT_BYTES) {
/* only try to seek and fail when we are going to a different
* position */
- if (filesink->current_pos != segment.start) {
+ if (filesink->current_pos != segment->start) {
/* FIXME, the seek should be performed on the pos field, start/stop are
* just boundaries for valid bytes offsets. We should also fill the file
* with zeroes if the new position extends the current EOF (sparse streams
* and segment accumulation). */
- if (!gst_file_sink_do_seek (filesink, (guint64) segment.start))
+ if (!gst_file_sink_do_seek (filesink, (guint64) segment->start))
goto seek_failed;
} else {
GST_DEBUG_OBJECT (filesink, "Ignored SEGMENT, no seek needed");
}
} else {
GST_DEBUG_OBJECT (filesink,
- "Ignored SEGMENT event of format %u (%s)", (guint) segment.format,
- gst_format_get_name (segment.format));
+ "Ignored SEGMENT event of format %u (%s)", (guint) segment->format,
+ gst_format_get_name (segment->format));
}
break;
}
case GST_EVENT_SEGMENT:
{
GST_OBJECT_LOCK (funnel);
- gst_event_parse_segment (event, &fpad->segment);
+ gst_event_copy_segment (event, &fpad->segment);
GST_OBJECT_UNLOCK (funnel);
forward = FALSE;
GstEvent *news;
GstSegment segment;
- gst_event_parse_segment (event, &segment);
+ gst_event_copy_segment (event, &segment);
/* This is the first segment, send out a (0, -1) segment */
gst_segment_init (&segment, segment.format);
{
GST_INPUT_SELECTOR_LOCK (sel);
GST_OBJECT_LOCK (selpad);
- gst_event_parse_segment (event, &selpad->segment);
+ gst_event_copy_segment (event, &selpad->segment);
GST_DEBUG_OBJECT (pad, "configured SEGMENT %" GST_SEGMENT_FORMAT,
&selpad->segment);
GST_OBJECT_UNLOCK (selpad);
apply_segment (GstMultiQueue * mq, GstSingleQueue * sq, GstEvent * event,
GstSegment * segment)
{
- gst_event_parse_segment (event, segment);
+ gst_event_copy_segment (event, segment);
/* now configure the values, we use these to track timestamps on the
* sinkpad. */
/* For newsegment events return the running time of the start position */
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
- GstSegment new_segment = *segment;
+ const GstSegment *new_segment;
gst_event_parse_segment (event, &new_segment);
- if (new_segment.format == GST_FORMAT_TIME) {
+ if (new_segment->format == GST_FORMAT_TIME) {
time =
- gst_segment_to_running_time (&new_segment, GST_FORMAT_TIME,
- new_segment.start);
+ gst_segment_to_running_time (new_segment, GST_FORMAT_TIME,
+ new_segment->start);
}
}
}
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEGMENT:
{
- gst_event_parse_segment (event, &sel->segment);
+ gst_event_copy_segment (event, &sel->segment);
GST_DEBUG_OBJECT (sel, "configured SEGMENT update %" GST_SEGMENT_FORMAT,
&sel->segment);
apply_segment (GstQueue * queue, GstEvent * event, GstSegment * segment,
gboolean sink)
{
- gst_event_parse_segment (event, segment);
+ gst_event_copy_segment (event, segment);
/* now configure the values, we use these to track timestamps on the
* sinkpad. */
apply_segment (GstQueue2 * queue, GstEvent * event, GstSegment * segment,
gboolean is_sink)
{
- gst_event_parse_segment (event, segment);
+ gst_event_copy_segment (event, segment);
if (segment->format == GST_FORMAT_BYTES) {
if (QUEUE_IS_USING_TEMP_FILE (queue)) {
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
fail_unless (GST_EVENT_IS_SERIALIZED (event));
- gst_event_parse_segment (event, &parsed);
+ gst_event_copy_segment (event, &parsed);
fail_unless (parsed.rate == 0.5);
fail_unless (parsed.applied_rate == 1.0);
fail_unless (parsed.format == GST_FORMAT_TIME);
GstEvent *seg_event = NULL;
GstEvent *rate_seek;
gboolean event_ret;
- GstSegment segment;
+ const GstSegment *segment;
pipe = gst_pipeline_new ("pipeline");
sink = gst_element_factory_make ("fakesink", "sink");
fail_unless (seg_event != NULL);
gst_event_parse_segment (seg_event, &segment);
- fail_unless (segment.rate == 0.5);
+ fail_unless (segment->rate == 0.5);
gst_pad_remove_event_probe (probe_pad, probe);
gst_object_unref (probe_pad);
gst_base_parse_set_duration
gst_base_parse_set_frame_rate
gst_base_parse_set_has_timing_info
+ gst_base_parse_set_latency
gst_base_parse_set_min_frame_size
gst_base_parse_set_passthrough
gst_base_parse_set_syncable
gst_element_unlink_many
gst_element_unlink_pads
gst_error_get_message
- gst_event_get_segment
+ gst_event_copy_segment
gst_event_get_seqnum
gst_event_get_structure
gst_event_has_name
gst_pad_get_query_types
gst_pad_get_query_types_default
gst_pad_get_range
+ gst_pad_get_sticky_event
gst_pad_get_type
gst_pad_has_current_caps
gst_pad_is_active