Commit 17240ac9 authored by René Stadler's avatar René Stadler

matroska: port to 0.11

Support for TAG_IMAGE and TAG_ATTACHMENT is commented out; this requires caps
on buffers which is gone from 0.11.

Segment handling in the demuxer is a bit complex; I added some FIXME comments
in places where I'm not yet sure if I ported correctly.
parent eeaa9e0b
......@@ -314,7 +314,7 @@ dnl *** plug-ins to include ***
dnl Non ported plugins (non-dependant, then dependant)
dnl Make sure you have a space before and after all plugins
GST_PLUGINS_NONPORTED="deinterlace flx goom2k1 \
imagefreeze interleave matroska monoscope smpte \
imagefreeze interleave monoscope smpte \
videobox videomixer \
cairo cairo_gobject dv1394 gdk_pixbuf libdv libpng \
oss oss4 shout2 \
......
......@@ -164,6 +164,7 @@ gst_ebml_read_init (GstEbmlRead * ebml, GstElement * el, GstBuffer * buf,
guint64 offset)
{
GstEbmlMaster m;
gsize buf_size;
g_return_if_fail (el);
g_return_if_fail (buf);
......@@ -171,9 +172,10 @@ gst_ebml_read_init (GstEbmlRead * ebml, GstElement * el, GstBuffer * buf,
ebml->el = el;
ebml->offset = offset;
ebml->buf = buf;
ebml->buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
ebml->readers = g_array_sized_new (FALSE, FALSE, sizeof (GstEbmlMaster), 10);
m.offset = ebml->offset;
gst_byte_reader_init (&m.br, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
gst_byte_reader_init (&m.br, ebml->buf_data, buf_size);
g_array_append_val (ebml->readers, m);
}
......@@ -183,8 +185,10 @@ gst_ebml_read_clear (GstEbmlRead * ebml)
if (ebml->readers)
g_array_free (ebml->readers, TRUE);
ebml->readers = NULL;
if (ebml->buf)
if (ebml->buf) {
gst_buffer_unmap (ebml->buf, ebml->buf_data, -1);
gst_buffer_unref (ebml->buf);
}
ebml->buf = NULL;
ebml->el = NULL;
}
......@@ -334,7 +338,8 @@ gst_ebml_read_buffer (GstEbmlRead * ebml, guint32 * id, GstBuffer ** buf)
offset = gst_ebml_read_get_pos (ebml) - ebml->offset;
if (G_LIKELY (gst_byte_reader_skip (gst_ebml_read_br (ebml), length))) {
*buf = gst_buffer_create_sub (ebml->buf, offset, length);
*buf = gst_buffer_copy_region (ebml->buf, GST_BUFFER_COPY_ALL,
offset, length);
} else {
*buf = NULL;
return GST_FLOW_PARSE;
......
......@@ -54,6 +54,7 @@ typedef struct _GstEbmlRead {
GstElement *el;
GstBuffer *buf;
gpointer buf_data;
guint64 offset;
GArray *readers;
......
......@@ -33,18 +33,14 @@
GST_DEBUG_CATEGORY_STATIC (gst_ebml_write_debug);
#define GST_CAT_DEFAULT gst_ebml_write_debug
#define _do_init(thing) \
#define _do_init \
GST_DEBUG_CATEGORY_INIT (gst_ebml_write_debug, "ebmlwrite", 0, "Write EBML structured data")
GST_BOILERPLATE_FULL (GstEbmlWrite, gst_ebml_write, GstObject, GST_TYPE_OBJECT,
#define parent_class gst_ebml_write_parent_class
G_DEFINE_TYPE_WITH_CODE (GstEbmlWrite, gst_ebml_write, GST_TYPE_OBJECT,
_do_init);
static void gst_ebml_write_finalize (GObject * object);
static void
gst_ebml_write_base_init (gpointer g_class)
{
}
static void
gst_ebml_write_class_init (GstEbmlWriteClass * klass)
{
......@@ -54,11 +50,11 @@ gst_ebml_write_class_init (GstEbmlWriteClass * klass)
}
static void
gst_ebml_write_init (GstEbmlWrite * ebml, GstEbmlWriteClass * klass)
gst_ebml_write_init (GstEbmlWrite * ebml)
{
ebml->srcpad = NULL;
ebml->pos = 0;
ebml->last_pos = G_MAXUINT64; /* force newsegment event */
ebml->last_pos = G_MAXUINT64; /* force segment event */
ebml->cache = NULL;
ebml->streamheader = NULL;
......@@ -89,7 +85,7 @@ gst_ebml_write_finalize (GObject * object)
ebml->caps = NULL;
}
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -126,7 +122,7 @@ void
gst_ebml_write_reset (GstEbmlWrite * ebml)
{
ebml->pos = 0;
ebml->last_pos = G_MAXUINT64; /* force newsegment event */
ebml->last_pos = G_MAXUINT64; /* force segment event */
if (ebml->cache) {
gst_byte_writer_free (ebml->cache);
......@@ -182,7 +178,7 @@ gst_ebml_stop_streamheader (GstEbmlWrite * ebml)
buffer = gst_byte_writer_free_and_get_buffer (ebml->streamheader);
ebml->streamheader = NULL;
GST_DEBUG ("Streamheader was size %d", GST_BUFFER_SIZE (buffer));
GST_DEBUG ("Streamheader was size %d", gst_buffer_get_size (buffer));
ebml->writing_streamheader = FALSE;
return buffer;
......@@ -211,14 +207,19 @@ gst_ebml_write_set_cache (GstEbmlWrite * ebml, guint size)
}
static gboolean
gst_ebml_writer_send_new_segment_event (GstEbmlWrite * ebml, guint64 new_pos)
gst_ebml_writer_send_segment_event (GstEbmlWrite * ebml, guint64 new_pos)
{
GstSegment segment;
gboolean res;
GST_INFO ("seeking to %" G_GUINT64_FORMAT, new_pos);
res = gst_pad_push_event (ebml->srcpad,
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, new_pos, -1, 0));
gst_segment_init (&segment, GST_FORMAT_BYTES);
segment.start = new_pos;
segment.stop = -1;
segment.position = 0;
res = gst_pad_push_event (ebml->srcpad, gst_event_new_segment (&segment));
if (!res)
GST_WARNING ("seek to %" G_GUINT64_FORMAT "failed", new_pos);
......@@ -244,14 +245,13 @@ gst_ebml_write_flush_cache (GstEbmlWrite * ebml, gboolean is_keyframe,
buffer = gst_byte_writer_free_and_get_buffer (ebml->cache);
ebml->cache = NULL;
GST_DEBUG ("Flushing cache of size %d", GST_BUFFER_SIZE (buffer));
gst_buffer_set_caps (buffer, ebml->caps);
GST_DEBUG ("Flushing cache of size %d", gst_buffer_get_size (buffer));
GST_BUFFER_TIMESTAMP (buffer) = timestamp;
GST_BUFFER_OFFSET (buffer) = ebml->pos - GST_BUFFER_SIZE (buffer);
GST_BUFFER_OFFSET (buffer) = ebml->pos - gst_buffer_get_size (buffer);
GST_BUFFER_OFFSET_END (buffer) = ebml->pos;
if (ebml->last_write_result == GST_FLOW_OK) {
if (GST_BUFFER_OFFSET (buffer) != ebml->last_pos) {
gst_ebml_writer_send_new_segment_event (ebml, GST_BUFFER_OFFSET (buffer));
gst_ebml_writer_send_segment_event (ebml, GST_BUFFER_OFFSET (buffer));
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
}
if (ebml->writing_streamheader) {
......@@ -290,7 +290,7 @@ gst_ebml_write_element_new (GstEbmlWrite * ebml, guint8 ** data_out, guint size)
buf = gst_buffer_new_and_alloc (size);
GST_BUFFER_TIMESTAMP (buf) = ebml->timestamp;
*data_out = GST_BUFFER_DATA (buf);
*data_out = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
return buf;
}
......@@ -408,31 +408,33 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
{
guint data_size;
if (!buf_data)
buf_data = GST_BUFFER_DATA (buf);
if (buf_data_end) {
if (buf_data_end)
data_size = buf_data_end - buf_data;
GST_BUFFER_SIZE (buf) = data_size;
} else {
data_size = GST_BUFFER_SIZE (buf);
}
else
data_size = gst_buffer_get_size (buf);
ebml->pos += data_size;
/* if there's no cache, then don't push it! */
if (ebml->writing_streamheader) {
if (!buf_data)
buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
gst_byte_writer_put_data (ebml->streamheader, buf_data, data_size);
}
if (ebml->cache) {
if (!buf_data)
buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
gst_byte_writer_put_data (ebml->cache, buf_data, data_size);
gst_buffer_unmap (buf, buf_data, -1);
gst_buffer_unref (buf);
return;
}
if (buf_data)
gst_buffer_unmap (buf, buf_data, -1);
if (ebml->last_write_result == GST_FLOW_OK) {
buf = gst_buffer_make_metadata_writable (buf);
gst_buffer_set_caps (buf, ebml->caps);
buf = gst_buffer_make_writable (buf);
GST_BUFFER_OFFSET (buf) = ebml->pos - data_size;
GST_BUFFER_OFFSET_END (buf) = ebml->pos;
if (ebml->writing_streamheader) {
......@@ -441,7 +443,7 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
if (GST_BUFFER_OFFSET (buf) != ebml->last_pos) {
gst_ebml_writer_send_new_segment_event (ebml, GST_BUFFER_OFFSET (buf));
gst_ebml_writer_send_segment_event (ebml, GST_BUFFER_OFFSET (buf));
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
}
ebml->last_pos = ebml->pos;
......@@ -730,12 +732,12 @@ gst_ebml_write_master_finish_full (GstEbmlWrite * ebml, guint64 startpos,
guint64 extra_size)
{
guint64 pos = ebml->pos;
GstBuffer *buf;
guint8 *data = g_malloc (8);
GstBuffer *buf = gst_buffer_new_wrapped (data, 8);
gst_ebml_write_seek (ebml, startpos);
buf = gst_buffer_new_and_alloc (8);
GST_WRITE_UINT64_BE (GST_BUFFER_DATA (buf),
GST_WRITE_UINT64_BE (data,
(G_GINT64_CONSTANT (1) << 56) | (pos - startpos - 8 + extra_size));
gst_ebml_write_element_push (ebml, buf, NULL, NULL);
......@@ -835,11 +837,12 @@ void
gst_ebml_replace_uint (GstEbmlWrite * ebml, guint64 pos, guint64 num)
{
guint64 oldpos = ebml->pos;
GstBuffer *buf = gst_buffer_new_and_alloc (8);
guint8 *data_start, *data_end;
GstBuffer *buf;
data_start = GST_BUFFER_DATA (buf);
data_start = g_malloc (8);
data_end = data_start;
buf = gst_buffer_new_wrapped (data_start, 8);
gst_ebml_write_seek (ebml, pos);
gst_ebml_write_set_uint (&data_end, num, 8);
......
This diff is collapsed.
......@@ -87,7 +87,7 @@ typedef struct _GstMatroskaDemux {
gboolean building_index;
guint64 index_offset;
GstEvent *seek_event;
gboolean need_newsegment;
gboolean need_segment;
/* reverse playback */
GArray *seek_index;
......
......@@ -486,10 +486,10 @@ struct _GstMatroskaTrackContext {
/* some often-used info */
gchar *codec_id, *codec_name, *name, *language;
guint8 *codec_priv;
guint codec_priv_size;
guint8 *codec_state;
guint codec_state_size;
gpointer codec_priv;
gsize codec_priv_size;
gpointer codec_state;
gsize codec_state_size;
GstMatroskaTrackType type;
guint uid, num;
GstMatroskaTrackFlags flags;
......
This diff is collapsed.
......@@ -53,10 +53,13 @@ typedef struct _GstMatroskaMetaSeekIndex {
guint64 pos;
} GstMatroskaMetaSeekIndex;
typedef gboolean (*GstMatroskaCapsFunc) (GstPad *pad, GstCaps *caps);
/* all information needed for one matroska stream */
typedef struct
{
GstCollectData collect; /* we extend the CollectData */
GstMatroskaCapsFunc capsfunc;
GstMatroskaTrackContext *track;
GstBuffer *buffer; /* the queued buffer for this pad */
......
......@@ -111,16 +111,14 @@ static gboolean gst_matroska_parse_element_query (GstElement * element,
static gboolean gst_matroska_parse_handle_seek_event (GstMatroskaParse * parse,
GstPad * pad, GstEvent * event);
static gboolean gst_matroska_parse_handle_src_event (GstPad * pad,
GstEvent * event);
static const GstQueryType *gst_matroska_parse_get_src_query_types (GstPad *
pad);
GstObject * parent, GstEvent * event);
static gboolean gst_matroska_parse_handle_src_query (GstPad * pad,
GstQuery * query);
GstObject * parent, GstQuery * query);
static gboolean gst_matroska_parse_handle_sink_event (GstPad * pad,
GstEvent * event);
GstObject * parent, GstEvent * event);
static GstFlowReturn gst_matroska_parse_chain (GstPad * pad,
GstBuffer * buffer);
GstObject * parent, GstBuffer * buffer);
static GstStateChangeReturn
gst_matroska_parse_change_state (GstElement * element,
......@@ -135,24 +133,8 @@ static gboolean perform_seek_to_offset (GstMatroskaParse * parse,
guint64 offset);
GType gst_matroska_parse_get_type (void);
GST_BOILERPLATE (GstMatroskaParse, gst_matroska_parse, GstElement,
GST_TYPE_ELEMENT);
static void
gst_matroska_parse_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_templ));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_templ));
gst_element_class_set_details_simple (element_class, "Matroska parser",
"Codec/Parser",
"Parses Matroska/WebM streams into video/audio/subtitles",
"GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
}
#define parent_class gst_matroska_parse_parent_class
G_DEFINE_TYPE (GstMatroskaParse, gst_matroska_parse, GST_TYPE_ELEMENT);
static void
gst_matroska_parse_finalize (GObject * object)
......@@ -196,11 +178,20 @@ gst_matroska_parse_class_init (GstMatroskaParseClass * klass)
GST_DEBUG_FUNCPTR (gst_matroska_parse_set_index);
gstelement_class->get_index =
GST_DEBUG_FUNCPTR (gst_matroska_parse_get_index);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_templ));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sink_templ));
gst_element_class_set_details_simple (gstelement_class,
"Matroska parser", "Codec/Parser",
"Parses Matroska/WebM streams into video/audio/subtitles",
"GStreamer maintainers <gstreamer-devel@lists.sourceforge.net>");
}
static void
gst_matroska_parse_init (GstMatroskaParse * parse,
GstMatroskaParseClass * klass)
gst_matroska_parse_init (GstMatroskaParse * parse)
{
parse->common.sinkpad = gst_pad_new_from_static_template (&sink_templ,
"sink");
......@@ -213,8 +204,6 @@ gst_matroska_parse_init (GstMatroskaParse * parse,
parse->srcpad = gst_pad_new_from_static_template (&src_templ, "src");
gst_pad_set_event_function (parse->srcpad,
GST_DEBUG_FUNCPTR (gst_matroska_parse_handle_src_event));
gst_pad_set_query_type_function (parse->srcpad,
GST_DEBUG_FUNCPTR (gst_matroska_parse_get_src_query_types));
gst_pad_set_query_function (parse->srcpad,
GST_DEBUG_FUNCPTR (gst_matroska_parse_handle_src_query));
gst_pad_use_fixed_caps (parse->srcpad);
......@@ -374,7 +363,7 @@ gst_matroska_parse_reset (GstElement * element)
if (parse->common.global_tags) {
gst_tag_list_free (parse->common.global_tags);
}
parse->common.global_tags = gst_tag_list_new ();
parse->common.global_tags = gst_tag_list_new_empty ();
if (parse->common.cached_buffer) {
gst_buffer_unref (parse->common.cached_buffer);
......@@ -1078,19 +1067,6 @@ gst_matroska_parse_add_stream (GstMatroskaParse * parse, GstEbmlRead * ebml)
return ret;
}
static const GstQueryType *
gst_matroska_parse_get_src_query_types (GstPad * pad)
{
static const GstQueryType query_types[] = {
GST_QUERY_POSITION,
GST_QUERY_DURATION,
GST_QUERY_SEEKING,
0
};
return query_types;
}
static gboolean
gst_matroska_parse_query (GstMatroskaParse * parse, GstPad * pad,
GstQuery * query)
......@@ -1115,7 +1091,7 @@ gst_matroska_parse_query (GstMatroskaParse * parse, GstPad * pad,
gst_query_set_position (query, GST_FORMAT_TIME, context->pos);
else
gst_query_set_position (query, GST_FORMAT_TIME,
parse->common.segment.last_stop);
parse->common.segment.position);
GST_OBJECT_UNLOCK (parse);
} else if (format == GST_FORMAT_DEFAULT && context
&& context->default_duration) {
......@@ -1175,7 +1151,7 @@ gst_matroska_parse_query (GstMatroskaParse * parse, GstPad * pad,
break;
}
default:
res = gst_pad_query_default (pad, query);
res = gst_pad_query_default (pad, (GstObject *) parse, query);
break;
}
......@@ -1189,15 +1165,14 @@ gst_matroska_parse_element_query (GstElement * element, GstQuery * query)
}
static gboolean
gst_matroska_parse_handle_src_query (GstPad * pad, GstQuery * query)
gst_matroska_parse_handle_src_query (GstPad * pad, GstObject * parent,
GstQuery * query)
{
gboolean ret;
GstMatroskaParse *parse = GST_MATROSKA_PARSE (gst_pad_get_parent (pad));
GstMatroskaParse *parse = GST_MATROSKA_PARSE (parent);
ret = gst_matroska_parse_query (parse, pad, query);
gst_object_unref (parse);
return ret;
}
......@@ -1248,6 +1223,8 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
GstFlowReturn ret = GST_FLOW_OK;
const guint chunk = 64 * 1024;
GstBuffer *buf = NULL;
gpointer data;
gsize size;
guint64 length;
guint32 id;
guint needed;
......@@ -1263,13 +1240,13 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
if (ret != GST_FLOW_OK)
break;
GST_DEBUG_OBJECT (parse, "read buffer size %d at offset %" G_GINT64_FORMAT,
GST_BUFFER_SIZE (buf), newpos);
gst_byte_reader_init_from_buffer (&reader, buf);
gst_buffer_get_size (buf), newpos);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_byte_reader_init (&reader, data, size);
cluster_pos = 0;
resume:
cluster_pos = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff,
GST_MATROSKA_ID_CLUSTER, cluster_pos,
GST_BUFFER_SIZE (buf) - cluster_pos);
GST_MATROSKA_ID_CLUSTER, cluster_pos, size - cluster_pos);
if (cluster_pos >= 0) {
newpos += cluster_pos;
GST_DEBUG_OBJECT (parse,
......@@ -1311,13 +1288,15 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
goto resume;
} else {
/* partial cluster id may have been in tail of buffer */
newpos += MAX (GST_BUFFER_SIZE (buf), 4) - 3;
newpos += MAX (size, 4) - 3;
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
buf = NULL;
}
}
if (buf) {
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
buf = NULL;
}
......@@ -1362,7 +1341,7 @@ gst_matroska_parse_handle_seek_event (GstMatroskaParse * parse,
if (event) {
GST_DEBUG_OBJECT (parse, "configuring seek");
gst_segment_set_seek (&seeksegment, rate, format, flags,
gst_segment_do_seek (&seeksegment, rate, format, flags,
cur_type, cur, stop_type, stop, &update);
}
......@@ -1371,7 +1350,7 @@ gst_matroska_parse_handle_seek_event (GstMatroskaParse * parse,
/* check sanity before we start flushing and all that */
GST_OBJECT_LOCK (parse);
if ((entry = gst_matroska_read_common_do_index_seek (&parse->common, track,
seeksegment.last_stop, &parse->seek_index, &parse->seek_entry)) ==
seeksegment.position, &parse->seek_index, &parse->seek_entry)) ==
NULL) {
/* pull mode without index can scan later on */
GST_DEBUG_OBJECT (parse, "No matching seek entry in index");
......@@ -1473,9 +1452,10 @@ gst_matroska_parse_handle_seek_push (GstMatroskaParse * parse, GstPad * pad,
}
static gboolean
gst_matroska_parse_handle_src_event (GstPad * pad, GstEvent * event)
gst_matroska_parse_handle_src_event (GstPad * pad, GstObject * parent,
GstEvent * event)
{
GstMatroskaParse *parse = GST_MATROSKA_PARSE (gst_pad_get_parent (pad));
GstMatroskaParse *parse = GST_MATROSKA_PARSE (parent);
gboolean res = TRUE;
switch (GST_EVENT_TYPE (event)) {
......@@ -1499,7 +1479,7 @@ gst_matroska_parse_handle_src_event (GstPad * pad, GstEvent * event)
GstClockTimeDiff diff;
GstClockTime timestamp;
gst_event_parse_qos (event, &proportion, &diff, &timestamp);
gst_event_parse_qos (event, NULL, &proportion, &diff, &timestamp);
GST_OBJECT_LOCK (parse);
videocontext->earliest_time = timestamp + diff;
......@@ -1522,8 +1502,6 @@ gst_matroska_parse_handle_src_event (GstPad * pad, GstEvent * event)
break;
}
gst_object_unref (parse);
return res;
}
......@@ -1635,6 +1613,8 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
guint32 id;
guint64 block_duration = 0;
GstBuffer *buf = NULL;
gpointer buf_data = NULL;
gsize buf_size = 0;
gint stream_num = -1, n, laces = 0;
guint size = 0;
gint *lace_size = NULL;
......@@ -1668,8 +1648,10 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
if ((ret = gst_ebml_read_buffer (ebml, &id, &buf)) != GST_FLOW_OK)
break;
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
data = buf_data;
size = buf_size;
/* first byte(s): blocknum */
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
......@@ -1873,18 +1855,18 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
}
/* need to refresh segment info ASAP */
if (GST_CLOCK_TIME_IS_VALID (lace_time) && parse->need_newsegment) {
GstSegment segment;
GST_DEBUG_OBJECT (parse,
"generating segment starting at %" GST_TIME_FORMAT,
GST_TIME_ARGS (lace_time));
/* pretend we seeked here */
gst_segment_set_seek (&parse->common.segment, parse->common.segment.rate,
gst_segment_do_seek (&parse->common.segment, parse->common.segment.rate,
GST_FORMAT_TIME, 0, GST_SEEK_TYPE_SET, lace_time,
GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE, NULL);
/* now convey our segment notion downstream */
gst_matroska_parse_send_event (parse, gst_event_new_new_segment (FALSE,
parse->common.segment.rate, parse->common.segment.format,
parse->common.segment.start, parse->common.segment.stop,
parse->common.segment.start));
segment = parse->common.segment;
segment.position = segment.start;
gst_matroska_parse_send_event (parse, gst_event_new_segment (&segment));
parse->need_newsegment = FALSE;
}
......@@ -2134,8 +2116,10 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
}
done:
if (buf)
if (buf) {
gst_buffer_unmap (buf, buf_data, buf_size);
gst_buffer_unref (buf);
}
g_free (lace_size);
return ret;
......@@ -2419,10 +2403,9 @@ gst_matroska_parse_check_seekability (GstMatroskaParse * parse)
/* try harder to query upstream size if we didn't get it the first time */
if (seekable && stop == -1) {
GstFormat fmt = GST_FORMAT_BYTES;
GST_DEBUG_OBJECT (parse, "doing duration query to fix up unset stop");
gst_pad_query_peer_duration (parse->common.sinkpad, &fmt, &stop);
gst_pad_peer_query_duration (parse->common.sinkpad, GST_FORMAT_BYTES,
&stop);
}
/* if upstream doesn't know the size, it's likely that it's not seekable in
......@@ -2506,14 +2489,15 @@ gst_matroska_parse_accumulate_streamheader (GstMatroskaParse * parse,
GstBuffer *buf;
buf = gst_buffer_span (parse->streamheader, 0, buffer,
GST_BUFFER_SIZE (parse->streamheader) + GST_BUFFER_SIZE (buffer));
gst_buffer_get_size (parse->streamheader) +
gst_buffer_get_size (buffer));
gst_buffer_unref (parse->streamheader);
parse->streamheader = buf;
} else {
parse->streamheader = gst_buffer_ref (buffer);
}
GST_DEBUG ("%d", GST_BUFFER_SIZE (parse->streamheader));
GST_DEBUG ("%d", gst_buffer_get_size (parse->streamheader));
}
static GstFlowReturn
......@@ -2529,7 +2513,7 @@ gst_matroska_parse_output (GstMatroskaParse * parse, GstBuffer * buffer,
GValue bufval = { 0 };
GstBuffer *buf;
caps = gst_caps_new_simple ("video/x-matroska", NULL);