Welcome to MfcCDDB, a collection of freeware C++ classes to support access to the Compact Disc DataBases on the Internet.
CDDB is an information database containing artist, disc title, track titles, and other information for digital audio compact discs. Over time, this archive has grown to contain a substantial collection of CD information and is continuing to grow at a rapid rate. This database can be accessed by applications via the CDDB server hosts that have been set up on the Internet around the world. The CDDB data format and the CDDB servers are designed to be open, and are used by many client applications requiring CD information. CDDB has become the de facto standard for Internet access of compact disc information. For more information please see https://gnudb.org.
Features |
Copyright |
Usage |
History |
API Reference |
Contacting the Author |
v1.47 (17 August 2022)
v1.46 (14 August 2022)
v1.45 (28 May 2022)
v1.44 (28 December 2021)
v1.43 (12 April 2020)
v1.42 (23 December 2019)
v1.41 (29 September 2019)
v1.40 (6 June 2019)
v1.39 (2 January 2019)
v1.38 (26 December 2017)
v1.37 (4 October 2017)
v1.36 (20 May 2017)
v1.35 (30 July 2016)
v1.34 (26 February 2016)
v1.33 (10 April 2010)
v1.32 (24 December 2009)
v1.31 (31 August 2008)
v1.30 (12 January 2008)
v1.29 (1 January 2007)
v1.28 (29 June 2005)
v1.27 (20 August 2004)
v1.26 (3 November 2003)
v1.25 (3 August 2003)
v1.24 (24 June 2002)
v1.23 (2 February 2002)
v1.22 (8 October 2001)
v1.21 (7 October 2001)
v1.20 (9 August 2001)
v1.19 (5 September 2000)
v1.18 (30 May 2000)
v1.17 (17 May 2000)
v1.16 (7 May 2000)
v1.15 (13 February 2000)
v1.14 (23 January 2000)
v1.13 (17 January 2000)
v1.12 (29 November 1999)
v1.11 (14 July 1999)
v1.1 (20 May 1999)
v1.0 (11 May 1999)
The API consists of the following classes and their methods and variables
CSite
CSite::CSite
CSite::operator=
CSite::m_sSite
CSite::m_nPort
CSite::m_sAddress
CSite::m_bNorthing
CSite::m_nLatitudeMinutes
CSite::m_bEasting
CSite::m_nLongitudeMinutes
CSite::m_sDescription
CQueryResult
CQueryResult::CQueryResult
CQueryResult::operator=
CQueryResult::m_sCategory
CQueryResult::m_dwDiscID
CQueryResult::m_sArtist
CQueryResult::m_sTitle
CRecord::m_TrackOffsets
CRecord::m_nDiskLength
CRecord::m_nDatabaseRevision
CRecord::m_sClientName
CRecord::m_sClientVersion
CRecord::m_sClientComments
CRecord::m_dwDiscID
CRecord::m_sArtist
CRecord::m_sTitle
CRecord::m_TrackTitles
CRecord::m_ExtendedData
CRecord::m_ExtendedTrackData
CRecord::m_PlayOrder
CStatus::m_nCurrentProtocol
CStatus::m_nMaxProtocol
CStatus::m_bGetsAllowed
CStatus::m_bUpdatesAllowed
CStatus::m_bPostingAllowed
CStatus::m_bQuotes
CStatus::m_nCurrentUsers
CStatus::m_nMaxUsers
CStatus::m_bStripExtended
CStatus::m_nDatabaseEntries
CStatus::m_Categories
CStatus::m_CategoryEntries
CStatus::m_PendingSites
CStatus::m_PendingEntries
CTrackPosition::operator=
CTrackPosition::m_nMinute
CTrackPosition::m_nSecond
CTrackPosition::m_nFrame
CClient::CClient
CClient::GetCDROMDrives
CClient::ComputeDiscID...
CClient::GetTrackPositions...
CClient::Sites
CClient::Categories
CClient::SetCDDBProtocolVersion
CClient::GetCDDBProtocolVersion
CClient::Status
CClient::Query
CClient::Read
CClient::Submit
CClient::MessageOfTheDay
CClient::GetProductName
CClient::SetProductName
CClient::GetProductVersion
CClient::SetProductVersion
CClient::GetHelloCommand
CSite(bool bRetrieve = true);
Parameters
bRetrieve true if the members of CDDBSite should be setup for retrieving data otherwise false for submitting albums.
Remarks
Standard constructor for the class. This class represents the information for a single site as returned from the CDDB::Sites function. This class is also used when calling any of the other CClient functions which access a CDDB server.
CSite& operator=(const CSite& site);
Parameters
site This CSite instance to copy into this instance.
Remarks
Standard operator= for the CSite class.
Remarks
m_sSite is of type CDDB::String and contains the IP address or domain name of the CDDB HTTP server.
Remarks
m_nSite is of type int and contains the IP port number of the CDDB HTTP server. Normally this will be 80 which is the standard HTTP port number.
Remarks
m_sAddress is of type CDDB::String and contains the URL which is requested when making the HTTP request. Normally this is either "~cddb/cddb.cgi" or "~cddb/submit.cgi".
Remarks
m_bNorthing is of type bool and is true if the CDDB site is reported as being in the northern hemisphere or false if in the southern hemisphere.
Remarks
m_nLatitudeMinutes is of type int and contains the latitude of the CDDB site in minutes of degrees north or south of the equator.
Remarks
m_bEasting is of type bool and is true if the CDDB site is reported as being west of the Greenwich prime meridian or false if west of it.
Remarks
m_nLongitudeMinutes is of type int and contains the longitude of the CDDB site in minutes of degrees east or west of the prime meridian.
Remarks
m_sDescription is of type CDDB::String and contains a simple description of the CDDB site e.g. "Random US Site".
CQueryResult();
Remarks
Standard constructor for the class. This class represents the information for a single site as returned from the CDDB::Query function.
CQueryResult& operator=(const CQueryResult& result);
Parameters
result This CQueryResult instance to copy into this instance.
Remarks
Standard operator= for the CQueryResult class.
Remarks
m_sCategory is of type CDDB::String and contains the category of the album.
Remarks
m_dwDiscID is of type DWORD and contains the CDDB DISC-ID of the album.
Remarks
m_sArtist is of type CDDB::String and contains the Artist of the album.
Remarks
m_sTitle is of type CDDB::String and contains the title of the album.
This class represents the information for a single album as returned from the CDDB::Read function.
Remarks
m_TrackOffsets is of type CArray<int, int&> and contains the offset of each track (including the leadout track) in frames.
Remarks
m_nDiskLength is of type int and contains the number of seconds of the CD's play length.
Remarks
m_nDatabaseRevision is of type int and contains the revision number of this album in the database. This is used internally by CDDB for database management. When you are allowing the user to modify a database entry, you should increment this number prior to submitting the modified entry to CDDB.
Remarks
m_sClientName is of type CDDB::String and contains the name of the client application which submitted this record to CDDB.
Remarks
m_sClientVersion is of type CDDB::String and contains the version number of the client application which submitted this record to CDDB. Please see the CDDB howto document for the format which should be used.
Remarks
m_sClientComments is of type CDDB::String and contains optional comments which you want to include along with the ClientName and Client Version.
Remarks
m_dwDiscID is of type DWORD and contains the CDDB DISC-ID of the album.
Remarks
m_sArtist is of type CDDB::String and contains the Artist of the album.
Remarks
m_sTitle is of type CDDB::String and contains the title of the album.
Remarks
m_TrackTitles is of type CDDB::StringArray and contains the title of each track of the album.
Remarks
m_ExtendedData is of type CDDB::StringArray and contains the names of any extended data associated with this album. For example it could contain "Producer:Jimmy Page", "Executive Producer: Peter Grant" and "Year: 1976".
Remarks
m_ExtendedTrackData is of type CDDB::StringArray and contains the extended data for each track on the album. For example this could contain the vocalists for each track. The array will come back with as many elements in the array as tracks on the album. If no data is present for any track then the string for that title will be a empty string.
Remarks
m_PlayOrder is of type CDDB::IntArray and contains the customized play order for this album. Generally this is stripped when submitted to a non-local CDDB database. You might want to allow your application to store this locally as a user preference. You should also ensure that this information is stripped prior to submitting this record to a CDDB server.
Remarks
This class represents the information as returned from the CClient::Status function.
Remarks
m_nCurrentProtocol is of type int and contains the server's current operating protocol level.
Remarks
m_nMaxProtocol is of type int and contains the server's maximum supported operating protocol level.
Remarks
m_bGetsAllowed is of type bool and is true if the client is allowed to get log information otherwise false.
Remarks
m_bUpdatesAllowed is of type bool and is true if the client is allowed to initiate a database update otherwise false.
Remarks
m_bPostingAllowed is of type bool and is true if the client is allowed to post new entries to the database otherwise false.
Remarks
m_bQuotes is of type bool and is true if quoted arguments are enabled otherwise false.
Remarks
m_nCurrentUsers is of type int and is the number of users currently connected to the server.
Remarks
m_nMaxUsers is of type int and is the maximum number of users that can connect to the server concurrently.
Remarks
m_bStripExtended is of type bool and is true if extended data is stripped by the server before being presented to the user otherwise false.
Remarks
m_nDatabaseEntries is of type int and is the total number of entries in the database.
Remarks
m_Categories is of type CDDB::StringArray and is the list of all the categories in the database.
Remarks
m_CategoryEntries is of type CDDB::IntArray and contains the number of entries for each category in the database. The elements at each offset correspond to the m_Categories array.
Remarks
m_PendingSites is of type CDDB::StringArray and is the list of sites which are fed database entries from the current site.
Remarks
m_PendingEntries is of type CDDB::IntArray and contains the number of pending entries to be sent to each site. The elements at each offset correspond to the m_PendingSites array.
Remarks
This class represents the absolute track position of a CD in MSF (Minute, Second, Frame) format. This class is used in the CClient::ComputeDiscID..., CClient::GetTrackPositions... & CClient::Query functions.
CTrackPosition& operator=(const CTrackPosition& position);
Parameters
position This CTrackPosition instance to copy into this instance.
Remarks
Standard operator= for the CTrackPosition class.
Remarks
m_nMinute is of type int and contains the minutes component of a track's position.
Remarks
m_nSecond is of type int and contains the seconds component of a track's position.
Remarks
m_nFrame is of type int and contains the frame component of a track's position. A frame is defined as 1/75 of a second meaning that this value ranges from 0 - 74.
CClient();
Remarks
Standard constructor for the class. This class is the main CDDB support class and contains all the CDDB related functions. It also includes a number of simple wrapper functions for accessing CD-Audio discs through the Windows MCI programming interface.
void GetCDROMDrives(StringArray& drives);
Parameters
drives Upon return this will contain the drive letters which correspond to CDROM drives.
Remarks
Upon return the "drives" array will contain all the drives on the current machine which are CDROM drives. Any of the values in the array can then be used in a call to CClient::ComputeDiscID.... The format returned is in the format of "x:" where x is the drive letter of the CDROM drive.
DWORD ComputeDiscIDUsingMCI(LPCTSTR pszDrive);
DWORD ComputeDiscIDUsingDeviceIoControl(LPCTSTR pszDrive);
DWORD ComputeDiscID(const TrackPositionArray& tracks);
Return Value
The computed DISC-ID of the specified track positions.
Parameters
pszDrive The drive letter of the CDROM drive to compute the DISC-ID of the inserted CD.
tracks An array specifying an albums contents which the DISC-ID is to be computed for.
Remarks
Computes the DISC-ID of the inserted CD in the specified CDROM drive. The two overloaded "Using" versions internally use MCI and DeviceIoControl respectively to compute the track positions. Please note that the tracks parameter includes the lead-out track position also. The tracks parameter can be computed using the CClient::GetTrackPostions function
void GetTrackPositionsUsingMCI(LPCTSTR pszDrive, TrackPositionArray& tracks);
void GetTrackPositionsUsingDeviceIoControl(LPCTSTR pszDrive, TrackPositionArray& tracks);
Parameters
tracks Upon successful return this will contain the track positions of the album in the specified CDROM drive.
pszDrive The drive letter of the CDROM drive to get the track positions of.
Remarks
Upon return the "tracks" array will contain the track positions for the specified album in the "pszDrive" CDROM drive. If you specify NULL for the drive in the "UsingMCI" version, then the default MCI CDROM drive will be used. Please note that the tracks array will include the leadout track position as the last element in the array as well as the normal audio tracks. This means that the size of the array upon return will be 1 greater than the number of audio tracks on the album. This is required for the calculation of the DISC-ID as returned from the CClient::ComputeDiscId... functions. Please note that the format of pszDrive should include a trailing colon e.g. "D:".
void Sites(SiteArray& sites, const String& sServer = _T("gnudb.gnudb.org"), const String& sAddress = _T("/~cddb/cddb.cgi"), int nPort = 80);
void Sites(const CSite& server, SiteArray& sites);
Parameters
sites Upon successful return this will contain the list of CDDB servers as returned from the Sites command.
sServer The IP address or domain name of the CDDB HTTP server to use.
sAddress The HTTP request to make.
nPort The TCP/IP port number on which to make the connection.
server The server to use as specified through its parameters m_sSite, m_nPort and m_sAddress parameters.
Remarks
Issues the CDDB "Sites" command. For more information about this command, please consult the CDDB howto document. The first form of the function uses the default CDDB server at "gnudb.gnudb.org" to retrieve the site list, whereas the second form allows you to specify the server details through the "server" parameter.
CClient::SetCDDBProtocolVersion
void SetCDDBProtocolVersion(int nProtocolVersion);
Parameters
nProtocolVersion The CDDB protocol version to use.
Remarks
Sets the CDDB protocol version to use.
CClient::GetCDDBProtocolVersion
int GetCDDBProtocolVersion() const;
Return Value
The current CDDB protocol version by using by the code.
Remarks
This is the corollary function to SetCDDBProtocolVersion.
void Categories(const CSite& server, StringArray& categories);
Parameters
server The server to use as specified through its parameters m_sSite, m_nPort and m_sAddress parameters.
categories Upon successful return this will contain the list of categories which this server's database contains.
Remarks
Issues the CDDB "lscat" command. This function returns the type of categories which this servers database contains. For more information about this command, please consult the CDDB howto document.
void Status(const CSite& server, CStatus& status);
Parameters
server The server to use as specified through its parameters m_sSite, m_nPort and m_sAddress parameters.
status Upon successful return this will contain the CDDB servers information.
Remarks
Issues the CDDB "stat" command. This function returns information relating to a CDDB server such as number of albums in the database etc in the status parameter. For more information about this command, please consult the CDDB howto document.
void Query(const CSite& server, DWORD dwDiscID, const TrackPositionArray& tracks, QueryResultArray& results);
Parameters
server The server to use as specified through its parameters m_sSite, m_nPort and m_sAddress parameters.
dwDiscID The DISC-ID of the inserted album.
tracks An array specifying an albums contents which the DISC-ID is to be computed for.
results Upon successful return this will contain an array of query result instances which represent the matching albums
Remarks
Issues the CDDB "query" command. This function queries the CDDB servers database about whether or not the specified album is present. If the album is not found, then the return value will be TRUE and there will be no entries in the "results" array. An exact match will have just one element in the array while an inexact match will result in multiple entries in the array. For more information about this command, please consult the CDDB howto document.
void Read(const CSite& server, DWORD dwDiscID, const String& sCategory, CRecord& record);
Parameters
server The server to use as specified through its parameters m_sSite, m_nPort and m_sAddress parameters.
dwDiscID The DISC-ID of the album.
sCategory The CDDB category which the album belongs to.
record Upon successful return this will contain the album details in a CRecord instance.
Remarks
Issues the CDDB "read" command. This function queries the CDDB servers database about a specified album's details. Normally this would be used after a successful call to Query. For more information about this command, please consult the CDDB howto document.
void Submit(const CSite& server, const String& sCategory, const String& sEmailAddress, CRecord& record, const String& sRejectionNotice, bool bReallySubmit = true);
Parameters
server The server to use as specified through its parameters m_sSite and m_nPort parameters.
sCategory The CDDB category which the album belongs to.
sEmailAddress The email address where any submission failure notices should be mailed to.
record Details of the album to be added to the CDDB database.
sRejectionNotice Arbitrary message to be included at the top of any rejection notice that may be sent to the submitting user
bReallySubmit Indicates whether the submission is a test submission or a real submission to the database.
Remarks
Submits an album for inclusion in the CDDB database. Any after the fact errors with the submission are reported through email to the email address "sEmailAddress". The CDDB protocol also includes a test mode specified by setting bReallySubmit to FALSE whereby a dummy run of the submission is made without actually adding the entry to the database. For more information about submitting albums, please consult the CDDB howto document.
void MessageOfTheDay(String& sMessage, const String& sServer = _T("gnudb.gnudb.org"), const String& sAddress = _T("/~cddb/cddb.cgi"), int nPort = 80);
void MessageOfTheDay(const CSite& server, String& sMessage);
Parameters
sMessage Upon successful return, this will contain the "Message of the Day".
sServer The IP address or domain name of the CDDB HTTP server to use.
sAddress The HTTP request to make.
nPort The TCP/IP port number on which to make the connection.
server The server to use as specified through its parameters m_sSite, m_nPort and m_sAddress parameters.
Remarks
Issues the CDDB "motd" command. This function queries the CDDB servers database for a message of the day. In Windows terms this is similar to the Tip of the Day which some applications implement. For more information about this command, please consult the CDDB howto document.
String GetProductName() const;
Return Value
The Product Name which the CClient class will use internally.
Remarks
When connections are being made to the CDDB server, part of the protocol requires the client program to identify itself. You will need to pick a name which has not been used by other CDDB enabled products. This function allows retrieval of the value as set by SetProductName. For more information about, please consult the CDDB howto document. By default the product name is set to the "MfcCDDB".
void GetProductName(const String& sProductName);
Parameters
sProductName The Product Name which the CClient class will use internally.
String GetProductVersion() const;
Return Value
The Product Version which the CClient class will use internally.
Remarks
As well as the product name being required when connecting to a CDDB server,
a version number is also required. By default the version number is set to the version
number of the MfcCDDB code. As mentioned in the howto document, this field has a
very specific format which should be observed:
[leading text]version_number[release
type][level]
Where:
Leading text: is any string
which does not include numbers.
Version number and level:
is any (possibly) decimal-separated list of
positive numbers.
Release type: is a string of the form:
alpha, a, beta, b,
patchlevel, patch, pl
Level: is a positive number.
For example:
release:2.35.1alpha7
v4.0PL0
2.4
void GetProductName(const String& sProductVersion);
Parameters
sProductVersion The Product Version which the CClient class will use internally.
virtual String GetHelloCommand();
Return Value
The string to use for the "hello" command which the CClient class will use internally.
Remarks
As part of all the CDDB HTTP requests, the CDDB Hello command is encoded into the request as well. The command takes the following format:
hello=username+domainname+ProductName+ProductVersion
The default implementation of this function in CClient uses the username as returned from the SDK function "GetUserName", the local machines domain name as returned from "gethostname" and the strings as stored using the functions: SetProductName and GetProductVersion. You can derive your own class from CClient and override this function if you so desire. For more information about these details, please consult the CDDB howto document.
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
17 August 2022