Start to merge in cue parsing from cuetools. Also moves forward CDTEXT
from a different direction.
This commit is contained in:
45
example/sample8.c
Normal file
45
example/sample8.c
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
$Id: sample8.c,v 1.1 2004/07/09 01:05:31 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Simple program to list CDTEXT info of a Compact Disc using libcdio. */
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <cdio/cdio.h>
|
||||||
|
#include <cdio/cdtext.h>
|
||||||
|
int
|
||||||
|
main(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
CdIo *cdio = cdio_open (NULL, DRIVER_UNKNOWN);
|
||||||
|
|
||||||
|
if (NULL == cdio) {
|
||||||
|
printf("Couldn't find a driver.. leaving.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
cdio_cdtext_query(cdio);
|
||||||
|
#endif
|
||||||
|
cdio_destroy(cdio);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdtext.h,v 1.1 2004/07/08 01:27:58 rocky Exp $
|
$Id: cdtext.h,v 1.2 2004/07/09 01:05:31 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -28,49 +28,29 @@
|
|||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
|
|
||||||
#define CDIO_CDTEXT_MAX_PACK_DATA 255
|
typedef struct cdtext cdtext_t;
|
||||||
#define CDIO_CDTEXT_MAX_TEXT_DATA 12
|
|
||||||
|
|
||||||
#define CDIO_CDTEXT_TITLE 0x80
|
/*! Initialize and allocate a new cdtext structure and return a
|
||||||
#define CDIO_CDTEXT_PERFORMER 0x81
|
pointer to that. When the structure is no longer needed, release the
|
||||||
#define CDIO_CDTEXT_SONGWRITER 0x82
|
resources using cdtext_delete.
|
||||||
#define CDIO_CDTEXT_COMPOSER 0x83
|
|
||||||
#define CDIO_CDTEXT_ARRANGER 0x84
|
|
||||||
#define CDIO_CDTEXT_MESSAGE 0x85
|
|
||||||
#define CDIO_CDTEXT_DISCID 0x86
|
|
||||||
#define CDIO_CDTEXT_GENRE 0x87
|
|
||||||
|
|
||||||
PRAGMA_BEGIN_PACKED
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
struct CDText_data
|
|
||||||
{
|
|
||||||
uint8_t type;
|
|
||||||
track_t i_track;
|
|
||||||
uint8_t seq;
|
|
||||||
uint8_t characterPosition:4; /* character position */
|
|
||||||
uint8_t block:3; /* block number 0..7 */
|
|
||||||
uint8_t bDBC:1; /* double byte character */
|
|
||||||
char text[12];
|
|
||||||
uint8_t crc[2];
|
|
||||||
} GNUC_PACKED;
|
|
||||||
|
|
||||||
PRAGMA_END_PACKED
|
|
||||||
|
|
||||||
typedef struct CDText_data CDText_data_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query the CDTEXT information
|
|
||||||
*
|
|
||||||
* @param cd The CD object to extract CDTEXT data from
|
|
||||||
*
|
|
||||||
* @return An allocated structure containing CDTEXT information found.
|
|
||||||
* NULL is returned if there was a problem.
|
|
||||||
*/
|
*/
|
||||||
CDText_data_t *cdio_cdtext_query(const CdIo *cd);
|
cdtext_t *cdtext_init (void);
|
||||||
|
|
||||||
|
/*! Free memory assocated with cdtext*/
|
||||||
|
void cdtext_delete (cdtext_t *cdtext);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns 0 if field is a CD-TEXT keyword, returns non-zero otherwise.
|
||||||
|
*/
|
||||||
|
int cdtext_is_keyword (char *key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
sets cdtext's keyword entry to field
|
||||||
|
*/
|
||||||
|
void cdtext_set (char *key, char *value, cdtext_t *cdtext);
|
||||||
|
|
||||||
|
char *cdtext_get (char *key, cdtext_t *cdtext);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.40 2004/06/27 22:00:09 rocky Exp $
|
# $Id: Makefile.am,v 1.41 2004/07/09 01:05:31 rocky Exp $
|
||||||
#
|
#
|
||||||
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
#
|
#
|
||||||
@@ -65,8 +65,10 @@ libcdio_sources = \
|
|||||||
_cdio_sunos.c \
|
_cdio_sunos.c \
|
||||||
bytesex.h \
|
bytesex.h \
|
||||||
bytesex_asm.h \
|
bytesex_asm.h \
|
||||||
cdio.c \
|
|
||||||
cd_types.c \
|
cd_types.c \
|
||||||
|
cdio.c \
|
||||||
|
cdtext.c \
|
||||||
|
cdtext_private.h \
|
||||||
ds.c \
|
ds.c \
|
||||||
ds.h \
|
ds.h \
|
||||||
FreeBSD/freebsd.c \
|
FreeBSD/freebsd.c \
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_linux.c,v 1.60 2004/07/08 01:27:59 rocky Exp $
|
$Id: _cdio_linux.c,v 1.61 2004/07/09 01:05:32 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.60 2004/07/08 01:27:59 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.61 2004/07/09 01:05:32 rocky Exp $";
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@ static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.60 2004/07/08 01:27:59 rock
|
|||||||
#include <cdio/util.h>
|
#include <cdio/util.h>
|
||||||
#include <cdio/scsi_mmc.h>
|
#include <cdio/scsi_mmc.h>
|
||||||
#include <cdio/cdtext.h>
|
#include <cdio/cdtext.h>
|
||||||
|
#include "cdtext_private.h"
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
|
|
||||||
@@ -674,11 +675,11 @@ _cdio_read_toc (_img_private_t *env)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CDTEXT_FIXED
|
||||||
static CDText_data_t *
|
static CDText_data_t *
|
||||||
_cdtext_query( void *user_data )
|
cdtext_init( void *user_data )
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef CDTEXT_FIXED
|
|
||||||
_img_private_t *env = user_data;
|
_img_private_t *env = user_data;
|
||||||
CDText_data_t *pdata;
|
CDText_data_t *pdata;
|
||||||
int i;
|
int i;
|
||||||
@@ -778,9 +779,9 @@ _cdtext_query( void *user_data )
|
|||||||
}
|
}
|
||||||
pdata++;
|
pdata++;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return NULL; /* FIXME */
|
return NULL; /* FIXME */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Eject using SCSI commands. Return 1 if successful, 0 otherwise.
|
* Eject using SCSI commands. Return 1 if successful, 0 otherwise.
|
||||||
@@ -1212,7 +1213,6 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
|
|||||||
char *psz_source;
|
char *psz_source;
|
||||||
|
|
||||||
cdio_funcs _funcs = {
|
cdio_funcs _funcs = {
|
||||||
.cdtext_query = _cdtext_query,
|
|
||||||
.eject_media = _eject_media_linux,
|
.eject_media = _eject_media_linux,
|
||||||
.free = cdio_generic_free,
|
.free = cdio_generic_free,
|
||||||
.get_arg = _get_arg_linux,
|
.get_arg = _get_arg_linux,
|
||||||
|
|||||||
20
lib/cdio.c
20
lib/cdio.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdio.c,v 1.57 2004/07/08 01:28:00 rocky Exp $
|
$Id: cdio.c,v 1.58 2004/07/09 01:05:32 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
#include <cdio/logging.h>
|
#include <cdio/logging.h>
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: cdio.c,v 1.57 2004/07/08 01:28:00 rocky Exp $";
|
static const char _rcsid[] = "$Id: cdio.c,v 1.58 2004/07/09 01:05:32 rocky Exp $";
|
||||||
|
|
||||||
|
|
||||||
const char *track_format2str[6] =
|
const char *track_format2str[6] =
|
||||||
@@ -212,22 +212,6 @@ scan_for_driver(driver_id_t start, driver_id_t end,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Return the value associatied with key. NULL is returned if obj is NULL
|
|
||||||
or "key" does not exist.
|
|
||||||
*/
|
|
||||||
CDText_data_t *
|
|
||||||
cdio_cdtext_query (const CdIo *obj)
|
|
||||||
{
|
|
||||||
if (obj == NULL) return NULL;
|
|
||||||
|
|
||||||
if (obj->op.get_arg) {
|
|
||||||
return obj->op.cdtext_query (obj->env);
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
cdio_driver_describe(driver_id_t driver_id)
|
cdio_driver_describe(driver_id_t driver_id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdio_private.h,v 1.25 2004/07/08 01:28:00 rocky Exp $
|
$Id: cdio_private.h,v 1.26 2004/07/09 01:05:32 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -40,12 +40,6 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
||||||
/*!
|
|
||||||
Return an allocated structure containing CDTEXT information found.
|
|
||||||
NULL is returned if there was a problem.
|
|
||||||
*/
|
|
||||||
CDText_data_t * (*cdtext_query) (void *env);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Eject media in CD drive. If successful, as a side effect we
|
Eject media in CD drive. If successful, as a side effect we
|
||||||
also free obj. Return 0 if success and 1 for failure.
|
also free obj. Return 0 if success and 1 for failure.
|
||||||
|
|||||||
132
lib/cdtext.c
Normal file
132
lib/cdtext.c
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
$Id: cdtext.c,v 1.1 2004/07/09 01:05:32 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
toc reading routine adapted from cuetools
|
||||||
|
Copyright (C) 2003 Svend Sanjay Sorensen <ssorensen@fastmail.fm>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cdio/cdtext.h>
|
||||||
|
#include <cdio/logging.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Private type */
|
||||||
|
struct cdtext {
|
||||||
|
const char *key;
|
||||||
|
char *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
const cdtext_t cdtext[] = {
|
||||||
|
{"TITLE", NULL},
|
||||||
|
{"PERFORMER", NULL},
|
||||||
|
{"SONGWRITER", NULL},
|
||||||
|
{"COMPOSER", NULL},
|
||||||
|
{"ARRANGER", NULL},
|
||||||
|
{"MESSAGE", NULL},
|
||||||
|
{"DISC_ID", NULL},
|
||||||
|
{"GENRE", NULL},
|
||||||
|
{"TOC_INFO", NULL},
|
||||||
|
{"TOC_INFO2", NULL},
|
||||||
|
{"UPC_EAN", NULL},
|
||||||
|
{"ISRC", NULL},
|
||||||
|
{"SIZE_INFO", NULL},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
cdtext_t *cdtext_init ()
|
||||||
|
{
|
||||||
|
cdtext_t *new_cdtext = NULL;
|
||||||
|
|
||||||
|
new_cdtext = (cdtext_t *) calloc (sizeof (cdtext) / sizeof (cdtext_t),
|
||||||
|
sizeof (cdtext_t));
|
||||||
|
if (NULL == new_cdtext)
|
||||||
|
cdio_warn("problem allocating memory");
|
||||||
|
else
|
||||||
|
memcpy (new_cdtext, cdtext, sizeof(cdtext));
|
||||||
|
|
||||||
|
return (new_cdtext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Free memory assocated with cdtext*/
|
||||||
|
void cdtext_delete (cdtext_t *cdtext)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (NULL != cdtext) {
|
||||||
|
for (i = 0; NULL != cdtext[i].key; i++)
|
||||||
|
free (cdtext[i].value);
|
||||||
|
free (cdtext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns 0 if field is a CD-TEXT keyword, returns non-zero otherwise
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
cdtext_is_keyword (char *key)
|
||||||
|
{
|
||||||
|
const char *cdtext_keywords[] =
|
||||||
|
{
|
||||||
|
"ARRANGER", /* name(s) of the arranger(s) */
|
||||||
|
"COMPOSER", /* name(s) of the composer(s) */
|
||||||
|
"DISC ID", /* disc identification information */
|
||||||
|
"GENRE", /* genre identification and genre information */
|
||||||
|
"ISRC", /* ISRC code of each track */
|
||||||
|
"MESSAGE", /* message(s) from the content provider and/or artist */
|
||||||
|
"PERFORMER", /* name(s) of the performer(s) */
|
||||||
|
"SIZE_INFO", /* size information of the block */
|
||||||
|
"SONGWRITER", /* name(s) of the songwriter(s) */
|
||||||
|
"TITLE", /* title of album name or track titles */
|
||||||
|
"TOC_INFO", /* table of contents information */
|
||||||
|
"TOC_INFO2" /* second table of contents information */
|
||||||
|
"UPC_EAN",
|
||||||
|
};
|
||||||
|
|
||||||
|
char *item;
|
||||||
|
|
||||||
|
item = bsearch(key,
|
||||||
|
cdtext_keywords, 12,
|
||||||
|
sizeof (char *),
|
||||||
|
(int (*)(const void *, const void *))
|
||||||
|
strcmp);
|
||||||
|
return (NULL != item) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! sets cdtext's keyword entry to field.
|
||||||
|
*/
|
||||||
|
void cdtext_set (char *key, char *value, cdtext_t *cdtext)
|
||||||
|
{
|
||||||
|
if (NULL != value) /* don't pass NULL to strdup! */
|
||||||
|
for (; NULL != cdtext->key; cdtext++)
|
||||||
|
if (0 == strcmp (cdtext->key, key)) {
|
||||||
|
free (cdtext->value);
|
||||||
|
cdtext->value = strdup (value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
68
lib/cdtext_private.h
Normal file
68
lib/cdtext_private.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
$Id: cdtext_private.h,v 1.1 2004/07/09 01:05:32 rocky Exp $
|
||||||
|
|
||||||
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CDIO_CDTEXT_PRIVATE_H__
|
||||||
|
#define __CDIO_CDTEXT_PRIVATE_H__
|
||||||
|
|
||||||
|
#include <cdio/cdio.h>
|
||||||
|
|
||||||
|
#define CDIO_CDTEXT_MAX_PACK_DATA 255
|
||||||
|
#define CDIO_CDTEXT_MAX_TEXT_DATA 12
|
||||||
|
|
||||||
|
#define CDIO_CDTEXT_TITLE 0x80
|
||||||
|
#define CDIO_CDTEXT_PERFORMER 0x81
|
||||||
|
#define CDIO_CDTEXT_SONGWRITER 0x82
|
||||||
|
#define CDIO_CDTEXT_COMPOSER 0x83
|
||||||
|
#define CDIO_CDTEXT_ARRANGER 0x84
|
||||||
|
#define CDIO_CDTEXT_MESSAGE 0x85
|
||||||
|
#define CDIO_CDTEXT_DISCID 0x86
|
||||||
|
#define CDIO_CDTEXT_GENRE 0x87
|
||||||
|
|
||||||
|
PRAGMA_BEGIN_PACKED
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
struct CDText_data
|
||||||
|
{
|
||||||
|
uint8_t type;
|
||||||
|
track_t i_track;
|
||||||
|
uint8_t seq;
|
||||||
|
uint8_t characterPosition:4; /* character position */
|
||||||
|
uint8_t block:3; /* block number 0..7 */
|
||||||
|
uint8_t bDBC:1; /* double byte character */
|
||||||
|
char text[12];
|
||||||
|
uint8_t crc[2];
|
||||||
|
} GNUC_PACKED;
|
||||||
|
|
||||||
|
PRAGMA_END_PACKED
|
||||||
|
|
||||||
|
typedef struct CDText_data CDText_data_t;
|
||||||
|
|
||||||
|
#endif /* __CDIO_CDTEXT_PRIVATE_H__ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local variables:
|
||||||
|
* c-file-style: "gnu"
|
||||||
|
* tab-width: 8
|
||||||
|
* indent-tabs-mode: nil
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp $
|
$Id: bincue.c,v 1.24 2004/07/09 01:05:32 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
(*.cue).
|
(*.cue).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp $";
|
static const char _rcsid[] = "$Id: bincue.c,v 1.24 2004/07/09 01:05:32 rocky Exp $";
|
||||||
|
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
@@ -33,6 +33,7 @@ static const char _rcsid[] = "$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp
|
|||||||
#include <cdio/logging.h>
|
#include <cdio/logging.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
#include <cdio/util.h>
|
#include <cdio/util.h>
|
||||||
|
#include <cdio/cdtext.h>
|
||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#ifdef HAVE_STDIO_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -65,6 +66,37 @@ static const char _rcsid[] = "$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp
|
|||||||
#define DEFAULT_CDIO_DEVICE "videocd.bin"
|
#define DEFAULT_CDIO_DEVICE "videocd.bin"
|
||||||
#define DEFAULT_CDIO_CUE "videocd.cue"
|
#define DEFAULT_CDIO_CUE "videocd.cue"
|
||||||
|
|
||||||
|
/* track modes (Table 350) */
|
||||||
|
typedef enum {
|
||||||
|
AUDIO, /* 2352 byte block length */
|
||||||
|
MODE1, /* 2048 byte block length */
|
||||||
|
MODE1_RAW, /* 2352 byte block length */
|
||||||
|
MODE2, /* 2336 byte block length */
|
||||||
|
MODE2_FORM1, /* 2048 byte block length */
|
||||||
|
MODE2_FORM2, /* 2324 byte block length */
|
||||||
|
MODE2_FORM_MIX, /* 2336 byte block length */
|
||||||
|
MODE2_RAW /* 2352 byte block length */
|
||||||
|
} trackmode_t;
|
||||||
|
|
||||||
|
/* disc modes (5.29.2.8) */
|
||||||
|
typedef enum {
|
||||||
|
CD_DA, /* CD-DA */
|
||||||
|
CD_ROM, /* CD-ROM mode 1 */
|
||||||
|
CD_ROM_XA /* CD-ROM XA and CD-I */
|
||||||
|
} discmode_t;
|
||||||
|
|
||||||
|
/* track flags
|
||||||
|
* Q Sub-channel Control Field (4.2.3.3)
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
NONE = 0x00, /* no flags set */
|
||||||
|
PRE_EMPHASIS = 0x01, /* audio track recorded with pre-emphasis */
|
||||||
|
COPY_PERMITTED = 0x02, /* digital copy permitted */
|
||||||
|
DATA = 0x04, /* data track */
|
||||||
|
FOUR_CHANNEL_AUDIO = 0x08, /* 4 audio channels */
|
||||||
|
SCMS = 0x10 /* SCMS (5.29.2.7) */
|
||||||
|
} flag_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
track_t track_num; /* Probably is index+1 */
|
track_t track_num; /* Probably is index+1 */
|
||||||
msf_t start_msf;
|
msf_t start_msf;
|
||||||
@@ -73,9 +105,15 @@ typedef struct {
|
|||||||
int sec_count; /* Number of sectors in this track. Does not
|
int sec_count; /* Number of sectors in this track. Does not
|
||||||
include pregap */
|
include pregap */
|
||||||
int num_indices;
|
int num_indices;
|
||||||
int flags; /* "DCP", "4CH", "PRE" */
|
flag_t flags; /* "DCP", "4CH", "PRE" */
|
||||||
track_format_t track_format;
|
track_format_t track_format;
|
||||||
|
char *filename;
|
||||||
bool track_green;
|
bool track_green;
|
||||||
|
long int pregap; /* pre-gap with zero audio data */
|
||||||
|
char *isrc; /* IRSC Code (5.22.4) exactly 12 bytes */
|
||||||
|
cdtext_t *cdtext; /* CD-TEXT */
|
||||||
|
|
||||||
|
trackmode_t mode;
|
||||||
uint16_t datasize; /* How much is in the portion we return back? */
|
uint16_t datasize; /* How much is in the portion we return back? */
|
||||||
uint16_t datastart; /* Offset from begining that data starts */
|
uint16_t datastart; /* Offset from begining that data starts */
|
||||||
uint16_t endsize; /* How much stuff at the end to skip over. This
|
uint16_t endsize; /* How much stuff at the end to skip over. This
|
||||||
@@ -99,6 +137,8 @@ typedef struct {
|
|||||||
add 1 for leadout. */
|
add 1 for leadout. */
|
||||||
track_t i_tracks; /* number of tracks in image */
|
track_t i_tracks; /* number of tracks in image */
|
||||||
track_t i_first_track; /* track number of first track */
|
track_t i_first_track; /* track number of first track */
|
||||||
|
char *catalog;
|
||||||
|
cdtext_t *cdtext; /* CD-TEXT */
|
||||||
bool have_cue;
|
bool have_cue;
|
||||||
} _img_private_t;
|
} _img_private_t;
|
||||||
|
|
||||||
@@ -301,7 +341,154 @@ _stat_size_bincue (void *user_data)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAXLINE 512
|
#define MAXLINE 4096 /* maximum line length + 1 */
|
||||||
|
|
||||||
|
static void
|
||||||
|
parse_cue (_img_private_t *cd, char *line, int line_num)
|
||||||
|
{
|
||||||
|
char *keyword, *field;
|
||||||
|
int i = cd->i_tracks - 1;
|
||||||
|
|
||||||
|
if (NULL != (keyword = strtok (line, " \t\n\r"))) {
|
||||||
|
/* REM remarks ... */
|
||||||
|
if (0 == strcmp ("REM", keyword)) {
|
||||||
|
;
|
||||||
|
|
||||||
|
/* global section */
|
||||||
|
/* CATALOG ddddddddddddd */
|
||||||
|
} else if (0 == strcmp ("CATALOG", keyword)) {
|
||||||
|
if (-1 == i) {
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r")))
|
||||||
|
cd->catalog = strdup (field);
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r")))
|
||||||
|
fprintf (stderr, "%s: format error\n", keyword);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%d: only allowed in global section: %s\n",
|
||||||
|
line_num, keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FILE "<filename>" <BINARY|WAVE|other?> */
|
||||||
|
} else if (0 == strcmp ("FILE", keyword)) {
|
||||||
|
if (NULL != (field = strtok (NULL, "\"\t\n\r")))
|
||||||
|
cd->tocent[i + 1].filename = strdup (field);
|
||||||
|
else
|
||||||
|
fprintf (stderr, "%d: format error: %s\n", line_num, keyword);
|
||||||
|
|
||||||
|
/* TRACK N <mode> */
|
||||||
|
} else if (0 == strcmp ("TRACK", keyword)) {
|
||||||
|
i++;
|
||||||
|
cd->tocent[i].cdtext = NULL;
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r")))
|
||||||
|
; /* skip index number */
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r"))) {
|
||||||
|
if (0 == strcmp ("AUDIO", field))
|
||||||
|
cd->tocent[i].mode = AUDIO;
|
||||||
|
else if (0 == strcmp ("MODE1/2048", field))
|
||||||
|
cd->tocent[i].mode = MODE1;
|
||||||
|
else if (0 == strcmp ("MODE1/2352", field))
|
||||||
|
cd->tocent[i].mode = MODE1_RAW;
|
||||||
|
else if (0 == strcmp ("MODE2/2336", field))
|
||||||
|
cd->tocent[i].mode = MODE2;
|
||||||
|
else if (0 == strcmp ("MODE2/2048", field))
|
||||||
|
cd->tocent[i].mode = MODE2_FORM1;
|
||||||
|
else if (0 == strcmp ("MODE2/2324", field))
|
||||||
|
cd->tocent[i].mode = MODE2_FORM2;
|
||||||
|
else if (0 == strcmp ("MODE2/2336", field))
|
||||||
|
cd->tocent[i].mode = MODE2_FORM_MIX;
|
||||||
|
else if (0 == strcmp ("MODE2/2352", field))
|
||||||
|
cd->tocent[i].mode = MODE2_RAW;
|
||||||
|
else
|
||||||
|
fprintf (stderr, "%d: format error: %s\n", line_num, keyword);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%d: format error: %s\n", line_num, keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FLAGS flag1 flag2 ... */
|
||||||
|
} else if (0 == strcmp ("FLAGS", keyword)) {
|
||||||
|
if (0 <= i) {
|
||||||
|
while (NULL != (field = strtok (NULL, " \t\n\r"))) {
|
||||||
|
if (0 == strcmp ("PRE", field)) {
|
||||||
|
cd->tocent[i].flags |= PRE_EMPHASIS;
|
||||||
|
} else if (0 == strcmp ("DCP", field)) {
|
||||||
|
cd->tocent[i].flags |= COPY_PERMITTED;
|
||||||
|
} else if (0 == strcmp ("4CH", field)) {
|
||||||
|
cd->tocent[i].flags |= FOUR_CHANNEL_AUDIO;
|
||||||
|
} else if (0 == strcmp ("SCMS", field)) {
|
||||||
|
cd->tocent[i].flags |= SCMS;
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%d: format error: %s\n", line_num, keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%d: not allowed in global section: %s\n", line_num,
|
||||||
|
keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ISRC CCOOOYYSSSSS */
|
||||||
|
} else if (0 == strcmp ("ISRC", keyword)) {
|
||||||
|
if (0 <= i) {
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r")))
|
||||||
|
cd->tocent[i].isrc = strdup (field);
|
||||||
|
else
|
||||||
|
fprintf (stderr, "%d: format error: %s\n", line_num, keyword);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%d: not allowed in global section: %s\n",
|
||||||
|
line_num, keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PREGAP MM:SS:FF */
|
||||||
|
} else if (0 == strcmp ("PREGAP", keyword)) {
|
||||||
|
if (0 <= i) {
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r")))
|
||||||
|
cd->tocent[i].pregap = msf_frame_from_mmssff (field);
|
||||||
|
else
|
||||||
|
fprintf (stderr, "%d: format error: %s\n", line_num, keyword);
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r")))
|
||||||
|
fprintf (stderr, "%d: format error: %s\n", line_num, keyword);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%d: not allowed in global section: %s\n",
|
||||||
|
line_num, keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* INDEX [##] MM:SS:FF */
|
||||||
|
} else if (0 == strcmp ("INDEX", keyword)) {
|
||||||
|
if (0 <= i) {
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r")))
|
||||||
|
; /* skip index number */
|
||||||
|
if (NULL != (field = strtok (NULL, " \t\n\r")))
|
||||||
|
#if 0
|
||||||
|
// cd->tocent[i].indexes[cd->tocent[i].nindex++] = msf_frame_from_mmssff (field);
|
||||||
|
#else
|
||||||
|
;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
fprintf (stderr, "%d: format error: %s\n", line_num, keyword);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%d: not allowed in global section: %s\n",
|
||||||
|
line_num, keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CD-TEXT */
|
||||||
|
} else if (0 == cdtext_is_keyword (keyword)) {
|
||||||
|
if (-1 == i) {
|
||||||
|
if (NULL == cd->cdtext)
|
||||||
|
cd->cdtext = cdtext_init ();
|
||||||
|
cdtext_set (keyword, strtok (NULL, "\"\t\n\r"), cd->cdtext);
|
||||||
|
} else {
|
||||||
|
if (NULL == cd->tocent[i].cdtext)
|
||||||
|
cd->tocent[i].cdtext = cdtext_init ();
|
||||||
|
cdtext_set (keyword, strtok (NULL, "\"\t\n\r"), cd->tocent[i].cdtext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* unrecognized line */
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%d: warning: unrecognized keyword: %s\n",
|
||||||
|
line_num, keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cd->i_tracks = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
_bincue_image_read_cue (_img_private_t *env)
|
_bincue_image_read_cue (_img_private_t *env)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdrdao.c,v 1.10 2004/06/27 15:29:22 rocky Exp $
|
$Id: cdrdao.c,v 1.11 2004/07/09 01:05:32 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
toc reading routine adapted from cuetools
|
toc reading routine adapted from cuetools
|
||||||
@@ -25,7 +25,11 @@
|
|||||||
(*.cue).
|
(*.cue).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: cdrdao.c,v 1.10 2004/06/27 15:29:22 rocky Exp $";
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char _rcsid[] = "$Id: cdrdao.c,v 1.11 2004/07/09 01:05:32 rocky Exp $";
|
||||||
|
|
||||||
#include "cdio_assert.h"
|
#include "cdio_assert.h"
|
||||||
#include "cdio_private.h"
|
#include "cdio_private.h"
|
||||||
@@ -34,6 +38,7 @@ static const char _rcsid[] = "$Id: cdrdao.c,v 1.10 2004/06/27 15:29:22 rocky Exp
|
|||||||
#include <cdio/logging.h>
|
#include <cdio/logging.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
#include <cdio/util.h>
|
#include <cdio/util.h>
|
||||||
|
#include <cdio/cdtext.h>
|
||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#ifdef HAVE_STDIO_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -119,37 +124,6 @@ static bool parse_tocfile (_img_private_t *cd, const char *toc_name);
|
|||||||
|
|
||||||
#include "image_common.h"
|
#include "image_common.h"
|
||||||
|
|
||||||
/* returns 0 if field is a CD-TEXT keyword, returns non-zero otherwise */
|
|
||||||
static int
|
|
||||||
cdtext_is_keyword (char *key)
|
|
||||||
{
|
|
||||||
const char *cdtext_keywords[] =
|
|
||||||
{
|
|
||||||
"ARRANGER", /* name(s) of the arranger(s) */
|
|
||||||
"COMPOSER", /* name(s) of the composer(s) */
|
|
||||||
"DISC ID", /* disc identification information */
|
|
||||||
"GENRE", /* genre identification and genre information */
|
|
||||||
"ISRC", /* ISRC code of each track */
|
|
||||||
"MESSAGE", /* message(s) from the content provider and/or artist */
|
|
||||||
"PERFORMER", /* name(s) of the performer(s) */
|
|
||||||
"SIZE_INFO", /* size information of the block */
|
|
||||||
"SONGWRITER", /* name(s) of the songwriter(s) */
|
|
||||||
"TITLE", /* title of album name or track titles */
|
|
||||||
"TOC_INFO", /* table of contents information */
|
|
||||||
"TOC_INFO2" /* second table of contents information */
|
|
||||||
"UPC_EAN",
|
|
||||||
};
|
|
||||||
|
|
||||||
char *item;
|
|
||||||
|
|
||||||
item = bsearch(key,
|
|
||||||
cdtext_keywords, 12,
|
|
||||||
sizeof (char *),
|
|
||||||
(int (*)(const void *, const void *))
|
|
||||||
strcmp);
|
|
||||||
return (NULL != item) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static lba_t
|
static lba_t
|
||||||
msf_to_lba (int minutes, int seconds, int frames)
|
msf_to_lba (int minutes, int seconds, int frames)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user