Go over documentation yet again. In particular:

Move section on image formats out of Appendix and expand.

Add a chapter on program internals

glossary: add item to concept index and regularize index names.
This commit is contained in:
rocky
2005-01-28 04:15:15 +00:00
parent 5586d10367
commit df27526f2e
2 changed files with 459 additions and 203 deletions

View File

@@ -46,7 +46,7 @@ development.''
@titlepage
@title GNU libcdio library
@subtitle $Id: libcdio.texi,v 1.31 2005/01/24 08:33:57 rocky Exp $
@subtitle $Id: libcdio.texi,v 1.32 2005/01/28 04:15:15 rocky Exp $
@author Rocky Bernstein et al.
@page
@@ -83,14 +83,15 @@ Copyright (C) 2003, 2004, 2005 Rocky Bernstein and Herbert Valerio Riedel
* Previous Work:: The problem and previous work
* Purpose:: What is in this package (and what's not)
* CD Formats:: A tour through the CD-specification spectrum
* CD Image Formats:: A tour through various CD-image formats
* CD Units:: The units that make up a CD
* How to use:: Okay enough babble, lemme at the library!
* Utility Programs:: Diagnostic programs that come with this library
* OS Considerations:: Operating System Considerations and Drivers
* Internal Program Organization:: Looking under the hood
Appendices
* ISO-9660 Character Sets::
* CD Image Formats::
* Glossary::
* GNU General Public License::
* GNU Free Documentation License::
@@ -529,7 +530,7 @@ System semantics.
@node Joliet Extensions
@subsubsection Joliet Extensions
@cindex Joliet Extensions
@cindex Joliet extensions
Joliet extensions were an upward-compatible extension to the ISO 9660
specification that removes the limitation initially put in to deal
@@ -621,6 +622,221 @@ In @value{libcdio} when you you want to read a mode2 format 2 audio
sector you call the @code{cdio_read_mode2_sector()} or
@code{cdio_read_mode2_sectors()} setting @code{b_form2} to @code{true}.
@node CD Image Formats
@chapter CD Image Formats
@menu
* CDRDAO TOC Format::
* CDRWIN BIN/CUE Format::
* NRG Format::
@end menu
In both the @command{cdrdao} and bin/cue formats there is one meta-file with
extensions @code{.toc} or @code{.cue} respectively and one or more
files (often with the extension @code{.bin}) which contains the
content of tracks. The format of the track data is often
interchangeable between the two formats. For example, in
@value{libcdio}'s regression tests we make use of this to reduce the
size of the test data and just provide alternate meta-data files
(@code{.toc} or @code{.cue}).
In contrast to the first two formats, the NRG format consists of a
single file. This has the advantage of being a self-contained
units. It is possible in the other two formats for the meta file to
refer to a file that can't be found. A disadvantage of the NRG format
is that the meta data can't be easily viewed or modified say in a text
file as it can be with the first two formats. In conjunction with this
disadvantage is another disadvantage that the format is not
documented, so how @value{libcdio} interprets an NRG image is based on
inference. It is recommended that one of the other forms be used
instead of NRG where possible.
@node CDRDAO TOC Format
@section CDRDAO TOC Format
This is @command{cdrdao}'s CD-image description format. Since this
program is GPL and everything about it is in the open, it is the
preferred format to use. (Alas, at present it isn't as well supported
in @value{libcdio} as the BIN/CUE format.)
The @emph{toc}-file describes what data is written to the media in the
@acronym{CD-ROM}; it allows control over track/index positions,
pre-gaps and sub-channel information. It is a text file, so a text
editor can be used to create, view or modify it.
The @cite{cdrdao(1) manual page}, contains more information about this
format.
@subsection CDRDAO Grammar
Here is a list of lexical tokens taken from the cdrdao grammar.
@example
#lexclass START
#token Eof "@@"
#token "[\t\r\ ]+"
#token Comment "//~[\n@@]*"
#token "\n"
#token BeginString "\""
#token Integer "[0-9]+"
#token Index "INDEX"
#tokclass AudioFile @{ "AUDIOFILE" "FILE" @}
#lexclass STRING
#token EndString "\""
#token StringQuote "\\\""
#token StringOctal "\\[0-9][0-9][0-9]"
#token String "\\"
#token String "[ ]+"
#token String "~[\\\n\"\t ]*"
@end example
@example
toc ::= ( "CATALOG" string | tocType )* @{ cdTextGlobal @} ( track )+ Eof
track ::= "TRACK" trackMode
@{ subChannelMode @}
( "ISRC" string | @{ "NO" @} "COPY" | @{ "NO" @} "PRE_EMPHASIS"
| "TWO_CHANNEL_AUDIO" | "FOUR_CHANNEL_AUDIO" )*
@{ cdTextTrack @}
@{ "PREGAP" msf @}
( subTrack | "START" | "END" )+
( Index msf )*
subTrack ::=
( AudioFile string @{ "SWAP" @} @{ "#" sLong @} samples
| "DATAFILE" string @{ "#" sLong @{ dataLength @} @}
| "FIFO" string dataLength
| "SILENCE" samples
| "ZERO" @{ dataMode @} @{ subChannelMode @} dataLength
)
string ::= BeginString ( ( String | StringQuote | StringOctal ) )+
EndString
stringEmpty ::= BeginString ( ( String | StringQuote | StringOctal ) )*
EndString
uLong ::= Integer
sLong ::= Integer
msf ::= Integer ":" Integer ":" Integer
samples ::= ( msf | uLong )
dataLength ::= ( msf | uLong )
dataMode ::= ( "AUDIO" | "MODE0" | "MODE1" | "MODE1_RAW" | "MODE2"
| "MODE2_RAW" | "MODE2_FORM1" | "MODE2_FORM2" | "MODE2_FORM_MIX" )
trackMode ::= ( "AUDIO" | "MODE1" | "MODE1_RAW" | "MODE2"
| "MODE2_RAW" | "MODE2_FORM1" | "MODE2_FORM2" | "MODE2_FORM_MIX" )
subChannelMode ::= ( "RW" | "RW_RAW" )
tocType ::= ( "CD_DA" | "CD_ROM" | "CD_ROM_XA" | "CD_I" )
packType ::= ( "TITLE" | "PERFORMER" | "SONGWRITER" | "COMPOSER" | "ARRANGER"
| "MESSAGE" | "DISC_ID" | "GENRE" | "TOC_INFO1" | "TOC_INFO2"
| "RESERVED1" | "RESERVED2" | "RESERVED3" | "RESERVED4" | "UPC_EAN" |
"ISRC" | "SIZE_INFO" )
binaryData ::= "\@{"
@{ Integer ( "," Integer )* @}
"\@}"
cdTextItem ::= packType ( stringEmpty | binaryData )
cdTextBlock ::= "LANGUAGE" Integer "\@{" ( cdTextItem )* "\@}"
cdTextLanguageMap ::=
LanguageMap "\@{"
( Integer ":" ( Integer | "EN" ) )+
"\@}"
cdTextTrack ::= "CD_TEXT" "\@{" ( cdTextBlock )* "\@}"
cdTextGlobal ::= "CD_TEXT" "\@{" @{ cdTextLanguageMap @} ( cdTextBlock )* "\@}"
@end example
@node CDRWIN BIN/CUE Format
@section CDRWIN BIN/CUE Format
@cindex BIN/CUE, CD Image Format
The format referred to as @emph{CDRWIN BIN/CUE Format} in this manual
is a popular CD image format used in the @acronym{PC} world. Not
unlike @command{cdrdao}'s toc file, the @emph{cue} file describes the
track layout, i.e. how the sectors are to be placed on the CD
media. The @emph{cue} file usually contains a reference to a file
traditionally having the @file{.bin} extension in its filename, the
@emph{bin} file. This @emph{bin} file contains the sector data payload
which is to be written to the CD medium according to the description
in the @emph{cue} file.
The following is an attempt to describe the subset of the @file{.cue}
file syntax used in @value{libcdio} and vcdimager in an EBNF-like
notation:
@subsection BIN/CUE Grammar
@example
@cartouche
<cue-document> ::= +( <file-line> +<track-expr> )
<digit> ::= "0" | "1" ... "8" | "9"
<number> ::= +<digit>
<msf> ::= <digit><digit> ":" <digit><digit> ":" <digit><digit>
<file-line> ::= "FILE" <pathname-expr> <file-type> <EOL>
<pathname-expr> ::= [ "\"" ] <pathname-str-without-spaces> [ "\"" ]
| "\"" <pathname-str> "\""
<file-type> ::= "BINARY"
<track-expr> ::= <track-line> [ <flag-line> ]
[ <pregap-line> ] *<index-line> [ <postgap-line> ]
<flag-line> ::= "FLAGS" *<flag-type> <EOL>
<flag-type> ::= "DCP"
<track-line> ::= "TRACK" <number> <track-type> <EOL>
<pregap-line> ::= "PREGAP" <msf> <EOL>
<index-line> ::= "INDEX" <number> <msf> <EOL>
<postgap-line> ::= "POSTGAP" <msf> <EOL>
<track-type> ::= "AUDIO" | "MODE1/2048" | "MODE1/2352"
| "MODE2/2336" | "MODE2/2352"
<comment-line> ::= "REM" *<char> <EOL>
@end cartouche
@end example
@node NRG Format
@section NRG Format
@cindex Nero NRG, CD-Image format
The format referred to as @emph{NRG Format} in this manual is another
popular CD image format. It is available only on Nero software
on a Microsoft Windows Operating System. It is proprietary and not
generally published, so the information we have comes from guessing
based on sample CD images. So support for this is incomplete and using
this format is not recommended.
Unlike @command{cdrdao}'s TOC file the BIN/CUE format everything is
contained in one file. that one can edit Meta information such as the
number of tracks and track format is contained at the end of the
file. This information is not inteded to be edited through a text
editor.
@node CD Units
@chapter The units that make up a CD
@@ -631,7 +847,8 @@ sector you call the @code{cdio_read_mode2_sector()} or
@node Tracks
@section tracks --- disc subdivisions
@cindex tracks
@cindex track
In this section we describe CD properties and terms that we make use
of in @value{libcdio}.
@@ -1616,10 +1833,181 @@ More work on this driver is needed. Volunteers?
A problem with OS/X is that if the OS thinks it understands the drive
it gains exclusive access to it and thus prevents a library like this
to get non-exclusive access.
to get non-exclusive access.
Currently @value{libcdio} access the CD-ROM non-exclusively. However
in order to be able to issue SCSI-MMC, the current belief is that
exclusive access is needed. Probably in a future @value{libcdio},
there will be some way to specify which kind of access is desired
(with the inherent consequences of each).
More work on this driver is needed. Volunteers?
@node Internal Program Organization
@chapter Internal Program Organization
@subsection file organization
Here is a list of @value{libcdio} directories.
@itemize
@item @code{include/cdio}
This contains the headers that are public. One that will probably be
used quite a bit is @code{<cdio/cdio.h>}.
@item @code{lib}
Code for installed libraries. See below for further breakout
@item @code{lib/driver}
Code for various OS-specific CD-ROM drivers, image drivers, and
common SCSI-MMC routines.
This code comprises @code{libcdio.a} (or the shared version of it).
@item @code{lib/iso9660}
Code for to extract or query ISO-9660 images.
This code comprises @code{libiso9660.a} (or the shared version of it).
@item @code{lib/paranoia}
This is from cdparanoia. It is the OS- and hardware- dependent code to
detect and correct jitter for CD-DA CDs.
@item @code{lib/cdda_interface}
This is also from cdparanoia. It is the OS- and hardware- independent
code to detect and correct jitter for CD-DA CDs.
@item @code{doc}
A home for fine documentation such as this masterpiece.
@item @code{example}
Here you will find various small example programs using
@value{libcdio} which are largely for pedagogical purposes. You might
be able to find one that is similar to what you want to do that could
be extended. In fact some these are contain the kernel ideas behind of
some of the larger programs in @file{src}.
@item @code{src}
Various stand-alone utility programs. See below.
@item @code{src/paranoia}
@value{libcdio}'s version of @code{cdparanoia}. Except for the fact
that the back-end CD-reading code has been replaced by
@value{libcdio}'s routines the code is pretty much identical.
@item @code{test}
Regression tests
@end itemize
@subsection libcdio
@value{libcdio} exports one opaque type @code{CdIo_t}. Internally this
an enumeration for the driver, a structure containing function
pointers and a generic ``environment'' pointer which is passed as a
parameter on a function call. See
@file{lib/driver/cdio_private.h}. The initialization routine for each
driver sets up the function pointers and allocates memory for the
environment. When a particular user-level cdio routine is called (e.g
@code{cdio_get_first_track_num} for lib/driver/track.c), the
environment pointer is passed to a device-specific routine which will
then cast this pointer into something of the appropriate type.
Because function pointers are used, there can be and is quite a bit
of sharing of common routines. Some of the common routines are found
in the file @file{lib/driver/_cdio_generic.c}.
Another set of routines that one is likely to find shared amongst
drivers are the SCSI-MMC commands. These are located in
@file{lib/driver/scsi_mmc.c}.
There not only an attempt to share functions but we've tried to create
a generic CD structure @code{generic_img_private_t} of file
@file{lib/driver/generic.h}. By putting information into a common
structure, we increase the likelihood of being able to have a common
routine to perform some sort of function.
The generic CD structure would also be useful in a utility to convert
one CD-image format to another. Basically the first image format is
``parsed'' into the common internal format and then from this
structure it is unparsed.
@subsection libiso9660
To be completed....
@subsection Coding Conventions
In @value{libcdio} there are a number of conventions used. If you
understand some of these conventions it may facilitate understanding
the code a little.
@subsubsection variable names
A number of prefixes are used in variable names here's what they mean
@itemize
@item @code{i_}
An integer type of some sort. A variable of this ilk one might find
being iterated over in @code{for} loops or used as the index of an
array for example.
@item @code{b_}
A boolean type of some sort. A variable of this ilk one might find
being in an @code{if} condition for example.
@item @code{p_}
A pointer of some sort. A variable of this ilk, say
@code{p_foo} one is like likely to see @code{*p_foo} or
@code{p_foo->...}.
@item @code{pp_}
A pointer to a pointer of some sort. A variable of this ilk, say
@code{pp_foo} one is like likely to see @code{**p_foo} or
@code{p_foo[x][y]} for example
@item @code{psz_}
A @code{char *} pointer of some sort. A variable of this ilk, say
@code{psz_foo} may be used in a string operation. For example
@code{printf(%s\n", psz_foo)} or @code{strdup(psz_foo)}.
@item @code{ppsz_}
A pointer to a @code{char *} pointer of some sort. A variable of this
ilk, say @code{ppsz_foo} is used for example to return a list of
CD-ROM device names
@end itemize
A couple other name conventions. Generally if a routine name starts
@code{cdio_}, e.g. @code{cdio_open}, then it is an externally
visable routine in @code{libcdio}. If a name starts @code{iso9660_},
e.g. @code{iso9660_isdchar} then it is an externally visable routine
in @code{libiso9660}. If a name starts @code{scsi_mmc_},
e.g. @code{scsi_mmc_get_discmode}, then it is an externally visable
SCSI-MMC routine. (We don't have a separate library for this yet.
Names in captal letters only that start @code{CDIO_} are externally
visable @code{#defines}.
@node ISO-9660 Character Sets
@appendix ISO-9660 Character Sets
@@ -1678,199 +2066,7 @@ e | . > N
f | / ? O _
@end example
@node CD Image Formats
@appendix CD Image Formats
@menu
* CDRDAO TOC Format::
* CDRWIN BIN/CUE Format::
* NRG Format::
@end menu
@node CDRDAO TOC Format
@appendixsec CDRDAO TOC Format
This is @command{cdrdao}'s own cd image description format. Since this
program is GPL and everything about it is in the open, it is the
preferred format to use. (Alas, at present it isn't as well supported
in @value{libcdio} as the BIN/CUE format.)
A snippet from the @cite{cdrdao(1) manual page}, which you should
refer to for more information about this format:
@quotation
The @emph{toc}-file describes what data is written to the
@acronym{CD-R} and allows control over track/index positions, pre-gaps
and sub-channel information. It is a simple text file, use your
favorite text editor to create it.
@end quotation
Here is a list of lexical tokens taken from the cdrdao grammar.
@example
#lexclass START
#token Eof "@@"
#token "[\t\r\ ]+"
#token Comment "//~[\n@@]*"
#token "\n"
#token BeginString "\""
#token Integer "[0-9]+"
#token Index "INDEX"
#tokclass AudioFile @{ "AUDIOFILE" "FILE" @}
#lexclass STRING
#token EndString "\""
#token StringQuote "\\\""
#token StringOctal "\\[0-9][0-9][0-9]"
#token String "\\"
#token String "[ ]+"
#token String "~[\\\n\"\t ]*"
@end example
@example
toc ::= ( "CATALOG" string | tocType )* @{ cdTextGlobal @} ( track )+ Eof
track ::= "TRACK" trackMode
@{ subChannelMode @}
( "ISRC" string | @{ "NO" @} "COPY" | @{ "NO" @} "PRE_EMPHASIS"
| "TWO_CHANNEL_AUDIO" | "FOUR_CHANNEL_AUDIO" )*
@{ cdTextTrack @}
@{ "PREGAP" msf @}
( subTrack | "START" | "END" )+
( Index msf )*
subTrack ::=
( AudioFile string @{ "SWAP" @} @{ "#" sLong @} samples
| "DATAFILE" string @{ "#" sLong @{ dataLength @} @}
| "FIFO" string dataLength
| "SILENCE" samples
| "ZERO" @{ dataMode @} @{ subChannelMode @} dataLength
)
string ::= BeginString ( ( String | StringQuote | StringOctal ) )+
EndString
stringEmpty ::= BeginString ( ( String | StringQuote | StringOctal ) )*
EndString
uLong ::= Integer
sLong ::= Integer
msf ::= Integer ":" Integer ":" Integer
samples ::= ( msf | uLong )
dataLength ::= ( msf | uLong )
dataMode ::= ( "AUDIO" | "MODE0" | "MODE1" | "MODE1_RAW" | "MODE2"
| "MODE2_RAW" | "MODE2_FORM1" | "MODE2_FORM2" | "MODE2_FORM_MIX" )
trackMode ::= ( "AUDIO" | "MODE1" | "MODE1_RAW" | "MODE2"
| "MODE2_RAW" | "MODE2_FORM1" | "MODE2_FORM2" | "MODE2_FORM_MIX" )
subChannelMode ::= ( "RW" | "RW_RAW" )
tocType ::= ( "CD_DA" | "CD_ROM" | "CD_ROM_XA" | "CD_I" )
packType ::= ( "TITLE" | "PERFORMER" | "SONGWRITER" | "COMPOSER" | "ARRANGER"
| "MESSAGE" | "DISC_ID" | "GENRE" | "TOC_INFO1" | "TOC_INFO2"
| "RESERVED1" | "RESERVED2" | "RESERVED3" | "RESERVED4" | "UPC_EAN" |
"ISRC" | "SIZE_INFO" )
binaryData ::= "\@{"
@{ Integer ( "," Integer )* @}
"\@}"
cdTextItem ::= packType ( stringEmpty | binaryData )
cdTextBlock ::= "LANGUAGE" Integer "\@{" ( cdTextItem )* "\@}"
cdTextLanguageMap ::=
LanguageMap "\@{"
( Integer ":" ( Integer | "EN" ) )+
"\@}"
cdTextTrack ::= "CD_TEXT" "\@{" ( cdTextBlock )* "\@}"
cdTextGlobal ::= "CD_TEXT" "\@{" @{ cdTextLanguageMap @} ( cdTextBlock )* "\@}"
@end example
@node CDRWIN BIN/CUE Format
@appendixsec CDRWIN BIN/CUE Format
@cindex BIN/CUE, CD Image Format
The format referred to as @emph{CDRWIN BIN/CUE Format} in this manual
is a popular CD image format used in the @acronym{PC} world. Not
unlike @command{cdrdao}'s toc file, the @emph{cue} file describes the
track layout, i.e. how the sectors are to be placed on the CD
media. The @emph{cue} file usually contains a reference to a file
traditionally having the @file{.bin} extension in its filename, the
@emph{bin} file. This @emph{bin} file contains the sector data payload
which is to be written to the CD medium according to the description
in the @emph{cue} file.
The following is an attempt to describe the subset of the @file{.cue}
file syntax as used in vcdimager in an EBNF-like notation:
@example
@cartouche
<cue-document> ::= +( <file-line> +<track-expr> )
<digit> ::= "0" | "1" ... "8" | "9"
<number> ::= +<digit>
<msf> ::= <digit><digit> ":" <digit><digit> ":" <digit><digit>
<file-line> ::= "FILE" <pathname-expr> <file-type> <EOL>
<pathname-expr> ::= [ "\"" ] <pathname-str-without-spaces> [ "\"" ]
| "\"" <pathname-str> "\""
<file-type> ::= "BINARY"
<track-expr> ::= <track-line> [ <flag-line> ]
[ <pregap-line> ] *<index-line> [ <postgap-line> ]
<flag-line> ::= "FLAGS" *<flag-type> <EOL>
<flag-type> ::= "DCP"
<track-line> ::= "TRACK" <number> <track-type> <EOL>
<pregap-line> ::= "PREGAP" <msf> <EOL>
<index-line> ::= "INDEX" <number> <msf> <EOL>
<postgap-line> ::= "POSTGAP" <msf> <EOL>
<track-type> ::= "AUDIO" | "MODE1/2048" | "MODE1/2352"
| "MODE2/2336" | "MODE2/2352"
<comment-line> ::= "REM" *<char> <EOL>
@end cartouche
@end example
@node NRG Format
@appendixsec NRG Format
@cindex NRG, CD Image Format
The format referred to as @emph{NRG Format} in this manual is another
popular CD image format. It is available only on Nero software
on a Microsoft Windows Operating System. It is proprietary and not
generally published, so the information we have comes from guessing
based on sample CD images. So support for this is incomplete and using
this format is not recommended.
Unlike @command{cdrdao}'s TOC file the BIN/CUE format everything is
contained in one file. that one can edit Meta information such as the
number of tracks and track format is contained at the end of the
file. This information is not inteded to be edited through a text
editor.
@node Glossary, GNU General Public License, CD Image Formats, Top
@node Glossary
@appendix Glossary
@include glossary.texi