From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeglib/lib/oggvorbis/vorbisInfo.cpp | 150 +++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 mpeglib/lib/oggvorbis/vorbisInfo.cpp (limited to 'mpeglib/lib/oggvorbis/vorbisInfo.cpp') diff --git a/mpeglib/lib/oggvorbis/vorbisInfo.cpp b/mpeglib/lib/oggvorbis/vorbisInfo.cpp new file mode 100644 index 00000000..b71f99c3 --- /dev/null +++ b/mpeglib/lib/oggvorbis/vorbisInfo.cpp @@ -0,0 +1,150 @@ +/* + info about vorbis files. + Copyright (C) 2001 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + +#include "vorbisInfo.h" + +#include + +using namespace std; + +#ifdef OGG_VORBIS +#define CHUNKSIZE 4096 + +#define GETINPUT(stream,input) \ + VorbisInfo* info=(VorbisInfo*) stream; \ + FileAccess* input=info->getInput(); + + +size_t fread_func2(void *ptr, size_t size, size_t nmemb, void *stream) { + GETINPUT(stream,input); + + size_t want=size*nmemb; + size_t back=input->read((char*)ptr,want); + return back; +} + + +int fseek_func2(void *stream, ogg_int64_t offset, int whence) { + int ret; + GETINPUT(stream,input); + + if (whence==SEEK_SET) { + ret=input->seek(offset); + info->setSeekPos(offset); + return ret; + } + if (whence==SEEK_CUR) { + ret=input->seek(input->getBytePosition()+offset); + return ret; + } + if (whence==SEEK_END) { + ret=input->seek(input->getByteLength()); + return ret; + } + cout << "hm, strange call"<getBytePosition(); +} + + + + +VorbisInfo::VorbisInfo(FileAccess* input) { + this->input=input; + vf=new OggVorbis_File(); + + ov_callbacks callbacks; + + callbacks.read_func = fread_func2; + callbacks.seek_func = fseek_func2; + callbacks.close_func = fclose_func2; + callbacks.tell_func = ftell_func2; + + if(ov_open_callbacks(this, vf, NULL, 0, callbacks) < 0) { + cout << "error ov_open_callbacks"<lastSeekPos=pos; +} + + +long VorbisInfo::getSeekPos() { + return lastSeekPos; +} + +FileAccess* VorbisInfo::getInput() { + return input; +} + + + +#endif -- cgit v1.2.3