qt: playlist: use item title if available
[vlc.git] / modules / access / vcd / cdrom.h
blobf0379fa4395d58cba6527500498fa159e4f85886
1 /****************************************************************************
2 * cdrom.h: cdrom tools header
3 *****************************************************************************
4 * Copyright (C) 1998-2001 VLC authors and VideoLAN
6 * Authors: Johan Bilien <jobi@via.ecp.fr>
7 * Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef VLC_CDROM_H
25 #define VLC_CDROM_H
27 enum {
28 CDDA_TYPE = 0,
29 VCD_TYPE = 1,
32 /* size of a CD sector */
33 #define CD_RAW_SECTOR_SIZE 2352
34 #define CD_ROM_MODE1_DATA_SIZE 2048
35 #define CD_ROM_MODE2_DATA_SIZE 2336
37 #define CD_ROM_XA_MODE2_F1_DATA_SIZE 2048
38 #define CD_ROM_XA_MODE2_F2_DATA_SIZE 2324
40 #define CD_ROM_XA_FRAMES 75
41 #define CD_ROM_XA_INTERVAL ((60 + 90 + 2) * CD_ROM_XA_FRAMES)
43 /* Subcode control flag */
44 #define CD_ROM_DATA_FLAG 0x04
46 /* size of a CD sector */
47 #define CD_SECTOR_SIZE CD_ROM_MODE1_DATA_SIZE
49 /* where the data start on a VCD sector */
50 #define VCD_DATA_START 24
51 /* size of the available data on a VCD sector */
52 #define VCD_DATA_SIZE CD_ROM_XA_MODE2_F2_DATA_SIZE
53 /* size of a VCD sector, header and tail included */
54 #define VCD_SECTOR_SIZE CD_RAW_SECTOR_SIZE
55 /* sector containing the entry points */
56 #define VCD_ENTRIES_SECTOR 151
58 /* where the data start on a CDDA sector */
59 #define CDDA_DATA_START 0
60 /* size of the available data on a CDDA sector */
61 #define CDDA_DATA_SIZE CD_RAW_SECTOR_SIZE
62 /* size of a CDDA sector, header and tail included */
63 #define CDDA_SECTOR_SIZE CD_RAW_SECTOR_SIZE
65 /*****************************************************************************
66 * Misc. Macros
67 *****************************************************************************/
68 static inline int MSF_TO_LBA(uint8_t min, uint8_t sec, uint8_t frame)
70 return (int)(frame + 75 * (sec + 60 * min));
72 static inline int MSF_TO_LBA2(uint8_t min, uint8_t sec, uint8_t frame)
74 return (int)(frame + 75 * (sec -2 + 60 * min));
77 /* Converts BCD to Binary data */
78 #define BCD_TO_BIN(i) \
79 (uint8_t)((uint8_t)(0xf & (uint8_t)i)+((uint8_t)10*((uint8_t)i >> 4)))
81 typedef struct vcddev_s vcddev_t;
82 typedef struct
84 int i_lba;
85 int i_control;
86 } vcddev_sector_t;
88 typedef struct
90 int i_tracks;
91 vcddev_sector_t *p_sectors;
92 int i_first_track;
93 int i_last_track;
94 } vcddev_toc_t;
96 static inline vcddev_toc_t * vcddev_toc_New( void )
98 return calloc(1, sizeof(vcddev_toc_t));
101 static inline void vcddev_toc_Reset( vcddev_toc_t *toc )
103 free(toc->p_sectors);
104 memset(toc, 0, sizeof(*toc));
107 static inline void vcddev_toc_Free( vcddev_toc_t *toc )
109 free(toc->p_sectors);
110 free(toc);
113 /*****************************************************************************
114 * structure to store minute/second/frame locations
115 *****************************************************************************/
116 typedef struct msf_s
118 uint8_t minute;
119 uint8_t second;
120 uint8_t frame;
121 } msf_t;
123 /*****************************************************************************
124 * entries_sect structure: the sector containing entry points
125 *****************************************************************************/
126 typedef struct entries_sect_s
128 char psz_id[8]; /* "ENTRYVCD" */
129 uint8_t i_version; /* 0x02 VCD2.0
130 0x01 SVCD */
131 uint8_t i_sys_prof_tag; /* 0x01 if VCD1.1
132 0x00 else */
133 uint16_t i_entries_nb; /* entries number <= 500 */
135 struct
137 uint8_t i_track; /* track number */
138 msf_t msf; /* msf location
139 (in BCD format) */
140 } entry[500];
141 uint8_t zeros[36]; /* should be 0x00 */
142 } entries_sect_t;
144 /*****************************************************************************
145 * Prototypes
146 *****************************************************************************/
147 vcddev_t *ioctl_Open ( vlc_object_t *, const char * );
148 void ioctl_Close ( vlc_object_t *, vcddev_t * );
149 vcddev_toc_t * ioctl_GetTOC ( vlc_object_t *, const vcddev_t *, bool );
150 int ioctl_ReadSectors ( vlc_object_t *, const vcddev_t *,
151 int, uint8_t *, int, int );
153 /* CDDA only
154 * The track 0 is for album meta data */
155 int ioctl_GetCdText( vlc_object_t *, const vcddev_t *,
156 vlc_meta_t ***ppp_tracks, int *pi_tracks );
158 #endif /* VLC_CDROM_H */