]> git.sesse.net Git - vlc/blob - modules/access/cdda/cdda.h
e5bd48d973482c94aa9a451703a5375b04336eb5
[vlc] / modules / access / cdda / cdda.h
1 /*****************************************************************************
2  * cdda.h : CD-DA input module header for vlc using libcdio.
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Author: Rocky Bernstein <rocky@panix.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
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 General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include <vlc_input.h>
25 #include <vlc_access.h>
26 #include <cdio/cdio.h>
27 #include <cdio/cdtext.h>
28 #if LIBCDIO_VERSION_NUM >= 73
29 #include <cdio/audio.h>
30 #include <cdio/mmc.h>
31 #endif
32
33 #include <vlc_meta.h>
34 #include <vlc_codecs.h>
35
36 #ifdef HAVE_LIBCDDB
37 #include <cddb/cddb.h>
38 #endif
39
40
41 #define CDDA_MRL_PREFIX "cddax://"
42
43 /* Frequency of sample in bits per second. */
44 #define CDDA_FREQUENCY_SAMPLE 44100
45
46 /*****************************************************************************
47  * Debugging
48  *****************************************************************************/
49 #define INPUT_DBG_META        1 /* Meta information */
50 #define INPUT_DBG_EVENT       2 /* Trace keyboard events */
51 #define INPUT_DBG_MRL         4 /* MRL debugging */
52 #define INPUT_DBG_EXT         8 /* Calls from external routines */
53 #define INPUT_DBG_CALL       16 /* all calls */
54 #define INPUT_DBG_LSN        32 /* LSN changes */
55 #define INPUT_DBG_SEEK       64 /* Seeks to set location */
56 #define INPUT_DBG_CDIO      128 /* Debugging from CDIO */
57 #define INPUT_DBG_CDDB      256 /* CDDB debugging  */
58
59 #define INPUT_DEBUG 1
60 #if INPUT_DEBUG
61 #define dbg_print(mask, s, args...) \
62    if (p_cdda->i_debug & mask) \
63      msg_Dbg(p_access, "%s: "s, __func__ , ##args)
64 #else
65 #define dbg_print(mask, s, args...)
66 #endif
67
68 #if LIBCDIO_VERSION_NUM >= 72
69 #include <cdio/cdda.h>
70 #include <cdio/paranoia.h>
71 #else
72 #define CdIo_t CdIo
73 #endif    
74
75 #if LIBCDIO_VERSION_NUM < 78
76 typedef enum {
77   PARANOIA_MODE_DISABLE = 0x00, /* Note: We make use of 0 as being the same as false */
78   PARANOIA_MODE_OVERLAP = 0x04, 
79   PARANOIA_MODE_FULL    = 0xff
80 } paranoia_mode_t;
81 #endif
82   
83 /*****************************************************************************
84  * cdda_data_t: CD audio information
85  *****************************************************************************/
86 typedef struct cdda_data_s
87 {
88   CdIo_t         *p_cdio;             /* libcdio CD device */
89   track_t        i_tracks;            /* # of tracks */
90   track_t        i_first_track;       /* # of first track */
91   track_t        i_titles;            /* # of titles in playlist */
92   
93   /* Current position */
94   track_t        i_track;             /* Current track */
95   lsn_t          i_lsn;               /* Current Logical Sector Number */
96   
97   lsn_t          first_frame;         /* LSN of first frame of this track   */
98   lsn_t          last_frame;          /* LSN of last frame of this track    */
99   lsn_t          last_disc_frame;     /* LSN of last frame on CD            */
100   int            i_blocks_per_read;   /* # blocks to get in a read */
101   int            i_debug;             /* Debugging mask */
102
103   /* Information about CD */
104   vlc_meta_t    *p_meta;
105   char *         psz_mcn;             /* Media Catalog Number */
106   char *         psz_source;          /* CD drive or CD image filename */
107   input_title_t *p_title[CDIO_CD_MAX_TRACKS]; /* This *is* 0 origin, not
108                                                  track number origin */
109
110 #if LIBCDIO_VERSION_NUM >= 72
111   /* Paranoia support */
112   paranoia_mode_t e_paranoia;         /* Use cd paranoia for reads? */
113   cdrom_drive_t *paranoia_cd;         /* Place to store drive
114                                          handle given by paranoia. */
115   cdrom_paranoia_t *paranoia;
116
117 #endif    
118   
119 #ifdef HAVE_LIBCDDB
120   vlc_bool_t     b_cddb_enabled;      /* Use CDDB at all? */
121   struct  {
122     vlc_bool_t   have_info;           /* True if we have any info */
123     cddb_disc_t *disc;                /* libcdio uses this to get disc
124                                          info */
125     int          disc_length;         /* Length in frames of cd. Used
126                                          in CDDB lookups */
127   } cddb;
128 #endif
129
130   vlc_bool_t   b_audio_ctl;           /* Use CD-Text audio controls and
131                                          audio output? */
132
133   vlc_bool_t   b_cdtext;              /* Use CD-Text at all? If not,
134                                          cdtext_preferred is meaningless. */
135   vlc_bool_t   b_cdtext_prefer;       /* Prefer CD-Text info over
136                                          CDDB? If no CDDB, the issue
137                                          is moot. */
138
139   const cdtext_t *p_cdtext[CDIO_CD_MAX_TRACKS]; /* CD-Text info. Origin is NOT 
140                                                    0 origin but origin of track
141                                                    number (usually 1).
142                                                  */
143
144   WAVEHEADER   waveheader;            /* Wave header for the output data  */
145   vlc_bool_t   b_header;
146   vlc_bool_t   b_nav_mode;           /* If false we view the entire CD as
147                                         as a unit rather than each track
148                                         as a unit. If b_nav_mode then the
149                                         slider area represents the Disc rather
150                                         than a track
151                                       */
152   
153   input_thread_t *p_input;
154   
155 } cdda_data_t;
156
157 /* FIXME: This variable is a hack. Would be nice to eliminate. */
158 extern access_t *p_cdda_input;