+2008-05-25 Tim-Philipp Müller <tim.muller at collabora co uk>
+
+ * gst/subparse/gstsubparse.c: (parser_state_init),
+ (gst_sub_parse_format_autodetect), (handle_buffer):
+ * gst/subparse/gstsubparse.h:
+ * tests/check/elements/subparse.c: (test_tmplayer_style3b):
+ Limit duration to a maximum of five seconds for tmplayer format where
+ we can guess the duration only from the timestamp of the next line of
+ text. We don't want to show a text for eternities just because nothing
+ else is being said for a while.
+
2008-05-23 Wim Taymans <wim.taymans@collabora.co.uk>
* gst-libs/gst/rtp/gstbasertpdepayload.c:
state->start_time = 0;
state->duration = 0;
+ state->max_duration = 0; /* no limit */
state->state = 0;
state->segment = NULL;
}
return gst_caps_new_simple ("text/x-pango-markup", NULL);
case GST_SUB_PARSE_FORMAT_TMPLAYER:
self->parse_line = parse_tmplayer;
+ self->state.max_duration = 5 * GST_SECOND;
return gst_caps_new_simple ("text/plain", NULL);
case GST_SUB_PARSE_FORMAT_MPL2:
self->parse_line = parse_mpl2;
GST_BUFFER_TIMESTAMP (buf) = self->state.start_time;
GST_BUFFER_DURATION (buf) = self->state.duration;
+ /* in some cases (e.g. tmplayer) we can only determine the duration
+ * of a text chunk from the timestamp of the next text chunk; in those
+ * cases, we probably want to limit the duration to something
+ * reasonable, so we don't end up showing some text for e.g. 40 seconds
+ * just because nothing else is being said during that time */
+ if (self->state.max_duration > 0 && GST_BUFFER_DURATION_IS_VALID (buf)) {
+ if (GST_BUFFER_DURATION (buf) > self->state.max_duration)
+ GST_BUFFER_DURATION (buf) = self->state.max_duration;
+ }
+
gst_segment_set_last_stop (&self->segment, GST_FORMAT_TIME,
self->state.start_time);
GString *buf;
guint64 start_time;
guint64 duration;
+ guint64 max_duration; /* to clamp duration, 0 = no limit (used by tmplayer parser) */
GstSegment *segment;
gpointer user_data;
gdouble fps; /* used by microdvd parser */
GST_END_TEST;
+/* also tests the max_duration stuff (see second-last chunk which is supposed
+ * to be clipped to 5s duration) */
GST_START_TEST (test_tmplayer_style3b)
{
static SubParseInputChunk tmplayer_style3b_input[] = {
"0:00:14:a lush and fertile planet.\n",
14 * GST_SECOND, 16 * GST_SECOND,
"a lush and fertile planet."}, {
- "0:00:16:Yet another line.",
- 16 * GST_SECOND, GST_CLOCK_TIME_NONE, "Yet another line."}
+ "0:00:16:And they liked it a lot.\n",
+ 16 * GST_SECOND, (16 + 5) * GST_SECOND, "And they liked it a lot."}, {
+ "0:00:30:Last line.",
+ 30 * GST_SECOND, GST_CLOCK_TIME_NONE, "Last line."}
};
test_tmplayer_do_test (tmplayer_style3b_input,