oggparse: better detection of delta unit flag

This commit is contained in:
David Schleef 2011-02-03 22:41:23 -08:00
parent f499810bdc
commit 15e23414d3
2 changed files with 37 additions and 11 deletions

View file

@ -115,6 +115,7 @@ free_stream (GstOggStream * stream)
{
g_list_foreach (stream->headers, (GFunc) gst_mini_object_unref, NULL);
g_list_foreach (stream->unknown_pages, (GFunc) gst_mini_object_unref, NULL);
g_list_foreach (stream->stored_buffers, (GFunc) gst_mini_object_unref, NULL);
g_free (stream);
}
@ -362,7 +363,7 @@ gst_ogg_parse_is_header (GstOggParse * ogg, GstOggStream * stream,
static GstBuffer *
gst_ogg_parse_buffer_from_page (ogg_page * page,
guint64 offset, gboolean keyframe, GstClockTime timestamp)
guint64 offset, GstClockTime timestamp)
{
int size = page->header_len + page->body_len;
GstBuffer *buf = gst_buffer_new_and_alloc (size);
@ -373,9 +374,6 @@ gst_ogg_parse_buffer_from_page (ogg_page * page,
GST_BUFFER_TIMESTAMP (buf) = timestamp;
GST_BUFFER_OFFSET (buf) = offset;
GST_BUFFER_OFFSET_END (buf) = offset + size;
if (!keyframe) {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
}
return buf;
}
@ -447,7 +445,7 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
keyframe = TRUE;
}
pagebuffer = gst_ogg_parse_buffer_from_page (&page, startoffset,
keyframe, buffertimestamp);
buffertimestamp);
/* We read out 'ret' bytes, so we set the next offset appropriately */
ogg->offset += ret;
@ -659,15 +657,42 @@ gst_ogg_parse_chain (GstPad * pad, GstBuffer * buffer)
g_list_free (stream->unknown_pages);
stream->unknown_pages = NULL;
}
}
gst_buffer_set_caps (pagebuffer, caps);
result = gst_pad_push (ogg->srcpad, GST_BUFFER (pagebuffer));
if (result != GST_FLOW_OK)
return result;
if (granule == -1) {
stream->stored_buffers = g_list_append (stream->stored_buffers,
pagebuffer);
} else {
/* Normal data page, submit buffer */
if (stream->stored_buffers) {
int j;
for (j = 0; j < g_list_length (stream->stored_buffers); j++) {
GstBuffer *buf =
GST_BUFFER (g_list_nth_data (stream->stored_buffers, j));
gst_buffer_set_caps (buf, ogg->caps);
GST_BUFFER_TIMESTAMP (buf) = buffertimestamp;
if (!keyframe) {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
} else {
keyframe = FALSE;
}
result = gst_pad_push (ogg->srcpad, buf);
if (result != GST_FLOW_OK)
return result;
}
g_list_free (stream->stored_buffers);
stream->stored_buffers = NULL;
}
gst_buffer_set_caps (pagebuffer, ogg->caps);
if (!keyframe) {
GST_BUFFER_FLAG_SET (pagebuffer, GST_BUFFER_FLAG_DELTA_UNIT);
} else {
keyframe = FALSE;
}
result = gst_pad_push (ogg->srcpad, GST_BUFFER (pagebuffer));
if (result != GST_FLOW_OK)
return result;

View file

@ -53,6 +53,7 @@ struct _GstOggStream
/* for oggparse */
gboolean in_headers;
GList *unknown_pages;
GList *stored_buffers;
gint map;
gboolean is_skeleton;