cdrom.h 4.72 KB
Newer Older
1
2
/****************************************************************************
 * cdrom.h: cdrom tools header
Renaud Dartus's avatar
Renaud Dartus committed
3
 *****************************************************************************
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
4
 * Copyright (C) 1998-2001 VLC authors and VideoLAN
5
 * $Id$
Renaud Dartus's avatar
Renaud Dartus committed
6
 *
gbazin's avatar
   
gbazin committed
7
8
 * Authors: Johan Bilien <jobi@via.ecp.fr>
 *          Gildas Bazin <gbazin@netcourrier.com>
Renaud Dartus's avatar
Renaud Dartus committed
9
 *
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
10
11
12
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
Renaud Dartus's avatar
Renaud Dartus committed
13
 * (at your option) any later version.
14
 *
Renaud Dartus's avatar
Renaud Dartus committed
15
16
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
17
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
Renaud Dartus's avatar
Renaud Dartus committed
19
 *
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
20
21
22
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
Renaud Dartus's avatar
Renaud Dartus committed
23
24
 *****************************************************************************/

25
26
27
#ifndef VLC_CDROM_H
#define VLC_CDROM_H

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
enum {
    CDDA_TYPE = 0,
    VCD_TYPE  = 1,
};

/* size of a CD sector */
#define CD_RAW_SECTOR_SIZE  2352
#define CD_ROM_MODE1_DATA_SIZE 2048
#define CD_ROM_MODE2_DATA_SIZE 2336

#define CD_ROM_XA_MODE2_F1_DATA_SIZE 2048
#define CD_ROM_XA_MODE2_F2_DATA_SIZE 2324

/* size of a CD sector */
#define CD_SECTOR_SIZE      CD_ROM_MODE1_DATA_SIZE
gbazin's avatar
   
gbazin committed
43

gbazin's avatar
   
gbazin committed
44
/* where the data start on a VCD sector */
45
46
47
#define VCD_DATA_START      24
/* size of the available data on a VCD sector */
#define VCD_DATA_SIZE       CD_ROM_XA_MODE2_F2_DATA_SIZE
gbazin's avatar
   
gbazin committed
48
/* size of a VCD sector, header and tail included */
49
#define VCD_SECTOR_SIZE     CD_RAW_SECTOR_SIZE
gbazin's avatar
   
gbazin committed
50
/* sector containing the entry points */
51
#define VCD_ENTRIES_SECTOR  151
gbazin's avatar
   
gbazin committed
52
53

/* where the data start on a CDDA sector */
54
55
56
#define CDDA_DATA_START     0
/* size of the available data on a CDDA sector */
#define CDDA_DATA_SIZE      CD_RAW_SECTOR_SIZE
gbazin's avatar
   
gbazin committed
57
/* size of a CDDA sector, header and tail included */
58
#define CDDA_SECTOR_SIZE    CD_RAW_SECTOR_SIZE
gbazin's avatar
   
gbazin committed
59
60
61
62
63
64
65
66

/*****************************************************************************
 * Misc. Macros
 *****************************************************************************/
/* LBA = msf.frame + 75 * ( msf.second + 60 * msf.minute ) */
#define MSF_TO_LBA(min, sec, frame) ((int)frame + 75 * (sec + 60 * min))
/* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */
#define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min))
gbazin's avatar
   
gbazin committed
67
68
69
/* Converts BCD to Binary data */
#define BCD_TO_BIN(i) \
    (uint8_t)((uint8_t)(0xf & (uint8_t)i)+((uint8_t)10*((uint8_t)i >> 4)))
gbazin's avatar
   
gbazin committed
70

gbazin's avatar
   
gbazin committed
71
typedef struct vcddev_s vcddev_t;
gbazin's avatar
   
gbazin committed
72
73

/*****************************************************************************
gbazin's avatar
   
gbazin committed
74
 * structure to store minute/second/frame locations
gbazin's avatar
   
gbazin committed
75
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
76
typedef struct msf_s
gbazin's avatar
   
gbazin committed
77
{
gbazin's avatar
   
gbazin committed
78
79
80
81
    uint8_t minute;
    uint8_t second;
    uint8_t frame;
} msf_t;
gbazin's avatar
   
gbazin committed
82

gbazin's avatar
   
gbazin committed
83
84
85
86
/*****************************************************************************
 * entries_sect structure: the sector containing entry points
 *****************************************************************************/
typedef struct entries_sect_s
gbazin's avatar
   
gbazin committed
87
{
88
    char psz_id[8];                                 /* "ENTRYVCD" */
gbazin's avatar
   
gbazin committed
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    uint8_t i_version;                              /* 0x02 VCD2.0
                                                       0x01 SVCD  */
    uint8_t i_sys_prof_tag;                         /* 0x01 if VCD1.1
                                                       0x00 else */
    uint16_t i_entries_nb;                          /* entries number <= 500 */

    struct
    {
        uint8_t i_track;                            /* track number */
        msf_t   msf;                                /* msf location
                                                       (in BCD format) */
    } entry[500];
    uint8_t zeros[36];                              /* should be 0x00 */
} entries_sect_t;
gbazin's avatar
   
gbazin committed
103
104

/*****************************************************************************
gbazin's avatar
   
gbazin committed
105
 * Prototypes
gbazin's avatar
   
gbazin committed
106
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
107
108
109
vcddev_t *ioctl_Open         ( vlc_object_t *, const char * );
void      ioctl_Close        ( vlc_object_t *, vcddev_t * );
int       ioctl_GetTracksMap ( vlc_object_t *, const vcddev_t *, int ** );
gbazin's avatar
   
gbazin committed
110
int       ioctl_ReadSectors  ( vlc_object_t *, const vcddev_t *,
111
                               int, uint8_t *, int, int );
112
113
114
115
116

/* CDDA only
 * The track 0 is for album meta data */
int       ioctl_GetCdText( vlc_object_t *, const vcddev_t *,
                           vlc_meta_t ***ppp_tracks, int *pi_tracks );
117
118

#endif /* VLC_CDROM_H */