libdiscid  0.6.4
discisrc.c

This example code uses libdiscid to read the TOC, MCN and ISRCs from a CD.If supported by the platform and provided by the CD the MCN for the disc and ISRCs for each track will be printed.

The CD device to use can be specified as the first command line parameter. If none is given the platform's default device will be used.

/* --------------------------------------------------------------------------
MusicBrainz -- The Internet music metadatabase
Copyright (C) 2006 Matthias Friedrich
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--------------------------------------------------------------------------- */
#include <stdio.h>
#include <discid/discid.h>
int main(int argc, char *argv[]) {
DiscId *disc;
int i;
char *device;
char *features[DISCID_FEATURE_LENGTH];
printf("%s\n", discid_get_version_string());
/* If we have an argument, use it as the device name */
if (argc > 1) {
device = argv[1];
} else {
}
printf("Device used: %s\n", device);
fprintf(stderr, "Error: not implemented on platform\n");
return 1;
} else {
disc = discid_new();
}
/* read the disc in the specified disc drive with the MCN and ISRC feature enabled */
fprintf(stderr, "Error: %s\n", discid_get_error_msg(disc));
discid_free(disc);
return 1;
}
printf("MCN : %s\n", discid_get_mcn(disc));
} else {
printf("MCN : (not implemented)\n");
}
for ( i = discid_get_first_track_num(disc);
i <= discid_get_last_track_num(disc); i++ ) {
printf("Track %-2d : %s\n", i,
}
} else {
printf("ISRCs : (not implemented)\n");
}
/* another way to access the features */
printf("All features: ");
for (i = 0; i < DISCID_FEATURE_LENGTH; i++) {
if (features[i]) {
if (i > 0) {
printf(", ");
}
printf("%s", features[i]);
}
}
printf("\n");
discid_free(disc);
return 0;
}
/* EOF */
#define DISCID_FEATURE_LENGTH
Definition: discid.h:456
LIBDISCID_API char * discid_get_track_isrc(DiscId *d, int track_num)
Return the ISRC for a track.
LIBDISCID_API DiscId * discid_new()
Return a handle for a new DiscId object.
LIBDISCID_API int discid_get_last_track_num(DiscId *d)
Return the number of the last audio track on this disc.
void * DiscId
A transparent handle for an Audio CD.
Definition: discid.h:122
LIBDISCID_API char * discid_get_version_string(void)
Return the full version string of this library, including the name.
@ DISCID_FEATURE_ISRC
Definition: discid.h:439
@ DISCID_FEATURE_READ
Definition: discid.h:437
@ DISCID_FEATURE_MCN
Definition: discid.h:438
LIBDISCID_API int discid_has_feature(enum discid_feature feature)
Check if a certain feature is implemented on the current platform.
LIBDISCID_API char * discid_get_error_msg(DiscId *d)
Return a human-readable error message.
LIBDISCID_API int discid_read_sparse(DiscId *d, const char *device, unsigned int features)
Read the disc in the given CD-ROM/DVD-ROM drive extracting only the TOC and additionally specified fe...
LIBDISCID_API char * discid_get_default_device(void)
Return the name of the default disc drive for this machine.
LIBDISCID_API void discid_get_feature_list(char *features[DISCID_FEATURE_LENGTH])
Return a list of features supported by the current platform.
LIBDISCID_API int discid_get_first_track_num(DiscId *d)
Return the number of the first track on this disc.
LIBDISCID_API void discid_free(DiscId *d)
Release the memory allocated for the DiscId object.
LIBDISCID_API char * discid_get_mcn(DiscId *d)
Return the Media Catalogue Number (MCN) for the disc.