1 /***************************************************************** 2 * gmerlin - a general purpose multimedia framework and applications 3 * 4 * Copyright (c) 2001 - 2011 Members of the Gmerlin project 5 * gmerlin-general@lists.sourceforge.net 6 * http://gmerlin.sourceforge.net 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 * *****************************************************************/ 21 22 #include <config.h> 23 #include <gmerlin/plugin.h> 24 25 #include <cdio/cdio.h> 26 27 #define DISCID_SIZE 33 28 29 /* Index structure */ 30 31 typedef struct 32 { 33 int num_tracks; 34 int num_audio_tracks; 35 36 struct 37 { 38 uint32_t first_sector; 39 uint32_t last_sector; 40 41 /* We read in all available tracks. This flag signals if we can play audio */ 42 int is_audio; 43 int index; /* Index into the track_info structre */ 44 } * tracks; 45 46 } bg_cdaudio_index_t; 47 48 void bg_cdaudio_index_dump(bg_cdaudio_index_t*); 49 void bg_cdaudio_index_destroy(bg_cdaudio_index_t*); 50 51 /* CD status (obtained periodically during playback) */ 52 53 typedef struct 54 { 55 int track; 56 int sector; 57 } bg_cdaudio_status_t; 58 59 /* Stuff, which varies from OS to OS. 60 For now, linux is the only supported 61 platform */ 62 63 CdIo_t * bg_cdaudio_open(const char * device); 64 65 bg_cdaudio_index_t * bg_cdaudio_get_index(CdIo_t *); 66 67 void bg_cdaudio_close(CdIo_t*); 68 int bg_cdaudio_check_device(const char * device, char ** name); 69 bg_device_info_t * bg_cdaudio_find_devices(); 70 71 int bg_cdaudio_play(CdIo_t*, int first_sector, int last_sector); 72 void bg_cdaudio_stop(CdIo_t*); 73 74 /* 75 * Get the status (time and track) of the currently played CD 76 * The st structure MUST be saved between calls 77 */ 78 79 80 void bg_cdaudio_get_disc_id(bg_cdaudio_index_t * idx, char disc_id[DISCID_SIZE]); 81 82 83 /* Functions for getting the metadata */ 84 85 #ifdef HAVE_MUSICBRAINZ 86 /* Try to get the metadata using musicbrainz */ 87 int bg_cdaudio_get_metadata_musicbrainz(bg_cdaudio_index_t*, 88 bg_track_info_t * info, 89 char * disc_id, 90 char * musicbrainz_host, 91 int musicbrainz_port, 92 char * musicbrainz_proxy_host, 93 int musicbrainz_proxy_port); 94 #endif 95 96 #ifdef HAVE_LIBCDDB 97 int bg_cdaudio_get_metadata_cddb(bg_cdaudio_index_t * idx, 98 bg_track_info_t * info, 99 char * cddb_host, 100 int cddb_port, 101 char * cddb_path, 102 char * cddb_proxy_host, 103 int cddb_proxy_port, 104 char * cddb_proxy_user, 105 char * cddb_proxy_pass, 106 int timeout); 107 #endif 108 109 /* 110 * Try to get metadata via CDtext. Requires a valid and open 111 * CDrom, returns False on failure 112 */ 113 114 int bg_cdaudio_get_metadata_cdtext(CdIo_t*, 115 bg_track_info_t * info, 116 bg_cdaudio_index_t*); 117 118 /* 119 * Ripping support 120 * Several versions (cdparanoia, simple linux ripper) can go here 121 */ 122 123 void * bg_cdaudio_rip_create(); 124 125 int bg_cdaudio_rip_init(void *, CdIo_t *cdio, int start_sector); 126 127 int bg_cdaudio_rip_rip(void * data, gavl_audio_frame_t * f); 128 129 /* Sector is absolute */ 130 131 void bg_cdaudio_rip_seek(void * data, int sector); 132 133 void bg_cdaudio_rip_close(void * data); 134 135 const bg_parameter_info_t * bg_cdaudio_rip_get_parameters(); 136 137 int 138 bg_cdaudio_rip_set_parameter(void * data, const char * name, 139 const bg_parameter_value_t * val); 140 141 void bg_cdaudio_rip_destroy(void * data); 142 143 /* Load and save cd metadata */ 144 145 int bg_cdaudio_load(bg_track_info_t * tracks, const char * filename); 146 147 void bg_cdaudio_save(bg_track_info_t * tracks, int num_tracks, 148 const char * filename); 149 150