From 79b7954ccfaf4bee370ca2996c90d6506139ab92 Mon Sep 17 00:00:00 2001 From: shatty Date: Sun, 25 Jan 2004 14:38:18 +0000 Subject: [PATCH] somewhat more fun duration stuff.. for testing purposes only git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6286 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../media/plugins/ogg/OggVorbisStream.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/add-ons/media/plugins/ogg/OggVorbisStream.cpp b/src/add-ons/media/plugins/ogg/OggVorbisStream.cpp index e1db9e50af..82fcce2654 100644 --- a/src/add-ons/media/plugins/ogg/OggVorbisStream.cpp +++ b/src/add-ons/media/plugins/ogg/OggVorbisStream.cpp @@ -181,7 +181,30 @@ OggVorbisStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration, } format->SetMetaData((void*)&fHeaderPackets,sizeof(fHeaderPackets)); + + // compute duration/frameCount + +#ifdef STREAMING_COMPATIBLE_HARDCODED_DURATION *duration = 100000000; *frameCount = 60000; +#else + int64 frame = 0; + bigtime_t time = 0; + void *chunkBuffer = 0; + int32 chunkSize = 0; + media_header mediaHeader; + off_t bytes = 0; + while (GetNextChunk(&chunkBuffer, &chunkSize, &mediaHeader) == B_OK) { + ogg_packet * packet = static_cast(chunkBuffer); + bytes += packet->bytes; + frame++; + } + time += (8000000 * bytes) / format->u.encoded_audio.bit_rate; + *frameCount = frame; + *duration = time; + int64 start_frame = 0; + bigtime_t start_time = 0; + Seek(B_MEDIA_SEEK_TO_FRAME, &start_frame, &start_time); +#endif return B_OK; }