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