dep: Add libcue

This commit is contained in:
Connor McLaughlin
2019-10-18 18:16:52 +10:00
parent c8bbd25f59
commit 52c16deba6
22 changed files with 7358 additions and 0 deletions

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2004, 2005, 2006, 2007, Svend Sorensen
* Copyright (c) 2009, 2010 Jochen Keil
* For license terms, see the file COPYING in this distribution.
*/
/* references: MMC-3 draft revsion - 10g */
#ifndef CD_H
#define CD_H
#include "libcue.h"
#include "cdtext.h"
#include "rem.h"
#define MAXTRACK 99 /* Red Book track limit (from 01 to 99) */
#define MAXINDEX 99 /* Red Book index limit (from 00 to 99) */
#define PARSER_BUFFER 1024 /* Parser buffer size */
/* return pointer to CD structure */
Cd *cd_init(void);
Track *track_init(void);
void track_delete(struct Track* track);
void cd_dump(Cd *cd);
/*
* Cd functions
*/
void cd_set_mode(Cd *cd, int mode);
void cd_set_catalog(Cd *cd, char *catalog);
void cd_set_cdtextfile(Cd *cd, char *cdtextfile);
/*
* add a new track to cd, increment number of tracks
* and return pointer to new track
*/
Track *cd_add_track(Cd *cd);
/*
* Track functions
*/
/* filename of data file */
void track_set_filename(Track *track, char *filename);
/* track start is starting position in data file */
void track_set_start(Track *track, long start);
/* track length is length of data file to use */
void track_set_length(Track *track, long length);
/* see enum TrackMode */
void track_set_mode(Track *track, int mode);
/* see enum TrackSubMode */
void track_set_sub_mode(Track *track, int sub_mode);
/* see enum TrackFlag */
void track_set_flag(Track *track, int flag);
void track_clear_flag(Track *track, int flag);
void track_set_zero_pre(Track *track, long length);
void track_set_zero_post(Track *track, long length);
void track_set_isrc(Track *track, char *isrc);
void track_set_index(Track *track, int i, long index);
#endif

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2004, 2005, 2006, 2007, Svend Sorensen
* Copyright (c) 2009, 2010 Jochen Keil
* For license terms, see the file COPYING in this distribution.
*/
/* references: MMC-3 draft revsion - 10g */
#ifndef CDTEXT_H
#define CDTEXT_H
#include "libcue.h"
enum PtiFormat {
FORMAT_CHAR, /* single or double byte character string */
FORMAT_BINARY /* binary data */
};
/* return a pointer to a new Cdtext */
Cdtext *cdtext_init(void);
/* release a Cdtext */
void cdtext_delete(Cdtext *cdtext);
/* returns non-zero if there are no CD-TEXT fields set, zero otherwise */
int cdtext_is_empty(Cdtext *cdtext);
/* set CD-TEXT field to value for PTI pti */
void cdtext_set(int pti, char *value, Cdtext *cdtext);
/*
* returns appropriate string for PTI pti
* if istrack is zero, UPC/EAN string will be returned for PTI_UPC_ISRC
* othwise ISRC string will be returned
*/
const char *cdtext_get_key(int pti, int istrack);
/*
* dump all cdtext info
* in human readable format (for debugging)
*/
void cdtext_dump(Cdtext *cdtext, int istrack);
#endif

View File

