diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2010-05-04 13:02:19 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2010-05-04 13:02:19 +0200 |
commit | 5c770a17dbf161675f3a21556633c32566c029f4 (patch) | |
tree | 32806d2cd1e60601542feba1d211c2349f5eb251 | |
parent | ff4479f00a427809b6e9fa0c1950b271ae3c1824 (diff) |
oggstream: parse duration from 3.3 skeleton
-rw-r--r-- | ext/ogg/gstoggstream.c | 41 | ||||
-rw-r--r-- | ext/ogg/gstoggstream.h | 1 |
2 files changed, 41 insertions, 1 deletions
diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c index 8f8df2dea..2acfd7a77 100644 --- a/ext/ogg/gstoggstream.c +++ b/ext/ogg/gstoggstream.c @@ -59,7 +59,7 @@ typedef gint64 (*GstOggMapPacketDurationFunc) (GstOggStream * pad, #define SKELETON_FISBONE_MIN_SIZE 52 - +#define SKELETON_FISHEAD_3_3_MIN_SIZE 112 struct _GstOggMap { @@ -714,6 +714,45 @@ setup_fishead_mapper (GstOggStream * pad, ogg_packet * packet) else pad->prestime = -1; + /* Ogg Skeleton 3.3 streams provide additional information in the header */ + if (packet->bytes >= SKELETON_FISHEAD_3_3_MIN_SIZE) { + gint64 firstsampletime_n, firstsampletime_d; + gint64 lastsampletime_n, lastsampletime_d; + gint64 firstsampletime, lastsampletime; + + firstsampletime_n = GST_READ_UINT64_LE (data + 64); + firstsampletime_d = GST_READ_UINT64_LE (data + 72); + lastsampletime_n = GST_READ_UINT64_LE (data + 80); + lastsampletime_d = GST_READ_UINT64_LE (data + 88); + + GST_INFO ("firstsampletime %" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, + firstsampletime_n, firstsampletime_d); + GST_INFO ("lastsampletime %" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, + lastsampletime_n, lastsampletime_d); + + if (firstsampletime_d > 0) + firstsampletime = gst_util_uint64_scale (GST_SECOND, + firstsampletime_n, firstsampletime_d); + else + firstsampletime = 0; + + if (lastsampletime_d > 0) + lastsampletime = gst_util_uint64_scale (GST_SECOND, + lastsampletime_n, lastsampletime_d); + else + lastsampletime = 0; + + if (lastsampletime > firstsampletime) + pad->total_time = lastsampletime - firstsampletime; + else + pad->total_time = -1; + + GST_INFO ("skeleton fishead parsed total: %" GST_TIME_FORMAT, + GST_TIME_ARGS (pad->total_time)); + } else { + pad->total_time = -1; + } + GST_INFO ("skeleton fishead parsed (basetime: %" GST_TIME_FORMAT ", prestime: %" GST_TIME_FORMAT ")", GST_TIME_ARGS (pad->basetime), GST_TIME_ARGS (pad->prestime)); diff --git a/ext/ogg/gstoggstream.h b/ext/ogg/gstoggstream.h index 6bcd89391..f47fdcef3 100644 --- a/ext/ogg/gstoggstream.h +++ b/ext/ogg/gstoggstream.h @@ -65,6 +65,7 @@ struct _GstOggStream gint64 accumulated_granule; gint frame_size; gint bitrate; + guint64 total_time; GstCaps *caps; |