11) intro 2-------- 3 4For efficient and accurate seeking, a plugin typically needs 5an index of possible seek positions (in time, bytes, samples, ...). 6 7The purpose of GstTimecache is to provide an infrastructure for 8plugins to maintain such an index. 9 10By creating a generic interface to this functionality, it is also 11possible for the application to make use of the generated index. 12possible use cases are: saving/loading of indexes, obtain an 13overview of the indexed stream (where is sample N, where is 14the keyframe...) 15 16 17This document describes a proposed API for this functionality. 18 19 202) Requirements 21--------------- 22 23Bare minimum: 24 25- store mappings between format1 and format2 (bytes<->time, 26 samples<->tracks, ...) 27- update the mappings (add/remove/change entries) 28- query the index, locate entries. 29- store arbitrary extra metadata in the timecache (media file, 30 time, author, ...) 31- set/get cache on elements. 32 33Nice to have: 34 35- cache groups with varying certainty that are merged. 36- API to control the indexing process, what gets indexed, how much, 37 ...) 38- Get notification when a new entry is added, together with an 39 option to turn off in-memory caching, this could be used to 40 do direct-to-disk indexing (for large files) insteda of to-memory. 41 423) use cases 43------------ 44 45a) indexing an mpeg systems stream 46 47 - create an empty timecache object 48 - create filesrc ! mpegparse 49 - set timecache on mpegparse 50 - run the pipeline to EOS 51 - mpegparse will create a mapping from SCR to byte offset 52 and add it to the cache. 53 - read/save timecache 54 55b) running an mpeg with a previously created cache 56 57 - create timecache object from saved index 58 - create filesrc ! mpegparse 59 - set the timecache on mpegparse 60 - run the pipeline, seek, ... 61 - mpegparse uses the timecache to do accurate seek to 62 SCR timestamps. 63 64c) indexing an mpeg systems stream, SCR, video and audio elementary 65 streams. 66 67 - create an empty timecache object 68 - create filesrc ! mpegdemux 69 - set timecache on mpegdemux 70 - run the pipeline to EOS 71 - mpegparse will create a mappings for: 72 * SCR to byte offset 73 * PTS + streamid to byte offset 74 and add it to the cache. 75 - read/save timecache 76 77d) complete indexing of mpeg systems streams and audio/video 78 streams. 79 80 - create 3 empty timecaches 81 - create filesrc ! mpegdemux video_%02d! mpeg2dec 82 mpegdemux0 audio_%02d! mad 83 - set timecaches on mpegdemux, mpeg2dec, mad 84 - run pipeline to EOS 85 - mpegdemux creates timecache for SCR, PTS + streamid 86 - mpeg2dec creates timecache for frames + I/P/B id 87 - mad creates timecache for mpeg audio headers 88 - read/save timecaches 89 90 seeking in a fully indexed stream: 91 - seek on timestamp in mpeg2dec 92 - mpeg2dec locates previous I frame in cache, does 93 a timeseek on sinkpad 94 - mpegparse uses the cache to convert the timestamp 95 to an offset, then does a seek on offset 96 - filesrc seeks to offset 97 984) Entry types 99-------------- 100 101 - mapping between formats: 102 103 <padid> <flags> <format> <position>, <format> <position>, ... 104 105 - metadata, streaminfo, other objects: 106 107 <padid> <format> <position>, <keyword> gpointer 108 109 1105) implementation 111----------------- 112 113We define an abstract base class GstTimeCache with following 114abstract methods: 115 116 1176) cache format example 118----------------------- 119 120We define a binary format for the cache for space/speed reasons. 121It is entirely possible to create alternative implementations. 122 123 124 125 126 127 128 129 130 131 132 133 134