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

Generated for libburn by  doxygen 1.4.7