libburn  1.2.2
libburn.h
Go to the documentation of this file.
00001 /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
00002 
00003 /* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
00004    Copyright (c) 2006 - 2012 Thomas Schmitt <scdbackup@gmx.net>
00005    Provided under GPL version 2 or later.
00006 
00007    This is the official API definition of libburn.
00008 
00009 */
00010 /* Important: If you add a public API function then add its name to file
00011                  libburn/libburn.ver
00012 */
00013 
00014 
00015 #ifndef LIBBURN_H
00016 #define LIBBURN_H
00017 
00018 /* 
00019 
00020 Applications must use 64 bit off_t. E.g. by defining
00021   #define _LARGEFILE_SOURCE
00022   #define _FILE_OFFSET_BITS 64
00023 or take special precautions to interface with the library by 64 bit integers
00024 where this .h files prescribe off_t.
00025 
00026 To prevent 64 bit file i/o in the library would keep the application from
00027 processing tracks of more than 2 GB size.
00028 
00029 */
00030 #include <sys/types.h>
00031 
00032 #ifndef DOXYGEN
00033 
00034 #if defined(__cplusplus)
00035 #define BURN_BEGIN_DECLS \
00036     namespace burn { \
00037         extern "C" {
00038 #define BURN_END_DECLS \
00039         } \
00040     }
00041 #else
00042 #define BURN_BEGIN_DECLS
00043 #define BURN_END_DECLS
00044 #endif
00045 
00046 BURN_BEGIN_DECLS
00047 
00048 #endif
00049 
00050 /** References a physical drive in the system */
00051 struct burn_drive;
00052 
00053 /** References a whole disc */
00054 struct burn_disc;
00055 
00056 /** References a single session on a disc */
00057 struct burn_session;
00058 
00059 /** References a single track on a disc */
00060 struct burn_track;
00061 
00062 /* ts A61111 */
00063 /** References a set of write parameters */
00064 struct burn_write_opts;
00065 
00066 /** Session format for normal audio or data discs */
00067 #define BURN_CDROM  0
00068 /** Session format for obsolete CD-I discs */
00069 #define BURN_CDI    0x10
00070 /** Session format for CDROM-XA discs */
00071 #define BURN_CDXA   0x20
00072 
00073 #define BURN_POS_END 100
00074 
00075 /** Mask for mode bits */
00076 #define BURN_MODE_BITS 127
00077 
00078 /** Track mode - mode 0 data
00079     0 bytes of user data.  it's all 0s.  mode 0.  get it?  HAH
00080 */
00081 #define BURN_MODE0      (1 << 0)
00082 /** Track mode - mode "raw" - all 2352 bytes supplied by app
00083     FOR DATA TRACKS ONLY!
00084 */
00085 #define BURN_MODE_RAW       (1 << 1)
00086 /** Track mode - mode 1 data
00087     2048 bytes user data, and all the LEC money can buy
00088 */
00089 #define BURN_MODE1      (1 << 2)
00090 /** Track mode - mode 2 data
00091     defaults to formless, 2336 bytes of user data, unprotected
00092     | with a data form if required.
00093 */
00094 #define BURN_MODE2      (1 << 3)
00095 /** Track mode modifier - Form 1, | with MODE2 for reasonable results
00096     2048 bytes of user data, 4 bytes of subheader
00097 */
00098 #define BURN_FORM1      (1 << 4)
00099 /** Track mode modifier - Form 2, | with MODE2 for reasonable results
00100     lots of user data.  not much LEC.
00101 */
00102 #define BURN_FORM2      (1 << 5)
00103 /** Track mode - audio
00104     2352 bytes per sector.  may be | with 4ch or preemphasis.
00105     NOT TO BE CONFUSED WITH BURN_MODE_RAW
00106     Audio data must be 44100Hz 16bit stereo with no riff or other header at
00107     beginning.  Extra header data will cause pops or clicks.  Audio data should
00108     also be in little-endian byte order.  Big-endian audio data causes static.
00109 */
00110 #define BURN_AUDIO      (1 << 6)
00111 /** Track mode modifier - 4 channel audio. */
00112 #define BURN_4CH        (1 << 7)
00113 /** Track mode modifier - Digital copy permitted, can be set on any track.*/
00114 #define BURN_COPY       (1 << 8)
00115 /** Track mode modifier - 50/15uS pre-emphasis */
00116 #define BURN_PREEMPHASIS    (1 << 9)
00117 /** Input mode modifier - subcodes present packed 16 */
00118 #define BURN_SUBCODE_P16    (1 << 10)
00119 /** Input mode modifier - subcodes present packed 96 */
00120 #define BURN_SUBCODE_P96    (1 << 11)
00121 /** Input mode modifier - subcodes present raw 96 */
00122 #define BURN_SUBCODE_R96    (1 << 12)
00123 
00124 /* ts B11230 */
00125 /** Track mode modifier - Serial Copy Management System, SAO only
00126     If this is set and BURN_COPY is not set, then copying the emerging
00127     track will be forbidden.
00128     @since 1.2.0
00129 */
00130 #define BURN_SCMS       (1 << 13)
00131 
00132 
00133 /** Possible disc writing style/modes */
00134 enum burn_write_types
00135 {
00136     /** Packet writing.
00137           currently unsupported, (for DVD Incremental Streaming use TAO)
00138     */
00139     BURN_WRITE_PACKET,
00140 
00141     /** With CD:                     Track At Once recording
00142           2s gaps between tracks, no fonky lead-ins
00143 
00144         With sequential DVD-R[W]:    Incremental Streaming
00145         With DVD+R and BD-R:         Track of open size
00146         With DVD-RAM, DVD+RW, BD-RE: Random Writeable (used sequentially)
00147         With overwriteable DVD-RW:   Rigid Restricted Overwrite 
00148     */
00149     BURN_WRITE_TAO,
00150 
00151     /** With CD:                     Session At Once
00152           Block type MUST be BURN_BLOCK_SAO
00153           ts A70122: Currently not capable of mixing data and audio tracks.
00154 
00155         With sequential DVD-R[W]:    Disc-at-once, DAO
00156           Single session, single track, fixed size mandatory, (-dvd-compat)
00157         With other DVD or BD media:  same as BURN_WRITE_TAO but may demand
00158                                      that track size is known in advance.
00159     */
00160     BURN_WRITE_SAO,
00161 
00162     /** With CD: Raw disc at once recording.
00163           all subcodes must be provided by lib or user
00164           only raw block types are supported
00165         With DVD and BD media: not supported.
00166 
00167         ts A90901: This had been disabled because its implementation
00168                    relied on code from cdrdao which is not understood
00169                    currently.
00170                    A burn run will abort with "FATAL" error message
00171                    if this mode is attempted.
00172                    @since 0.7.2
00173         ts A91016: Re-implemented according to ECMA-130 Annex A and B.
00174                    Now understood, explained and not stemming from cdrdao.
00175                    @since 0.7.4
00176     */
00177     BURN_WRITE_RAW,
00178 
00179     /** In replies this indicates that not any writing will work.
00180         As parameter for inquiries it indicates that no particular write
00181             mode shall is specified.
00182         Do not use for setting a write mode for burning. It will not work.
00183     */
00184     BURN_WRITE_NONE
00185 };
00186 
00187 /** Data format to send to the drive */
00188 enum burn_block_types
00189 {
00190     /** sync, headers, edc/ecc provided by lib/user */
00191     BURN_BLOCK_RAW0 = 1,
00192     /** sync, headers, edc/ecc and p/q subs provided by lib/user */
00193     BURN_BLOCK_RAW16 = 2,
00194     /** sync, headers, edc/ecc and packed p-w subs provided by lib/user */
00195     BURN_BLOCK_RAW96P = 4,
00196     /** sync, headers, edc/ecc and raw p-w subs provided by lib/user */
00197     BURN_BLOCK_RAW96R = 8,
00198     /** only 2048 bytes of user data provided by lib/user */
00199     BURN_BLOCK_MODE1 = 256,
00200     /** 2336 bytes of user data provided by lib/user */
00201     BURN_BLOCK_MODE2R = 512,
00202     /** 2048 bytes of user data provided by lib/user
00203         subheader provided in write parameters
00204         are we ever going to support this shit?  I vote no.
00205         (supposed to be supported on all drives...)
00206     */
00207     BURN_BLOCK_MODE2_PATHETIC = 1024,
00208     /** 2048 bytes of data + 8 byte subheader provided by lib/user
00209         hey, this is also dumb
00210     */
00211     BURN_BLOCK_MODE2_LAME = 2048,
00212     /** 2324 bytes of data provided by lib/user
00213         subheader provided in write parameters
00214         no sir, I don't like it.
00215     */
00216     BURN_BLOCK_MODE2_OBSCURE = 4096,
00217     /** 2332 bytes of data supplied by lib/user
00218         8 bytes sub header provided in write parameters
00219         this is the second least suck mode2, and is mandatory for
00220         all drives to support.
00221     */
00222     BURN_BLOCK_MODE2_OK = 8192,
00223     /** SAO block sizes are based on cue sheet, so use this. */
00224     BURN_BLOCK_SAO = 16384
00225 };
00226 
00227 /** Possible status of the drive in regard to the disc in it. */
00228 enum burn_disc_status
00229 {
00230     /** The current status is not yet known */
00231     BURN_DISC_UNREADY,
00232 
00233     /** The drive holds a blank disc. It is ready for writing from scratch.
00234         Unused multi-session media:
00235           CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, BD-R
00236         Blanked multi-session media (i.e. treated by burn_disc_erase())
00237           CD-RW, DVD-RW
00238         Overwriteable media with or without valid data
00239           DVD-RAM, DVD+RW, formatted DVD-RW, BD-RE
00240     */
00241     BURN_DISC_BLANK,
00242 
00243     /** There is no disc at all in the drive */
00244     BURN_DISC_EMPTY,
00245 
00246     /** There is an incomplete disc in the drive. It is ready for appending
00247         another session.
00248         Written but not yet closed multi-session media
00249           CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, BD-R
00250     */
00251     BURN_DISC_APPENDABLE,
00252 
00253     /** There is a disc with data on it in the drive. It is usable only for
00254         reading.
00255         Written and closed multi-session media
00256           CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, BD-R
00257         Read-Only media
00258           CD-ROM, DVD-ROM, BD-ROM
00259         Note that many DVD-ROM drives report any written media
00260         as Read-Only media and not by their real media types.
00261     */
00262     BURN_DISC_FULL,
00263 
00264     /* ts A61007 */
00265         /* @since 0.2.4 */
00266     /** The drive was not grabbed when the status was inquired */
00267     BURN_DISC_UNGRABBED,
00268 
00269     /* ts A61020 */
00270         /* @since 0.2.6 */
00271     /** The media seems to be unsuitable for reading and for writing */
00272     BURN_DISC_UNSUITABLE
00273 };
00274 
00275 
00276 /** Possible data source return values */
00277 enum burn_source_status
00278 {
00279     /** The source is ok */
00280     BURN_SOURCE_OK,
00281     /** The source is at end of file */
00282     BURN_SOURCE_EOF,
00283     /** The source is unusable */
00284     BURN_SOURCE_FAILED
00285 };
00286 
00287 
00288 /** Possible busy states for a drive */
00289 enum burn_drive_status
00290 {
00291     /** The drive is not in an operation */
00292     BURN_DRIVE_IDLE,
00293     /** The library is spawning the processes to handle a pending
00294         operation (A read/write/etc is about to start but hasn't quite
00295         yet) */
00296     BURN_DRIVE_SPAWNING,
00297     /** The drive is reading data from a disc */
00298     BURN_DRIVE_READING,
00299     /** The drive is writing data to a disc */
00300     BURN_DRIVE_WRITING,
00301     /** The drive is writing Lead-In */
00302     BURN_DRIVE_WRITING_LEADIN,
00303     /** The drive is writing Lead-Out */
00304     BURN_DRIVE_WRITING_LEADOUT,
00305     /** The drive is erasing a disc */
00306     BURN_DRIVE_ERASING,
00307     /** The drive is being grabbed */
00308     BURN_DRIVE_GRABBING,
00309 
00310     /* ts A61102 */
00311         /* @since 0.2.6 */
00312     /** The drive gets written zeroes before the track payload data */
00313     BURN_DRIVE_WRITING_PREGAP,
00314     /** The drive is told to close a track (TAO only) */
00315     BURN_DRIVE_CLOSING_TRACK,
00316     /** The drive is told to close a session (TAO only) */
00317     BURN_DRIVE_CLOSING_SESSION,
00318 
00319     /* ts A61223 */
00320         /* @since 0.3.0 */
00321     /** The drive is formatting media */
00322     BURN_DRIVE_FORMATTING,
00323 
00324     /* ts A70822 */
00325         /* @since 0.4.0 */
00326     /** The drive is busy in synchronous read (if you see this then it
00327         has been interrupted) */
00328     BURN_DRIVE_READING_SYNC,
00329     /** The drive is busy in synchronous write (if you see this then it
00330         has been interrupted) */
00331     BURN_DRIVE_WRITING_SYNC
00332     
00333 };
00334 
00335     
00336 /** Information about a track on a disc - this is from the q sub channel of the
00337     lead-in area of a disc.  The documentation here is very terse.
00338     See a document such as mmc3 for proper information.
00339 
00340     CAUTION : This structure is prone to future extension !
00341 
00342     Do not restrict your application to unsigned char with any counter like
00343     "session", "point", "pmin", ...
00344     Do not rely on the current size of a burn_toc_entry. 
00345 
00346     ts A70201 : DVD extension, see below
00347 */
00348 struct burn_toc_entry
00349 {
00350     /** Session the track is in */
00351     unsigned char session;
00352     /** Type of data.  for this struct to be valid, it must be 1 */
00353     unsigned char adr;
00354     /** Type of data in the track */
00355     unsigned char control;
00356     /** Zero.  Always.  Really. */
00357     unsigned char tno;
00358     /** Track number or special information */
00359     unsigned char point;
00360     unsigned char min;
00361     unsigned char sec;
00362     unsigned char frame;
00363     unsigned char zero;
00364     /** Track start time minutes for normal tracks */
00365     unsigned char pmin;
00366     /** Track start time seconds for normal tracks */
00367     unsigned char psec;
00368     /** Track start time frames for normal tracks */
00369     unsigned char pframe;
00370 
00371     /* Indicates whether extension data are valid and eventually override
00372        older elements in this structure:
00373          bit0= DVD extension is valid @since 0.3.2
00374                    @since 0.5.2 : DVD extensions are made valid for CD too
00375     */
00376     unsigned char extensions_valid;  
00377 
00378     /* ts A70201 : DVD extension. extensions_valid:bit0
00379        If invalid the members are guaranteed to be 0. */
00380         /* @since 0.3.2 */
00381     /* Tracks and session numbers are 16 bit. Here are the high bytes. */
00382     unsigned char session_msb;
00383     unsigned char point_msb;
00384     /* pmin, psec, and pframe may be too small if DVD extension is valid */
00385     int start_lba; 
00386     /* min, sec, and frame may be too small if DVD extension is valid */
00387     int track_blocks;
00388     
00389     /* ts A90909 : LRA extension. extensions_valid:bit1 */
00390     /* @since 0.7.2 */
00391     /* MMC-5 6.27.3.18 : The Last Recorded Address is valid for DVD-R,
00392                       DVD-R DL when LJRS = 00b, DVD-RW, HD DVD-R, and BD-R.
00393        This would mean profiles: 0x11, 0x15, 0x13, 0x14, 0x51, 0x41, 0x42 
00394     */
00395     int last_recorded_address;
00396 };
00397 
00398 
00399 /** Data source interface for tracks.
00400     This allows to use arbitrary program code as provider of track input data.
00401 
00402     Objects compliant to this interface are either provided by the application
00403     or by API calls of libburn: burn_fd_source_new() , burn_file_source_new(),
00404     and burn_fifo_source_new().
00405 
00406     The API calls allow to use any file object as data source. Consider to feed
00407     an eventual custom data stream asynchronously into a pipe(2) and to let
00408     libburn handle the rest. 
00409     In this case the following rule applies:
00410     Call burn_source_free() exactly once for every source obtained from
00411     libburn API. You MUST NOT otherwise use or manipulate its components.
00412 
00413     In general, burn_source objects can be freed as soon as they are attached
00414     to track objects. The track objects will keep them alive and dispose them
00415     when they are no longer needed. With a fifo burn_source it makes sense to
00416     keep the own reference for inquiring its state while burning is in
00417     progress.
00418 
00419     ---
00420 
00421     The following description of burn_source applies only to application
00422     implemented burn_source objects. You need not to know it for API provided
00423     ones.
00424 
00425     If you really implement an own passive data producer by this interface,
00426     then beware: it can do anything and it can spoil everything.
00427 
00428     In this case the functions (*read), (*get_size), (*set_size), (*free_data)
00429     MUST be implemented by the application and attached to the object at
00430     creation time.
00431     Function (*read_sub) is allowed to be NULL or it MUST be implemented and
00432     attached.
00433 
00434     burn_source.refcount MUST be handled properly: If not exactly as many
00435     references are freed as have been obtained, then either memory leaks or
00436     corrupted memory are the consequence.
00437     All objects which are referred to by *data must be kept existent until
00438     (*free_data) is called via burn_source_free() by the last referer.
00439 */
00440 struct burn_source {
00441 
00442     /** Reference count for the data source. MUST be 1 when a new source
00443             is created and thus the first reference is handed out. Increment
00444             it to take more references for yourself. Use burn_source_free()
00445             to destroy your references to it. */
00446     int refcount;
00447 
00448 
00449     /** Read data from the source. Semantics like with read(2), but MUST
00450         either deliver the full buffer as defined by size or MUST deliver
00451         EOF (return 0) or failure (return -1) at this call or at the
00452         next following call. I.e. the only incomplete buffer may be the
00453         last one from that source.
00454         libburn will read a single sector by each call to (*read).
00455         The size of a sector depends on BURN_MODE_*. The known range is
00456         2048 to 2352.
00457 
00458             If this call is reading from a pipe then it will learn
00459             about the end of data only when that pipe gets closed on the
00460             feeder side. So if the track size is not fixed or if the pipe
00461             delivers less than the predicted amount or if the size is not
00462             block aligned, then burning will halt until the input process
00463             closes the pipe.
00464 
00465         IMPORTANT:
00466         If this function pointer is NULL, then the struct burn_source is of
00467         version >= 1 and the job of .(*read)() is done by .(*read_xt)().
00468         See below, member .version.
00469     */
00470     int (*read)(struct burn_source *, unsigned char *buffer, int size);
00471 
00472 
00473     /** Read subchannel data from the source (NULL if lib generated) 
00474         WARNING: This is an obscure feature with CD raw write modes.
00475         Unless you checked the libburn code for correctness in that aspect
00476         you should not rely on raw writing with own subchannels.
00477         ADVICE: Set this pointer to NULL.
00478     */
00479     int (*read_sub)(struct burn_source *, unsigned char *buffer, int size);
00480 
00481 
00482     /** Get the size of the source's data. Return 0 means unpredictable
00483         size. If application provided (*get_size) allows return 0, then
00484         the application MUST provide a fully functional (*set_size).
00485     */
00486     off_t (*get_size)(struct burn_source *); 
00487 
00488 
00489     /* ts A70125 : BROKE BINARY BACKWARD COMPATIBILITY AT libburn-0.3.1. */
00490         /* @since 0.3.2 */
00491     /** Program the reply of (*get_size) to a fixed value. It is advised
00492         to implement this by a attribute  off_t fixed_size;  in *data .
00493         The read() function does not have to take into respect this fake
00494         setting. It is rather a note of libburn to itself. Eventually
00495         necessary truncation or padding is done in libburn. Truncation
00496         is usually considered a misburn. Padding is considered ok.
00497 
00498         libburn is supposed to work even if (*get_size) ignores the
00499             setting by (*set_size). But your application will not be able to
00500         enforce fixed track sizes by  burn_track_set_size() and possibly
00501         even padding might be left out.
00502     */
00503     int (*set_size)(struct burn_source *source, off_t size);
00504 
00505 
00506     /** Clean up the source specific data. This function will be called
00507         once by burn_source_free() when the last referer disposes the
00508         source.
00509     */
00510     void (*free_data)(struct burn_source *);
00511 
00512 
00513     /** Next source, for when a source runs dry and padding is disabled
00514         WARNING: This is an obscure feature. Set to NULL at creation and
00515                  from then on leave untouched and uninterpreted.
00516     */
00517     struct burn_source *next;
00518 
00519 
00520     /** Source specific data. Here the various source classes express their
00521         specific properties and the instance objects store their individual
00522         management data.
00523             E.g. data could point to a struct like this:
00524         struct app_burn_source
00525         {
00526             struct my_app *app_handle;
00527             ... other individual source parameters ...
00528             off_t fixed_size;
00529         };
00530 
00531         Function (*free_data) has to be prepared to clean up and free
00532         the struct.
00533     */
00534     void *data;
00535 
00536 
00537     /* ts A71222 : Supposed to be binary backwards compatible extension. */
00538         /* @since 0.4.2 */
00539     /** Valid only if above member .(*read)() is NULL. This indicates a
00540         version of struct burn_source younger than 0.
00541         From then on, member .version tells which further members exist
00542         in the memory layout of struct burn_source. libburn will only touch
00543         those announced extensions.
00544 
00545         Versions:
00546          0  has .(*read)() != NULL, not even .version is present.
00547              1  has .version, .(*read_xt)(), .(*cancel)()
00548     */
00549     int version;
00550 
00551     /** This substitutes for (*read)() in versions above 0. */
00552     int (*read_xt)(struct burn_source *, unsigned char *buffer, int size);
00553 
00554     /** Informs the burn_source that the consumer of data prematurely
00555         ended reading. This call may or may not be issued by libburn
00556         before (*free_data)() is called.
00557     */
00558     int (*cancel)(struct burn_source *source);
00559 };
00560 
00561 
00562 /** Information on a drive in the system */
00563 struct burn_drive_info
00564 {
00565     /** Name of the vendor of the drive */
00566     char vendor[9];
00567     /** Name of the drive */
00568     char product[17];
00569     /** Revision of the drive */
00570     char revision[5];
00571 
00572     /** Invalid: Was: "Location of the drive in the filesystem." */
00573     /** This string has no meaning any more. Once it stored the drive
00574             device file address. Now always use function burn_drive_d_get_adr()
00575             to inquire a device file address.            ^^^^^ ALWAYS ^^^^^^^*/
00576     char location[17];
00577 
00578     /** Can the drive read DVD-RAM discs */
00579     unsigned int read_dvdram:1;
00580     /** Can the drive read DVD-R discs */
00581     unsigned int read_dvdr:1;
00582     /** Can the drive read DVD-ROM discs */
00583     unsigned int read_dvdrom:1;
00584     /** Can the drive read CD-R discs */
00585     unsigned int read_cdr:1;
00586     /** Can the drive read CD-RW discs */
00587     unsigned int read_cdrw:1;
00588 
00589     /** Can the drive write DVD-RAM discs */
00590     unsigned int write_dvdram:1;
00591     /** Can the drive write DVD-R discs */
00592     unsigned int write_dvdr:1;
00593     /** Can the drive write CD-R discs */
00594     unsigned int write_cdr:1;
00595     /** Can the drive write CD-RW discs */
00596     unsigned int write_cdrw:1;
00597 
00598     /** Can the drive simulate a write */
00599     unsigned int write_simulate:1;
00600 
00601     /** Can the drive report C2 errors */
00602     unsigned int c2_errors:1;
00603 
00604     /** The size of the drive's buffer (in kilobytes) */
00605     int buffer_size;
00606     /** 
00607      * The supported block types in tao mode.
00608      * They should be tested with the desired block type.
00609      * See also burn_block_types.
00610      */
00611     int tao_block_types;
00612     /** 
00613      * The supported block types in sao mode.
00614      * They should be tested with the desired block type.
00615      * See also burn_block_types.
00616      */
00617     int sao_block_types;
00618     /** 
00619      * The supported block types in raw mode.
00620      * They should be tested with the desired block type.
00621      * See also burn_block_types.
00622      */
00623     int raw_block_types;
00624     /** 
00625      * The supported block types in packet mode.
00626      * They should be tested with the desired block type.
00627      * See also burn_block_types.
00628      */
00629     int packet_block_types;
00630 
00631     /** The value by which this drive can be indexed when using functions
00632         in the library. This is the value to pass to all libbburn functions
00633         that operate on a drive. */
00634     struct burn_drive *drive;
00635 };
00636 
00637 
00638 /** Operation progress report. All values are 0 based indices. 
00639  * */
00640 struct burn_progress {
00641     /** The total number of sessions */
00642     int sessions;
00643     /** Current session.*/
00644     int session;
00645     /** The total number of tracks */
00646     int tracks;
00647     /** Current track. */
00648     int track;
00649     /** The total number of indices */
00650     int indices;
00651     /** Curent index. */
00652     int index;
00653     /** The starting logical block address */
00654     int start_sector;
00655     /** On write: The number of sectors.
00656         On blank: 0x10000 as upper limit for relative progress steps */
00657     int sectors;
00658     /** On write: The current sector being processed.
00659         On blank: Relative progress steps 0 to 0x10000 */
00660     int sector;
00661 
00662     /* ts A61023 */
00663         /* @since 0.2.6 */
00664     /** The capacity of the drive buffer */
00665     unsigned buffer_capacity;
00666     /** The free space in the drive buffer (might be slightly outdated) */
00667     unsigned buffer_available;
00668 
00669     /* ts A61119 */
00670         /* @since 0.2.6 */
00671     /** The number of bytes sent to the drive buffer */
00672     off_t buffered_bytes;
00673     /** The minimum number of bytes stored in buffer during write.
00674             (Caution: Before surely one buffer size of bytes was processed,
00675                       this value is 0xffffffff.) 
00676     */
00677     unsigned buffer_min_fill;
00678 };
00679 
00680 
00681 /* ts A61226 */
00682 /* @since 0.3.0 */
00683 /** Description of a speed capability as reported by the drive in conjunction
00684     with eventually loaded media. There can be more than one such object per
00685     drive. So they are chained via .next and .prev , where NULL marks the end
00686     of the chain. This list is set up by burn_drive_scan() and gets updated
00687     by burn_drive_grab().
00688     A copy may be obtained by burn_drive_get_speedlist() and disposed by
00689     burn_drive_free_speedlist().
00690     For technical background info see SCSI specs MMC and SPC:
00691     mode page 2Ah (from SPC 5Ah MODE SENSE) , mmc3r10g.pdf , 6.3.11 Table 364
00692     ACh GET PERFORMANCE, Type 03h , mmc5r03c.pdf , 6.8.5.3 Table 312
00693 */
00694 struct burn_speed_descriptor {
00695 
00696     /** Where this info comes from : 
00697         0 = misc , 1 = mode page 2Ah , 2 = ACh GET PERFORMANCE */
00698     int source;
00699 
00700     /** The media type that was current at the time of report
00701         -2 = state unknown, -1 = no media was loaded , else see
00702         burn_disc_get_profile() */
00703     int profile_loaded;
00704     char profile_name[80];
00705 
00706     /** The attributed capacity of appropriate media in logical block units
00707         i.e. 2352 raw bytes or 2048 data bytes. -1 = capacity unknown. */
00708     int end_lba;
00709 
00710     /** Speed is given in 1000 bytes/s , 0 = invalid. The numbers
00711         are supposed to be usable with burn_drive_set_speed() */
00712     int write_speed;
00713     int read_speed;
00714 
00715     /** Expert info from ACh GET PERFORMANCE and/or mode page 2Ah.
00716         Expect values other than 0 or 1 to get a meaning in future.*/
00717     /* Rotational control: 0 = CLV/default , 1 = CAV */
00718     int wrc;
00719     /* 1 = drive promises reported performance over full media */
00720     int exact;
00721     /* 1 = suitable for mixture of read and write */
00722     int mrw;
00723 
00724     /** List chaining. Use .next until NULL to iterate over the list */
00725     struct burn_speed_descriptor *prev;
00726     struct burn_speed_descriptor *next;
00727 };
00728 
00729 
00730 /** Initialize the library.
00731     This must be called before using any other functions in the library. It
00732     may be called more than once with no effect.
00733     It is possible to 'restart' the library by shutting it down and
00734     re-initializing it. Once this was necessary if you follow the older and
00735     more general way of accessing a drive via burn_drive_scan() and
00736     burn_drive_grab(). See burn_drive_scan_and_grab() with its strong
00737     urges and its explanations.
00738     @return Nonzero if the library was able to initialize; zero if
00739             initialization failed.
00740 */
00741 int burn_initialize(void);
00742 
00743 /** Shutdown the library.
00744     This should be called before exiting your application. Make sure that all
00745     drives you have grabbed are released <i>before</i> calling this.
00746 */
00747 void burn_finish(void);
00748 
00749 
00750 /* ts A61002 */
00751 /** Abort any running drive operation and eventually call burn_finish().
00752 
00753     You MUST shut down the busy drives if an aborting event occurs during a
00754     burn run. For that you may call this function either from your own signal
00755     handling code or indirectly by activating the built-in signal handling:
00756       burn_set_signal_handling("my_app_name : ", NULL, 0);
00757     Else you may eventually call burn_drive_cancel() on the active drives and
00758     wait for them to assume state BURN_DRIVE_IDLE.
00759     @param patience      Maximum number of seconds to wait for drives to
00760                          finish.
00761                          @since 0.7.8 :
00762                          If this is -1, then only the cancel operations will
00763                          be performed and no burn_finish() will happen.
00764     @param pacifier_func If not NULL: a function to produce appeasing messages.
00765                          See burn_abort_pacifier() for an example.
00766     @param handle        Opaque handle to be used with pacifier_func
00767     @return 1  ok, all went well
00768             0  had to leave a drive in unclean state
00769             <0 severe error, do no use libburn again
00770     @since 0.2.6
00771 */
00772 int burn_abort(int patience, 
00773                int (*pacifier_func)(void *handle, int patience, int elapsed),
00774                void *handle);
00775 
00776 /** A pacifier function suitable for burn_abort.
00777     @param handle If not NULL, a pointer to a text suitable for printf("%s")
00778     @param patience Maximum number of seconds to wait
00779     @param elapsed  Elapsed number of seconds
00780 */
00781 int burn_abort_pacifier(void *handle, int patience, int elapsed);
00782 
00783 
00784 /** ts A61006 : This is for development only. Not suitable for applications.
00785     Set the verbosity level of the library. The default value is 0, which means
00786     that nothing is output on stderr. The more you increase this, the more
00787     debug output should be displayed on stderr for you.
00788     @param level The verbosity level desired. 0 for nothing, higher positive
00789                  values for more information output.
00790 */
00791 void burn_set_verbosity(int level);
00792 
00793 /* ts A91111 */
00794 /** Enable resp. disable logging of SCSI commands.
00795     This call can be made at any time - even before burn_initialize().
00796     It is in effect for all active drives and currently not very thread
00797     safe for multiple drives.
00798     @param flag  Bitfield for control purposes. The default is 0.
00799                  bit0= log to file /tmp/libburn_sg_command_log
00800                  bit1= log to stderr
00801                  bit2= flush output after each line
00802     @since 0.7.4
00803 */
00804 void burn_set_scsi_logging(int flag);
00805 
00806 /* ts A60813 */
00807 /** Set parameters for behavior on opening device files. To be called early
00808     after burn_initialize() and before any bus scan. But not mandatory at all.
00809     Parameter value 1 enables a feature, 0 disables.  
00810     Default is (1,0,0). Have a good reason before you change it.
00811     @param exclusive
00812                      0 = no attempt to make drive access exclusive.
00813                      1 = Try to open only devices which are not marked as busy
00814                      and try to mark them busy if opened sucessfully. (O_EXCL
00815                      on GNU/Linux , flock(LOCK_EX) on FreeBSD.)
00816                      2 = in case of a SCSI device, also try to open exclusively
00817                          the matching /dev/sr, /dev/scd and /dev/st .
00818                      One may select a device SCSI file family by adding
00819                       0 = default family
00820                       4 = /dev/sr%d
00821                       8 = /dev/scd%d
00822                      16 = /dev/sg%d
00823                      Do not use other values !
00824                      Add 32 to demand on GNU/Linux an exclusive lock by
00825                      fcntl(,F_SETLK,) after open() has succeeded.
00826     @param blocking  Try to wait for drives which do not open immediately but
00827                      also do not return an error as well. (O_NONBLOCK)
00828                      This might stall indefinitely with /dev/hdX hard disks.
00829     @param abort_on_busy  Unconditionally abort process when a non blocking
00830                           exclusive opening attempt indicates a busy drive.
00831                           Use this only after thorough tests with your app.
00832     @since 0.2.2
00833 */
00834 void burn_preset_device_open(int exclusive, int blocking, int abort_on_busy);
00835 
00836 
00837 /* ts A70223 */
00838 /** Allows the use of media types which are implemented in libburn but not yet
00839     tested. The list of those untested profiles is subject to change.
00840              - Currently no media types are under test reservation -
00841     If you really test such media, then please report the outcome on
00842     libburn-hackers@pykix.org
00843     If ever then this call should be done soon after burn_initialize() before
00844     any drive scanning.
00845     @param yes 1=allow all implemented profiles, 0=only tested media (default)
00846     @since 0.3.4
00847 */
00848 void burn_allow_untested_profiles(int yes);
00849 
00850 
00851 /* ts A60823 */
00852 /** Aquire a drive with known device file address.
00853 
00854     This is the sysadmin friendly way to open one drive and to leave all
00855     others untouched. It bundles the following API calls to form a
00856     non-obtrusive way to use libburn:
00857       burn_drive_add_whitelist() , burn_drive_scan() , burn_drive_grab()
00858     You are *strongly urged* to use this call whenever you know the drive
00859     address in advance.
00860 
00861     If not, then you have to use directly above calls. In that case, you are
00862     *strongly urged* to drop any unintended drive which will be exclusively
00863     occupied and not closed by burn_drive_scan().
00864     This can be done by shutting down the library including a call to
00865     burn_finish(). You may later start a new libburn session and should then
00866     use the function described here with an address obtained after
00867     burn_drive_scan() via burn_drive_d_get_adr(drive_infos[driveno].drive,adr).
00868     Another way is to drop the unwanted drives by burn_drive_info_forget().
00869 
00870     Operating on multiple drives:
00871 
00872     Different than with burn_drive_scan() it is allowed to call
00873     burn_drive_scan_and_grab() without giving up any other scanned drives. So
00874     this call can be used to get a collection of more than one aquired drives.
00875     The attempt to aquire the same drive twice will fail, though.
00876 
00877     Pseudo-drives:
00878 
00879     burn_drive_scan_and_grab() is able to aquire virtual drives which will
00880     accept options much like a MMC burner drive. Many of those options will not
00881     cause any effect, though. The address of a pseudo-drive begins with
00882     prefix "stdio:" followed by a path.
00883     Examples:  "stdio:/tmp/pseudo_drive" , "stdio:/dev/null" , "stdio:-"
00884 
00885     If the path is empty, the result is a null-drive = drive role 0.
00886     It pretends to have loaded no media and supports no reading or writing.
00887 
00888     If the path leads to an existing regular file, or to a not yet existing
00889     file, or to an existing block device, then the result is a random access
00890     stdio-drive capable of reading and writing = drive role 2.
00891 
00892     If the path leads to an existing file of any type other than directory,
00893     then the result is a sequential write-only stdio-drive = drive role 3.
00894 
00895     The special address form "stdio:/dev/fd/{number}" is interpreted literally
00896     as reference to open file descriptor {number}. This address form coincides
00897     with real files on some systems, but it is in fact hardcoded in libburn.
00898     Special address "stdio:-" means stdout = "stdio:/dev/fd/1".
00899     The role of such a drive is determined by the file type obtained via
00900     fstat({number}).
00901    
00902     Roles 2 and 3 perform all their eventual data transfer activities on a file
00903     via standard i/o functions open(2), lseek(2), read(2), write(2), close(2).
00904     The media profile is reported as 0xffff. Write space information from those
00905     media is not necessarily realistic.
00906 
00907     The capabilities of role 2 resemble DVD-RAM but it can simulate writing.
00908     If the path does not exist in the filesystem yet, it is attempted to create
00909     it as a regular file as soon as write operations are started.
00910 
00911     The capabilities of role 3 resemble a blank DVD-R. Nevertheless each
00912     burn_disc_write() run may only write a single track.
00913 
00914     One may distinguish pseudo-drives from MMC drives by call
00915     burn_drive_get_drive_role().
00916 
00917     @param drive_infos On success returns a one element array with the drive
00918                   (cdrom/burner). Thus use with driveno 0 only. On failure
00919                   the array has no valid elements at all.
00920                   The returned array should be freed via burn_drive_info_free()
00921                   when it is no longer needed.
00922                   This is a result from call burn_drive_scan(). See there.
00923                   Use with driveno 0 only.
00924     @param adr    The device file address of the desired drive. Either once
00925                   obtained by burn_drive_d_get_adr() or composed skillfully by
00926                   application resp. its user. E.g. "/dev/sr0".
00927                   Consider to preprocess it by burn_drive_convert_fs_adr().
00928     @param load   Nonzero to make the drive attempt to load a disc (close its
00929                   tray door, etc).
00930     @return       1 = success , 0 = drive not found , -1 = other error
00931     @since 0.2.2
00932 */    
00933 int burn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
00934                              char* adr, int load);
00935 
00936 
00937 /* ts A51221 */
00938 /* @since 0.2.2 */
00939 /** Maximum number of particularly permissible drive addresses */
00940 #define BURN_DRIVE_WHITELIST_LEN 255
00941 
00942 /** Add a device to the list of permissible drives. As soon as some entry is in
00943     the whitelist all non-listed drives are banned from scanning.
00944     @return 1 success, <=0 failure
00945     @since 0.2.2
00946 */
00947 int burn_drive_add_whitelist(char *device_address);
00948 
00949 /** Remove all drives from whitelist. This enables all possible drives. */
00950 void burn_drive_clear_whitelist(void);
00951 
00952 
00953 /** Scan for drives. This function MUST be called until it returns nonzero.
00954     In case of re-scanning:
00955     All pointers to struct burn_drive and all struct burn_drive_info arrays
00956     are invalidated by using this function. Do NOT store drive pointers across
00957     calls to this function !
00958     To avoid invalid pointers one MUST free all burn_drive_info arrays
00959     by burn_drive_info_free() before calling burn_drive_scan() a second time.
00960     If there are drives left, then burn_drive_scan() will refuse to work.
00961 
00962     After this call all drives depicted by the returned array are subject
00963     to eventual (O_EXCL) locking. See burn_preset_device_open(). This state
00964     ends either with burn_drive_info_forget() or with burn_drive_release().
00965     It is unfriendly to other processes on the system to hold drives locked
00966     which one does not definitely plan to use soon.
00967     @param drive_infos Returns an array of drive info items (cdroms/burners).
00968                   The returned array must be freed by burn_drive_info_free()
00969                   before burn_finish(), and also before calling this function
00970                   burn_drive_scan() again.
00971     @param n_drives Returns the number of drive items in drive_infos.
00972     @return 0 while scanning is not complete
00973             >0 when it is finished sucessfully,
00974             <0 when finished but failed.
00975 */
00976 int burn_drive_scan(struct burn_drive_info *drive_infos[],
00977             unsigned int *n_drives);
00978 
00979 /* ts A60904 : ticket 62, contribution by elmom */
00980 /** Release memory about a single drive and any exclusive lock on it.
00981     Become unable to inquire or grab it. Expect FATAL consequences if you try.
00982     @param drive_info pointer to a single element out of the array
00983                       obtained from burn_drive_scan() : &(drive_infos[driveno])
00984     @param force controls degree of permissible drive usage at the moment this
00985                  function is called, and the amount of automatically provided
00986                  drive shutdown : 
00987                   0= drive must be ungrabbed and BURN_DRIVE_IDLE
00988                   1= try to release drive resp. accept BURN_DRIVE_GRABBING 
00989                  Use these two only. Further values are to be defined.
00990     @return 1 on success, 2 if drive was already forgotten,
00991             0 if not permissible, <0 on other failures, 
00992     @since 0.2.2
00993 */
00994 int burn_drive_info_forget(struct burn_drive_info *drive_info, int force);
00995 
00996 
00997 /** When no longer needed, free a whole burn_drive_info array which was
00998     returned by burn_drive_scan().
00999     For freeing single drive array elements use burn_drive_info_forget().
01000 */
01001 void burn_drive_info_free(struct burn_drive_info drive_infos[]);
01002 
01003 
01004 /* ts A60823 */
01005 /* @since 0.2.2 */
01006 /** Maximum length+1 to expect with a drive device file address string */
01007 #define BURN_DRIVE_ADR_LEN 1024
01008 
01009 /* ts A70906 */
01010 /** Inquire the device file address of the given drive.
01011     @param drive The drive to inquire.
01012     @param adr   An application provided array of at least BURN_DRIVE_ADR_LEN
01013                  characters size. The device file address gets copied to it.
01014     @return >0 success , <=0 error (due to libburn internal problem)
01015     @since 0.4.0
01016 */
01017 int burn_drive_d_get_adr(struct burn_drive *drive, char adr[]);
01018 
01019 /* A60823 */
01020 /** Inquire the device file address of a drive via a given drive_info object.
01021     (Note: This is a legacy call.)
01022     @param drive_info The drive to inquire.Usually some &(drive_infos[driveno])
01023     @param adr   An application provided array of at least BURN_DRIVE_ADR_LEN
01024                  characters size. The device file address gets copied to it.
01025     @return >0 success , <=0 error (due to libburn internal problem)
01026     @since 0.2.6
01027 */
01028 int burn_drive_get_adr(struct burn_drive_info *drive_info, char adr[]);
01029 
01030 
01031 /* ts A60922 ticket 33 */
01032 /** Evaluate whether the given address would be a drive device file address
01033     which could be listed by a run of burn_drive_scan(). No check is made
01034     whether a device file with this address exists or whether it leads
01035     to a usable MMC drive.
01036     @return 1 means yes, 0 means no
01037     @since 0.2.6
01038 */
01039 int burn_drive_is_enumerable_adr(char *adr);
01040 
01041 /* ts A60922 ticket 33 */
01042 /** Try to convert a given existing filesystem address into a drive device file
01043     address. This succeeds with symbolic links or if a hint about the drive's
01044     system address can be read from the filesystem object and a matching drive
01045     is found.
01046     @param path The address of an existing file system object
01047     @param adr  An application provided array of at least BURN_DRIVE_ADR_LEN
01048                 characters size. The device file address gets copied to it.
01049     @return     1 = success , 0 = failure , -1 = severe error
01050     @since 0.2.6
01051 */
01052 int burn_drive_convert_fs_adr(char *path, char adr[]);
01053 
01054 /* ts A60923 */
01055 /** Try to convert a given SCSI address of bus,host,channel,target,lun into
01056     a drive device file address. If a SCSI address component parameter is < 0
01057     then it is not decisive and the first enumerated address which matches
01058     the >= 0 parameters is taken as result.
01059     Note: bus and (host,channel) are supposed to be redundant.
01060     @param bus_no "Bus Number" (something like a virtual controller)
01061     @param host_no "Host Number" (something like half a virtual controller)
01062     @param channel_no "Channel Number" (other half of "Host Number")
01063     @param target_no "Target Number" or "SCSI Id" (a device)
01064     @param lun_no "Logical Unit Number" (a sub device)
01065     @param adr  An application provided array of at least BURN_DRIVE_ADR_LEN
01066                 characters size. The device file address gets copied to it.
01067     @return     1 = success , 0 = failure , -1 = severe error
01068     @since 0.2.6
01069 */
01070 int burn_drive_convert_scsi_adr(int bus_no, int host_no, int channel_no,
01071                  int target_no, int lun_no, char adr[]);
01072 
01073 /* ts B10728 */
01074 /** Try to convert a given drive device file address into the address of a
01075     symbolic link that points to this drive address.
01076     Modern GNU/Linux systems may shuffle drive addresses from boot to boot.
01077     The udev daemon is supposed to create links which always point to the
01078     same drive, regardless of its system address.
01079     This call tries to find such links.
01080     @param dev_adr     Should contain a drive address as returned by
01081                        burn_drive_scan().
01082     @param link_adr    An application provided array of at least
01083                        BURN_DRIVE_ADR_LEN characters size. The found link
01084                        address gets copied to it.
01085     @param dir_adr     The address of the directory where to look for links.
01086                        Normally: "/dev"
01087     @param templ       An array of pointers to name templates, which
01088                        links have to match. A symbolic link in dir_adr matches
01089                        a name template if it begins by that text. E.g.
01090                        link address "/dev/dvdrw1" matches template "dvdrw".
01091                        If templ is NULL, then the default array gets used:
01092                         {"dvdrw", "cdrw", "dvd", "cdrom", "cd"}
01093                        If several links would match, then a link will win,
01094                        which matches the template with the lowest array index.
01095                        Among these candidates, the one with the lowest strcmp()
01096                        rank will be chosen as link_adr.
01097     @param num_templ   Number of array elements in templ.
01098     @param flag        Bitfield for control purposes. Unused yet. Submit 0.
01099     @return            <0 severe error, 0 failed to search, 2 nothing found
01100                        1 success, link_adr is valid
01101     @since 1.1.4
01102 */
01103 int burn_lookup_device_link(char *dev_adr, char link_adr[],
01104                          char *dir_adr, char **templ, int num_templ, int flag);
01105 
01106 /* ts A60923 - A61005 */
01107 /** Try to obtain bus,host,channel,target,lun from path. If there is an SCSI
01108     address at all, then this call should succeed with a drive device file
01109     address obtained via burn_drive_d_get_adr(). It is also supposed to
01110     succeed with any device file of a (possibly emulated) SCSI device.
01111     @return     1 = success , 0 = failure , -1 = severe error
01112     @since 0.2.6
01113 */
01114 int burn_drive_obtain_scsi_adr(char *path, int *bus_no, int *host_no,
01115                 int *channel_no, int *target_no, int *lun_no);
01116 
01117 /** Grab a drive. This must be done before the drive can be used (for reading,
01118     writing, etc).
01119     @param drive The drive to grab. This is found in a returned
01120                  burn_drive_info struct.
01121     @param load Nonzero to make the drive attempt to load a disc (close its
01122                 tray door, etc).
01123     @return 1 if it was possible to grab the drive, else 0
01124 */
01125 int burn_drive_grab(struct burn_drive *drive, int load);
01126 
01127 /* ts B00114 */
01128 /* Probe available CD write modes and block types. In earlier versions this
01129    was done unconditionally on drive examination or aquiration. But it is
01130    lengthy and obtrusive, up to spoiling burn runs on the examined drives.
01131    So now this probing is omitted by default. All drives which announce to be
01132    capable of CD or DVD writing, get blindly attributed the capability for
01133    SAO and TAO. Applications which are interested in RAW modes or want to
01134    rely on the traditional write mode information, may use this call.
01135    @param drive_info  drive object to be inquired
01136    @return            >0 indicates success, <=0 means failure
01137    @since 0.7.6
01138 */
01139 int burn_drive_probe_cd_write_modes(struct burn_drive_info *drive_info);
01140 
01141 /* ts A90824 */
01142 /** Calm down or alert a drive. Some drives stay alert after reading for
01143     quite some time. This saves time with the startup for the next read
01144     operation but also causes noise and consumes extra energy. It makes
01145     sense to calm down the drive if no read operation is expected for the
01146     next few seconds. The drive will get alert automatically if operations
01147     are required.
01148     @param d      The drive to influence.
01149     @param flag   Bitfield for control purposes
01150                   bit0= become alert (else start snoozing)
01151                         This is not mandatory to allow further drive operations
01152     @return       1= success , 0= drive role not suitable for calming
01153     @since 0.7.0
01154 */
01155 int burn_drive_snooze(struct burn_drive *d, int flag);
01156 
01157 
01158 /** Re-assess drive and media status. This should be done after a drive
01159     underwent a status change and shall be further used without intermediate
01160     burn_drive_release(), burn_drive_grab(). E.g. after blanking or burning.
01161     @param drive  The already grabbed drive to re-assess.
01162     @param flag   Unused yet. Submit 0.
01163     @return       1 success , <= 0 could not determine drive and media state
01164     @since 1.1.8
01165 */
01166 int burn_drive_re_assess(struct burn_drive *d, int flag);
01167 
01168 
01169 /** Release a drive. This should not be done until the drive is no longer
01170     busy (see burn_drive_get_status).
01171     @param drive The drive to release.
01172     @param eject Nonzero to make the drive eject the disc in it.
01173 */
01174 void burn_drive_release(struct burn_drive *drive, int eject);
01175 
01176 
01177 /* ts A70918 */
01178 /** Like burn_drive_release() but keeping the drive tray closed and its
01179     eject button disabled. This physically locked drive state will last until
01180     the drive is grabbed again and released via burn_drive_release().
01181     Programs like eject, cdrecord, growisofs will break that ban too.
01182     @param d    The drive to release and leave locked.
01183     @param flag Bitfield for control purposes (unused yet, submit 0)
01184     @return 1 means success, <=0 means failure
01185     @since 0.4.0
01186 */
01187 int burn_drive_leave_locked(struct burn_drive *d, int flag);
01188 
01189 
01190 /** Returns what kind of disc a drive is holding. This function may need to be
01191     called more than once to get a proper status from it. See burn_disc_status
01192     for details.
01193     @param drive The drive to query for a disc.
01194     @return The status of the drive, or what kind of disc is in it.
01195             Note: BURN_DISC_UNGRABBED indicates wrong API usage
01196 */
01197 enum burn_disc_status burn_disc_get_status(struct burn_drive *drive);
01198 
01199 
01200 /* ts A61020 */
01201 /** WARNING: This revives an old bug-like behavior that might be dangerous.
01202     Sets the drive status to BURN_DISC_BLANK if it is BURN_DISC_UNREADY
01203     or BURN_DISC_UNSUITABLE. Thus marking media as writable which actually
01204     failed to declare themselves either blank or (partially) filled.
01205     @return 1 drive status has been set , 0 = unsuitable drive status
01206     @since 0.2.6
01207 */
01208 int burn_disc_pretend_blank(struct burn_drive *drive);
01209 
01210 
01211 /* ts A61106 */
01212 /** WARNING: This overrides the safety measures against unsuitable media.
01213     Sets the drive status to BURN_DISC_FULL if it is BURN_DISC_UNREADY
01214     or BURN_DISC_UNSUITABLE. Thus marking media as blankable which actually
01215     failed to declare themselves either blank or (partially) filled.
01216     @since 0.2.6
01217 */
01218 int burn_disc_pretend_full(struct burn_drive *drive);
01219 
01220 
01221 /* ts A61021 */
01222 /** Reads ATIP information from inserted media. To be obtained via
01223     burn_drive_get_write_speed(), burn_drive_get_min_write_speed(),
01224     burn_drive_get_start_end_lba(). The drive must be grabbed for this call.
01225     @param drive The drive to query.
01226     @return 1=sucess, 0=no valid ATIP info read, -1 severe error
01227     @since 0.2.6
01228 */
01229 int burn_disc_read_atip(struct burn_drive *drive);
01230 
01231 
01232 /* ts A61020 */
01233 /** Returns start and end lba of the media which is currently inserted
01234     in the given drive. The drive has to be grabbed to have hope for reply.
01235     Shortcomming (not a feature): unless burn_disc_read_atip() was called 
01236     only blank media will return valid info.
01237     @param drive The drive to query.
01238     @param start_lba Returns the start lba value
01239     @param end_lba Returns the end lba value
01240     @param flag Bitfield for control purposes (unused yet, submit 0)
01241     @return 1 if lba values are valid , 0 if invalid
01242     @since 0.2.6
01243 */
01244 int burn_drive_get_start_end_lba(struct burn_drive *drive,
01245                                  int *start_lba, int *end_lba, int flag);
01246 
01247 
01248 /* ts A90902 */
01249 /** Guess the manufacturer name of CD media from the ATIP addresses of lead-in
01250     and lead-out. (Currently only lead-in is interpreted. Lead-out may in
01251     future be used to identify the media type in more detail.)
01252     The parameters of this call should be obtained by burn_disc_read_atip(d),
01253     burn_drive_get_start_end_lba(d, &start_lba, &end_lba, 0),
01254     burn_lba_to_msf(start_lba, &m_li, &s_li, &f_li) and
01255     burn_lba_to_msf(end_lba, &m_lo, &s_lo, &f_lo).
01256     @param m_li  "minute" part of ATIP lead-in resp. start_lba
01257     @param s_li  "second" of lead-in resp. start_lba
01258     @param f_li  "frame" of lead-in
01259     @param m_lo  "minute" part of ATIP lead-out
01260     @param s_lo  "second" of lead-out
01261     @param f_lo  "frame" of lead-out
01262     @param flag  Bitfield for control purposes,
01263                  bit0= append a text "(aka ...)" to reply if other brands or
01264                        vendor names are known.
01265     @return      Printable text or NULL on memory shortage.
01266                  Dispose by free() when no longer needed.
01267     @since 0.7.2
01268 */
01269 char *burn_guess_cd_manufacturer(int m_li, int s_li, int f_li,
01270                                  int m_lo, int s_lo, int f_lo, int flag);
01271 
01272 /* ts A90909 */
01273 /** Retrieve some media information which is mainly specific to CD. For other
01274     media only the bits in reply parameter valid are supposed to be meaningful.
01275     @param d         The drive to query.
01276     @param disc_type A string saying either "CD-DA or CD-ROM", or "CD-I",
01277                      or ""CD-ROM XA", or "undefined".
01278     @param disc_id   A 32 bit number read from the media. (Meaning unclear yet)
01279     @param bar_code  8 hex digits from a barcode on media read by the drive
01280                      (if the drive has a bar code reader built in).
01281     @param app_code  The Host Application Code which must be set in the Write
01282                      Parameters Page if the media is not unrestricted (URU==0).
01283     @param valid     Replies bits which indicate the validity of other reply
01284                      parameters or the state of certain CD info bits:
01285                      bit0= disc_type is valid
01286                      bit1= disc_id is valid
01287                      bit2= bar_code is valid
01288                      bit3= disc_app_code is valid
01289                      bit4= Disc is unrestricted (URU bit, 51h READ DISC INFO)
01290                            This seems to be broken with my drives. The bit is
01291                            0 and the validity bit for disc_app_code is 0 too.
01292                      bit5= Disc is nominally erasable (Erasable bit)
01293                            This will be set with overwriteable media which
01294                            libburn normally considers to be unerasable blank.
01295     @return          1 success, <= 0 an error occured
01296     @since 0.7.2
01297 */
01298 int burn_disc_get_cd_info(struct burn_drive *d, char disc_type[80],
01299                         unsigned int *disc_id, char bar_code[9], int *app_code,
01300             int *valid);
01301 
01302 /* ts B11201 */
01303 /** Read the array of CD-TEXT packs from the Lead-in of an audio CD.
01304     Each pack consists of 18 bytes, of which 4 are header. 12 bytes are pieces
01305     of 0-terminated texts or binary data. 2 bytes hold a CRC.
01306     For a description of the format of the array, see file doc/cdtext.txt.
01307     @param d          The drive to query.
01308     @param text_packs  Will point to an allocated memory buffer with CD-TEXT.
01309                       It will only contain text packs, and not be prepended
01310                       by the TOC header of four bytes, which gets stored with
01311                       file cdtext.dat by cdrecord -vv -toc. (The first two of
01312                       these bytes are supposed to hold the number of CD-TEXT
01313                       bytes + 2. The other two bytes are supposed to be 0.)
01314                       Dispose this buffer by free(), when no longer needed.
01315     @param num_packs  Will tell the number of text packs, i.e. the number of
01316                       bytes in text_packs divided by 18.
01317     @param flag       Bitfield for control purposes,
01318                       Unused yet. Submit 0.
01319     @return           1 success, 0= no CD-TEXT found, < 0 an error occured
01320     @since 1.2.0
01321 */
01322 int burn_disc_get_leadin_text(struct burn_drive *d,
01323                               unsigned char **text_packs, int *num_packs,
01324                               int flag);
01325 
01326 /* ts B00924 */
01327 /** Read the current usage of the eventual BD Spare Area. This area gets
01328     reserved on BD media during formatting. During writing it is used to
01329     host replacements of blocks which failed the checkread immediately after
01330     writing.
01331     This call applies only to recordable BD media. I.e. profiles 0x41 to 0x43.
01332     @param d            The drive to query.
01333     @param alloc_blocks Returns the number of blocks reserved as Spare Area
01334     @param free_blocks  Returns the number of yet unused blocks in that area
01335     @param flag         Bitfield for control purposes (unused yet, submit 0)
01336     @return             1 = reply prarameters are valid,
01337                         <=0 = reply is invalid (e.g. because no BD profile)
01338     @since 0.8.8
01339 */
01340 int burn_disc_get_bd_spare_info(struct burn_drive *d,
01341                                 int *alloc_blocks, int *free_blocks, int flag);
01342 
01343 /* ts B10801 */
01344 /** Retrieve some media information which is mainly specific to media of
01345     the DVD-R family: DVD-R , DVD-RW , DVD-R DL , HD DVD-R
01346     Currently the information cannot be retrieved from other media types.
01347     @param d              The drive to query.
01348     @param disk_category  returns DVD Book to which the media complies
01349     @param book_name      returns a pointer to the book name of disk_category.
01350                           This memory is static. Do not alter or free it !
01351     @param part_version   returns the Media Version in the DVD Book
01352     @param num_layers     returns the number of media layers
01353     @param num_blocks     returns the number of blocks between pysical start
01354                           and physical end of the media
01355     @param flag           Bitfield for control purposes (unused yet, submit 0)
01356     @return               1 = reply prarameters are valid,
01357                           <=0 = reply is invalid (e.g. because no DVD-R)
01358     @since 1.1.4
01359 */
01360 int burn_disc_get_phys_format_info(struct burn_drive *d, int *disk_category,
01361                         char **book_name, int *part_version, int *num_layers,
01362                         int *num_blocks, int flag);
01363 
01364 /* ts A61110 */
01365 /** Read start lba and Next Writeable Address of a track from media.
01366     Usually a track lba is obtained from the result of burn_track_get_entry().
01367     This call retrieves an updated lba, eventual nwa, and can address the
01368     invisible track to come.
01369     The drive must be grabbed for this call. One may not issue this call
01370     during ongoing burn_disc_write() or burn_disc_erase().
01371     @param d The drive to query.
01372     @param o If not NULL: write parameters to be set on drive before query
01373     @param trackno 0=next track to come, >0 number of existing track
01374                    The first existing track on a CD may have a number higher
01375                    than 1. Use burn_session_get_start_tno() to inquire this
01376                    start number.
01377     @param lba return value: start lba
01378     @param nwa return value: Next Writeable Address
01379     @return 1=nwa is valid , 0=nwa is not valid , -1=error
01380     @since 0.2.6
01381 */
01382 int burn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o,
01383                 int trackno, int *lba, int *nwa);
01384 
01385 /* ts B10525 */
01386 /** Tells whether a previous attempt to determine the Next Writeable Address
01387     of the upcomming track reveiled that the READ TRACK INFORMATION Damage Bit
01388     is set for this track, resp. that no valid writable address is available. 
01389     See MMC-5 6.27.3.7 Damage Bit, 6.27.3.11 NWA_V (NWA valid)
01390     @param d     The drive to query.
01391     @param flag  Bitfield for control purposes (unused yet, submit 0)
01392     @return      0= Looks ok: Damage Bit is not set, NWA_V is set
01393                  1= Damaged and theoretically writable (NWA_V is set)
01394                  2= Not writable: NWA_V is not set
01395                  3= Damaged and not writable (NWA_V is not set),
01396     @since 1.1.0
01397 */
01398 int burn_disc_next_track_is_damaged(struct burn_drive *d, int flag);
01399 
01400 /* ts B10527 */
01401 /** Try to close the last track and session of media which have bit0 set in
01402     the return value of call burn_disc_next_track_is_damaged().
01403     Whether it helps depends much on the reason why the media is reported
01404     as damaged by the drive.
01405     This call works only for profiles 0x09 CD-R, 0x0a CD-RW, 0x11 DVD-R,
01406     0x14 DVD-RW sequential, 0x1b DVD+R, 0x2b DVD+R DL, 0x41 BD-R sequential.
01407     Note: After writing it is advised to give up the drive and to grab it again
01408           in order to learn about its view on the new media state.
01409     @param o     Write options created by burn_write_opts_new() and
01410                  manipulated by burn_write_opts_set_multi().
01411                  burn_write_opts_set_write_type() should be set to
01412                  BURN_WRITE_TAO, burn_write_opts_set_simulate() should be
01413                  set to 0.
01414     @param flag  Bitfield for control purposes
01415                  bit0= force close, even if no damage was seen
01416     @return      <=0 media not marked as damaged, or media type not suitable,
01417                      or closing attempted but failed
01418                  1= attempt finished without error indication
01419     @since 1.1.0
01420 */
01421 int burn_disc_close_damaged(struct burn_write_opts *o, int flag);
01422 
01423 
01424 /* ts A70131 */
01425 /** Read start lba of the first track in the last complete session.
01426     This is the first parameter of mkisofs option -C. The second parameter
01427     is nwa as obtained by burn_disc_track_lba_nwa() with trackno 0.
01428     @param d The drive to query.
01429     @param start_lba returns the start address of that track
01430     @return <= 0 : failure, 1 = ok 
01431     @since 0.3.2
01432 */
01433 int burn_disc_get_msc1(struct burn_drive *d, int *start_lba);
01434 
01435 
01436 /* ts A70213 */
01437 /** Return the best possible estimation of the currently available capacity of
01438     the media. This might depend on particular write option settings. For
01439     inquiring the space with such a set of options, the drive has to be
01440     grabbed and BURN_DRIVE_IDLE. If not, then one will only get a canned value
01441     from the most recent automatic inquiry (e.g. during last drive grabbing).
01442     An eventual start address from burn_write_opts_set_start_byte() will be
01443     subtracted from the obtained capacity estimation. Negative results get
01444     defaulted to 0.
01445     If the drive is actually a file in a large filesystem or a large block
01446     device, then the capacity is curbed to a maximum of 0x7ffffff0 blocks
01447     = 4 TB - 32 KB.
01448     @param d The drive to query.
01449     @param o If not NULL: write parameters to be set on drive before query
01450     @return number of most probably available free bytes
01451     @since 0.3.4
01452 */
01453 off_t burn_disc_available_space(struct burn_drive *d,
01454                                 struct burn_write_opts *o);
01455 
01456 /* ts A61202 */
01457 /** Tells the MMC Profile identifier of the loaded media. The drive must be
01458     grabbed in order to get a non-zero result.
01459     libburn currently writes only to profiles 
01460       0x09 "CD-R"
01461       0x0a "CD-RW"
01462       0x11 "DVD-R sequential recording"
01463       0x12 "DVD-RAM"
01464       0x13 "DVD-RW restricted overwrite"
01465       0x14 "DVD-RW sequential recording",
01466       0x15 "DVD-R/DL sequential recording",
01467       0x1a "DVD+RW"
01468       0x1b "DVD+R",
01469       0x2b "DVD+R/DL",
01470       0x41 "BD-R sequential recording",
01471       0x43 "BD-RE",
01472       0xffff "stdio file"
01473     Note: 0xffff is not a MMC profile but a libburn invention.
01474     Read-only are the profiles
01475       0x08 "CD-ROM",
01476       0x10 "DVD-ROM",
01477       0x40 "BD-ROM",
01478     Read-only for now is this BD-R profile (testers wanted)
01479       0x42 "BD-R random recording"
01480     Empty drives are supposed to report
01481       0x00 ""
01482     @param d The drive where the media is inserted.
01483     @param pno Profile Number. See also mmc5r03c.pdf, table 89
01484     @param name Profile Name (see above list, unknown profiles have empty name)
01485     @return 1 profile is valid, 0 no profile info available 
01486     @since 0.3.0
01487 */
01488 int burn_disc_get_profile(struct burn_drive *d, int *pno, char name[80]);
01489 
01490 
01491 /* ts A90903 : API */
01492 /** Obtain product id and standards defined media codes.
01493     The product id is a printable string which is supposed to be the same
01494     for identical media but should vary with non-identical media. Some media
01495     do not allow to obtain such an id at all. 
01496     The pair (profile_number, product_id) should be the best id to identify
01497     media with identical product specifications.
01498     The reply parameters media_code1 and media_code2 can be used with
01499     burn_guess_manufacturer()
01500     The reply parameters have to be disposed by free() when no longer needed.
01501     @param d           The drive where the media is inserted.
01502     @param product_id  Reply: Printable text depicting manufacturer and
01503                        eventually media id.
01504     @param media_code1 Reply: The eventual manufacturer identification as read
01505                        from DVD/BD media or a text "XXmYYsZZf" from CD media
01506                        ATIP lead-in.
01507     @param media_code2 The eventual media id as read from DVD+/BD media or a
01508                        text "XXmYYsZZf" from CD ATIP lead-out.
01509     @param book_type   Book type text for DVD and BD.
01510                        Caution: is NULL with CD, even if return value says ok.
01511     @param flag        Bitfield for control purposes
01512                        bit0= do not escape " _/" (not suitable for
01513                              burn_guess_manufacturer())
01514     @return            1= ok, product_id and media codes are valid,
01515                        0= no product id_available, reply parameters are NULL
01516                       <0= error
01517     @since 0.7.2
01518 */
01519 int burn_disc_get_media_id(struct burn_drive *d,
01520     char **product_id, char **media_code1, char **media_code2,
01521     char **book_type, int flag);
01522 
01523 
01524 /* ts A90904 */
01525 /** Guess the name of a manufacturer by profile number, manufacturer code
01526     and media code. The profile number can be obtained by
01527     burn_disc_get_profile(), the other two parameters can be obtained as
01528     media_code1 and media_code2 by burn_get_media_product_id().
01529     @param profile_no   Profile number (submit -1 if not known)
01530     @param manuf_code   Manufacturer code from media (e.g. "RICOHJPN")
01531     @param media_code   Media ID code from media (e.g. "W11")
01532     @param flag  Bitfield for control purposes, submit 0
01533     @return      Printable text or NULL on memory shortage.
01534                  If the text begins with "Unknown " then no item of the
01535                  manufacturer list matched the codes.
01536                  Dispose by free() when no longer needed.
01537     @since 0.7.2
01538 */
01539 char *burn_guess_manufacturer(int profile_no,
01540                  char *manuf_code, char *media_code, int flag);
01541 
01542 
01543 /** Tells whether a disc can be erased or not
01544     @param d The drive to inquire.
01545     @return Non-zero means erasable
01546 */
01547 int burn_disc_erasable(struct burn_drive *d);
01548 
01549 /** Returns the progress and status of a drive.
01550     @param drive The drive to query busy state for.
01551     @param p Returns the progress of the operation, NULL if you don't care
01552     @return the current status of the drive. See also burn_drive_status.
01553 */
01554 enum burn_drive_status burn_drive_get_status(struct burn_drive *drive,
01555                          struct burn_progress *p);
01556 
01557 /** Creates a write_opts struct for burning to the specified drive.
01558     The returned object must later be freed with burn_write_opts_free().
01559     @param drive The drive to write with
01560     @return The write_opts, NULL on error
01561 */
01562 struct burn_write_opts *burn_write_opts_new(struct burn_drive *drive);
01563 
01564 
01565 /* ts A70901 */
01566 /** Inquires the drive associated with a burn_write_opts object.
01567     @param opts object to inquire
01568     @return pointer to drive
01569     @since 0.4.0
01570 */
01571 struct burn_drive *burn_write_opts_get_drive(struct burn_write_opts *opts);
01572 
01573 
01574 /** Frees a write_opts struct created with burn_write_opts_new
01575     @param opts write_opts to free
01576 */
01577 void burn_write_opts_free(struct burn_write_opts *opts);
01578 
01579 /** Creates a read_opts struct for reading from the specified drive
01580     must be freed with burn_read_opts_free
01581     @param drive The drive to read from
01582     @return The read_opts
01583 */
01584 struct burn_read_opts *burn_read_opts_new(struct burn_drive *drive);
01585 
01586 /** Frees a read_opts struct created with burn_read_opts_new
01587     @param opts write_opts to free
01588 */
01589 void burn_read_opts_free(struct burn_read_opts *opts);
01590 
01591 /** Erase a disc in the drive. The drive must be grabbed successfully BEFORE
01592     calling this functions. Always ensure that the drive reports a status of
01593     BURN_DISC_FULL before calling this function. An erase operation is not
01594     cancellable, as control of the operation is passed wholly to the drive and
01595     there is no way to interrupt it safely.
01596     @param drive The drive with which to erase a disc.
01597                  Only drive roles 1 (MMC) and 5 (stdio random write-only)
01598                  support erasing.
01599     @param fast Nonzero to do a fast erase, where only the disc's headers are
01600                 erased; zero to erase the entire disc.
01601                 With DVD-RW, fast blanking yields media capable only of DAO.
01602 */
01603 void burn_disc_erase(struct burn_drive *drive, int fast);
01604 
01605 
01606 /* ts A70101 - A70417 */
01607 /** Format media for use with libburn. This currently applies to DVD-RW
01608     in state "Sequential Recording" (profile 0014h) which get formatted to
01609     state "Restricted Overwrite" (profile 0013h). DVD+RW can be "de-iced"
01610     by setting bit2 of flag. DVD-RAM and BD-RE may get formatted initially
01611     or re-formatted to adjust their Defect Managment.
01612     This function usually returns while the drive is still in the process
01613     of formatting. The formatting is done, when burn_drive_get_status()
01614     returns BURN_DRIVE_IDLE. This may be immediately after return or may
01615     need several thousand seconds to occur.
01616     @param drive The drive with the disc to format.
01617     @param size The size in bytes to be used with the format command. It should
01618                 be divisible by 32*1024. The effect of this parameter may
01619                 depend on the media profile and on parameter flag.
01620     @param flag Bitfield for control purposes:
01621                 bit0= after formatting, write the given number of zero-bytes
01622                       to the media and eventually perform preliminary closing.
01623                 bit1+2: size mode
01624                    0 = use parameter size as far as it makes sense
01625                    1 = insist in size 0 even if there is a better default known
01626                        (on DVD-RAM or BD-R identical to size mode 0,
01627                         i.e. they never get formatted with payload size 0)
01628                    2 = without bit7: format to maximum available size
01629                        with bit7   : take size from indexed format descriptor
01630                    3 = without bit7: format to default size
01631                        with bit7   : take size from indexed format descriptor
01632                 bit3= -reserved-
01633                 bit4= enforce re-format of (partly) formatted media
01634                 bit5= try to disable eventual defect management
01635         bit6= try to avoid lengthy media certification
01636                 bit7, bit8 to bit15 =
01637                       bit7 enables MMC expert application mode (else libburn
01638                       tries to choose a suitable format type):
01639                       If it is set then bit8 to bit15 contain the index of
01640                       the format to use. See burn_disc_get_formats(),
01641                       burn_disc_get_format_descr().
01642                       Acceptable types are: 0x00, 0x01, 0x10, 0x11, 0x13,
01643                       0x15, 0x26, 0x30, 0x31, 0x32.
01644                       If bit7 is set, then bit4 is set automatically.
01645                bit16= enable POW on blank BD-R
01646     @since 0.3.0
01647 */
01648 void burn_disc_format(struct burn_drive *drive, off_t size, int flag);
01649 
01650 
01651 /* ts A70112 */
01652 /* @since 0.3.0 */
01653 /** Possible formatting status values */
01654 #define BURN_FORMAT_IS_UNFORMATTED 1
01655 #define BURN_FORMAT_IS_FORMATTED   2
01656 #define BURN_FORMAT_IS_UNKNOWN     3
01657 
01658 /* ts A70112 */
01659 /** Inquire the formatting status, the associated sizes and the number of
01660     available formats.  The info is media specific and stems from MMC command
01661     23h READ FORMAT CAPACITY. See mmc5r03c.pdf 6.24 for background details.
01662     Media type can be determined via burn_disc_get_profile().
01663     @param drive The drive with the disc to format.
01664     @param status The current formatting status of the inserted media.
01665                   See BURN_FORMAT_IS_* macros. Note: "unknown" is the
01666                   legal status for quick formatted, yet unwritten DVD-RW.
01667     @param size The size in bytes associated with status.
01668                 unformatted: the maximum achievable size of the media
01669                 formatted:   the currently formatted capacity
01670                 unknown:     maximum capacity of drive or of media
01671     @param bl_sas Additional info "Block Length/Spare Area Size".
01672                   Expected to be constantly 2048 for non-BD media.
01673     @param num_formats The number of available formats. To be used with
01674                        burn_disc_get_format_descr() to obtain such a format
01675                        and eventually with burn_disc_format() to select one.
01676     @return 1 reply is valid , <=0 failure
01677     @since 0.3.0
01678 */
01679 int burn_disc_get_formats(struct burn_drive *drive, int *status, off_t *size,
01680                 unsigned *bl_sas, int *num_formats);
01681 
01682 /* ts A70112 */
01683 /** Inquire parameters of an available media format.
01684     @param drive The drive with the disc to format.
01685     @param index The index of the format item. Beginning with 0 up to reply
01686                  parameter from burn_disc_get_formats() : num_formats - 1
01687     @param type  The format type.  See mmc5r03c.pdf, 6.5, 04h FORMAT UNIT.
01688                  0x00=full, 0x10=CD-RW/DVD-RW full, 0x11=CD-RW/DVD-RW grow,
01689                  0x15=DVD-RW quick, 0x13=DVD-RW quick grow,
01690                  0x26=DVD+RW background, 0x30=BD-RE with spare areas,
01691                  0x31=BD-RE without spare areas
01692     @param size  The maximum size in bytes achievable with this format.
01693     @param tdp   Type Dependent Parameter. See mmc5r03c.pdf.
01694     @return 1 reply is valid , <=0 failure
01695     @since 0.3.0
01696 */
01697 int burn_disc_get_format_descr(struct burn_drive *drive, int index,
01698                 int *type, off_t *size, unsigned *tdp);
01699 
01700 
01701 
01702 /* ts A61109 : this was and is defunct */
01703 /** Read a disc from the drive and write it to an fd pair. The drive must be
01704     grabbed successfully BEFORE calling this function. Always ensure that the
01705     drive reports a status of BURN_DISC_FULL before calling this function.
01706     @param drive The drive from which to read a disc.
01707     @param o The options for the read operation.
01708 */
01709 void burn_disc_read(struct burn_drive *drive, const struct burn_read_opts *o);
01710 
01711 
01712 
01713 /* ts A70222 */
01714 /* @since 0.3.4 */
01715 /** The length of a rejection reasons string for burn_precheck_write() and
01716     burn_write_opts_auto_write_type() .
01717 */
01718 #define BURN_REASONS_LEN 4096
01719 
01720 
01721 /* ts A70219 */
01722 /** Examines a completed setup for burn_disc_write() whether it is permissible
01723     with drive and media. This function is called by burn_disc_write() but
01724     an application might be interested in this check in advance.
01725     @param o The options for the writing operation.
01726     @param disc The descrition of the disc to be created
01727     @param reasons Eventually returns a list of rejection reason statements
01728     @param silent 1= do not issue error messages , 0= report problems
01729     @return 1 ok, -1= no recordable media detected, 0= other failure
01730     @since 0.3.4
01731 */
01732 int burn_precheck_write(struct burn_write_opts *o, struct burn_disc *disc,
01733                         char reasons[BURN_REASONS_LEN], int silent);
01734 
01735 
01736 /** Write a disc in the drive. The drive must be grabbed successfully before
01737     calling this function. Always ensure that the drive reports a status of
01738     BURN_DISC_BLANK ot BURN_DISC_APPENDABLE before calling this function.
01739     Note: write_type BURN_WRITE_SAO is currently not capable of writing a mix
01740     of data and audio tracks. You must use BURN_WRITE_TAO for such sessions.
01741     To be set by burn_write_opts_set_write_type(). 
01742     Note: This function is not suitable for overwriting data in the middle of
01743           a valid data area because it is allowed to append trailing data.
01744           For exact random access overwriting use burn_random_access_write().
01745     Note: After writing it is advised to give up the drive and to grab it again
01746           in order to learn about its view on the new media state.
01747     Note: Before mounting the written media it might be necessary to eject
01748           and reload in order to allow the operating system to notice the new
01749           media state.
01750     @param o The options for the writing operation.
01751     @param disc The struct burn_disc * that described the disc to be created
01752 */
01753 void burn_disc_write(struct burn_write_opts *o, struct burn_disc *disc);
01754 
01755 
01756 /* ts A90227 */
01757 /** Control stream recording during the write run and eventually set the start
01758     LBA for stream recording.
01759     Stream recording is set from struct burn_write_opts when the write run
01760     gets started. See burn_write_opts_set_stream_recording().
01761     The call described here can be used later to override this setting and
01762     to program automatic switching at a given LBA. It also affects subsequent
01763     calls to burn_random_access_write().
01764     @param drive    The drive which performs the write operation.
01765     @param recmode  -1= disable stream recording
01766                      0= leave setting as is
01767                      1= enable stream recording
01768     @param start    The LBA where actual stream recording shall start.
01769                     (0 means unconditional stream recording)
01770     @param flag     Bitfield for control purposes (unused yet, submit 0).
01771     @return         1=success , <=0 failure
01772     @since 0.6.4
01773 */
01774 int burn_drive_set_stream_recording(struct burn_drive *drive, int recmode,
01775                                     int start, int flag);
01776 
01777 /** Cancel an operation on a drive.
01778     This will only work when the drive's busy state is BURN_DRIVE_READING or
01779     BURN_DRIVE_WRITING.
01780     @param drive The drive on which to cancel the current operation.
01781 */
01782 void burn_drive_cancel(struct burn_drive *drive);
01783 
01784 
01785 /* ts A61223 */
01786 /** Inquire whether the most recent asynchronous media job was successful.
01787     This applies to burn_disc_erase(), burn_disc_format(), burn_disc_write().
01788     Reasons for non-success may be: rejection of burn parameters, abort due to
01789     fatal errors during write, blank or format, a call to burn_drive_cancel()
01790     by the application thread.
01791     @param d The drive to inquire.
01792     @return 1=burn seems to have went well, 0=burn failed 
01793     @since 0.2.6
01794 */
01795 int burn_drive_wrote_well(struct burn_drive *d);
01796 
01797 
01798 /** Convert a minute-second-frame (MSF) value to sector count
01799     @param m Minute component
01800     @param s Second component
01801     @param f Frame component
01802     @return The sector count
01803 */
01804 int burn_msf_to_sectors(int m, int s, int f);
01805 
01806 /** Convert a sector count to minute-second-frame (MSF)
01807     @param sectors The sector count
01808     @param m Returns the minute component
01809     @param s Returns the second component
01810     @param f Returns the frame component
01811 */
01812 void burn_sectors_to_msf(int sectors, int *m, int *s, int *f);
01813 
01814 /** Convert a minute-second-frame (MSF) value to an lba
01815     @param m Minute component
01816     @param s Second component
01817     @param f Frame component
01818     @return The lba
01819 */
01820 int burn_msf_to_lba(int m, int s, int f);
01821 
01822 /** Convert an lba to minute-second-frame (MSF)
01823     @param lba The lba
01824     @param m Returns the minute component
01825     @param s Returns the second component
01826     @param f Returns the frame component
01827 */
01828 void burn_lba_to_msf(int lba, int *m, int *s, int *f);
01829 
01830 /** Create a new disc
01831     @return Pointer to a burn_disc object or NULL on failure.
01832 */
01833 struct burn_disc *burn_disc_create(void);
01834 
01835 /** Delete disc and decrease the reference count on all its sessions
01836     @param d The disc to be freed
01837 */
01838 void burn_disc_free(struct burn_disc *d);
01839 
01840 /** Create a new session
01841     @return Pointer to a burn_session object or NULL on failure.
01842  */
01843 struct burn_session *burn_session_create(void);
01844 
01845 /** Free a session (and decrease reference count on all tracks inside)
01846     @param s Session to be freed
01847 */
01848 void burn_session_free(struct burn_session *s);
01849 
01850 /** Add a session to a disc at a specific position, increasing the 
01851     sessions's reference count.
01852     @param d Disc to add the session to
01853     @param s Session to add to the disc
01854     @param pos position to add at (BURN_POS_END is "at the end")
01855     @return 0 for failure, 1 for success
01856 */
01857 int burn_disc_add_session(struct burn_disc *d, struct burn_session *s,
01858               unsigned int pos);
01859 
01860 /** Remove a session from a disc
01861     @param d Disc to remove session from
01862     @param s Session pointer to find and remove
01863 */
01864 int burn_disc_remove_session(struct burn_disc *d, struct burn_session *s);
01865 
01866 
01867 /* ts B11219 */
01868 /** Read a CDRWIN cue sheet file and equip the session object by tracks and
01869     CD-TEXT according to the content of the file.
01870     For a description of CDRWIN file format see
01871       http://digitalx.org/cue-sheet/syntax/
01872     Fully supported commands are:
01873       CATALOG , CDTEXTFILE , FLAGS , INDEX , ISRC , PERFORMER ,
01874       POSTGAP , PREGAP , REM , SONGWRITER , TITLE
01875     Further supported commands introduced by cdrecord (usage like PERFORMER):
01876       ARRANGER , COMPOSER , MESSAGE
01877     Partly supported commands are:
01878       FILE which supports only types BINARY , MOTOROLA , WAVE
01879       TRACK which supports only datatypes AUDIO , MODE1/2048
01880     Unsupported types of FILE or TRACK lead to failure of the call.
01881     libburn does not yet support mixing of AUDIO and MODE1/2048. So this call
01882     will fail if such a mix is found.
01883     CD-TEXT information is allowed only if all tracks are of datatype AUDIO.
01884     Empty lines and lines which start by '#' are ignored.
01885     @param session     Session where to attach tracks. It must not yet have
01886                        tracks or else this call will fail.
01887     @param path        Filesystem address of the CDRWIN cue sheet file.
01888                        Normally with suffix .cue
01889     @param fifo_size   Number of bytes in fifo. This will be rounded up by
01890                        the block size of the track mode. <= 0 means no fifo.
01891     @param fifo        Returns a reference to the burn_source object that
01892                        was installed as fifo between FILE and the track
01893                        burn sources. One may use this to inquire the fifo
01894                        state. Dispose it by burn_source_free() when no longer
01895                        needed. It is permissible to pass this parameter to
01896                        libburn as NULL, in order to immediately drop ownership
01897                        on the fifo.
01898     @param text_packs  Returns pre-formatted CD-TEXT packs resulting from
01899                        cue sheet command CDTEXTFILE. To be used with call
01900                        burn_write_opts_set_leadin_text().
01901                        It is permissible to pass this parameter to libburn
01902                        as NULL, in order to disable CDTEXTFILE.
01903     @param num_packs   Returns the number of 18 byte records in text_packs.
01904     @param flag        Bitfield for control purposes.
01905                        bit0= Do not attach CD-TEXT information to session and
01906                              tracks. Do not load text_packs.
01907                        bit1= Do not use media catalog string of session or ISRC
01908                              strings of tracks for writing to Q sub-channel.
01909     @return            > 0 indicates success, <= 0 indicates failure
01910     @since 1.2.0
01911 */
01912 int burn_session_by_cue_file(struct burn_session *session,
01913             char *path, int fifo_size, struct burn_source **fifo,
01914                         unsigned char **text_packs, int *num_packs, int flag);
01915 
01916 
01917 /** Create a track */
01918 struct burn_track *burn_track_create(void);
01919 
01920 /** Free a track
01921     @param t Track to free
01922 */
01923 void burn_track_free(struct burn_track *t);
01924 
01925 /** Add a track to a session at specified position
01926     @param s Session to add to
01927     @param t Track to insert in session
01928     @param pos position to add at (BURN_POS_END is "at the end")
01929     @return 0 for failure, 1 for success
01930 */
01931 int burn_session_add_track(struct burn_session *s, struct burn_track *t,
01932                unsigned int pos);
01933 
01934 /** Remove a track from a session
01935     @param s Session to remove track from
01936     @param t Track pointer to find and remove
01937     @return 0 for failure, 1 for success
01938 */
01939 int burn_session_remove_track(struct burn_session *s, struct burn_track *t);
01940 
01941 
01942 /* ts B20107 */
01943 /** Set the number which shall be written as CD track number with the first
01944     track of the session. The following tracks will then get written with
01945     consecutive CD track numbers. The resulting number of the last track
01946     must not exceed 99. The lowest possible start number is 1, which is also
01947     the default. This setting applies only to CD SAO writing.
01948     @param session   The session to be manipulated
01949     @param tno       A number between 1 and 99
01950     @param flag      Bitfield for control purposes. Unused yet. Submit 0.
01951     @return          > 0 indicates success, <= 0 indicates failure
01952     @since 1.2.0
01953 */
01954 int burn_session_set_start_tno(struct burn_session *session, int tno,
01955                                int flag);
01956 
01957 /* ts B20108 */
01958 /** Inquire the CD track start number, as set by default ot by 
01959     burn_session_set_start_tno().
01960     @param session   The session to be inquired
01961     @return          > 0 is the currently set CD track start number
01962                      <= 0 indicates failure
01963     @since 1.2.0
01964 */
01965 int burn_session_get_start_tno(struct burn_session *session, int flag);
01966 
01967 
01968 
01969 /* ts B11206 */
01970 /** Set the Character Codes, the Copyright bytes, and the Language Codes
01971     for CD-TEXT blocks 0 to 7. They will be used in the block summaries
01972     of text packs which get generated from text or binary data submitted
01973     by burn_session_set_cdtext() and burn_track_set_cdtext().
01974     Character Code value can be
01975       0x00 = ISO-8859-1
01976       0x01 = 7 bit ASCII
01977       0x80 = MS-JIS (japanesei Kanji, double byte characters)
01978     Copyright byte value can be
01979       0x00 = not copyrighted
01980       0x03 = copyrighted
01981     Language Code value will typically be 0x09 = English or 0x69 = Japanese.
01982     See below macros BURN_CDTEXT_LANGUAGES_0X00 and BURN_CDTEXT_LANGUAGES_0X45,
01983     but be aware that many of these codes have never been seen on CD, and that
01984     many of them do not have a character representation among the above
01985     Character Codes. 
01986     Default is 0x09 = English for block 0 and 0x00 = Unknown for block 1 to 7.
01987     Copyright and Character Code are 0x00 for all blocks by default.
01988     See also file doc/cdtext.txt, "Format of a CD-TEXT packs array",
01989     "Pack type 0x8f".
01990 
01991     Parameter value -1 leaves the current setting of the session parameter
01992     unchanged.
01993     @param s            Session where to change settings
01994     @param char_codes   Character Codes for block 0 to 7
01995     @param copyrights   Copyright bytes for block 0 to 7
01996     @param languages    Language Codes for block 0 to 7
01997     @param flag         Bitfiled for control purposes. Unused yet. Submit 0.
01998     @return             <=0 failure, > 0 success
01999     @since 1.2.0
02000 */
02001 int burn_session_set_cdtext_par(struct burn_session *s,
02002                                 int char_codes[8], int copyrights[8],
02003                                 int languages[8], int flag);
02004 
02005 /** This is the first list of languages sorted by their Language codes,
02006     which start at 0x00.  They stem from from EBU Tech 3264, appendix 3.
02007     E.g. language 0x00 is "Unknown", 0x08 is "German", 0x10 is "Frisian",
02008     0x18 is "Latvian", 0x20 is "Polish", 0x28 is "Swedish", 0x2b is "Wallon".
02009     See also file doc/cdtext.txt.
02010     @since 1.2.0
02011 */
02012 #define BURN_CDTEXT_LANGUAGES_0X00 \
02013         "Unknown", "Albanian", "Breton", "Catalan", \
02014         "Croatian", "Welsh", "Czech", "Danish", \
02015         "German", "English", "Spanish", "Esperanto", \
02016         "Estonian", "Basque", "Faroese", "French", \
02017         "Frisian", "Irish", "Gaelic", "Galician", \
02018         "Icelandic", "Italian", "Lappish", "Latin", \
02019         "Latvian", "Luxembourgian", "Lithuanian", "Hungarian", \
02020         "Maltese", "Dutch", "Norwegian", "Occitan", \
02021         "Polish", "Portuguese", "Romanian", "Romansh", \
02022         "Serbian", "Slovak", "Slovenian", "Finnish", \
02023         "Swedish", "Turkish", "Flemish", "Wallon" 
02024 
02025 /** This is the second list of languages sorted by their Language codes,
02026     which start at 0x45.  They stem from from EBU Tech 3264, appendix 3.
02027     E.g. language 0x45 is "Zulu", 0x50 is "Sranan Tongo", 0x58 is "Pushtu",
02028     0x60 is "Moldavian", 0x68 is "Kannada", 0x70 is "Greek", 0x78 is "Bengali",
02029     0x7f is "Amharic".
02030     See also file doc/cdtext.txt.
02031     @since 1.2.0
02032 */
02033 #define BURN_CDTEXT_LANGUAGES_0X45 \
02034                  "Zulu", "Vietnamese", "Uzbek", \
02035         "Urdu", "Ukrainian", "Thai", "Telugu", \
02036         "Tatar", "Tamil", "Tadzhik", "Swahili", \
02037         "Sranan Tongo", "Somali", "Sinhalese", "Shona", \
02038         "Serbo-croat", "Ruthenian", "Russian", "Quechua", \
02039         "Pushtu", "Punjabi", "Persian", "Papamiento", \
02040         "Oriya", "Nepali", "Ndebele", "Marathi", \
02041         "Moldavian", "Malaysian", "Malagasay", "Macedonian", \
02042         "Laotian", "Korean", "Khmer", "Kazakh", \
02043         "Kannada", "Japanese", "Indonesian", "Hindi", \
02044         "Hebrew", "Hausa", "Gurani", "Gujurati", \
02045         "Greek", "Georgian", "Fulani", "Dari", \
02046         "Churash", "Chinese", "Burmese", "Bulgarian", \
02047         "Bengali", "Bielorussian", "Bambora", "Azerbaijani", \
02048         "Assamese", "Armenian", "Arabic", "Amharic"
02049 
02050 /* This is the list of empty languages names between 0x30 and 0x44.
02051    Together the three macros fill an array of 128 char pointers.
02052     static char *languages[] = {
02053       BURN_CDTEXT_LANGUAGES_0X00,
02054       BURN_CDTEXT_FILLER,
02055       BURN_CDTEXT_LANGUAGES_0X45
02056     };
02057 */
02058 #define BURN_CDTEXT_FILLER \
02059          "", "", "", "", \
02060          "", "", "", "", \
02061          "", "", "", "", \
02062          "", "", "", "", \
02063          "", "", "", "", \
02064          "", "", "", "", \
02065          ""
02066 
02067 /* ts B11206 */
02068 /** Obtain the current settings as of burn_session_set_cdtext_par() resp.
02069     by default.
02070     @param s            Session which to inquire
02071     @param char_codes   Will return Character Codes for block 0 to 7
02072     @param copyrights   Will return Copyright bytes for block 0 to 7
02073     @param languages    Will return Language Codes for block 0 to 7
02074     @param flag         Bitfiled for control purposes. Unused yet. Submit 0.
02075     @return             <=0 failure, reply invalid, > 0 success, reply valid
02076     @since 1.2.0
02077 */
02078 int burn_session_get_cdtext_par(struct burn_session *s,
02079                                 int char_codes[8], int copyrights[8],
02080                                 int block_languages[8], int flag);
02081 
02082 
02083 /* ts B11206 */
02084 /** Attach text or binary data as CD-TEXT attributes to a session.
02085     They can be used to generate CD-TEXT packs by burn_cdtext_from_session()
02086     or to write CD-TEXT packs into the lead-in of a CD SAO session.
02087     The latter happens only if no array of CD-TEXT packs is attached to
02088     the write options by burn_write_opts_set_leadin_text().
02089     For details of the CD-TEXT format and of the payload content, see file
02090     doc/cdtext.txt .
02091     @param s            Session where to attach CD-TEXT attribute
02092     @param block        Number of the language block in which the attribute
02093                         shall appear. Possible values: 0 to 7.
02094     @param pack_type    Pack type number. 0x80 to 0x8e. Used if pack_type_name
02095                         is NULL or empty text. Else submit 0 and a name.
02096                         Pack type 0x8f is generated automatically and may not
02097                         be set by applications.
02098     @param pack_type_name  The pack type by name. Defined names are:
02099                           0x80 = "TITLE"         0x81 = "PERFORMER"
02100                           0x82 = "SONGWRITER"    0x83 = "COMPOSER"
02101                           0x84 = "ARRANGER"      0x85 = "MESSAGE"
02102                           0x86 = "DISCID"        0x87 = "GENRE"
02103                           0x88 = "TOC"           0x89 = "TOC2"
02104                           0x8d = "CLOSED"        0x8e = "UPC_ISRC"
02105                         Names are recognized uppercase and lowercase.
02106     @param payload      Text or binary bytes. The data will be copied to
02107                         session-internal memory.
02108                         Pack types 0x80 to 0x85 contain 0-terminated cleartext
02109                         encoded according to the block's Character Code.
02110                         If double byte characters are used, then two 0-bytes
02111                         terminate the cleartext.
02112                         Pack type 0x86 is 0-terminated ASCII cleartext.
02113                         Pack type 0x87 consists of two byte big-endian
02114                         Genre code (see below BURN_CDTEXT_GENRE_LIST), and
02115                         0-terminated ASCII cleartext of genre description.
02116                         Pack type 0x88 mirrors the session table-of-content.
02117                         Pack type 0x89 is not understood yet.
02118                         Pack types 0x8a to 0x8c are reserved.
02119                         Pack type 0x8d contains ISO-8859-1 cleartext which is
02120                         not to be shown by commercial audio CD players.
02121                         Pack type 0x8e is ASCII cleartext with UPC/EAN code.
02122     @pram length        Number of bytes in payload. Including terminating
02123                         0-bytes.
02124     @param flag         Bitfield for control purposes.
02125                         bit0= payload contains double byte characters
02126                               (with character code 0x80 MS-JIS japanese Kanji)
02127     @return             > 0 indicates success , <= 0 is failure
02128     @since 1.2.0
02129 */
02130 int burn_session_set_cdtext(struct burn_session *s, int block,
02131                             int pack_type, char *pack_type_name,
02132                             unsigned char *payload, int length, int flag);
02133 
02134 
02135 /** This is the list of Genres sorted by their Genre codes.
02136     E.g. genre code 0x0000 is "No Used", 0x0008 is "Dance, 0x0010 is "Musical",
02137     0x0018 is "Rhythm & Blues", 0x001b is "World Music".
02138     See also file doc/cdtext.txt.
02139     @since 1.2.0
02140 */
02141 #define BURN_CDTEXT_GENRE_LIST \
02142         "Not Used", "Not Defined", "Adult Contemporary", "Alternative Rock", \
02143         "Childrens Music", "Classical", "Contemporary Christian", "Country", \
02144         "Dance", "Easy Listening", "Erotic", "Folk", \
02145         "Gospel", "Hip Hop", "Jazz", "Latin", \
02146         "Musical", "New Age", "Opera", "Operetta", \
02147         "Pop Music", "Rap", "Reggae", "Rock Music", \
02148         "Rhythm & Blues", "Sound Effects", "Spoken Word", "World Music"
02149 
02150 /* The number of genre names in BURN_CDTEXT_GENRE_LIST.
02151 */
02152 #define BURN_CDTEXT_NUM_GENRES 28
02153 
02154 
02155 /* ts B11206 */
02156 /** Obtain a CD-TEXT attribute that was set by burn_session_set_cdtext()
02157     @param s            Session to inquire
02158     @param block        Number of the language block to inquire.
02159     @param pack_type    Pack type number to inquire. Used if pack_type_name
02160                         is NULL or empty text. Else submit 0 and a name.
02161                         Pack type 0x8f is generated automatically and may not
02162                         be inquire in advance. Use burn_cdtext_from_session()
02163                         to generate all packs including type 0x8f packs.
02164     @param pack_type_name  The pack type by name.
02165                         See above burn_session_set_cdtext().
02166     @param payload      Will return a pointer to text or binary bytes.
02167                         Not a copy of data. Do not free() this address.
02168                         If no text attribute is attached for pack type and
02169                         block, then payload is returned as NULL. The return
02170                         value will not indicate error in this case.
02171     @pram length        Will return the number of bytes pointed to by payload.
02172                         Including terminating 0-bytes.
02173     @param flag         Bitfield for control purposes. Unused yet. Submit 0.
02174     @return             1 single byte char, 2 double byte char, <=0 error
02175     @since 1.2.0
02176 */
02177 int burn_session_get_cdtext(struct burn_session *s, int block,
02178                             int pack_type, char *pack_type_name,
02179                             unsigned char **payload, int *length, int flag);
02180 
02181 
02182 /* ts B11215 */
02183 /** Read a Sony CD-TEXT Input Sheet Version 0.7T file and attach its text
02184     attributes to the given session and its tracks for the given CD-TEXT
02185     block number. This overrides previous settings made by
02186     burn_session_set_cdtext(), burn_track_set_cdtext(), burn_track_set_isrc(),
02187     burn_session_set_start_tno(). It can later be overridden by said function
02188     calls.
02189     The media catalog number from purpose specifier "UPC / EAN" gets into
02190     effect only if burn_write_opts_set_has_mediacatalog() is set to 0.
02191     The format of a v07t sheet file is documented in doc/cdtext.txt.
02192     @param s           Session where to attach CD-TEXT attributes
02193     @param path        Local filesystem address of the sheet file which
02194                        shall be read and interpreted.
02195     @param block       Number of the language block in which the attributes
02196                        shall appear. Possible values: 0 to 7.
02197     @param flag        Bitfield for control purposes.
02198                        bit1= Do not use media catalog string of session or ISRC
02199                              strings of tracks for writing to Q sub-channel.
02200     @return            > 0 indicates success , <= 0 is failure
02201     @since 1.2.0
02202 */
02203 int burn_session_input_sheet_v07t(struct burn_session *session,
02204                                   char *path, int block, int flag);
02205 
02206 
02207 /* ts B11210 */
02208 /** Produce an array of CD-TEXT packs that could be submitted to
02209     burn_write_opts_set_leadin_text() or stored as *.cdt file.
02210     For a description of the format of the array, see file doc/cdtext.txt.
02211     The input data stem from burn_session_set_cdtext_par(),
02212     burn_session_set_cdtext(), and burn_track_set_cdtext().
02213     @param s            Session from which to produce CD-TEXT packs.
02214     @param text_packs   Will return the buffer with the CD-TEXT packs.
02215                         Dispose by free() when no longer needed.
02216     @param num_packs    Will return the number of 18 byte text packs.
02217     @param flag         Bitfield for control purposes.
02218                         bit0= do not return generated CD-TEXT packs,
02219                               but check whether production would work and
02220                               indicate the number of packs by the call return
02221                               value. This happens also if
02222                               (text_packs == NULL || num_packs == NULL).
02223     @return             Without flag bit0: > 0 is success, <= 0 failure
02224                         With flag bit0: > 0 is number of packs,
02225                                           0 means no packs will be generated,
02226                                         < 0 means failure  
02227     @since 1.2.0
02228 */
02229 int burn_cdtext_from_session(struct burn_session *s,
02230                              unsigned char **text_packs, int *num_packs,
02231                              int flag);
02232 
02233 
02234 /* ts B11206 */
02235 /** Remove all CD-TEXT attributes of the given block from the session.
02236     They were attached by burn_session_set_cdtext().
02237     @param s            Session where to remove the CD-TEXT attribute
02238     @param block        Number of the language block in which the attribute
02239                         shall appear. Possible values: 0 to 7.
02240                         -1 causes text packs of all blocks to be removed.
02241     @return             > 0 is success, <= 0 failure
02242     @since 1.2.0
02243 */
02244 int burn_session_dispose_cdtext(struct burn_session *s, int block);
02245 
02246 
02247 /* ts B11221*/ 
02248 /** Read an array of CD-TEXT packs from a file. This array should be suitable
02249     for burn_write_opts_set_leadin_text().
02250     The function tolerates and removes 4-byte headers as produced by
02251     cdrecord -vv -toc, if this header tells the correct number of bytes which
02252     matches the file size. If no 4-byte header is present, then the function
02253     tolerates and removes a trailing 0-byte as of Sony specs.
02254     @param path         Filesystem address of the CD-TEXT pack file.
02255                         Normally with suffix .cdt or .dat
02256     @param text_packs   Will return the buffer with the CD-TEXT packs.
02257                         Dispose by free() when no longer needed.
02258     @param num_packs    Will return the number of 18 byte text packs.
02259     @param flag         Bitfield for control purposes. Unused yet.Submit 0.
02260     @return             0 is success, <= 0 failure
02261     @since 1.2.0
02262 */
02263 int burn_cdtext_from_packfile(char *path, unsigned char **text_packs,
02264                               int *num_packs, int flag);
02265 
02266 
02267 /** Define the data in a track
02268     @param t the track to define
02269     @param offset The lib will write this many 0s before start of data
02270     @param tail The number of extra 0s to write after data
02271     @param pad 1 means the lib should pad the last sector with 0s if the
02272            track isn't exactly sector sized.  (otherwise the lib will
02273            begin reading from the next track)
02274     @param mode data format (bitfield)
02275 */
02276 void burn_track_define_data(struct burn_track *t, int offset, int tail,
02277                 int pad, int mode);
02278 
02279 
02280 /* ts B11206 */
02281 /** Attach text or binary data as CD-TEXT attributes to a track.
02282     The payload will be used to generate CD-TEXT packs by
02283     burn_cdtext_from_session() or to write CD-TEXT packs into the lead-in
02284     of a CD SAO session. This happens if the CD-TEXT attribute of the session
02285     gets generated, which has the same block number and pack type. In this
02286     case, each track should have such a CD-TEXT attribute, too.
02287     See burn_session_set_cdtext().
02288     Be cautious not to exceed the maximum number of 253 payload packs per
02289     language block. Use burn_cdtext_from_session() to learn whether a valid
02290     array of CD-TEXT packs can be generated from your attributes.
02291     @param t            Track where to attach CD-TEXT attribute.
02292     @param block        Number of the language block in which the attribute
02293                         shall appear. Possible values: 0 to 7.
02294     @param pack_type    Pack type number. 0x80 to 0x85 or 0x8e. Used if
02295                         pack_type_name is NULL or empty text. Else submit 0
02296                         and a name.
02297     @param pack_type_name  The pack type by name. Applicable names are:
02298                           0x80 = "TITLE"         0x81 = "PERFORMER"
02299                           0x82 = "SONGWRITER"    0x83 = "COMPOSER"
02300                           0x84 = "ARRANGER"      0x85 = "MESSAGE"
02301                           0x8e = "UPC_ISRC"
02302     @param payload      0-terminated cleartext. If double byte characters
02303                         are used, then two 0-bytes terminate the cleartext.
02304     @pram length        Number of bytes in payload. Including terminating
02305                         0-bytes.
02306     @param flag         Bitfield for control purposes.
02307                         bit0= payload contains double byte characters
02308                               (with character code 0x80 MS-JIS japanese Kanji)
02309     @return             > 0 indicates success , <= 0 is failure
02310     @since 1.2.0
02311 */
02312 int burn_track_set_cdtext(struct burn_track *t, int block,
02313                           int pack_type, char *pack_type_name,
02314                           unsigned char *payload, int length, int flag);
02315 
02316 /* ts B11206 */
02317 /** Obtain a CD-TEXT attribute that was set by burn_track_set_cdtext().
02318     @param t            Track to inquire
02319     @param block        Number of the language block to inquire.
02320     @param pack_type    Pack type number to inquire. Used if pack_type_name
02321                         is NULL or empty text. Else submit 0 and a name.
02322     @param pack_type_name  The pack type by name.
02323                         See above burn_track_set_cdtext().
02324     @param payload      Will return a pointer to text bytes.
02325                         Not a copy of data. Do not free() this address.
02326                         If no text attribute is attached for pack type and
02327                         block, then payload is returned as NULL. The return
02328                         value will not indicate error in this case.
02329     @pram length        Will return the number of bytes pointed to by payload.
02330                         Including terminating 0-bytes.
02331     @param flag         Bitfield for control purposes. Unused yet. Submit 0.
02332     @return             1=single byte char , 2= double byte char , <=0 error
02333     @since 1.2.0
02334 */
02335 int burn_track_get_cdtext(struct burn_track *t, int block,
02336                           int pack_type, char *pack_type_name,
02337                           unsigned char **payload, int *length, int flag);
02338 
02339 /* ts B11206 */
02340 /** Remove all CD-TEXT attributes of the given block from the track.
02341     They were attached by burn_track_set_cdtext().
02342     @param t            Track where to remove the CD-TEXT attribute.
02343     @param block        Number of the language block in which the attribute
02344                         shall appear. Possible values: 0 to 7. 
02345                         -1 causes text packs of all blocks to be removed.
02346     @return             > 0 is success, <= 0 failure 
02347     @since 1.2.0
02348 */
02349 int burn_track_dispose_cdtext(struct burn_track *t, int block);
02350 
02351 
02352 /* ts A90910 */
02353 /** Activates CD XA compatibility modes.
02354     libburn currently writes data only in CD mode 1. Some programs insist in
02355     sending data with additional management bytes. These bytes have to be
02356     stripped in order to make the input suitable for BURN_MODE1.
02357     @param t     The track to manipulate
02358     @param value 0= no conversion
02359                  1= strip 8 byte sector headers of CD-ROM XA mode 2 form 1
02360                     see MMC-5 4.2.3.8.5.3 Block Format for Mode 2 form 1 Data
02361                  all other values are reserved
02362     @return 1=success , 0=unacceptable value
02363     @since 0.7.2
02364 */
02365 int burn_track_set_cdxa_conv(struct burn_track *t, int value);
02366 
02367 
02368 /** Set the ISRC details for a track. When writing to CD media, ISRC will get
02369     written into the Q sub-channel.
02370     @param t The track to change
02371     @param country the 2 char country code. Each character must be
02372            only numbers or letters.
02373     @param owner 3 char owner code. Each character must be only numbers
02374            or letters.
02375     @param year 2 digit year. A number in 0-99 (Yep, not Y2K friendly).
02376     @param serial 5 digit serial number. A number in 0-99999.
02377 */
02378 void burn_track_set_isrc(struct burn_track *t, char *country, char *owner,
02379              unsigned char year, unsigned int serial);
02380 
02381 /* ts B11226 */
02382 /** Set the composed ISRC string for a track. This is an alternative to
02383     burn_track_set_isrc().
02384     @param t      The track to be manipulated
02385     @param isrc   12 characters which are composed from ISRC details.
02386                   Format is CCOOOYYSSSSS, terminated by a 0-byte:
02387                   Country, Owner, Year(decimal digits), Serial(decimal digits).
02388     @param flag   Bitfield for control purposes. Unused yet. Submit 0.
02389     @return       > 0 indicates success, <= 0 means failure
02390     @since 1.2.0
02391 */
02392 int burn_track_set_isrc_string(struct burn_track *t, char isrc[13], int flag);
02393 
02394 /** Disable ISRC parameters for a track
02395     @param t The track to change
02396 */
02397 void burn_track_clear_isrc(struct burn_track *t);
02398 
02399 
02400 /* ts B20103 */
02401 /** Define an index start address within a track. The index numbers inside a
02402     track have to form sequence starting at 0 or 1 with no gaps up to the
02403     highest number used. They affect only writing of CD SAO sessions.
02404     The first index start address of a track must be 0.
02405     Blocks between index 0 and index 1 are considered to be located before the
02406     track start as of the table-of-content.
02407     @param t             The track to be manipulated
02408     @param index_number  A number between 0 and 99
02409     @param relative_lba  The start address relative to the start of the
02410                          burn_source of the track. It will get mapped to the
02411                          appropriate absolute block address.
02412     @param flag          Bitfield for control purposes. Unused yet. Submit 0.
02413     @return              > 0 indicates success, <= 0 means failure
02414     @since 1.2.0
02415 */
02416 int burn_track_set_index(struct burn_track *t, int index_number,
02417                                         unsigned int relative_lba, int flag);
02418 
02419 /* ts B20103 */
02420 /** Remove all index start addresses and reset to the default indexing of
02421     CD SAO sessions. This means index 0 of track 1 reaches from LBA -150
02422     to LBA -1. Index 1 of track 1 reaches from LBA 0 to track end. Index 1
02423     of track 2 follows immediately. The same happens for all further tracks
02424     after the end of their predecessor.
02425     @param t             The track to be manipulated
02426     @param flag          Bitfield for control purposes. Unused yet. Submit 0.
02427     @return              > 0 indicates success, <= 0 means failure
02428     @since 1.2.0
02429 */
02430 int burn_track_clear_indice(struct burn_track *t, int flag);
02431 
02432 
02433 /* ts B20110 */
02434 /** Define whether a pre-gap shall be written before the track and how many
02435     sectors this pre-gap shall have. A pre-gap is written in the range of track
02436     index 0 and contains zeros resp. silence. No bytes from the track source
02437     will be read for writing the pre-gap.
02438     This setting affects only CD SAO write runs.
02439     The first track automatically gets a pre-gap of at least 150 sectors. Its
02440     size may be enlarged by this call. Further pre-gaps are demanded by MMC
02441     for tracks which follow tracks of a different mode. (But Mode mixing in
02442     CD SAO sessions is currently not supported by libburn.)
02443     @param t             The track to change
02444     @param size          Number of sectors in the pre-gap.
02445                          -1 disables pre-gap, except for the first track.
02446                          libburn allows 0, but MMC does not propose this.
02447     @param flag          Bitfield for control purposes. Unused yet. Submit 0.
02448     @return              > 0 indicates success, <= 0 means failure
02449     @since 1.2.0
02450 */
02451 int burn_track_set_pregap_size(struct burn_track *t, int size, int flag);
02452 
02453 /* ts B20111 */
02454 /** Define whether a post-gap shall be written at the end of the track and
02455     how many sectors this gap shall have. A post-gap occupies the range of
02456     an additional index of the track. It contains zeros. No bytes from the
02457     track source will be read for writing the post-gap.
02458     This setting affects only CD SAO write runs.
02459     MMC prescribes to add a post-gap to a data track which is followed by
02460     a non-data track. (But libburn does not yet support mixed mode CD SAO
02461     sessions.)
02462     @param t             The track to change
02463     @param size          Number of sectors in the post-gap.
02464                          -1 disables post-gap.
02465                          libburn allows 0, but MMC does not propose this.
02466     @param flag          Bitfield for control purposes. Unused yet. Submit 0.
02467     @return              > 0 indicates success, <= 0 means failure
02468     @since 1.2.0
02469 */
02470 int burn_track_set_postgap_size(struct burn_track *t, int size, int flag);
02471 
02472 
02473 /* ts A61024 */
02474 /** Define whether a track shall swap bytes of its input stream.
02475     @param t The track to change
02476     @param swap_source_bytes 0=do not swap, 1=swap byte pairs
02477     @return 1=success , 0=unacceptable value
02478     @since 0.2.6
02479 */
02480 int burn_track_set_byte_swap(struct burn_track *t, int swap_source_bytes);
02481 
02482 
02483 /** Hide the first track in the "pre gap" of the disc
02484     @param s session to change
02485     @param onoff 1 to enable hiding, 0 to disable
02486 */
02487 void burn_session_hide_first_track(struct burn_session *s, int onoff);
02488 
02489 /** Get the drive's disc struct - free when done
02490     @param d drive to query
02491     @return the disc struct or NULL on failure
02492 */
02493 struct burn_disc *burn_drive_get_disc(struct burn_drive *d);
02494 
02495 /** Set the track's data source
02496     @param t The track to set the data source for
02497     @param s The data source to use for the contents of the track
02498     @return An error code stating if the source is ready for use for
02499             writing the track, or if an error occured
02500     
02501 */
02502 enum burn_source_status burn_track_set_source(struct burn_track *t,
02503                           struct burn_source *s);
02504 
02505 
02506 /* ts A70218 */
02507 /** Set a default track size to be used only if the track turns out to be of
02508     unpredictable length and if the effective write type demands a fixed size.
02509     This can be useful to enable write types CD SAO or DVD DAO together with
02510     a track source like stdin. If the track source delivers fewer bytes than
02511     announced then the track will be padded up with zeros.
02512     @param t The track to change
02513     @param size The size to set
02514     @return 0=failure 1=sucess
02515     @since 0.3.4
02516 */
02517 int burn_track_set_default_size(struct burn_track *t, off_t size);
02518 
02519 /** Free a burn_source (decrease its refcount and maybe free it)
02520     @param s Source to free
02521 */
02522 void burn_source_free(struct burn_source *s);
02523 
02524 /** Creates a data source for an image file (and maybe subcode file)
02525     @param path The file address for the main channel payload.
02526     @param subpath Eventual address for subchannel data. Only used in exotic
02527                    raw write modes. Submit NULL for normal tasks.
02528     @return Pointer to a burn_source object, NULL indicates failure
02529 */
02530 struct burn_source *burn_file_source_new(const char *path,
02531                      const char *subpath);
02532 
02533 
02534 /* ts A91122 : An interface to open(O_DIRECT) or similar OS tricks. */
02535 
02536 /** Opens a file with eventual acceleration preparations which may depend
02537     on the operating system and on compile time options of libburn.
02538     You may use this call instead of open(2) for opening file descriptors
02539     which shall be handed to burn_fd_source_new().
02540     This should only be done for tracks with BURN_BLOCK_MODE1 (2048 bytes
02541     per block).
02542 
02543     If you use this call then you MUST allocate the buffers which you use
02544     with read(2) by call burn_os_alloc_buffer(). Read sizes MUST be a multiple
02545     of a safe buffer amount. Else you risk that track data get altered during
02546     transmission.
02547     burn_disk_write() will allocate a suitable read/write buffer for its own
02548     operations. A fifo created by burn_fifo_source_new() will allocate
02549     suitable memory for its buffer if called with flag bit0 and a multiple
02550     of a safe buffer amount. 
02551     @param path       The file address to open
02552     @param open_flags The flags as of man 2 open. Normally just O_RDONLY.
02553     @param flag       Bitfield for control purposes (unused yet, submit 0).
02554     @return           A file descriptor as of open(2). Finally to be disposed
02555                       by close(2).
02556                       -1 indicates failure.
02557     @since 0.7.4
02558 */
02559 int burn_os_open_track_src(char *path, int open_flags, int flag);
02560 
02561 /** Allocate a memory area that is suitable for reading with a file descriptor
02562     opened by burn_os_open_track_src().
02563     @param amount     Number of bytes to allocate. This should be a multiple
02564                       of the operating system's i/o block size. 32 KB is
02565                       guaranteed by libburn to be safe.
02566     @param flag       Bitfield for control purposes (unused yet, submit 0).
02567     @return           The address of the allocated memory, or NULL on failure.
02568                       A non-NULL return value has finally to be disposed via
02569                       burn_os_free_buffer().
02570     @since 0.7.4
02571 */
02572 void *burn_os_alloc_buffer(size_t amount, int flag);
02573 
02574 /** Dispose a memory area which was obtained by burn_os_alloc_buffer(),
02575     @param buffer     Memory address to be freed.
02576     @param amount     The number of bytes which was allocated at that
02577                       address.
02578     @param flag       Bitfield for control purposes (unused yet, submit 0).
02579     @return           1 success , <=0 failure
02580     @since 0.7.4
02581 */
02582 int burn_os_free_buffer(void *buffer, size_t amount, int flag);
02583 
02584 
02585 /** Creates a data source for an image file (a track) from an open
02586     readable filedescriptor, an eventually open readable subcodes file
02587     descriptor and eventually a fixed size in bytes.
02588     @param datafd The source of data.
02589     @param subfd The eventual source of subchannel data. Only used in exotic
02590                  raw write modes. Submit -1 for normal tasks.
02591     @param size The eventual fixed size of eventually both fds. 
02592                 If this value is 0, the size will be determined from datafd.
02593     @return Pointer to a burn_source object, NULL indicates failure
02594 */
02595 struct burn_source *burn_fd_source_new(int datafd, int subfd, off_t size);
02596 
02597 
02598 /* ts B00922 */
02599 /** Creates an offset source which shall provide a byte interval of a stream
02600     to its consumer. It is supposed to be chain-linked with other offset
02601     sources which serve neighboring consumers. The chronological sequence
02602     of consumers and the sequence of offset sources must match. The intervals
02603     of the sources must not overlap.
02604 
02605     A chain of these burn_source objects may be used to feed multiple tracks
02606     from one single stream of input bytes.
02607     Each of the offset sources will skip the bytes up to its start address and
02608     provide the prescribed number of bytes to the track. Skipping takes into
02609     respect the bytes which have been processed by eventual predecessors in the
02610     chain.
02611     Important: It is not allowed to free an offset source before its successor
02612                has ended its work. Best is to keep them all until all tracks
02613                are done.
02614 
02615     @param inp   The burn_source object from which to read stream data.
02616                  E.g. created by burn_file_source_new().
02617     @param prev  The eventual offset source object which shall read data from
02618                  inp before the new offset source will begin its own work.
02619                  This must either be a result of  burn_offst_source_new()  or
02620                  it must be NULL.
02621     @param start The byte address where to start reading bytes for the
02622                  consumer. inp bytes may get skipped to reach this address.
02623     @param size  The number of bytes to be delivered to the consumer.
02624                  If size is <= 0 then it may be set later by a call of method
02625                  set_size(). If it is >= 0, then it can only be changed if
02626                  flag bit0 was set with burn_offst_source_new().
02627     @param flag  Bitfield for control purposes
02628                  bit0 = Prevent set_size() from overriding interval sizes > 0.
02629                         If such a size is already set, then the new one will
02630                         only affect the reply of get_size().
02631                         See also above struct burn_source.
02632                         @since 1.2.0
02633     @return      Pointer to a burn_source object, later to be freed by
02634                  burn_source_free(). NULL indicates failure.
02635     @since 0.8.8
02636 */
02637 struct burn_source *burn_offst_source_new(
02638                 struct burn_source *inp, struct burn_source *prev,
02639                 off_t start, off_t size, int flag);
02640 
02641 /* ts A70930 */
02642 /** Creates a fifo which acts as proxy for an already existing data source.
02643     The fifo provides a ring buffer which shall smoothen the data stream
02644     between burn_source and writer thread. Each fifo serves only for one
02645     data source. It may be attached to one track as its only data source
02646     by burn_track_set_source(), or it may be used as input for other burn
02647     sources.
02648     A fifo starts its life in "standby" mode with no buffer space allocated.
02649     As soon as its consumer requires bytes, the fifo establishes a worker
02650     thread and allocates its buffer. After input has ended and all buffer
02651     content is consumed, the buffer space gets freed and the worker thread
02652     ends. This happens asynchronously. So expect two buffers and worker threads
02653     to exist for a short time between tracks. Be modest in your size demands if
02654     multiple tracks are to be expected. 
02655     @param inp        The burn_source for which the fifo shall act as proxy.
02656                       It can be disposed by burn_source_free() immediately
02657                       after this call.
02658     @param chunksize  The size in bytes of a chunk.
02659                       Use 2048 for sources suitable for BURN_BLOCK_MODE1,
02660                       2352 for sources which deliver for BURN_BLOCK_AUDIO,
02661                       2056 for sources which shall get treated by 
02662                       burn_track_set_cdxa_conv(track, 1).
02663                       Some variations of burn_source might work only with
02664                       a particular chunksize. E.g. libisofs demands 2048.
02665     @param chunks     The number of chunks to be allocated in ring buffer.
02666                       This value must be >= 2.
02667     @param flag       Bitfield for control purposes:
02668                       bit0= The read method of inp is capable of delivering
02669                             arbitrary amounts of data per call. Not only one
02670                             sector.
02671                             Suitable for inp from burn_file_source_new()
02672                             and burn_fd_source_new() if not the fd has
02673                             exotic limitations on read size.
02674                             You MUST use this on inp which uses an fd opened
02675                             with burn_os_open_track_src().
02676                             Better do not use with other inp types.
02677                             @since 0.7.4
02678     @return           A pointer to the newly created burn_source.
02679                       Later both burn_sources, inp and the returned fifo, have
02680                       to be disposed by calling burn_source_free() for each.
02681                       inp can be freed immediately, the returned fifo may be
02682                       kept as handle for burn_fifo_inquire_status().
02683     @since 0.4.0
02684 */
02685 struct burn_source *burn_fifo_source_new(struct burn_source *inp,
02686                                          int chunksize, int chunks, int flag);
02687 
02688 /* ts A71003 */
02689 /** Inquires state and fill parameters of a fifo burn_source which was created
02690     by burn_fifo_source_new() . Do not use with other burn_source variants.
02691     @param fifo  The fifo object to inquire
02692     @param size  The total size of the fifo
02693     @param free_bytes  The current free capacity of the fifo
02694     @param status_text  Returns a pointer to a constant text, see below
02695     @return  <0 reply invalid, >=0 fifo status code:
02696              bit0+1=input status, bit2=consumption status, i.e:
02697              0="standby"   : data processing not started yet
02698              1="active"    : input and consumption are active
02699              2="ending"    : input has ended without error
02700              3="failing"   : input had error and ended,
02701              4="unused"    : ( consumption has ended before processing start )
02702              5="abandoned" : consumption has ended prematurely
02703              6="ended"     : consumption has ended without input error
02704              7="aborted"   : consumption has ended after input error
02705     @since 0.4.0
02706 */
02707 int burn_fifo_inquire_status(struct burn_source *fifo, int *size, 
02708                             int *free_bytes, char **status_text);
02709 
02710 /* ts A91125 */
02711 /** Inquire various counters which reflect the fifo operation.
02712     @param fifo              The fifo object to inquire
02713     @param total_min_fill    The minimum number of bytes in the fifo. Beginning
02714                              from the moment when fifo consumption is enabled.
02715     @param interval_min_fill The minimum byte number beginning from the moment
02716                              when fifo consumption is enabled or from the
02717                              most recent moment when burn_fifo_next_interval()
02718                              was called.
02719     @param put_counter       The number of data transactions into the fifo.
02720     @param get_counter       The number of data transactions out of the fifo.
02721     @param empty_counter     The number of times the fifo was empty.
02722     @param full_counter      The number of times the fifo was full.
02723     @since 0.7.4
02724 */
02725 void burn_fifo_get_statistics(struct burn_source *fifo,
02726                              int *total_min_fill, int *interval_min_fill,
02727                              int *put_counter, int *get_counter,
02728                              int *empty_counter, int *full_counter);
02729 
02730 /* ts A91125 */
02731 /** Inquire the fifo minimum fill counter for intervals and reset that counter.
02732     @param fifo              The fifo object to inquire
02733     @param interval_min_fill The minimum number of bytes in the fifo. Beginning
02734                              from the moment when fifo consumption is enabled
02735                              or from the most recent moment when
02736                              burn_fifo_next_interval() was called.
02737     @since 0.7.4
02738 */
02739 void burn_fifo_next_interval(struct burn_source *fifo, int *interval_min_fill);
02740 
02741 /* ts A80713 */
02742 /** Obtain a preview of the first input data of a fifo which was created
02743     by burn_fifo_source_new(). The data will later be delivered normally to
02744     the consumer track of the fifo.
02745     bufsize may not be larger than the fifo size (chunk_size * chunks) - 32k.
02746     This call will succeed only if data consumption by the track has not
02747     started yet, i.e. best before the call to burn_disc_write().
02748     It will start the worker thread of the fifo with the expectable side
02749     effects on the external data source. Then it waits either until enough
02750     data have arrived or until it becomes clear that this will not happen.
02751     The call may be repeated with increased bufsize. It will always yield
02752     the bytes beginning from the first one in the fifo.
02753     @param fifo     The fifo object to inquire resp. start
02754     @param buf      Pointer to memory of at least bufsize bytes where to
02755                     deliver the peeked data.
02756     @param bufsize  Number of bytes to peek from the start of the fifo data
02757     @param flag     Bitfield for control purposes (unused yet, submit 0).
02758     @return <0 on severe error, 0 if not enough data, 1 if bufsize bytes read
02759     @since 0.5.0
02760 */
02761 int burn_fifo_peek_data(struct burn_source *fifo, char *buf, int bufsize,
02762                         int flag);
02763 
02764 /* ts A91125 */
02765 /** Start the fifo worker thread and wait either until the requested number
02766     of bytes have arrived or until it becomes clear that this will not happen.
02767     Filling will go on asynchronously after burn_fifo_fill() returned.
02768     This call and burn_fifo_peek_data() do not disturb each other.
02769     @param fifo     The fifo object to start
02770     @param fill     Number of bytes desired. Expect to get return 1 if 
02771                     at least fifo size - 32k were read.
02772     @param flag     Bitfield for control purposes.
02773                     bit0= fill fifo to maximum size
02774     @return <0 on severe error, 0 if not enough data,
02775              1 if desired amount or fifo full
02776     @since 0.7.4
02777 */
02778 int burn_fifo_fill(struct burn_source *fifo, int fill, int flag);
02779 
02780 
02781 /* ts A70328 */
02782 /** Sets a fixed track size after the data source object has already been
02783     created.
02784     @param t The track to operate on
02785     @param size the number of bytes to use as track size
02786     @return <=0 indicates failure , >0 success
02787     @since 0.3.6
02788 */
02789 int burn_track_set_size(struct burn_track *t, off_t size);
02790 
02791 
02792 /** Tells how many sectors a track will have on disc, resp. already has on
02793     disc. This includes offset, payload, tail, and post-gap, but not pre-gap.
02794     The result is NOT RELIABLE with tracks of undefined length
02795 */
02796 int burn_track_get_sectors(struct burn_track *);
02797 
02798 
02799 /* ts A61101 */
02800 /** Tells how many source bytes have been read and how many data bytes have
02801     been written by the track during burn.
02802     @param t The track to inquire
02803     @param read_bytes Number of bytes read from the track source
02804     @param written_bytes Number of bytes written to track
02805     @since 0.2.6
02806 */
02807 int burn_track_get_counters(struct burn_track *t, 
02808                             off_t *read_bytes, off_t *written_bytes);
02809 
02810 
02811 /** Sets drive read and write speed
02812     Note: "k" is 1000, not 1024. 1xCD = 176.4 k/s, 1xDVD = 1385 k/s.
02813           Fractional speeds should be rounded up. Like 4xCD = 706.
02814     @param d The drive to set speed for
02815     @param read Read speed in k/s (0 is max, -1 is min).
02816     @param write Write speed in k/s (0 is max, -1 is min). 
02817 */
02818 void burn_drive_set_speed(struct burn_drive *d, int read, int write);
02819 
02820 
02821 /* ts A70711 */
02822 /** Controls the behavior with writing when the drive buffer is suspected to
02823     be full. To check and wait for enough free buffer space before writing
02824     will move the task of waiting from the operating system's device driver
02825     to libburn. While writing is going on and waiting is enabled, any write
02826     operation will be checked whether it will fill the drive buffer up to
02827     more than max_percent. If so, then waiting will happen until the buffer
02828     fill is predicted with at most min_percent.
02829     Thus: if min_percent < max_percent then transfer rate will oscillate. 
02830     This may allow the driver to operate on other devices, e.g. a disk from
02831     which to read the input for writing. On the other hand, this checking might
02832     reduce maximum throughput to the drive or even get misled by faulty buffer
02833     fill replies from the drive.
02834     If a setting parameter is < 0, then this setting will stay unchanged
02835     by the call.
02836     Known burner or media specific pitfalls:
02837     To have max_percent larger than the burner's best reported buffer fill has
02838     the same effect as min_percent==max_percent. Some burners do not report
02839     their full buffer with all media types. Some are not suitable because
02840     they report their buffer fill with delay.
02841     @param d The drive to control
02842     @param enable 0= disable , 1= enable waiting , (-1 = do not change setting)
02843     @param min_usec Shortest possible sleeping period (given in micro seconds)
02844     @param max_usec Longest possible sleeping period (given in micro seconds)
02845     @param timeout_sec If a single write has to wait longer than this number
02846                        of seconds, then waiting gets disabled and mindless
02847                        writing starts. A value of 0 disables this timeout.
02848     @param min_percent Minimum of desired buffer oscillation: 25 to 100
02849     @param max_percent Maximum of desired buffer oscillation: 25 to 100
02850     @return 1=success , 0=failure
02851     @since 0.3.8
02852 */
02853 int burn_drive_set_buffer_waiting(struct burn_drive *d, int enable,
02854                                 int min_usec, int max_usec, int timeout_sec,
02855                                 int min_percent, int max_percent);
02856 
02857 
02858 /* these are for my [Derek Foreman's ?] debugging, they will disappear */
02859 /* ts B11012 :
02860    Of course, API symbols will not disappear. But these functions are of
02861    few use, as they only print DEBUG messages.
02862 */
02863 void burn_structure_print_disc(struct burn_disc *d);
02864 void burn_structure_print_session(struct burn_session *s);
02865 void burn_structure_print_track(struct burn_track *t);
02866 
02867 /** Sets the write type for the write_opts struct.
02868     Note: write_type BURN_WRITE_SAO is currently not capable of writing a mix
02869     of data and audio tracks. You must use BURN_WRITE_TAO for such sessions.
02870     @param opts The write opts to change
02871     @param write_type The write type to use
02872     @param block_type The block type to use
02873     @return Returns 1 on success and 0 on failure.
02874 */
02875 int burn_write_opts_set_write_type(struct burn_write_opts *opts,
02876                    enum burn_write_types write_type,
02877                    int block_type);
02878 
02879 
02880 /* ts A70207 */
02881 /** As an alternative to burn_write_opts_set_write_type() this function tries
02882     to find a suitable write type and block type for a given write job
02883     described by opts and disc. To be used after all other setups have been
02884     made, i.e. immediately before burn_disc_write().
02885     @param opts The nearly complete write opts to change
02886     @param disc The already composed session and track model
02887     @param reasons This text string collects reasons for decision resp. failure
02888     @param flag Bitfield for control purposes:
02889                 bit0= do not choose type but check the one that is already set
02890                 bit1= do not issue error messages via burn_msgs queue
02891                       (is automatically set with bit0)
02892     @return Chosen write type. BURN_WRITE_NONE on failure.
02893     @since 0.3.2
02894 */
02895 enum burn_write_types burn_write_opts_auto_write_type(
02896           struct burn_write_opts *opts, struct burn_disc *disc,
02897           char reasons[BURN_REASONS_LEN], int flag);
02898 
02899 
02900 /** Supplies toc entries for writing - not normally required for cd mastering
02901     @param opts The write opts to change
02902     @param count The number of entries
02903     @param toc_entries
02904 */
02905 void burn_write_opts_set_toc_entries(struct burn_write_opts *opts,
02906                      int count,
02907                      struct burn_toc_entry *toc_entries);
02908 
02909 /** Sets the session format for a disc
02910     @param opts The write opts to change
02911     @param format The session format to set
02912 */
02913 void burn_write_opts_set_format(struct burn_write_opts *opts, int format);
02914 
02915 /** Sets the simulate value for the write_opts struct . 
02916     This corresponds to the Test Write bit in MMC mode page 05h. Several media
02917     types do not support this. See struct burn_multi_caps.might_simulate for
02918     actual availability of this feature. 
02919     If the media is suitable, the drive will perform burn_disc_write() as a
02920     simulation instead of effective write operations. This means that the
02921     media content and burn_disc_get_status() stay unchanged.
02922     Note: With stdio-drives, the target file gets eventually created, opened,
02923           lseeked, and closed, but not written. So there are effects on it.
02924     Warning: Call burn_random_access_write() will never do simulation because
02925              it does not get any burn_write_opts.
02926     @param opts The write opts to change
02927     @param sim  Non-zero enables simulation, 0 enables real writing
02928     @return Returns 1 on success and 0 on failure.
02929 */
02930 int  burn_write_opts_set_simulate(struct burn_write_opts *opts, int sim);
02931 
02932 /** Controls buffer underrun prevention. This is only needed with CD media
02933     and possibly with old DVD-R drives. All other media types are not
02934     vulnerable to burn failure due to buffer underrun.
02935     @param opts The write opts to change
02936     @param underrun_proof if non-zero, buffer underrun protection is enabled
02937     @return Returns 1 if the drive announces to be capable of underrun
02938                       prevention,
02939             Returns 0 if not.
02940 */
02941 int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts,
02942                        int underrun_proof);
02943 
02944 /** Sets whether to use opc or not with the write_opts struct
02945     @param opts The write opts to change
02946     @param opc If non-zero, optical power calibration will be performed at
02947                start of burn
02948      
02949 */
02950 void burn_write_opts_set_perform_opc(struct burn_write_opts *opts, int opc);
02951 
02952 
02953 /** The Q sub-channel of a CD may contain a Media Catalog Number of 13 decimal
02954     digits. This call sets the string of digits, but does not yet activate it
02955     for writing.
02956     @param opts          The write opts to change
02957     @param mediacatalog  The 13 decimal digits as ASCII bytes. I.e. '0' = 0x30.
02958 */
02959 void burn_write_opts_set_mediacatalog(struct burn_write_opts *opts,
02960                                       unsigned char mediacatalog[13]);
02961 
02962 /** This call activates the Media Catalog Number for writing. The digits of
02963     that number have to be set by call burn_write_opts_set_mediacatalog().
02964     @param opts             The write opts to change
02965     @param has_mediacatalog 1= activate writing of catalog to Q sub-channel
02966                             0= deactivate it
02967 */
02968 void burn_write_opts_set_has_mediacatalog(struct burn_write_opts *opts,
02969                                           int has_mediacatalog);
02970 
02971 
02972 /* ts A61106 */
02973 /** Sets the multi flag which eventually marks the emerging session as not
02974     being the last one and thus creating a BURN_DISC_APPENDABLE media.
02975     Note: DVD-R[W] in write mode BURN_WRITE_SAO are not capable of this.
02976           DVD-R DL are not capable of this at all.
02977           libburn will refuse to write if burn_write_opts_set_multi() is
02978           enabled under such conditions.
02979     @param opts The option object to be manipulated
02980     @param multi 1=media will be appendable, 0=media will be closed (default) 
02981     @since 0.2.6
02982 */
02983 void burn_write_opts_set_multi(struct burn_write_opts *opts, int multi);
02984 
02985 /* ts B11204 */
02986 /** Submit an array of CD-TEXT packs which shall be written to the Lead-in
02987     of a SAO write run on CD.
02988     @param opts        The option object to be manipulated
02989     @param text_packs  Array of bytes which form CD-TEXT packs of 18 bytes
02990                        each. For a description of the format of the array,
02991                        see file doc/cdtext.txt.
02992                        No header of 4 bytes must be prepended which would
02993                        tell the number of pack bytes + 2.
02994                        This parameter may be NULL if the currently attached
02995                        array of packs shall be removed.
02996     @param num_packs   The number of 18 byte packs in text_packs.
02997                        This parameter may be 0 if the currently attached
02998                        array of packs shall be removed.
02999     @param flag        Bitfield for control purposes.
03000                        bit0= do not verify checksums
03001                        bit1= repair mismatching checksums
03002                        bit2= repair checksums if they are 00 00 with each pack
03003     @return            1 on success, <= 0 on failure
03004     @since 1.2.0
03005 */
03006 int burn_write_opts_set_leadin_text(struct burn_write_opts *opts,
03007                                     unsigned char *text_packs,
03008                                     int num_packs, int flag);
03009 
03010 
03011 /* ts A61222 */
03012 /** Sets a start address for writing to media and write modes which allow to
03013     choose this address at all (for now: DVD+RW, DVD-RAM, formatted DVD-RW).
03014     now). The address is given in bytes. If it is not -1 then a write run
03015     will fail if choice of start address is not supported or if the block
03016     alignment of the address is not suitable for media and write mode.
03017     Alignment to 32 kB blocks is supposed to be safe with DVD media.
03018     Call burn_disc_get_multi_caps() can obtain the necessary media info. See
03019     resulting struct burn_multi_caps elements .start_adr , .start_alignment ,
03020     .start_range_low , .start_range_high .
03021     @param opts The write opts to change
03022     @param value The address in bytes (-1 = start at default address)
03023     @since 0.3.0
03024 */
03025 void burn_write_opts_set_start_byte(struct burn_write_opts *opts, off_t value);
03026 
03027 
03028 /* ts A70213 */
03029 /** Caution: still immature and likely to change. Problems arose with
03030     sequential DVD-RW on one drive.
03031 
03032     Controls whether the whole available space of the media shall be filled up
03033     by the last track of the last session.
03034     @param opts The write opts to change
03035     @param fill_up_media If 1 : fill up by last track, if 0 = do not fill up
03036     @since 0.3.4
03037 */
03038 void burn_write_opts_set_fillup(struct burn_write_opts *opts,
03039                                 int fill_up_media);
03040 
03041 
03042 /* ts A70303 */
03043 /** Eventually makes libburn ignore the failure of some conformance checks:
03044     - the check whether CD write+block type is supported by the drive
03045     - the check whether the media profile supports simulated burning 
03046     @param opts The write opts to change
03047     @param use_force 1=ignore above checks, 0=refuse work on failed check
03048     @since 0.3.4
03049 */
03050 void burn_write_opts_set_force(struct burn_write_opts *opts, int use_force);
03051 
03052 
03053 /* ts A80412 */
03054 /** Eventually makes use of the more modern write command AAh WRITE12 and
03055     sets the Streaming bit. With DVD-RAM and BD this can override the
03056     traditional slowdown to half nominal speed. But if it speeds up writing
03057     then it also disables error management and correction. Weigh your
03058     priorities. This affects the write operations of burn_disc_write()
03059     and subsequent calls of burn_random_access_write().
03060     @param opts The write opts to change
03061     @param value  0=use 2Ah WRITE10, 1=use AAh WRITE12 with Streaming bit
03062                   @since 0.6.4:
03063                   >=16 use WRITE12 but not before the LBA given by value
03064     @since 0.4.6
03065 */
03066 void burn_write_opts_set_stream_recording(struct burn_write_opts *opts, 
03067                                          int value);
03068 
03069 /* ts A91115 */
03070 /** Overrides the write chunk size for DVD and BD media which is normally
03071     determined according to media type and setting of stream recording.
03072     A chunk size of 64 KB may improve throughput with bus systems which show
03073     latency problems.
03074     @param opts The write opts to change
03075     @param obs  Number of bytes which shall be sent by a single write command.
03076                 0 means automatic size, 32768 and 65336 are the only other
03077                 accepted sizes for now.
03078     @since 0.7.4
03079 */
03080 void burn_write_opts_set_dvd_obs(struct burn_write_opts *opts, int obs);
03081 
03082 /* ts A91115 */
03083 /** Sets the rythm by which stdio pseudo drives force their output data to
03084     be consumed by the receiving storage device. This forcing keeps the memory
03085     from being clogged with lots of pending data for slow devices.
03086     @param opts   The write opts to change
03087     @param rythm  Number of 2KB output blocks after which fsync(2) is
03088                   performed. -1 means no fsync(), 0 means default,
03089                   elsewise the value must be >= 32.
03090                   Default is currently 8192 = 16 MB.
03091     @since 0.7.4
03092 */
03093 void burn_write_opts_set_stdio_fsync(struct burn_write_opts *opts, int rythm);
03094 
03095 
03096 /** Sets whether to read in raw mode or not
03097     @param opts The read opts to change
03098     @param raw_mode If non-zero, reading will be done in raw mode, so that everything in the data tracks on the
03099             disc is read, including headers.
03100 */
03101 void burn_read_opts_set_raw(struct burn_read_opts *opts, int raw_mode);
03102 
03103 /** Sets whether to report c2 errors or not 
03104     @param opts The read opts to change
03105     @param c2errors If non-zero, report c2 errors.
03106 */
03107 void burn_read_opts_set_c2errors(struct burn_read_opts *opts, int c2errors);
03108 
03109 /** Sets whether to read subcodes from audio tracks or not
03110     @param opts The read opts to change
03111     @param subcodes_audio If non-zero, read subcodes from audio tracks on the disc.
03112 */
03113 void burn_read_opts_read_subcodes_audio(struct burn_read_opts *opts,
03114                     int subcodes_audio);
03115 
03116 /** Sets whether to read subcodes from data tracks or not 
03117     @param opts The read opts to change
03118     @param subcodes_data If non-zero, read subcodes from data tracks on the disc.
03119 */
03120 void burn_read_opts_read_subcodes_data(struct burn_read_opts *opts,
03121                        int subcodes_data);
03122 
03123 /** Sets whether to recover errors if possible
03124     @param opts The read opts to change
03125     @param hardware_error_recovery If non-zero, attempt to recover errors if possible.
03126 */
03127 void burn_read_opts_set_hardware_error_recovery(struct burn_read_opts *opts,
03128                         int hardware_error_recovery);
03129 
03130 /** Sets whether to report recovered errors or not
03131     @param opts The read opts to change
03132     @param report_recovered_errors If non-zero, recovered errors will be reported.
03133 */
03134 void burn_read_opts_report_recovered_errors(struct burn_read_opts *opts,
03135                         int report_recovered_errors);
03136 
03137 /** Sets whether blocks with unrecoverable errors should be read or not
03138     @param opts The read opts to change
03139     @param transfer_damaged_blocks If non-zero, blocks with unrecoverable errors will still be read.
03140 */
03141 void burn_read_opts_transfer_damaged_blocks(struct burn_read_opts *opts,
03142                         int transfer_damaged_blocks);
03143 
03144 /** Sets the number of retries to attempt when trying to correct an error
03145     @param opts The read opts to change
03146     @param hardware_error_retries The number of retries to attempt when correcting an error.
03147 */
03148 void burn_read_opts_set_hardware_error_retries(struct burn_read_opts *opts,
03149                            unsigned char hardware_error_retries);
03150 
03151 
03152 /* ts A90815 */
03153 /** Gets the list of profile codes supported by the drive.
03154     Profiles depict the feature sets which constitute media types. For
03155     known profile codes and names see burn_disc_get_profile().
03156     @param d            is the drive to query
03157     @param num_profiles returns the number of supported profiles
03158     @param profiles     returns the profile codes
03159     @param is_current   returns the status of the corresponding profile code:
03160                         1= current, i.e. the matching media is loaded
03161                         0= not current, i.e. the matching media is not loaded
03162     @return  always 1 for now
03163     @since 0.7.0
03164 */
03165 int burn_drive_get_all_profiles(struct burn_drive *d, int *num_profiles,
03166                                 int profiles[64], char is_current[64]);
03167 
03168 
03169 /* ts A90815 */
03170 /** Obtains the profile name associated with a profile code.
03171     @param profile_code the profile code to be translated
03172     @param name         returns the profile name (e.g. "DVD+RW")  
03173     @return             1= known profile code , 0= unknown profile code
03174     @since 0.7.0
03175 */
03176 int burn_obtain_profile_name(int profile_code, char name[80]);
03177 
03178 
03179 /** Gets the maximum write speed for a drive and eventually loaded media.
03180     The return value might change by the media type of already loaded media,
03181     again by call burn_drive_grab() and again by call burn_disc_read_atip(). 
03182     @param d Drive to query
03183     @return Maximum write speed in K/s
03184 */
03185 int burn_drive_get_write_speed(struct burn_drive *d);
03186 
03187 
03188 /* ts A61021 */
03189 /** Gets the minimum write speed for a drive and eventually loaded media.
03190     The return value might change by the media type of already loaded media, 
03191     again by call burn_drive_grab() and again by call burn_disc_read_atip().
03192     @param d Drive to query
03193     @return Minimum write speed in K/s
03194     @since 0.2.6
03195 */
03196 int burn_drive_get_min_write_speed(struct burn_drive *d);
03197 
03198 
03199 /** Gets the maximum read speed for a drive
03200     @param d Drive to query
03201     @return Maximum read speed in K/s
03202 */
03203 int burn_drive_get_read_speed(struct burn_drive *d);
03204 
03205 
03206 /* ts A61226 */
03207 /** Obtain a copy of the current speed descriptor list. The drive's list gets
03208     updated on various occasions such as burn_drive_grab() but the copy
03209     obtained here stays untouched. It has to be disposed via
03210     burn_drive_free_speedlist() when it is not longer needed. Speeds
03211     may appear several times in the list. The list content depends much on
03212     drive and media type. It seems that .source == 1 applies mostly to CD media
03213     whereas .source == 2 applies to any media.
03214     @param d Drive to query
03215     @param speed_list The copy. If empty, *speed_list gets returned as NULL.
03216     @return 1=success , 0=list empty , <0 severe error
03217     @since 0.3.0
03218 */
03219 int burn_drive_get_speedlist(struct burn_drive *d,
03220                              struct burn_speed_descriptor **speed_list);
03221 
03222 /* ts A70713 */
03223 /** Look up the fastest speed descriptor which is not faster than the given
03224     speed_goal. If it is 0, then the fastest one is chosen among the
03225     descriptors with the highest end_lba. If it is -1 then the slowest speed
03226     descriptor is chosen regardless of end_lba. Parameter flag decides whether
03227     the speed goal means write speed or read speed.
03228     @param d Drive to query
03229     @param speed_goal Upper limit for speed,
03230                       0=search for maximum speed , -1 search for minimum speed
03231     @param best_descr Result of the search, NULL if no match
03232     @param flag Bitfield for control purposes
03233                 bit0= look for best read speed rather than write speed
03234                 bit1= look for any source type (else look for source==2 first
03235                   and for any other source type only with CD media)
03236     @return >0 indicates a valid best_descr, 0 = no valid best_descr
03237     @since 0.3.8
03238 */
03239 int burn_drive_get_best_speed(struct burn_drive *d, int speed_goal,
03240                         struct burn_speed_descriptor **best_descr, int flag);
03241 
03242 
03243 /* ts A61226 */
03244 /** Dispose a speed descriptor list copy which was obtained by
03245     burn_drive_get_speedlist().
03246     @param speed_list The list copy. *speed_list gets set to NULL.
03247     @return 1=list disposed , 0= *speedlist was already NULL
03248     @since 0.3.0
03249 */
03250 int burn_drive_free_speedlist(struct burn_speed_descriptor **speed_list);
03251 
03252 
03253 /* ts A70203 */
03254 /* @since 0.3.2 */
03255 /** The reply structure for burn_disc_get_multi_caps()
03256 */
03257 struct burn_multi_caps {
03258 
03259     /* Multi-session capability allows to keep the media appendable after
03260        writing a session. It also guarantees that the drive will be able
03261        to predict and use the appropriate Next Writeable Address to place
03262        the next session on the media without overwriting the existing ones.
03263        It does not guarantee that the selected write type is able to do
03264        an appending session after the next session. (E.g. CD SAO is capable
03265        of multi-session by keeping a disc appendable. But .might_do_sao
03266        will be 0 afterwards, when checking the appendable media.)
03267         1= media may be kept appendable by burn_write_opts_set_multi(o,1)
03268         0= media will not be appendable
03269     */
03270     int multi_session;
03271 
03272     /* Multi-track capability allows to write more than one track source
03273        during a single session. The written tracks can later be found in
03274        libburn's TOC model with their start addresses and sizes.
03275         1= multiple tracks per session are allowed
03276         0= only one track per session allowed
03277     */
03278     int multi_track;
03279 
03280     /* Start-address capability allows to set a non-zero address with
03281        burn_write_opts_set_start_byte(). Eventually this has to respect
03282        .start_alignment and .start_range_low, .start_range_high in this
03283        structure.
03284         1= non-zero start address is allowed
03285             0= only start address 0 is allowed (to depict the drive's own idea
03286                about the appropriate write start)
03287     */
03288     int start_adr;
03289 
03290     /** The alignment for start addresses.
03291         ( start_address % start_alignment ) must be 0.
03292     */
03293     off_t start_alignment;
03294 
03295     /** The lowest permissible start address.
03296     */
03297     off_t start_range_low;
03298 
03299     /** The highest addressable start address.
03300     */
03301     off_t start_range_high;
03302 
03303     /** Potential availability of write modes
03304          4= needs no size prediction, not to be chosen automatically
03305          3= needs size prediction, not to be chosen automatically
03306          2= available, no size prediction necessary
03307          1= available, needs exact size prediction
03308          0= not available
03309         With CD media (profiles 0x09 and 0x0a) check also the elements
03310         *_block_types of the according write mode.
03311     */
03312     int might_do_tao;
03313     int might_do_sao;
03314     int might_do_raw;
03315 
03316     /** Generally advised write mode.
03317         Not necessarily the one chosen by burn_write_opts_auto_write_type()
03318         because the burn_disc structure might impose particular demands.
03319     */
03320     enum burn_write_types advised_write_mode;
03321 
03322     /** Write mode as given by parameter wt of burn_disc_get_multi_caps().
03323     */
03324     enum burn_write_types selected_write_mode;
03325 
03326     /** Profile number which was current when the reply was generated */
03327     int current_profile;
03328 
03329     /** Wether the current profile indicates CD media. 1=yes, 0=no */
03330     int current_is_cd_profile;
03331 
03332         /* ts A70528 */
03333         /* @since 0.3.8 */
03334     /** Wether the current profile is able to perform simulated write */
03335     int might_simulate;
03336 };
03337 
03338 /** Allocates a struct burn_multi_caps (see above) and fills it with values
03339     which are appropriate for the drive and the loaded media. The drive
03340     must be grabbed for this call. The returned structure has to be disposed
03341     via burn_disc_free_multi_caps() when no longer needed.
03342     @param d The drive to inquire
03343     @param wt With BURN_WRITE_NONE the best capabilities of all write modes
03344               get returned. If set to a write mode like BURN_WRITE_SAO the
03345               capabilities with that particular mode are returned and the
03346               return value is 0 if the desired mode is not possible.
03347     @param caps returns the info structure
03348     @param flag Bitfield for control purposes (unused yet, submit 0)
03349     @return < 0 : error , 0 : writing seems impossible , 1 : writing possible 
03350     @since 0.3.2
03351 */
03352 int burn_disc_get_multi_caps(struct burn_drive *d, enum burn_write_types wt,
03353              struct burn_multi_caps **caps, int flag);
03354 
03355 /** Removes from memory a multi session info structure which was returned by
03356     burn_disc_get_multi_caps(). The pointer *caps gets set to NULL.
03357     @param caps the info structure to dispose (note: pointer to pointer)
03358     @return 0 : *caps was already NULL, 1 : memory object was disposed
03359     @since 0.3.2
03360 */
03361 int burn_disc_free_multi_caps(struct burn_multi_caps **caps);
03362 
03363 
03364 /** Gets a copy of the toc_entry structure associated with a track
03365     @param t Track to get the entry from
03366     @param entry Struct for the library to fill out
03367 */
03368 void burn_track_get_entry(struct burn_track *t, struct burn_toc_entry *entry);
03369 
03370 /** Gets a copy of the toc_entry structure associated with a session's lead out
03371     @param s Session to get the entry from
03372     @param entry Struct for the library to fill out
03373 */
03374 void burn_session_get_leadout_entry(struct burn_session *s,
03375                                     struct burn_toc_entry *entry);
03376 
03377 /** Gets an array of all the sessions for the disc
03378     THIS IS NO LONGER VALID AFTER YOU ADD OR REMOVE A SESSION
03379     @param d Disc to get session array for
03380     @param num Returns the number of sessions in the array
03381     @return array of sessions
03382 */
03383 struct burn_session **burn_disc_get_sessions(struct burn_disc *d,
03384                                              int *num);
03385 
03386 int burn_disc_get_sectors(struct burn_disc *d);
03387 
03388 /** Gets an array of all the tracks for a session
03389     THIS IS NO LONGER VALID AFTER YOU ADD OR REMOVE A TRACK
03390     @param s session to get track array for
03391     @param num Returns the number of tracks in the array
03392     @return array of tracks
03393 */
03394 struct burn_track **burn_session_get_tracks(struct burn_session *s,
03395                                             int *num);
03396 
03397 int burn_session_get_sectors(struct burn_session *s);
03398 
03399 /** Gets the mode of a track
03400     @param track the track to query
03401     @return the track's mode
03402 */
03403 int burn_track_get_mode(struct burn_track *track);
03404 
03405 /** Returns whether the first track of a session is hidden in the pregap
03406     @param session the session to query
03407     @return non-zero means the first track is hidden
03408 */
03409 int burn_session_get_hidefirst(struct burn_session *session);
03410 
03411 /** Returns the library's version in its parts.
03412     This is the runtime counterpart of the three build time macros 
03413     burn_header_version_* below.
03414     @param major The major version number
03415     @param minor The minor version number
03416     @param micro The micro version number
03417 */
03418 void burn_version(int *major, int *minor, int *micro);
03419 
03420 
03421 /* ts A80129 */
03422 /* @since 0.4.4 */
03423 /** These three release version numbers tell the revision of this header file
03424     and of the API it describes. They are memorized by applications at build
03425     time.
03426     Immediately after burn_initialize() an application should do this check:
03427       burn_version(&major, &minor, &micro);
03428       if(major > burn_header_version_major
03429          || (major == burn_header_version_major
03430              && (minor > burn_header_version_minor
03431                  || (minor == burn_header_version_minor
03432                      && micro >= burn_header_version_micro)))) {
03433           ... Young enough. Go on with program run ....
03434       } else {
03435           ... Too old. Do not use this libburn version ...
03436       }
03437 
03438 */
03439 #define burn_header_version_major  1
03440 #define burn_header_version_minor  2
03441 #define burn_header_version_micro  2
03442 /** Note:
03443     Above version numbers are also recorded in configure.ac because libtool
03444     wants them as parameters at build time.
03445     For the library compatibility check, BURN_*_VERSION in configure.ac
03446     are not decisive. Only the three numbers above do matter.
03447 */
03448 /** Usage discussion:
03449 
03450 Some developers of the libburnia project have differing
03451 opinions how to ensure the compatibility of libaries
03452 and applications.
03453 
03454 It is about whether to use at compile time and at runtime
03455 the version numbers isoburn_header_version_* provided here.
03456 Thomas Schmitt advises to use them.
03457 Vreixo Formoso advises to use other means.
03458 
03459 At compile time:
03460 
03461 Vreixo Formoso advises to leave proper version matching
03462 to properly programmed checks in the the application's
03463 build system, which will eventually refuse compilation.
03464 
03465 Thomas Schmitt advises to use the macros defined here
03466 for comparison with the application's requirements of
03467 library revisions and to eventually break compilation.
03468 
03469 Both advises are combinable. I.e. be master of your
03470 build system and have #if checks in the source code
03471 of your application, nevertheless.
03472 
03473 At runtime (via *_is_compatible()):
03474 
03475 Vreixo Formoso advises to compare the application's
03476 requirements of library revisions with the runtime
03477 library. This is to allow runtime libraries which are
03478 young enough for the application but too old for
03479 the lib*.h files seen at compile time.
03480 
03481 Thomas Schmitt advises to compare the header
03482 revisions defined here with the runtime library.
03483 This is to enforce a strictly monotonous chain
03484 of revisions from app to header to library,
03485 at the cost of excluding some older libraries.
03486 
03487 These two advises are mutually exclusive.
03488 
03489 */
03490 
03491 /* ts A91226 */
03492 /** Obtain the id string of the SCSI transport interface.
03493     This interface may be a system specific adapter module of libburn or
03494     an adapter to a supporting library like libcdio.
03495     @param flag  Bitfield for control puposes, submit 0 for now
03496     @return      A pointer to the id string. Do not alter the string content.
03497     @since 0.7.6
03498 */
03499 char *burn_scsi_transport_id(int flag);
03500 
03501 /* ts A60924 : ticket 74 */
03502 /** Control queueing and stderr printing of messages from libburn.
03503     Severity may be one of "NEVER", "ABORT", "FATAL", "FAILURE", "SORRY",
03504     "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL".
03505     @param queue_severity Gives the minimum limit for messages to be queued.
03506                           Default: "NEVER". If you queue messages then you
03507                           must consume them by burn_msgs_obtain().
03508     @param print_severity Does the same for messages to be printed directly
03509                           to stderr. Default: "FATAL".
03510     @param print_id       A text prefix to be printed before the message.
03511     @return               >0 for success, <=0 for error
03512     @since 0.2.6
03513 */
03514 int burn_msgs_set_severities(char *queue_severity,
03515                              char *print_severity, char *print_id);
03516 
03517 /* ts A60924 : ticket 74 */
03518 /*  @since 0.2.6 */
03519 #define BURN_MSGS_MESSAGE_LEN 4096
03520 
03521 /** Obtain the oldest pending libburn message from the queue which has at
03522     least the given minimum_severity. This message and any older message of
03523     lower severity will get discarded from the queue and is then lost forever.
03524     @param minimum_severity  may be one of "NEVER", "ABORT", "FATAL",
03525                       "FAILURE", "SORRY", "WARNING", "HINT", "NOTE", "UPDATE",
03526                       "DEBUG", "ALL".
03527                       To call with minimum_severity "NEVER" will discard the
03528                       whole queue.
03529     @param error_code Will become a unique error code as listed in
03530                       libburn/libdax_msgs.h
03531     @param msg_text   Must provide at least BURN_MSGS_MESSAGE_LEN bytes.
03532     @param os_errno   Will become the eventual errno related to the message
03533     @param severity   Will become the severity related to the message and
03534                       should provide at least 80 bytes.
03535     @return 1 if a matching item was found, 0 if not, <0 for severe errors
03536     @since 0.2.6
03537 */
03538 int burn_msgs_obtain(char *minimum_severity,
03539                      int *error_code, char msg_text[], int *os_errno,
03540                      char severity[]);
03541 
03542 
03543 /* ts A70922 */
03544 /** Submit a message to the libburn queueing system. It will be queued or
03545     printed as if it was generated by libburn itself.
03546     @param error_code The unique error code of your message.
03547                       Submit 0 if you do not have reserved error codes within
03548                       the libburnia project.
03549     @param msg_text   Not more than BURN_MSGS_MESSAGE_LEN characters of
03550                       message text.
03551     @param os_errno   Eventual errno related to the message. Submit 0 if
03552                       the message is not related to a operating system error.
03553     @param severity   One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING",
03554                       "HINT", "NOTE", "UPDATE", "DEBUG". Defaults to "FATAL".
03555     @param d          An eventual drive to which the message shall be related.
03556                       Submit NULL if the message is not specific to a
03557                       particular drive object.
03558     @return           1 if message was delivered, <=0 if failure
03559     @since 0.4.0
03560 */
03561 int burn_msgs_submit(int error_code, char msg_text[], int os_errno,
03562                      char severity[], struct burn_drive *d);
03563 
03564 
03565 /* ts A71016 */
03566 /** Convert a severity name into a severity number, which gives the severity
03567     rank of the name.
03568     @param severity_name A name as with burn_msgs_submit(), e.g. "SORRY".
03569     @param severity_number The rank number: the higher, the more severe.
03570     @param flag Bitfield for control purposes (unused yet, submit 0)
03571     @return >0 success, <=0 failure
03572     @since 0.4.0
03573 */
03574 int burn_text_to_sev(char *severity_name, int *severity_number, int flag);
03575 
03576 
03577 /* ts A80202 */
03578 /** Convert a severity number into a severity name
03579     @since 0.4.4
03580     @param severity_number The rank number: the higher, the more severe.
03581     @param severity_name A name as with burn_msgs_submit(), e.g. "SORRY".
03582     @param flag Bitfield for control purposes (unused yet, submit 0)
03583     @since 0.4.4
03584 */
03585 int burn_sev_to_text(int severity_number, char **severity_name, int flag);
03586 
03587 
03588 
03589 /* ts A70915 */
03590 /** Replace the messenger object handle of libburn by a compatible handle
03591     obtained from a related library. 
03592     See also: libisofs, API function iso_get_messenger().
03593     @param messenger The foreign but compatible message handle.
03594     @return 1 : success, <=0 : failure
03595     @since 0.4.0
03596 */
03597 int burn_set_messenger(void *messenger);
03598 
03599 
03600 /* ts A61002 */
03601 /* @since 0.2.6 */
03602 /** The prototype of a handler function suitable for burn_set_signal_handling()
03603     Such a function has to return -2 if it does not want the process to
03604     exit with value 1.
03605 */
03606 typedef int (*burn_abort_handler_t)(void *handle, int signum, int flag);
03607 
03608 /** Control built-in signal handling. Either by setting an own handler or
03609     by activating the built-in signal handler.
03610 
03611     A function parameter handle of NULL activates the built-in abort handler. 
03612     Depending on mode it may cancel all drive operations, wait for all drives
03613     to become idle, exit(1). It may also prepare function
03614     burn_drive_get_status() for waiting and performing exit(1). 
03615     If parameter handle may be NULL or a text that shall be used as prefix for
03616     pacifier messages of burn_abort_pacifier(). Other than with an application
03617     provided handler, the prefix char array does not have to be kept existing
03618     until the eventual signal event.
03619     Before version 0.7.8 only action 0 was available. I.e. the built-in handler
03620     waited for the drives to become idle and then performed exit(1) directly.
03621     But during burn_disc_write() onto real CD or DVD, FreeBSD 8.0 pauses the
03622     other threads until the signal handler returns.
03623     The new actions try to avoid this deadlock. It is advised to use action 3
03624     at least during burn_disc_write(), burn_disc_erase(), burn_disc_format():
03625       burn_set_signal_handling(text, NULL, 0x30);
03626     and to call burn_is_aborting(0) when the drive is BURN_DRIVE_IDLE.
03627     If burn_is_aborting(0) returns 1, then call burn_abort() and exit(1).
03628 
03629     @param handle Opaque handle eventually pointing to an application
03630                   provided memory object
03631     @param handler A function to be called on signals, if the handling bits
03632                   in parameter mode are set 0.
03633                   It will get parameter handle as argument. flag will be 0.
03634                   It should finally call burn_abort(). See there.
03635                   If the handler function returns 2 or -2, then the wrapping
03636                   signal handler of libburn will return and let the program
03637                   continue its operations. Any other return value causes
03638                   exit(1).
03639     @param mode : bit0 - bit3: Handling of received signals:
03640                     0 Install libburn wrapping signal handler, which will call
03641                       handler(handle, signum, 0) on nearly all signals
03642                     1 Enable system default reaction on all signals
03643                     2 Try to ignore nearly all signals
03644                    10 like mode 2 but handle SIGABRT like with mode 0
03645                   bit4 - bit7: With handler == NULL :
03646                     Action of built-in handler. "control thread" is the one
03647                     which called burn_set_signal_handling().
03648                     All actions activate receive mode 2 to ignore further
03649                     signals.
03650                     0 Same as 1 (for pre-0.7.8 backward compatibility)
03651                     @since 0.7.8
03652                     1 Catch the control thread in abort handler, call
03653                       burn_abort(>0) and finally exit(1).
03654                       Does not always work with FreeBSD.
03655                     2 Call burn_abort(-1) and return from handler. When the
03656                       control thread calls burn_drive_get_status(), then do
03657                       burn_abort(>0) instead, and finally exit(1).
03658                       Does not always work with FreeBSD.
03659                     3 Call burn_abort(-1), return from handler. It is duty of
03660                       the application to detect a pending abort condition
03661                       by calling burn_is_aborting() and to wait for all
03662                       drives to become idle. E.g. by calling burn_abort(>0).
03663                     4 Like 3, but without calling burn_abort(-1). Only the
03664                       indicator of burn_is_aborting() gets set.
03665     @since 0.2.6
03666 */
03667 void burn_set_signal_handling(void *handle, burn_abort_handler_t handler, 
03668                  int mode);
03669 
03670 
03671 /* ts B00304 */
03672 /* Inquire whether the built-in abort handler was triggered by a signal.
03673    This has to be done to detect pending abort handling if signal handling
03674    was set to the built-in handler and action was set to 2 or 3.
03675    @param flag  Bitfield for control purposes (unused yet, submit 0)
03676    @return    0 = no abort was triggered
03677              >0 = action that was triggered (action 0 is reported as 1)
03678    @since 0.7.8
03679 */
03680 int burn_is_aborting(int flag);
03681 
03682 
03683 /* ts A70811 */
03684 /** Write data in random access mode.
03685     The drive must be grabbed successfully before calling this function which
03686     circumvents usual libburn session processing and rather writes data without
03687     preparations or finalizing. This will work only with overwriteable media
03688     which are also suitable for burn_write_opts_set_start_byte(). The same
03689     address alignment restrictions as with this function apply. I.e. for DVD
03690     it is best to align to 32 KiB blocks (= 16 LBA units). The amount of data
03691     to be written is subject to the same media dependent alignment rules.
03692     Again, 32 KiB is most safe.
03693     Call burn_disc_get_multi_caps() can obtain the necessary media info. See
03694     resulting struct burn_multi_caps elements .start_adr , .start_alignment ,
03695     .start_range_low , .start_range_high .
03696     Other than burn_disc_write() this is a synchronous call which returns
03697     only after the write transaction has ended (sucessfully or not). So it is
03698     wise not to transfer giant amounts of data in a single call.
03699     Important: Data have to fit into the already formatted area of the media.
03700     @param d            The drive to which to write 
03701     @param byte_address The start address of the write in byte
03702                         (1 LBA unit = 2048 bytes) (do respect media alignment)
03703     @param data         The bytes to be written
03704     @param data_count   The number of those bytes (do respect media alignment)
03705                         data_count == 0 is permitted (e.g. to flush the
03706                         drive buffer without further data transfer).
03707     @param flag         Bitfield for control purposes:
03708                         bit0 = flush the drive buffer after eventual writing
03709     @return 1=sucessful , <=0 : number of transfered bytes * -1
03710     @since 0.4.0
03711 */
03712 int burn_random_access_write(struct burn_drive *d, off_t byte_address,
03713                              char *data, off_t data_count, int flag);
03714 
03715 
03716 /* ts A81215 */
03717 /** Inquire the maximum amount of readable data.
03718     It is supposed that all LBAs in the range from 0 to media_read_acpacity-1
03719     can be read via burn_read_data() although some of them may never have been
03720     recorded. If tracks are recognizable then it is better to only read
03721     LBAs which are part of some track.
03722     If the drive is actually a large file or block device, then the capacity
03723     is curbed to a maximum of 0x7ffffff0 blocks = 4 TB - 32 KB.
03724     @param d            The drive from which to read
03725     @param capacity     Will return the result if valid
03726     @param flag         Bitfield for control purposes: Unused yet, submit 0.
03727     @return 1=sucessful , <=0 an error occured
03728     @since 0.6.0
03729 */
03730 int burn_get_read_capacity(struct burn_drive *d, int *capacity, int flag);
03731 
03732 
03733 /* ts A70812 */
03734 /** Read data in random access mode.
03735     The drive must be grabbed successfully before calling this function.
03736     With all currently supported drives and media the byte_address has to
03737     be aligned to 2048 bytes. Only data tracks with 2048 bytes per sector
03738     can be read this way. I.e. not CD-audio, not CD-video-stream ...
03739     This is a synchronous call which returns only after the full read job
03740     has ended (sucessfully or not). So it is wise not to read giant amounts
03741     of data in a single call.
03742     @param d            The drive from which to read
03743     @param byte_address The start address of the read in byte (aligned to 2048)
03744     @param data         A memory buffer capable of taking data_size bytes
03745     @param data_size    The amount of data to be read. This does not have to
03746                         be aligned to any block size.
03747     @param data_count   The amount of data actually read (interesting on error)
03748     @param flag         Bitfield for control purposes:
03749                         bit0= - reserved -
03750                         bit1= do not submit error message if read error
03751                         bit2= on error do not try to read a second time
03752                               with single block steps.
03753                               @since 0.5.2 
03754                         bit3= return -2 on permission denied error rather than
03755                               issueing a warning message.
03756                               @since 1.0.6
03757     @return 1=sucessful , <=0 an error occured
03758                           with bit3:  -2= permission denied error
03759     @since 0.4.0
03760 */
03761 int burn_read_data(struct burn_drive *d, off_t byte_address,
03762                    char data[], off_t data_size, off_t *data_count, int flag);
03763 
03764 
03765 /* ts A70904 */
03766 /** Inquire whether the drive object is a real MMC drive or a pseudo-drive
03767     created by a stdio: address.
03768     @param d      The drive to inquire
03769     @return       0= null-drive
03770                   1= real MMC drive
03771                   2= stdio-drive, random access, read-write
03772                   3= stdio-drive, sequential, write-only
03773                   4= stdio-drive, random access, read-only
03774                      (only if enabled by burn_allow_drive_role_4())
03775                   5= stdio-drive, random access, write-only
03776                      (only if enabled by burn_allow_drive_role_4())
03777     @since 0.4.0
03778 */
03779 int burn_drive_get_drive_role(struct burn_drive *d);
03780 
03781 
03782 /* ts B10312 */
03783 /** Allow drive role 4 "random access read-only"
03784     and drive role 5 "random access write-only".
03785     By default a random access file assumes drive role 2 "read-write"
03786     regardless whether it is actually readable or writeable.
03787     If enabled, random-access file objects which recognizably allow no
03788     writing will be classified as role 4 and those which allow no reading
03789     will get role 5.
03790     Candidates are drive addresses of the form stdio:/dev/fd/# , where # is
03791     the integer number of an open file descriptor. If this descriptor was
03792     opened read-only resp. write-only, then it gets role 4 resp. role 5.
03793     Other paths may get tested by an attempt to open them for read-write
03794     (role 2) resp. read-only (role 4) resp. write-only (role 5). See bit1.
03795     @param allowed      Bitfield for control purposes:
03796                         bit0= Enable roles 4 and 5 for drives which get
03797                               aquired after this call
03798                         bit1= with bit0:
03799                               Test whether the file can be opened for
03800                               read-write resp. read-only resp. write-only.
03801                               Classify as roles 2 resp. 4 resp. 5.
03802                         bit2= with bit0 and bit1:
03803                               Classify files which cannot be opened at all
03804                               as role 0 : useless dummy.
03805                               Else classify as role 2.
03806                         bit3= Classify non-empty role 5 drives as
03807                               BURN_DISC_APPENDABLE with Next Writeable Address
03808                               after the end of the file. It is nevertheless
03809                               possible to change this address by call
03810                               burn_write_opts_set_start_byte().
03811     @since 1.0.6
03812 */
03813 void burn_allow_drive_role_4(int allowed);
03814 
03815 
03816 /* ts A70923 */
03817 /** Find out whether a given address string would lead to the given drive
03818     object. This should be done in advance for track source addresses
03819     with parameter drive_role set to 2. 
03820     Although a real MMC drive should hardly exist as two drive objects at
03821     the same time, this can easily happen with stdio-drives. So if more than
03822     one drive is used by the application, then this gesture is advised:
03823       burn_drive_d_get_adr(d2, adr2);
03824       if (burn_drive_equals_adr(d1, adr2, burn_drive_get_drive_role(d2)))
03825         ... Both drive objects point to the same storage facility ...
03826  
03827     @param d1      Existing drive object
03828     @param adr2    Address string to be tested. Prefix "stdio:" overrides
03829                    parameter drive_role2 by either 0 or 2 as appropriate.
03830                    The string must be shorter than BURN_DRIVE_ADR_LEN.
03831     @param drive_role2  Role as burn_drive_get_drive_role() would attribute
03832                    to adr2 if it was a drive. Use value 2 for checking track
03833                    sources resp. pseudo-drive addresses without "stdio:".
03834                    Use 1 for checking drive addresses including those with
03835                    prefix "stdio:".
03836     @return        1= adr2 leads to d1 , 0= adr2 seems not to lead to d1,
03837                    -1 = adr2 is bad
03838     @since 0.4.0
03839 */
03840 int burn_drive_equals_adr(struct burn_drive *d1, char *adr2, int drive_role2);
03841 
03842 
03843 
03844 /*
03845   Audio track data extraction facility.
03846 */
03847 
03848 /* Maximum size for address paths and fmt_info strings */
03849 #define LIBDAX_AUDIOXTR_STRLEN 4096
03850 
03851 
03852 /** Extractor object encapsulating intermediate states of extraction.
03853     The clients of libdax_audioxtr shall only allocate pointers to this
03854     struct and get a storage object via libdax_audioxtr_new().
03855     Appropriate initial value for the pointer is NULL.
03856 */
03857 struct libdax_audioxtr;
03858 
03859 
03860 /** Open an audio file, check wether suitable, create extractor object.
03861     @param xtr Opaque handle to extractor. Gets attached extractor object.
03862     @param path Address of the audio file to extract. "-" is stdin (but might
03863                 be not suitable for all futurely supported formats).
03864     @param flag Bitfield for control purposes (unused yet, submit 0)
03865     @return >0 success
03866              0 unsuitable format
03867             -1 severe error
03868             -2 path not found
03869     @since 0.2.4
03870 */
03871 int libdax_audioxtr_new(struct libdax_audioxtr **xtr, char *path, int flag);
03872 
03873 
03874 /** Obtain identification parameters of opened audio source.
03875     @param xtr Opaque handle to extractor
03876     @param fmt Gets pointed to the audio file format id text: ".wav" , ".au"
03877     @param fmt_info Gets pointed to a format info text telling parameters
03878     @param num_channels     e.g. 1=mono, 2=stereo, etc
03879     @param sample_rate      e.g. 11025, 44100
03880     @param bits_per_sample  e.g. 8= 8 bits per sample, 16= 16 bits ...
03881     @param msb_first Byte order of samples: 0= Intel    = Little Endian
03882                                             1= Motorola = Big Endian
03883     @param flag Bitfield for control purposes (unused yet, submit 0)
03884     @return >0 success, <=0 failure
03885     @since 0.2.4
03886 */
03887 int libdax_audioxtr_get_id(struct libdax_audioxtr *xtr,
03888                            char **fmt, char **fmt_info,
03889                            int *num_channels, int *sample_rate,
03890                            int *bits_per_sample, int *msb_first, int flag);
03891 
03892 
03893 /** Obtain a prediction about the extracted size based on internal information
03894     of the formatted file.
03895     @param xtr Opaque handle to extractor
03896     @param size Gets filled with the predicted size
03897     @param flag Bitfield for control purposes (unused yet, submit 0)
03898     @return 1 prediction was possible , 0 no prediction could be made
03899     @since 0.2.4
03900 */
03901 int libdax_audioxtr_get_size(struct libdax_audioxtr *o, off_t *size, int flag);
03902 
03903 
03904 /** Obtain next buffer full of extracted data in desired format (only raw audio
03905     for now).
03906     @param xtr Opaque handle to extractor
03907     @param buffer Gets filled with extracted data
03908     @param buffer_size Maximum number of bytes to be filled into buffer
03909     @param flag Bitfield for control purposes
03910                 bit0= do not stop at predicted end of data
03911     @return >0 number of valid buffer bytes,
03912              0 End of file
03913             -1 operating system reports error
03914             -2 usage error by application
03915     @since 0.2.4
03916 */
03917 int libdax_audioxtr_read(struct libdax_audioxtr *xtr,
03918                          char buffer[], int buffer_size, int flag);
03919 
03920 
03921 /** Try to obtain a file descriptor which will deliver extracted data
03922     to normal calls of read(2). This may fail because the format is
03923     unsuitable for that, but ".wav" is ok. If this call succeeds the xtr
03924     object will have forgotten its file descriptor and libdax_audioxtr_read()
03925     will return a usage error. One may use *fd after libdax_audioxtr_destroy()
03926     and will have to close it via close(2) when done with it.
03927     @param xtr Opaque handle to extractor
03928     @param fd Eventually returns the file descriptor number
03929     @param flag Bitfield for control purposes
03930                 bit0= do not dup(2) and close(2) but hand out original fd
03931     @return 1 success, 0 cannot hand out fd , -1 severe error
03932     @since 0.2.4
03933 */
03934 int libdax_audioxtr_detach_fd(struct libdax_audioxtr *o, int *fd, int flag);
03935 
03936 
03937 /** Clean up after extraction and destroy extractor object.
03938     @param xtr Opaque handle to extractor, *xtr is allowed to be NULL,
03939                *xtr is set to NULL by this function
03940     @param flag Bitfield for control purposes (unused yet, submit 0)
03941     @return 1 = destroyed object, 0 = was already destroyed
03942     @since 0.2.4
03943 */
03944 int libdax_audioxtr_destroy(struct libdax_audioxtr **xtr, int flag);
03945 
03946 
03947 #ifndef DOXYGEN
03948 
03949 BURN_END_DECLS
03950 
03951 #endif
03952 
03953 
03954 /* ts A91205 */
03955 /* The following experiments may be interesting in future:
03956 */
03957 
03958 /* Perform OPC explicitely.
03959    # define Libburn_pioneer_dvr_216d_with_opC 1
03960 */
03961 
03962 /* Load mode page 5 and modify it rather than composing from scratch.
03963    # define Libburn_pioneer_dvr_216d_load_mode5 1
03964 */
03965 
03966 /* Inquire drive events and react by reading configuration or starting unit.
03967    # define Libburn_pioneer_dvr_216d_get_evenT 1
03968 */
03969 
03970 /* ts A91112 */
03971 /* Do not probe CD modes but declare only data and audio modes supported.
03972    For other modes resp. real probing one has to call
03973    burn_drive_probe_cd_write_modes().
03974 
03975 */
03976 #define Libburn_dummy_probe_write_modeS 1
03977 
03978 
03979 #endif /*LIBBURN_H*/