From cba98e05cfb1a2045b5c7401c8f51f9fdf704425 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 8 Jun 2010 12:01:15 +0200 Subject: [PATCH] oggdemux: Add parsing of Skeleton 4.0 indexes --- ext/ogg/gstoggdemux.c | 4 ++-- ext/ogg/gstoggstream.c | 35 +++++++++++++++++++++++++++++++++-- ext/ogg/gstoggstream.h | 4 ++-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 28507ec..90a6958 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -762,11 +762,11 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet) /* parse the remainder of the fisbone in the pad with the serialno, * note that we ignore the start_time as this is usually wrong for * live streams */ - gst_ogg_map_add_fisbone (&skel_pad->map, packet->packet, + gst_ogg_map_add_fisbone (&skel_pad->map, &pad->map, packet->packet, packet->bytes, NULL); break; case GST_OGG_SKELETON_INDEX: - gst_ogg_map_add_index (&skel_pad->map, packet->packet, + gst_ogg_map_add_index (&skel_pad->map, &pad->map, packet->packet, packet->bytes); break; default: diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c index 766e738..d07a221 100644 --- a/ext/ogg/gstoggstream.c +++ b/ext/ogg/gstoggstream.c @@ -957,7 +957,7 @@ gst_ogg_map_parse_fisbone (GstOggStream * pad, const guint8 * data, guint size, } gboolean -gst_ogg_map_add_fisbone (GstOggStream * pad, +gst_ogg_map_add_fisbone (GstOggStream * pad, GstOggStream * skel_pad, const guint8 * data, guint size, GstClockTime * p_start_time) { GstClockTime start_time; @@ -1020,7 +1020,8 @@ read_vlc (const guint8 ** data, guint * size, guint64 * result) } gboolean -gst_ogg_map_add_index (GstOggStream * pad, const guint8 * data, guint size) +gst_ogg_map_add_index (GstOggStream * pad, GstOggStream * skel_pad, + const guint8 * data, guint size) { guint64 i, n_keypoints, isize; guint64 offset, timestamp; @@ -1049,6 +1050,36 @@ gst_ogg_map_add_index (GstOggStream * pad, const guint8 * data, guint size) data += 16; size -= 16; + if (skel_pad->skeleton_major == 4) { + guint64 firstsampletime_n, lastsampletime_n; + guint64 firstsampletime, lastsampletime; + + firstsampletime_n = GST_READ_UINT64_LE (data); + lastsampletime_n = GST_READ_UINT64_LE (data + 8); + + GST_INFO ("firstsampletime %" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, + firstsampletime_n, pad->kp_denom); + GST_INFO ("lastsampletime %" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, + lastsampletime_n, pad->kp_denom); + + firstsampletime = gst_util_uint64_scale (GST_SECOND, + firstsampletime_n, pad->kp_denom); + + lastsampletime = gst_util_uint64_scale (GST_SECOND, + lastsampletime_n, pad->kp_denom); + + if (lastsampletime > firstsampletime) + pad->total_time = lastsampletime - firstsampletime; + else + pad->total_time = -1; + + GST_INFO ("skeleton index parsed total: %" GST_TIME_FORMAT, + GST_TIME_ARGS (pad->total_time)); + + data += 16; + size -= 16; + } + GST_INFO ("skeleton index has %" G_GUINT64_FORMAT " keypoints, denom: %" G_GINT64_FORMAT, n_keypoints, pad->kp_denom); diff --git a/ext/ogg/gstoggstream.h b/ext/ogg/gstoggstream.h index 5903b61..da6ee14 100644 --- a/ext/ogg/gstoggstream.h +++ b/ext/ogg/gstoggstream.h @@ -114,9 +114,9 @@ gint64 gst_ogg_stream_get_packet_duration (GstOggStream * pad, ogg_packet *packe gboolean gst_ogg_map_parse_fisbone (GstOggStream * pad, const guint8 * data, guint size, guint32 * serialno, GstOggSkeleton *type); -gboolean gst_ogg_map_add_fisbone (GstOggStream * pad, const guint8 * data, guint size, +gboolean gst_ogg_map_add_fisbone (GstOggStream * pad, GstOggStream * skel_pad, const guint8 * data, guint size, GstClockTime * p_start_time); -gboolean gst_ogg_map_add_index (GstOggStream * pad, const guint8 * data, guint size); +gboolean gst_ogg_map_add_index (GstOggStream * pad, GstOggStream * skel_pad, const guint8 * data, guint size); gboolean gst_ogg_map_search_index (GstOggStream * pad, gboolean before, guint64 *timestamp, guint64 *offset); -- 2.7.4