@ -0,0 +1,156 @@
/*
* Copyright (c) 2009, 2010 Jochen Keil
* For license terms, see the file COPYING in this distribution.
*/
#ifndef LIBCUE_H
#define LIBCUE_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
// #define CUE_EXPORT __attribute__((visibility("default")))
#define CUE_EXPORT
/*
* disc modes
* DATA FORM OF MAIN DATA (5.29.2.8)
*/
enum DiscMode {
MODE_CD_DA, /* CD-DA */
MODE_CD_ROM, /* CD-ROM mode 1 */
MODE_CD_ROM_XA /* CD-ROM XA and CD-I */
};
/*
* track modes
* 5.29.2.8 DATA FORM OF MAIN DATA
* Table 350 - Data Block Type Codes
*/
enum TrackMode {
MODE_AUDIO, /* 2352 byte block length */
MODE_MODE1, /* 2048 byte block length */
MODE_MODE1_RAW, /* 2352 byte block length */
MODE_MODE2, /* 2336 byte block length */
MODE_MODE2_FORM1, /* 2048 byte block length */
MODE_MODE2_FORM2, /* 2324 byte block length */
MODE_MODE2_FORM_MIX, /* 2332 byte block length */
MODE_MODE2_RAW /* 2352 byte block length */
};
/*
* sub-channel mode
* 5.29.2.13 Data Form of Sub-channel
* NOTE: not sure if this applies to cue files
*/
enum TrackSubMode {
SUB_MODE_RW, /* RAW Data */
SUB_MODE_RW_RAW /* PACK DATA (written R-W */
};
/*
* track flags
* Q Sub-channel Control Field (4.2.3.3, 5.29.2.2)
*/
enum TrackFlag {
FLAG_NONE = 0x00, /* no flags set */
FLAG_PRE_EMPHASIS = 0x01, /* audio recorded with pre-emphasis */
FLAG_COPY_PERMITTED = 0x02, /* digital copy permitted */
FLAG_DATA = 0x04, /* data track */
FLAG_FOUR_CHANNEL = 0x08, /* 4 audio channels */
FLAG_SCMS = 0x10, /* SCMS (not Q Sub-ch.) (5.29.2.7) */
FLAG_ANY = 0xff /* any flags set */
};
enum DataType {
DATA_AUDIO,
DATA_DATA,
DATA_FIFO,
DATA_ZERO
};
/* cdtext pack type indicators */
enum Pti {
PTI_TITLE, /* title of album or track titles */
PTI_PERFORMER, /* name(s) of the performer(s) */
PTI_SONGWRITER, /* name(s) of the songwriter(s) */
PTI_COMPOSER, /* name(s) of the composer(s) */
PTI_ARRANGER, /* name(s) of the arranger(s) */
PTI_MESSAGE, /* message(s) from the content provider and/or artist */
PTI_DISC_ID, /* (binary) disc identification information */
PTI_GENRE, /* (binary) genre identification and genre information */
PTI_TOC_INFO1, /* (binary) table of contents information */
PTI_TOC_INFO2, /* (binary) second table of contents information */
PTI_RESERVED1, /* reserved */
PTI_RESERVED2, /* reserved */
PTI_RESERVED3, /* reserved */
PTI_RESERVED4, /* reserved for content provider only */
PTI_UPC_ISRC, /* UPC/EAN code of the album and ISRC code of each track */
PTI_SIZE_INFO, /* (binary) size information of the block */
PTI_END /* terminating PTI (for stepping through PTIs) */
};
enum RemType {
REM_DATE, /* date of cd/track */
REM_REPLAYGAIN_ALBUM_GAIN,
REM_REPLAYGAIN_ALBUM_PEAK,
REM_REPLAYGAIN_TRACK_GAIN,
REM_REPLAYGAIN_TRACK_PEAK,
REM_END /* terminating REM (for stepping through REMs) */
};
/* ADTs */
typedef struct Cd Cd;
typedef struct Track Track;
typedef struct Cdtext Cdtext;
typedef struct Rem Rem;
typedef enum Pti Pti;
typedef enum TrackFlag TrackFlag;
typedef enum RemType RemType;
CUE_EXPORT Cd* cue_parse_file(FILE*);
CUE_EXPORT Cd* cue_parse_string(const char*);
CUE_EXPORT void cd_delete(Cd* cd);
/* CD functions */
CUE_EXPORT enum DiscMode cd_get_mode(const Cd *cd);
CUE_EXPORT const char *cd_get_cdtextfile(const Cd *cd);
/*
* return number of tracks in cd
*/
CUE_EXPORT int cd_get_ntrack(const Cd *cd);
/* CDTEXT functions */
CUE_EXPORT Cdtext *cd_get_cdtext(const Cd *cd);
CUE_EXPORT Cdtext *track_get_cdtext(const Track *track);
CUE_EXPORT const char *cdtext_get(enum Pti pti, const Cdtext *cdtext);
CUE_EXPORT Rem* cd_get_rem(const Cd* cd);
CUE_EXPORT Rem* track_get_rem(const Track* track);
/**
* return pointer to value for rem comment
* @param unsigned int: enum of rem comment
*/
CUE_EXPORT const char* rem_get(unsigned int, Rem*);
/* Track functions */
CUE_EXPORT Track *cd_get_track(const Cd *cd, int i);
CUE_EXPORT const char *track_get_filename(const Track *track);
CUE_EXPORT long track_get_start(const Track *track);
CUE_EXPORT long track_get_length(const Track *track);
CUE_EXPORT enum TrackMode track_get_mode(const Track *track);
CUE_EXPORT enum TrackSubMode track_get_sub_mode(const Track *track);
CUE_EXPORT int track_is_set_flag(const Track *track, enum TrackFlag flag);
CUE_EXPORT long track_get_zero_pre(const Track *track);
CUE_EXPORT long track_get_zero_post(const Track *track);
CUE_EXPORT const char *track_get_isrc(const Track *track);
CUE_EXPORT long track_get_index(const Track *track, int i);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2009, 2010 Jochen Keil
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Jochen Keil ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Jochen Keil BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef REM_H
#define REM_H
#include "libcue.h"
/**
* return new allocated rem struct
*/
Rem*
rem_new( void);
/**
* free rem struct
*/
void
rem_free( Rem*);
/**
* return true if allocated rem struct is empty
*/
int
rem_is_emtpy( Rem*);
/**
* set value of rem comment
* @param unsigned int: enum of rem comment
*/
void
rem_set( unsigned int,
char*,
Rem*);
/**
* dump all rem comments in human readable form
* @param bool: if track: true; else false
*/
void
rem_dump( Rem*);
#endif

View File

@ -0,0 +1,15 @@
/*
* time.h -- time declarations
*
* Copyright (C) 2004, 2005, 2006, 2007 Svend Sorensen
* For license terms, see the file COPYING in this distribution.
*/
#ifndef TIME_H
#define TIME_H
long time_msf_to_frame(int m, int s, int f);
void time_frame_to_msf(long frame, int *m, int *s, int *f);
char *time_frame_to_mmssff(long f);
#endif