ScummVM API documentation
cue.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_FORMATS_CUE_H
23 #define COMMON_FORMATS_CUE_H
24 
25 #include "common/array.h"
26 
27 namespace Common {
28 
29 class SeekableReadStream;
30 
34 class CueSheet {
35 public:
36  CueSheet(const char *sheet);
38 
39 public:
40  enum FileType {
41  kFileTypeBinary,
42  kFileTypeAIFF,
43  kFileTypeWave,
44  kFileTypeMP3,
45  kFileTypeMotorola,
46  };
47 
48  enum TrackType {
49  kTrackTypeAudio, // Audio (sector size: 2352)
50  kTrackTypeCDG, // Karaoke CD+G (sector size: 2448)
51  kTrackTypeMode1_Raw, // CD-ROM Mode 1 data (raw) (sector size: 2352), used by cdrdao
52  kTrackTypeMode1_2048, // CD-ROM Mode 1 data (cooked) (sector size: 2048)
53  kTrackTypeMode1_2352, // CD-ROM Mode 1 data (raw) (sector size: 2352)
54  kTrackTypeMode2_Raw, // CD-ROM Mode 2 data (raw) (sector size: 2352), used by cdrdao
55  kTrackTypeMode2_2048, // CD-ROM Mode 2 XA form-1 data (sector size: 2048)
56  kTrackTypeMode2_2324, // CD-ROM Mode 2 XA form-2 data (sector size: 2324)
57  kTrackTypeMode2_2366, // CD-ROM Mode 2 data (sector size: 2336)
58  kTrackTypeMode2_2352, // CD-ROM Mode 2 data (raw) (sector size: 2352)
59  kTrackTypeCDI_2336, // CDI Mode 2 data
60  kTrackTypeCDI_2352, // CDI Mode 2 data
61  };
62 
63  enum TrackFlags {
64  kTrackFlag4ch = 1 << 0, // Four channel audio
65  kTrackFlagDCP = 1 << 1, // Digital copy permitted
66  kTrackFlagPre = 1 << 2, // Pre-emphasis enabled, for audio tracks only
67  kTrackFlagSCMS = 1 << 3, // Serial copy management system
68  };
69 
70  struct CueFile {
71  String name;
72  FileType type = kFileTypeBinary;
73  };
74 
75  struct CueTrack {
76  int number = 0;
77  CueFile file;
78  TrackType type;
79  String title;
80  String performer;
81  Array<int> indices;
82  int pregap = 0;
83  uint32 flags;
84  int size = 2352;
85  };
86 
87  struct CueMetadata {
88  String title;
89  String date;
90  String genre;
91  String performer;
92  String catalog;
93  };
94 
95  struct LookupTable;
96 
97  Array<CueFile> files();
98  Array<CueTrack> tracks();
99  CueTrack *getTrack(int tracknum);
100  CueTrack *getTrackAtFrame(int frame);
101 
102 private:
103  void parse(const char *sheet);
104 
105  int lookupInTable(const LookupTable *table, const char *key);
106  int parseMSF(const char *str);
107 
108  void parseHeaderContext(const char *line);
109  void parseFilesContext(const char *line);
110  void parseTracksContext(const char *line);
111 
112 private:
113  int _lineNum = 0;
114  int _context;
115  int _currentFile = -1;
116  int _currentTrack = -1;
117 
118  Array<CueFile> _files;
119  Array<CueTrack> _tracks;
120  CueMetadata _metadata;
121 
122 };
123 
124 } // End of namespace Common
125 
126 #endif
Definition: cue.h:75
Definition: str.h:59
Definition: cue.h:34
Definition: stream.h:745
Definition: cue.h:70
Definition: algorithm.h:29
Definition: cue.h:87