2
reads toc from cdrom (system dependend)
3
Copyright (C) 1999 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
19
CDRomToc::CDRomToc() {
24
CDRomToc::~CDRomToc() {
28
void CDRomToc::insertTocEntry(int minute,int second,int frame) {
31
if (isElement(minute,second,frame)) {
35
i=getNextTocEntryPos(minute,second,frame);
37
// now shift from i to end
38
if (maxEntries == 100) {
39
cerr << "maximum of toc entries reached"<<endl;
42
for (j=maxEntries;j>i;j--) {
43
tocEntries[j].minute=tocEntries[j-1].minute;
44
tocEntries[j].second=tocEntries[j-1].second;
45
tocEntries[j].frame=tocEntries[j-1].frame;
49
tocEntries[i].minute=minute;
50
tocEntries[i].second=second;
51
tocEntries[i].frame=frame;
56
int CDRomToc::getNextTocEntryPos(int minute,int second,int frame) {
58
if (maxEntries == 0) {
62
for (i=0;i<maxEntries;i++) {
63
if (tocEntries[i].minute <= minute) {
68
if (tocEntries[i].second <= second) {
73
if (tocEntries[i].frame <= frame) {
83
int CDRomToc::isElement(int minute,int second,int frame) {
86
for (i=0;i<maxEntries;i++) {
87
if (tocEntries[i].minute == minute) {
88
if (tocEntries[i].second == second) {
89
if (tocEntries[i].frame == frame) {
103
int CDRomToc::getTocEntries() {
108
TocEntry* CDRomToc::getTocEntry(int entry) {
109
return &(tocEntries[entry]);
113
void CDRomToc::print() {
115
cerr << "******* printing TOC [START]"<<endl;
116
for(i=0;i<maxEntries;i++) {
118
<<" M:"<<tocEntries[i].minute
119
<<" S:"<<tocEntries[i].second
120
<<" F:"<<tocEntries[i].frame<<endl;
122
cerr << "******* printing TOC [END}"<<endl;
126
int CDRomToc::isInRange(int minute,int second,int) {
127
long val=minute*60+second;
128
if (val < startByte) {
137
int CDRomToc::calculateRange() {
140
if (maxEntries < 2) {
141
cout << "no two elemts in toc"<<endl;
144
startByte=tocEntries[0].minute*60*+tocEntries[0].second;
146
// do a safty end because of the kernel bug
147
int minute=tocEntries[maxEntries-1].minute;
148
int second=tocEntries[maxEntries-1].second-20;
158
endByte=minute*60+second;
165
int CDRomToc::getEndSecond() {
172
int CDRomToc::open(const char* openfile) {
176
const char* filename=strchr(openfile,'/');
177
FILE* file =fopen(filename, "rb");
182
cout << "reading toc on:"<<filename<<" openfile:"<<openfile<<endl;
187
if (getStartEnd(file,startToc,endToc) == false) {
188
cout << "getStartEnd in CDRomToc failed"<<endl;
192
cout << "startToc:"<<startToc<<" endToc:"<<endToc<<endl;
193
cout << "reading toc -2"<<endl;
194
/* read individual tracks */
199
for (i=startToc; i<=endToc; i++) {
204
if (readToc(file,i,min,sec,frame) == false) {
205
cout << "error in CDRomToc::readToc"<<endl;
209
cout << "min:"<<min<<endl;
210
cout << "sec:"<<sec<<endl;
211
cout << "frame:"<<frame<<endl;
213
insertTocEntry(min,sec,frame);
218
/* read the lead-out track */
219
if (readLeadOut(file,min,sec,frame) == false) {
220
cout << "error in CDRomToc::reatLeadOut"<<endl;
224
insertTocEntry(min,sec,frame);