diff options
author | Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> | 2010-12-17 14:16:18 +0000 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-12-18 20:33:09 +0100 |
commit | 22aa87e98fd931840a3a1e45e1d0a6a23564e214 (patch) | |
tree | b73e5716b85ebb410f06c665290faff988223aad | |
parent | aa07af41f30cab25bb8b4bc6faa5d9b958306058 (diff) |
ogg: implement packet duration query for kate streams
https://bugzilla.gnome.org/show_bug.cgi?id=637519
-rw-r--r-- | ext/ogg/gstoggdemux.c | 7 | ||||
-rw-r--r-- | ext/ogg/gstoggstream.c | 28 |
2 files changed, 33 insertions, 2 deletions
diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index df470f9b1..8da7288e7 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -540,7 +540,12 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet, } else if (pad->map.is_sparse) { out_timestamp = gst_ogg_stream_granule_to_time (&pad->map, pad->current_granule); - out_duration = GST_CLOCK_TIME_NONE; + if (duration == GST_CLOCK_TIME_NONE) { + out_duration = GST_CLOCK_TIME_NONE; + } else { + out_duration = gst_util_uint64_scale (duration, + GST_SECOND * pad->map.granulerate_d, pad->map.granulerate_n); + } } else { out_timestamp = gst_ogg_stream_granule_to_time (&pad->map, pad->current_granule - duration); diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c index eeaf4b9b5..f8ba6c09f 100644 --- a/ext/ogg/gstoggstream.c +++ b/ext/ogg/gstoggstream.c @@ -1732,6 +1732,32 @@ setup_kate_mapper (GstOggStream * pad, ogg_packet * packet) return TRUE; } +static gint64 +packet_duration_kate (GstOggStream * pad, ogg_packet * packet) +{ + gint64 duration; + + if (packet->bytes < 1) + return 0; + + switch (packet->packet[0]) { + case 0x00: /* text data */ + if (packet->bytes < 1 + 8 * 2) { + duration = 0; + } else { + duration = GST_READ_UINT64_LE (packet->packet + 1 + 8); + if (duration < 0) + duration = 0; + } + break; + default: + duration = GST_CLOCK_TIME_NONE; + break; + } + + return duration; +} + /* *INDENT-OFF* */ /* indent hates our freedoms */ @@ -1875,7 +1901,7 @@ const GstOggMap mappers[] = { granule_to_granulepos_default, NULL, is_header_count, - NULL, + packet_duration_kate, NULL, NULL }, |