#define SUBPARSE_SEEK_TRYLOCK(elem) g_mutex_trylock(SUBPARSE_SEEK_GET_LOCK(elem))
#define SUBPARSE_SEEK_UNLOCK(elem) g_mutex_unlock(SUBPARSE_SEEK_GET_LOCK(elem))
#endif
-
#define DEFAULT_ENCODING NULL
#define ATTRIBUTE_REGEX "\\s?[a-zA-Z0-9\\. \t\\(\\)]*"
static const gchar *allowed_srt_tags[] = { "i", "b", "u", NULL };
#ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
#define DEFAULT_CURRENT_LANGUAGE NULL
#endif
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+#define DEFAULT_DROP_OUT_OF_SEGMENT TRUE
+#endif
enum
{
PROP_0,
PROP_ENCODING,
PROP_VIDEOFPS,
#ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
- PROP_EXTSUB_CURRENT_LANGUAGE
+ PROP_EXTSUB_CURRENT_LANGUAGE,
+#endif
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ PROP_DROP_OUT_OF_SEGMENT,
#endif
};
#ifdef TIZEN_FEATURE_HLS_WEBVTT
DEFAULT_CURRENT_LANGUAGE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#endif
+
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ g_object_class_install_property (object_class, PROP_DROP_OUT_OF_SEGMENT,
+ g_param_spec_boolean ("drop-out-of-segment",
+ "Drop out-of-segment buffers",
+ "Drop and don't send out-of-segment buffers",
+ DEFAULT_DROP_OUT_OF_SEGMENT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif
}
static void
subparse->state.language_list = NULL;
subparse->state.current_language = NULL;
subparse->state.langlist_msg_posted = FALSE;
-
g_mutex_init (&subparse->seek_lock);
#endif
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ subparse->state.drop_out_of_segment = DEFAULT_DROP_OUT_OF_SEGMENT;
+#endif
}
/*
sami_context_change_language (&subparse->state);
break;
#endif
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ case PROP_DROP_OUT_OF_SEGMENT:
+ subparse->state.drop_out_of_segment = g_value_get_boolean (value);
+ GST_DEBUG_OBJECT (object, "Drop out of segment set to %d",
+ subparse->state.drop_out_of_segment);
+ break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
g_value_set_string (value, subparse->state.current_language);
break;
#endif
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ case PROP_DROP_OUT_OF_SEGMENT:
+ g_value_set_boolean (value, subparse->state.drop_out_of_segment);
+ break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
state->fps_n);
/* Check our segment start/stop */
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ if (state->drop_out_of_segment) {
+#endif
in_seg = gst_segment_clip (state->segment, GST_FORMAT_TIME,
state->start_time, state->start_time + state->duration, &clip_start,
&clip_stop);
} else {
return NULL;
}
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ }
+#endif
markup = g_string_new (NULL);
while (1) {
if ((end_time = strstr (line, " --> ")) &&
parse_subrip_time (line, &ts_start) &&
parse_subrip_time (end_time + strlen (" --> "), &ts_end) &&
+#ifdef TIZEN_FEATURE_HLS_WEBVTT
+ state->start_time <=
+ ts_end + MPEGTIME_TO_GSTTIME (state->mpegts) - state->local) {
+#else
state->start_time <= ts_end) {
+#endif
state->state = 2;
state->start_time = ts_start;
+#ifdef TIZEN_FEATURE_HLS_WEBVTT
+ state->start_time += MPEGTIME_TO_GSTTIME (state->mpegts) - state->local;
+#endif
state->duration = ts_end - ts_start;
} else {
GST_DEBUG ("error parsing subrip time line '%s'", line);
case 2:
{
/* No need to parse that text if it's out of segment */
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ if (state->drop_out_of_segment) {
+#endif
guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
state->state = 0;
return NULL;
}
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ }
+#endif
}
/* looking for subtitle text; empty line ends this subtitle entry */
if (state->buf->len)
case 1:
{
/* No need to parse that text if it's out of segment */
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ if (state->drop_out_of_segment) {
+#endif
guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
state->state = 0;
return NULL;
}
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ }
+#endif
}
/* looking for subtitle text; empty line ends this subtitle entry */
if (state->buf->len)
return NULL;
case 1:
{ /* No need to parse that text if it's out of segment */
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ if (state->drop_out_of_segment) {
+#endif
guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
state->state = 0;
return NULL;
}
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ }
+#endif
}
/* looking for subtitle text; empty line ends this
* subtitle entry */
GST_WARNING ("Failed to parse subtitle end time");
return NULL;
}
-
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ if (state->drop_out_of_segment) {
+#endif
/* Check if this subtitle is out of the current segment */
in_seg = gst_segment_clip (state->segment, GST_FORMAT_TIME,
state->start_time, state->start_time + state->duration,
if (!in_seg) {
return NULL;
}
+#ifdef TIZEN_FEATURE_SUBPARSE_DROP_OUT_OF_SEGMENT
+ }
+#endif
state->start_time = clip_start;
state->duration = clip_stop - clip_start;
state->local = 0;
state->mpegts = 0;
#endif
-
-#ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
- state->language_list = NULL;
-
- g_free (state->current_language);
- state->current_language = NULL;
-
- state->langlist_msg_posted = FALSE;
-#endif
}
static void