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 *****************************************************************************/
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 /*****************************************************************************
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
;
91 vcddev_sector_t
*p_sectors
;
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
);
113 /*****************************************************************************
114 * structure to store minute/second/frame locations
115 *****************************************************************************/
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
131 uint8_t i_sys_prof_tag
; /* 0x01 if VCD1.1
133 uint16_t i_entries_nb
; /* entries number <= 500 */
137 uint8_t i_track
; /* track number */
138 msf_t msf
; /* msf location
141 uint8_t zeros
[36]; /* should be 0x00 */
144 /*****************************************************************************
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 );
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 */