cdrom.h 4.69 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
 *
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
43

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
48
/* size of a VCD sector, header and tail included */
49
#define VCD_SECTOR_SIZE     CD_RAW_SECTOR_SIZE
50
/* sector containing the entry points */
51
#define VCD_ENTRIES_SECTOR  151
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
57
/* size of a CDDA sector, header and tail included */
58
#define CDDA_SECTOR_SIZE    CD_RAW_SECTOR_SIZE
59 60 61 62

/*****************************************************************************
 * Misc. Macros
 *****************************************************************************/
63 64 65 66 67 68 69 70 71
static inline int MSF_TO_LBA(uint8_t min, uint8_t sec, uint8_t frame)
{
    return (int)(frame + 75 * (sec + 60 * min));
}
static inline int MSF_TO_LBA2(uint8_t min, uint8_t sec, uint8_t frame)
{
    return (int)(frame + 75 * (sec -2 + 60 * min));
}

72 73 74
/* 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)))
75

76
typedef struct vcddev_s vcddev_t;
77 78

/*****************************************************************************
79
 * structure to store minute/second/frame locations
80
 *****************************************************************************/
81
typedef struct msf_s
82
{
83 84 85 86
    uint8_t minute;
    uint8_t second;
    uint8_t frame;
} msf_t;
87

88 89 90 91
/*****************************************************************************
 * entries_sect structure: the sector containing entry points
 *****************************************************************************/
typedef struct entries_sect_s
92
{
93
    char psz_id[8];                                 /* "ENTRYVCD" */
94 95 96 97 98 99 100 101 102 103 104 105 106 107
    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;
108 109

/*****************************************************************************
110
 * Prototypes
111
 *****************************************************************************/
112 113 114
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 ** );
115
int       ioctl_ReadSectors  ( vlc_object_t *, const vcddev_t *,
116
                               int, uint8_t *, int, int );
117 118 119 120 121

/* 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 );
122 123

#endif /* VLC_CDROM_H */