Commit faf149d0 authored by Max Kellermann's avatar Max Kellermann

lib/xiph/OggVisitor: add method ReadGranulepos()

parent e01bbad7
...@@ -108,3 +108,14 @@ OggVisitor::PostSeek(uint64_t offset) ...@@ -108,3 +108,14 @@ OggVisitor::PostSeek(uint64_t offset)
post_seek = true; post_seek = true;
} }
ogg_int64_t
OggVisitor::ReadGranulepos() noexcept
{
ogg_packet packet;
while (stream.PacketOut(packet) == 1)
if (packet.granulepos >= 0)
return packet.granulepos;
return -1;
}
...@@ -66,6 +66,22 @@ public: ...@@ -66,6 +66,22 @@ public:
*/ */
void PostSeek(uint64_t offset); void PostSeek(uint64_t offset);
/**
* Skip packets (#ogg_packet) from the #OggStreamState until a
* packet with a valid granulepos is found or until the stream
* has run dry.
*
* Since this will discard pending packets and will disturb
* this object, this should only be used while seeking.
*
* This method must not be called from within one of the
* virtual methods.
*
* @return the granulepos or -1 if no valid granulepos was
* found
*/
ogg_int64_t ReadGranulepos() noexcept;
private: private:
void EndStream(); void EndStream();
bool ReadNextPage(); bool ReadNextPage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment