libkate is an implementation of a codec for the Kate bitstream format.
The Kate bitstream format is a timed text codec designed for embedding in an Ogg bitstream. It was originally designed for karaoke and text. The Kate bitstream format is documented here.
The HOWTO page lists various uses of Kate streams and how to use them that way.
libkate is thread safe, with the usual caveat that a single thread accesses a given kate stream at the same time (eg, two different threads may use libkate at the same time, provided they access two different streams).
See here for a list of software with Kate support.
A commented high level decoding example.
A commented decoding example.
A commented encoding example.