{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rmdemux_sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rmdemux_videosrc_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rmdemux_audiosrc_template));
+ gst_element_class_add_static_pad_template (element_class,
+ &gst_rmdemux_sink_template);
+ gst_element_class_add_static_pad_template (element_class,
+ &gst_rmdemux_videosrc_template);
+ gst_element_class_add_static_pad_template (element_class,
+ &gst_rmdemux_audiosrc_template);
gst_element_class_set_static_metadata (element_class, "RealMedia Demuxer",
"Codec/Demuxer",
"Demultiplex a RealMedia file into audio and video streams",
GST_LOG_OBJECT (rmdemux, "Took streamlock");
if (event) {
- gst_segment_do_seek (&rmdemux->segment, rate, format, flags,
- cur_type, cur, stop_type, stop, &update);
+ if (!gst_segment_do_seek (&rmdemux->segment, rate, format, flags,
+ cur_type, cur, stop_type, stop, &update)) {
+ ret = FALSE;
+ goto done;
+ }
}
GST_DEBUG_OBJECT (rmdemux, "segment positions set to %" GST_TIME_FORMAT "-%"
gst_rmdemux_send_event (rmdemux, gst_event_new_eos ());
}
} else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
- GST_ELEMENT_ERROR (rmdemux, STREAM, FAILED,
- (NULL), ("stream stopped, reason %s", reason));
+ GST_ELEMENT_FLOW_ERROR (rmdemux, ret);
gst_rmdemux_send_event (rmdemux, gst_event_new_eos ());
}
return;
tags = gst_rm_utils_read_tags (data, length, gst_rm_utils_read_string16);
- GST_LOG_OBJECT (rmdemux, "tags: %" GST_PTR_FORMAT, tags);
+ if (tags) {
+ GstTagList *old_tags = rmdemux->pending_tags;
+
+ GST_LOG_OBJECT (rmdemux, "tags: %" GST_PTR_FORMAT, tags);
- rmdemux->pending_tags =
- gst_tag_list_merge (rmdemux->pending_tags, tags, GST_TAG_MERGE_APPEND);
- gst_tag_list_unref (tags);
+ rmdemux->pending_tags =
+ gst_tag_list_merge (old_tags, tags, GST_TAG_MERGE_APPEND);
+
+ gst_tag_list_unref (tags);
+ if (old_tags)
+ gst_tag_list_unref (old_tags);
+
+ gst_tag_list_set_scope (rmdemux->pending_tags, GST_TAG_SCOPE_GLOBAL);
+ }
}
static void
gst_buffer_map (in, &map, GST_MAP_READ);
+ if (map.size < offset)
+ goto not_enough_data;
+
data = map.data + offset;
size = map.size - offset;
}
GST_DEBUG_OBJECT (rmdemux, "fragment size %d", fragment_size);
+ if (map.size < (data - map.data) + fragment_size)
+ goto not_enough_data;
+
/* get the fragment */
fragment =
gst_buffer_copy_region (in, GST_BUFFER_COPY_ALL, data - map.data,
GstFlowReturn ret;
GstBuffer *buffer;
+ if (gst_buffer_get_size (in) < offset)
+ goto not_enough_data;
+
buffer = gst_buffer_copy_region (in, GST_BUFFER_COPY_MEMORY, offset, -1);
if (rmdemux->first_ts != -1 && timestamp > rmdemux->first_ts)
ret = gst_pad_push (stream->pad, buffer);
}
+done:
gst_buffer_unref (in);
return ret;
+
+ /* ERRORS */
+not_enough_data:
+ {
+ GST_ELEMENT_WARNING (rmdemux, STREAM, DECODE, ("Skipping bad packet."),
+ (NULL));
+ ret = GST_FLOW_OK;
+ goto done;
+ }
}
static GstFlowReturn
data = map.data;
size = map.size;
+ if (size < 4 + 6 + 1 + 2)
+ goto not_enough_data;
+
/* stream number */
id = RMDEMUX_GUINT16_GET (data);
/* version 1 has an extra byte */
if (version == 1) {
+ if (size < 1)
+ goto not_enough_data;
+
data += 1;
size -= 1;
}
gst_buffer_unref (in);
return GST_FLOW_OK;
}
+
+ /* ERRORS */
+not_enough_data:
+ {
+ GST_ELEMENT_WARNING (rmdemux, STREAM, DECODE, ("Skipping bad packet."),
+ (NULL));
+ gst_buffer_unmap (in, &map);
+ gst_buffer_unref (in);
+ return GST_FLOW_OK;
+ }
}
gboolean