ext/pango/gsttextoverlay.c: Some more logging. Only accept newsegment events in TIME format and send a WARNING messag...

Original commit message from CVS:
* ext/pango/gsttextoverlay.c: (gst_text_overlay_text_event),
(gst_text_overlay_video_event):
Some more logging. Only accept newsegment events in TIME format and
send a WARNING message if they are not in TIME format.
* gst/subparse/gstsubparse.c: (gst_sub_parse_dispose),
(gst_sub_parse_init), (gst_sub_parse_src_event), (handle_buffer),
(gst_sub_parse_chain), (gst_sub_parse_sink_event):
* gst/subparse/gstsubparse.h:
No need to allocate GstSegment structure dynamically, just put it
into the instance structure; ignore newsegment events in BYTE
format and in particular don't let it overwrite our saved TIME
segment from the last seek.
This commit is contained in:
Tim-Philipp Müller 2007-03-09 16:28:04 +00:00
parent c9cd89bbab
commit b9ca5573a9
4 changed files with 60 additions and 33 deletions

View file

@ -1,3 +1,19 @@
2007-03-09 Tim-Philipp Müller <tim at centricular dot net>
* ext/pango/gsttextoverlay.c: (gst_text_overlay_text_event),
(gst_text_overlay_video_event):
Some more logging. Only accept newsegment events in TIME format and
send a WARNING message if they are not in TIME format.
* gst/subparse/gstsubparse.c: (gst_sub_parse_dispose),
(gst_sub_parse_init), (gst_sub_parse_src_event), (handle_buffer),
(gst_sub_parse_chain), (gst_sub_parse_sink_event):
* gst/subparse/gstsubparse.h:
No need to allocate GstSegment structure dynamically, just put it
into the instance structure; ignore newsegment events in BYTE
format and in particular don't let it overwrite our saved TIME
segment from the last seek.
2007-03-09 Michael Smith <msmith@fluendo.com> 2007-03-09 Michael Smith <msmith@fluendo.com>
* gst/typefind/gsttypefindfunctions.c: (ac3_type_find): * gst/typefind/gsttypefindfunctions.c: (ac3_type_find):

View file

@ -1092,7 +1092,11 @@ gst_text_overlay_text_event (GstPad * pad, GstEvent * event)
GST_DEBUG_OBJECT (overlay, "TEXT SEGMENT now: %" GST_SEGMENT_FORMAT, GST_DEBUG_OBJECT (overlay, "TEXT SEGMENT now: %" GST_SEGMENT_FORMAT,
&overlay->text_segment); &overlay->text_segment);
GST_OBJECT_UNLOCK (overlay); GST_OBJECT_UNLOCK (overlay);
} else {
GST_ELEMENT_WARNING (overlay, STREAM, MUX, (NULL),
("received non-TIME newsegment event on text input"));
} }
gst_event_unref (event); gst_event_unref (event);
ret = TRUE; ret = TRUE;
@ -1164,9 +1168,16 @@ gst_text_overlay_video_event (GstPad * pad, GstEvent * event)
gst_event_parse_new_segment (event, &update, &rate, &format, &start, gst_event_parse_new_segment (event, &update, &rate, &format, &start,
&stop, &time); &stop, &time);
/* now copy over the values */ if (format == GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (overlay, "VIDEO SEGMENT now: %" GST_SEGMENT_FORMAT,
overlay->segment);
gst_segment_set_newsegment (overlay->segment, update, rate, format, gst_segment_set_newsegment (overlay->segment, update, rate, format,
start, stop, time); start, stop, time);
} else {
GST_ELEMENT_WARNING (overlay, STREAM, MUX, (NULL),
("received non-TIME newsegment event on video input"));
}
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
break; break;
@ -1194,6 +1205,7 @@ gst_text_overlay_video_event (GstPad * pad, GstEvent * event)
break; break;
default: default:
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
break;
} }
gst_object_unref (overlay); gst_object_unref (overlay);

View file

