1
/* cdrdao - write audio CD-Rs in disc-at-once mode
3
* Copyright (C) 1998-2001 Andreas Mueller <andreas@daneb.de>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
#include "CdTextContainer.h"
26
#include "CdTextItem.h"
34
enum TocType { CD_DA, CD_ROM, CD_I, CD_ROM_XA };
36
// sets/returns toc type
37
void tocType(TocType);
38
TocType tocType() const;
40
int nofTracks() const { return nofTracks_; }
42
Msf length() const { return length_; }
44
// returns mode that should be used for lead-in and gap
45
TrackData::Mode leadInMode() const;
46
// returns mode that should be used for lead-out
47
TrackData::Mode leadOutMode() const;
49
int append(const Track *);
50
void insert(int, const Track *);
53
Track *getTrack(int trackNr);
55
int moveTrackMarker(int trackNr, int indexNr, long lba);
56
int removeTrackMarker(int trackNr, int indexNr);
57
int addIndexMarker(long lba);
58
int addTrackMarker(long lba);
59
int addPregap(long lba);
61
void appendTrack(const TrackDataList *, long *start, long *end);
62
int appendTrackData(const TrackDataList *, long *start, long *end);
64
int removeTrackData(unsigned long start, unsigned long end,
66
int insertTrackData(unsigned long pos, const TrackDataList *list);
70
static Toc *read(const char *);
71
int write(const char *) const;
72
bool write(int fd) const;
74
int catalogValid() const { return catalogValid_; }
76
int catalog(const char *); // sets catalog number
77
char catalog(int i) const { return catalog_[i]; } // BCD
78
const char *catalog() const;
80
void addCdTextItem(int trackNr, CdTextItem *);
81
void removeCdTextItem(int trackNr, CdTextItem::PackType, int blockNr);
82
int existCdTextBlock(int blockNr) const;
83
const CdTextItem *getCdTextItem(int trackNr, int blockNr,
84
CdTextItem::PackType) const;
85
void cdTextLanguage(int blockNr, int lang);
86
int cdTextLanguage(int blockNr) const;
87
int checkCdTextData() const;
89
void trackSummary(int *nofAudioTracks, int *nofMode1Tracks,
90
int *nofMode2Tracks) const;
92
void print(std::ostream &) const;
94
static const char *tocType2String(TocType);
98
friend class TocParserGram;
99
friend class TocReader;
100
friend class TrackIterator;
103
TrackEntry() : absStart(0), start(0), end(0) {
104
trackNr = 0; track = 0; next = 0; pred = 0;
109
Msf absStart; // absoulte track start (end of last track)
110
Msf start; // logical track start (after pre-gap)
113
struct TrackEntry *next;
114
struct TrackEntry *pred;
119
TrackEntry *findTrack(unsigned long sample) const;
121
TrackEntry *findTrackByNumber(int trackNr) const;
123
void remove(TrackEntry *);
125
void checkConsistency();
128
TocType tocType_; // type of TOC
132
TrackEntry *lastTrack_;
134
Msf length_; // total length of disc
139
CdTextContainer cdtext_;
145
TocReader(const Toc * = 0);
148
void init(const Toc *);
151
//long readData(long lba, char *buf, long len);
152
int seekSample(unsigned long sample);
153
long readSamples(Sample *buf, long len);
161
const Toc::TrackEntry *readTrack_; // actual read track
162
long readPos_; // actual read position (blocks)
163
long readPosSample_; // actual read position (samples)
164
int open_; // != 0 indicates that toc was opened for reading data
168
class TrackIterator {
170
TrackIterator(const Toc *);
173
const Track *find(int trackNr, Msf &start, Msf &end);
174
const Track *find(unsigned long sample, Msf &start, Msf &end,
176
const Track *first(Msf &start, Msf &end);
177
const Track *first();
178
const Track *next(Msf &start, Msf &end);
183
Toc::TrackEntry *iterator_;
189
void Toc::tocType(TocType t)
195
Toc::TocType Toc::tocType() const