1 /* -------------------------------------------------------------------------- 2 3 MusicBrainz -- The Internet music metadatabase 4 5 Copyright (C) 2006 Matthias Friedrich 6 7 This library is free software; you can redistribute it and/or 8 modify it under the terms of the GNU Lesser General Public 9 License as published by the Free Software Foundation; either 10 version 2.1 of the License, or (at your option) any later version. 11 12 This library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Lesser General Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public 18 License along with this library; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 21 $Id$ 22 23 --------------------------------------------------------------------------- */ 24 /* 25 * For internal use only. This header file is not installed. 26 */ 27 #ifndef MUSICBRAINZ_DISC_ID_PRIVATE_H 28 #define MUSICBRAINZ_DISC_ID_PRIVATE_H 29 30 #include "discid/discid.h" 31 32 /* Length of toc string, "xxx+xxx" + 100 tracks 7 bytes each ("+xxxxxx") 33 * The highest possible offset is 90 minutes * 60 seconds/minute * 75 frames/second = 405000. 34 * That is 6 digits plus one plus sign = 7 characters per track. 35 * So 3 + 3 (first and last) + 100*7 (disc length plus 99 tracks) = 706 36 */ 37 #define MB_TOC_STRING_LENGTH (3 + 3 + 100*7) 38 39 /* Length of a MusicBrainz DiscID in bytes (without a trailing '\0'-byte). */ 40 #define MB_DISC_ID_LENGTH 32 41 42 /* Length of a FreeDB DiscID in bytes (without a trailing '\0'-byte). */ 43 #define FREEDB_DISC_ID_LENGTH 8 44 45 /* The maximum permitted length for an error message (without the '\0'-byte). */ 46 #define MB_ERROR_MSG_LENGTH 255 47 48 /* Length of url prefixes */ 49 #define MB_URL_PREFIX_LENGTH 300 50 51 /* Maximum length of any url (including query string) */ 52 #define MB_MAX_URL_LENGTH (MB_URL_PREFIX_LENGTH + MB_DISC_ID_LENGTH + MB_TOC_STRING_LENGTH) 53 54 /* The URL that can be used for submitting DiscIDs (no parameters yet) */ 55 #define MB_SUBMISSION_URL "http://musicbrainz.org/cdtoc/attach" 56 57 /* The URL that can be used for retrieving XML for a CD */ 58 #define MB_WEBSERVICE_URL "http://musicbrainz.org/ws/1/release" 59 60 /* Maximum length of a Media Catalogue Number string */ 61 #define MCN_STR_LENGTH 13 62 63 /* Maximum length of a ISRC code string */ 64 #define ISRC_STR_LENGTH 12 65 66 /* Maximum disc length in frames/sectors 67 * This is already not according to spec, but many players might still work 68 * Spec is 79:59.75 = 360000 + lead-in + lead-out */ 69 #define MAX_DISC_LENGTH (90 * 60 * 75) 70 71 /* 72 * This data structure represents an audio disc. 73 * 74 * We use fixed length strings here because that way the user doesn't have to 75 * check for memory exhaustion conditions. As soon as the mb_disc object has 76 * been created, all calls returning strings will be successful. 77 */ 78 typedef struct { 79 int first_track_num; 80 int last_track_num; 81 int track_offsets[100]; 82 char id[MB_DISC_ID_LENGTH+1]; 83 char freedb_id[FREEDB_DISC_ID_LENGTH+1]; 84 char submission_url[MB_MAX_URL_LENGTH+1]; 85 char webservice_url[MB_MAX_URL_LENGTH+1]; 86 char toc_string[MB_TOC_STRING_LENGTH+1]; 87 char error_msg[MB_ERROR_MSG_LENGTH+1]; 88 char isrc[100][ISRC_STR_LENGTH+1]; 89 char mcn[MCN_STR_LENGTH+1]; 90 int success; 91 } mb_disc_private; 92 93 typedef struct { 94 int control; 95 int address; 96 } mb_disc_toc_track; 97 98 typedef struct { 99 int first_track_num; 100 int last_track_num; 101 mb_disc_toc_track tracks[100]; 102 } mb_disc_toc; 103 104 /* 105 * This function has to be implemented once per operating system. 106 * 107 * The caller guarantees that both the disc and device parameters are 108 * not NULL. 109 * 110 * Implementors have to set mb_disc_private's first_track_num, last_track_num, 111 * and track_offsets attributes. If there is an error, the error_msg attribute 112 * has to be set to a human-readable error message. 113 * 114 * On error, 0 is returned. On success, 1 is returned. 115 */ 116 LIBDISCID_INTERNAL int mb_disc_read_unportable(mb_disc_private *disc, const char *device, unsigned int features); 117 118 119 /* 120 * This should return the name of the default/preferred CDROM/DVD device 121 * on this operating system. It has to be in a format usable for the second 122 * parameter of mb_disc_read_unportable(). 123 */ 124 LIBDISCID_INTERNAL char *mb_disc_get_default_device_unportable(void); 125 126 /* 127 * This should return 1 if the feature is supported by the platform 128 * and 0 if not. 129 */ 130 LIBDISCID_INTERNAL int mb_disc_has_feature_unportable(enum discid_feature feature); 131 132 /* 133 * Load data to the mb_disc_private structure based on mb_disc_toc. 134 * 135 * On error, 0 is returned. On success, 1 is returned. 136 */ 137 LIBDISCID_INTERNAL int mb_disc_load_toc(mb_disc_private *disc, mb_disc_toc *toc); 138 139 #endif /* MUSICBRAINZ_DISC_ID_PRIVATE_H */ 140