@ -137,10 +137,6 @@ gst_sub_parse_dispose (GObject * object)
GST_DEBUG_OBJECT (subparse, "cleaning up subtitle parser"); GST_DEBUG_OBJECT (subparse, "cleaning up subtitle parser");
if (subparse->segment) {
gst_segment_free (subparse->segment);
subparse->segment = NULL;
}
if (subparse->encoding) { if (subparse->encoding) {
g_free (subparse->encoding); g_free (subparse->encoding);
subparse->encoding = NULL; subparse->encoding = NULL;
@ -194,14 +190,8 @@ gst_sub_parse_init (GstSubParse * subparse)
subparse->textbuf = g_string_new (NULL); subparse->textbuf = g_string_new (NULL);
subparse->parser_type = GST_SUB_PARSE_FORMAT_UNKNOWN; subparse->parser_type = GST_SUB_PARSE_FORMAT_UNKNOWN;
subparse->flushing = FALSE; subparse->flushing = FALSE;
subparse->segment = gst_segment_new (); gst_segment_init (&subparse->segment, GST_FORMAT_TIME);
if (subparse->segment) {
gst_segment_init (subparse->segment, GST_FORMAT_TIME);
subparse->need_segment = TRUE; subparse->need_segment = TRUE;
} else {
GST_WARNING_OBJECT (subparse, "segment creation failed");
g_assert_not_reached ();
}
subparse->encoding = g_strdup (DEFAULT_ENCODING); subparse->encoding = g_strdup (DEFAULT_ENCODING);
} }
@ -243,14 +233,11 @@ gst_sub_parse_src_event (GstPad * pad, GstEvent * event)
if (ret) { if (ret) {
/* Apply the seek to our segment */ /* Apply the seek to our segment */
gst_segment_set_seek (self->segment, rate, format, self->segment_flags, gst_segment_set_seek (&self->segment, rate, format, self->segment_flags,
start_type, start, stop_type, stop, &update); start_type, start, stop_type, stop, &update);
GST_DEBUG_OBJECT (self, "segment configured from %" GST_TIME_FORMAT GST_DEBUG_OBJECT (self, "segment after seek: %" GST_SEGMENT_FORMAT,
" to %" GST_TIME_FORMAT ", position %" GST_TIME_FORMAT, &self->segment);
GST_TIME_ARGS (self->segment->start),
GST_TIME_ARGS (self->segment->stop),
GST_TIME_ARGS (self->segment->last_stop));
self->next_offset = 0; self->next_offset = 0;
@ -944,7 +931,7 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
while ((line = get_next_line (self)) && !self->flushing) { while ((line = get_next_line (self)) && !self->flushing) {
/* Set segment on our parser state machine */ /* Set segment on our parser state machine */
self->state.segment = self->segment; self->state.segment = &self->segment;
/* Now parse the line, out of segment lines will just return NULL */ /* Now parse the line, out of segment lines will just return NULL */
GST_LOG_OBJECT (self, "Parsing line '%s'", line); GST_LOG_OBJECT (self, "Parsing line '%s'", line);
subtitle = self->parse_line (&self->state, line); subtitle = self->parse_line (&self->state, line);
@ -965,7 +952,7 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
GST_BUFFER_TIMESTAMP (buf) = self->state.start_time; GST_BUFFER_TIMESTAMP (buf) = self->state.start_time;
GST_BUFFER_DURATION (buf) = self->state.duration; GST_BUFFER_DURATION (buf) = self->state.duration;
gst_segment_set_last_stop (self->segment, GST_FORMAT_TIME, gst_segment_set_last_stop (&self->segment, GST_FORMAT_TIME,
self->state.start_time); self->state.start_time);
GST_DEBUG_OBJECT (self, "Sending text '%s', %" GST_TIME_FORMAT " + %" GST_DEBUG_OBJECT (self, "Sending text '%s', %" GST_TIME_FORMAT " + %"
@ -998,10 +985,12 @@ gst_sub_parse_chain (GstPad * sinkpad, GstBuffer * buf)
/* Push newsegment if needed */ /* Push newsegment if needed */
if (self->need_segment) { if (self->need_segment) {
GST_LOG_OBJECT (self, "pushing newsegment event with %" GST_SEGMENT_FORMAT,
&self->segment);
gst_pad_push_event (self->srcpad, gst_event_new_new_segment (FALSE, gst_pad_push_event (self->srcpad, gst_event_new_new_segment (FALSE,
self->segment->rate, self->segment->format, self->segment.rate, self->segment.format,
self->segment->last_stop, self->segment->stop, self->segment.last_stop, self->segment.stop, self->segment.time));
self->segment->time));
self->need_segment = FALSE; self->need_segment = FALSE;
} }
@ -1042,14 +1031,24 @@ gst_sub_parse_sink_event (GstPad * pad, GstEvent * event)
gint64 start, stop, time; gint64 start, stop, time;
gboolean update; gboolean update;
GST_DEBUG_OBJECT (self, "received new segment");
gst_event_parse_new_segment (event, &update, &rate, &format, &start, gst_event_parse_new_segment (event, &update, &rate, &format, &start,
&stop, &time); &stop, &time);
/* now copy over the values */ GST_DEBUG_OBJECT (self, "newsegment (%s)", gst_format_get_name (format));
gst_segment_set_newsegment (self->segment, update, rate, format,
if (format == GST_FORMAT_TIME) {
gst_segment_set_newsegment (&self->segment, update, rate, format,
start, stop, time); start, stop, time);
} else {
/* if not time format, we'll either start with a 0 timestamp anyway or
* it's following a seek in which case we'll have saved the requested
* seek segment and don't want to overwrite it (remember that on a seek
* we always just seek back to the start in BYTES format and just throw
* away all text that's before the requested position; if the subtitles
* come from an upstream demuxer, it won't be able to handle our BYTES
* seek request and instead send us a newsegment from the seek request
* it received via its video pads instead, so all is fine then too) */
}
ret = TRUE; ret = TRUE;
gst_event_unref (event); gst_event_unref (event);

View file

@ -83,7 +83,7 @@ struct _GstSubParse {
guint64 next_offset; guint64 next_offset;
/* Segment */ /* Segment */
GstSegment *segment; GstSegment segment;
GstSeekFlags segment_flags; GstSeekFlags segment_flags;
gboolean need_segment; gboolean need_segment;