static gboolean gst_sub_parse_src_event (GstPad * pad, GstEvent * event);
-static gboolean gst_sub_parse_src_query (GstPad * pad, GstQuery ** query);
+static gboolean gst_sub_parse_src_query (GstPad * pad, GstQuery * query);
static gboolean gst_sub_parse_sink_event (GstPad * pad, GstEvent * event);
static GstStateChangeReturn gst_sub_parse_change_state (GstElement * element,
*/
static gboolean
-gst_sub_parse_src_query (GstPad * pad, GstQuery ** query)
+gst_sub_parse_src_query (GstPad * pad, GstQuery * query)
{
GstSubParse *self = GST_SUBPARSE (gst_pad_get_parent (pad));
gboolean ret = FALSE;
- GST_DEBUG ("Handling %s query", GST_QUERY_TYPE_NAME (*query));
+ GST_DEBUG ("Handling %s query", GST_QUERY_TYPE_NAME (query));
- switch (GST_QUERY_TYPE (*query)) {
+ switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:{
GstFormat fmt;
- gst_query_parse_position (*query, &fmt, NULL);
+ gst_query_parse_position (query, &fmt, NULL);
if (fmt != GST_FORMAT_TIME) {
ret = gst_pad_peer_query (self->sinkpad, query);
} else {
ret = TRUE;
- gst_query_set_position (*query, GST_FORMAT_TIME,
- self->segment.last_stop);
+ gst_query_set_position (query, GST_FORMAT_TIME, self->segment.position);
}
+ break;
}
case GST_QUERY_SEEKING:
{
ret = TRUE;
- gst_query_parse_seeking (*query, &fmt, NULL, NULL, NULL);
+ gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL);
if (fmt == GST_FORMAT_TIME) {
GstQuery *peerquery = gst_query_new_seeking (GST_FORMAT_BYTES);
- seekable = gst_pad_peer_query (self->sinkpad, &peerquery);
+ seekable = gst_pad_peer_query (self->sinkpad, peerquery);
if (seekable)
gst_query_parse_seeking (peerquery, NULL, &seekable, NULL, NULL);
gst_query_unref (peerquery);
}
- gst_query_set_seeking (*query, fmt, seekable, seekable ? 0 : -1, -1);
-
+ gst_query_set_seeking (query, fmt, seekable, seekable ? 0 : -1, -1);
break;
}
default:
case GST_EVENT_SEEK:
{
GstFormat format;
+ GstSeekFlags flags;
GstSeekType start_type, stop_type;
gint64 start, stop;
gdouble rate;
gboolean update;
- gst_event_parse_seek (event, &rate, &format, &self->segment_flags,
+ gst_event_parse_seek (event, &rate, &format, &flags,
&start_type, &start, &stop_type, &stop);
if (format != GST_FORMAT_TIME) {
/* Convert that seek to a seeking in bytes at position 0,
FIXME: could use an index */
ret = gst_pad_push_event (self->sinkpad,
- gst_event_new_seek (rate, GST_FORMAT_BYTES, self->segment_flags,
+ gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, 0));
if (ret) {
/* Apply the seek to our segment */
- gst_segment_set_seek (&self->segment, rate, format, self->segment_flags,
+ gst_segment_do_seek (&self->segment, rate, format, flags,
start_type, start, stop_type, stop, &update);
GST_DEBUG_OBJECT (self, "segment after seek: %" GST_SEGMENT_FORMAT,
const gchar *line_split;
gchar *line_chunk;
guint start_frame, end_frame;
- gint64 clip_start = 0, clip_stop = 0;
+ guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
GString *markup;
gchar *ret;
case 2:
{
/* No need to parse that text if it's out of segment */
- gint64 clip_start = 0, clip_stop = 0;
+ guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
/* Check our segment start/stop */
case 1:
{
/* No need to parse that text if it's out of segment */
- gint64 clip_start = 0, clip_stop = 0;
+ guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
/* Check our segment start/stop */
return NULL;
case 1:
{ /* No need to parse that text if it's out of segment */
- gint64 clip_start = 0, clip_stop = 0;
+ guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg = FALSE;
/* Check our segment start/stop */
return NULL;
case 1:
{
- gint64 clip_start = 0, clip_stop = 0;
+ guint64 clip_start = 0, clip_stop = 0;
gboolean in_seg;
gchar *ret;
switch (regtype) {
case GST_SUB_PARSE_REGEX_MDVDSUB:
result =
- (gpointer) g_regex_new ("^\\{[0-9]+\\}\\{[0-9]+\\}", 0, 0, &gerr);
+ (gpointer) g_regex_new ("^\\{[0-9]+\\}\\{[0-9]+\\}",
+ G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, &gerr);
if (result == NULL) {
g_warning ("Compilation of mdvd regex failed: %s", gerr->message);
g_error_free (gerr);
result = (gpointer) g_regex_new ("^([ 0-9]){0,3}[0-9]\\s*(\x0d)?\x0a"
"[ 0-9][0-9]:[ 0-9][0-9]:[ 0-9][0-9][,.][ 0-9]{0,2}[0-9]"
" +--> +([ 0-9])?[0-9]:[ 0-9][0-9]:[ 0-9][0-9][,.][ 0-9]{0,2}[0-9]",
- 0, 0, &gerr);
+ G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, &gerr);
if (result == NULL) {
g_warning ("Compilation of subrip regex failed: %s", gerr->message);
g_error_free (gerr);
break;
case GST_SUB_PARSE_REGEX_DKS:
result = (gpointer) g_regex_new ("^\\[[0-9]+:[0-9]+:[0-9]+\\].*",
- 0, 0, &gerr);
+ G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, &gerr);
if (result == NULL) {
g_warning ("Compilation of dks regex failed: %s", gerr->message);
g_error_free (gerr);
gst_adapter_push (self->adapter, buf);
avail = gst_adapter_available (self->adapter);
- data = gst_adapter_map (self->adapter, avail),
- input = convert_encoding (self, (const gchar *) data, avail, &consumed);
+ data = gst_adapter_map (self->adapter, avail);
+ input = convert_encoding (self, (const gchar *) data, avail, &consumed);
if (input && consumed > 0) {
self->textbuf = g_string_append (self->textbuf, input);
GST_BUFFER_DURATION (buf) = self->state.max_duration;
}
- gst_segment_set_last_stop (&self->segment, GST_FORMAT_TIME,
- self->state.start_time);
+ self->segment.position = self->state.start_time;
GST_DEBUG_OBJECT (self, "Sending text '%s', %" GST_TIME_FORMAT " + %"
GST_TIME_FORMAT, subtitle, GST_TIME_ARGS (self->state.start_time),
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.applied_rate,
- self->segment.format, self->segment.last_stop, self->segment.stop,
- self->segment.time));
+ gst_pad_push_event (self->srcpad, gst_event_new_segment (&self->segment));
self->need_segment = FALSE;
}
ret = gst_pad_event_default (pad, event);
break;
}
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
- gboolean update;
-
- gst_event_parse_new_segment (event, &update, &rate, &arate, &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, arate, 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) */
- }
-
+ gst_event_copy_segment (event, &self->segment);
+ GST_DEBUG_OBJECT (self, "newsegment (%s)",
+ gst_format_get_name (self->segment.format));
+
+ /* 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);
break;
}
}
converted_str = gst_convert_to_utf8 (str, 128, enc, &tmp, &err);
- if (converted_str == NULL) {
- GST_DEBUG ("Charset conversion failed: %s", err->message);
- g_error_free (err);
- g_free (str);
- return;
- } else {
+ if (converted_str != NULL) {
g_free (str);
str = converted_str;
}