From b9ca5573a92a689a6539a3a4e85723a167086e5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 9 Mar 2007 16:28:04 +0000 Subject: [PATCH] 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. --- ChangeLog | 16 ++++++++++++++ ext/pango/gsttextoverlay.c | 18 ++++++++++++--- gst/subparse/gstsubparse.c | 55 +++++++++++++++++++++++----------------------- gst/subparse/gstsubparse.h | 4 ++-- 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0194cc..86fc579 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-03-09 Tim-Philipp Müller + + * 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 * gst/typefind/gsttypefindfunctions.c: (ac3_type_find): diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c index 9679f9c..93b5fc9 100644 --- a/ext/pango/gsttextoverlay.c +++ b/ext/pango/gsttextoverlay.c @@ -1092,7 +1092,11 @@ gst_text_overlay_text_event (GstPad * pad, GstEvent * event) GST_DEBUG_OBJECT (overlay, "TEXT SEGMENT now: %" GST_SEGMENT_FORMAT, &overlay->text_segment); GST_OBJECT_UNLOCK (overlay); + } else { + GST_ELEMENT_WARNING (overlay, STREAM, MUX, (NULL), + ("received non-TIME newsegment event on text input")); } + gst_event_unref (event); 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, &stop, &time); - /* now copy over the values */ - gst_segment_set_newsegment (overlay->segment, update, rate, format, - start, stop, time); + 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, + 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); break; @@ -1194,6 +1205,7 @@ gst_text_overlay_video_event (GstPad * pad, GstEvent * event) break; default: ret = gst_pad_event_default (pad, event); + break; } gst_object_unref (overlay); diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index b1605b1..0c63d96 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -137,10 +137,6 @@ gst_sub_parse_dispose (GObject * object) GST_DEBUG_OBJECT (subparse, "cleaning up subtitle parser"); - if (subparse->segment) { - gst_segment_free (subparse->segment); - subparse->segment = NULL; - } if (subparse->encoding) { g_free (subparse->encoding); subparse->encoding = NULL; @@ -194,14 +190,8 @@ gst_sub_parse_init (GstSubParse * subparse) subparse->textbuf = g_string_new (NULL); subparse->parser_type = GST_SUB_PARSE_FORMAT_UNKNOWN; subparse->flushing = FALSE; - subparse->segment = gst_segment_new (); - if (subparse->segment) { - gst_segment_init (subparse->segment, GST_FORMAT_TIME); - subparse->need_segment = TRUE; - } else { - GST_WARNING_OBJECT (subparse, "segment creation failed"); - g_assert_not_reached (); - } + gst_segment_init (&subparse->segment, GST_FORMAT_TIME); + subparse->need_segment = TRUE; subparse->encoding = g_strdup (DEFAULT_ENCODING); } @@ -243,14 +233,11 @@ gst_sub_parse_src_event (GstPad * pad, GstEvent * event) if (ret) { /* 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); - GST_DEBUG_OBJECT (self, "segment configured from %" GST_TIME_FORMAT - " to %" GST_TIME_FORMAT ", position %" GST_TIME_FORMAT, - GST_TIME_ARGS (self->segment->start), - GST_TIME_ARGS (self->segment->stop), - GST_TIME_ARGS (self->segment->last_stop)); + GST_DEBUG_OBJECT (self, "segment after seek: %" GST_SEGMENT_FORMAT, + &self->segment); self->next_offset = 0; @@ -944,7 +931,7 @@ handle_buffer (GstSubParse * self, GstBuffer * buf) while ((line = get_next_line (self)) && !self->flushing) { /* 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 */ GST_LOG_OBJECT (self, "Parsing line '%s'", 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_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); 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 */ 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, - self->segment->rate, self->segment->format, - self->segment->last_stop, self->segment->stop, - self->segment->time)); + self->segment.rate, self->segment.format, + self->segment.last_stop, self->segment.stop, self->segment.time)); self->need_segment = FALSE; } @@ -1042,14 +1031,24 @@ gst_sub_parse_sink_event (GstPad * pad, GstEvent * event) gint64 start, stop, time; gboolean update; - GST_DEBUG_OBJECT (self, "received new segment"); - gst_event_parse_new_segment (event, &update, &rate, &format, &start, &stop, &time); - /* now copy over the values */ - gst_segment_set_newsegment (self->segment, update, rate, format, - start, stop, time); + GST_DEBUG_OBJECT (self, "newsegment (%s)", gst_format_get_name (format)); + + if (format == GST_FORMAT_TIME) { + gst_segment_set_newsegment (&self->segment, update, rate, format, + 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; gst_event_unref (event); diff --git a/gst/subparse/gstsubparse.h b/gst/subparse/gstsubparse.h index c9feede..9af882d 100644 --- a/gst/subparse/gstsubparse.h +++ b/gst/subparse/gstsubparse.h @@ -83,9 +83,9 @@ struct _GstSubParse { guint64 next_offset; /* Segment */ - GstSegment *segment; + GstSegment segment; GstSeekFlags segment_flags; - gboolean need_segment; + gboolean need_segment; gboolean flushing; gboolean valid_utf8; -- 2.7.4