2
info about vorbis files.
3
Copyright (C) 2001 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
14
#include "vorbisInfo.h"
17
#define CHUNKSIZE 4096
19
#define GETINPUT(stream,input) \
20
VorbisInfo* info=(VorbisInfo*) stream; \
21
FileAccess* input=info->getInput();
24
size_t fread_func2(void *ptr, size_t size, size_t nmemb, void *stream) {
25
GETINPUT(stream,input);
27
size_t want=size*nmemb;
28
size_t back=input->read((char*)ptr,want);
33
int fseek_func2(void *stream, ogg_int64_t offset, int whence) {
35
GETINPUT(stream,input);
37
if (whence==SEEK_SET) {
38
ret=input->seek(offset);
39
info->setSeekPos(offset);
42
if (whence==SEEK_CUR) {
43
ret=input->seek(input->getBytePosition()+offset);
46
if (whence==SEEK_END) {
47
ret=input->seek(input->getByteLength());
50
cout << "hm, strange call"<<endl;
55
int fclose_func2 (void * stream) {
56
cout << "fclose_func"<<endl;
57
GETINPUT(stream,input);
58
// its handled different in kmpg
59
// we close the stream if the decoder signals eof.
65
long ftell_func2 (void *stream) {
66
GETINPUT(stream,input);
67
return input->getBytePosition();
73
VorbisInfo::VorbisInfo(FileAccess* input) {
75
vf=new OggVorbis_File();
77
ov_callbacks callbacks;
79
callbacks.read_func = fread_func2;
80
callbacks.seek_func = fseek_func2;
81
callbacks.close_func = fclose_func2;
82
callbacks.tell_func = ftell_func2;
84
if(ov_open_callbacks(this, vf, NULL, 0, callbacks) < 0) {
85
cout << "error ov_open_callbacks"<<endl;
94
VorbisInfo::~VorbisInfo() {
102
long VorbisInfo::getSeekPosition(int seconds) {
106
ov_time_seek(vf,seconds);
113
long VorbisInfo::getLength() {
116
back = (int) ov_time_total(vf, -1);
124
void VorbisInfo::print(const char* msg) {
125
cout << "VorbisInfo:"<<msg<<endl;
126
cout << "Length (sec):"<<getLength()<<endl;
131
void VorbisInfo::setSeekPos(long pos) {
132
this->lastSeekPos=pos;
136
long VorbisInfo::getSeekPos() {
140
FileAccess* VorbisInfo::getInput() {