discid_private.h 4.7 KB

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