libburn-0.3.6/libburn/libburn.h

Go to the documentation of this file.
00001 /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
00002 
00003 #ifndef LIBBURN_H
00004 #define LIBBURN_H
00005 
00006 /* Needed for  off_t  which is the (POSIX-ly) appropriate type for
00007    expressing a file or stream size.
00008 
00009    XXX we should enforce 64-bitness for off_t
00010    ts A61101 : this is usually done by the build system (if it is not broken)
00011 */
00012 #include <sys/types.h>
00013 
00014 #ifndef DOXYGEN
00015 
00016 #if defined(__cplusplus)
00017 #define BURN_BEGIN_DECLS \
00018     namespace burn { \
00019         extern "C" {
00020 #define BURN_END_DECLS \
00021         } \
00022     }
00023 #else
00024 #define BURN_BEGIN_DECLS
00025 #define BURN_END_DECLS
00026 #endif
00027 
00028 BURN_BEGIN_DECLS
00029 
00030 #endif
00031 
00032 /** References a physical drive in the system */
00033 struct burn_drive;
00034 
00035 /** References a whole disc */
00036 struct burn_disc;
00037 
00038 /** References a single session on a disc */
00039 struct burn_session;
00040 
00041 /** References a single track on a disc */
00042 struct burn_track;
00043 
00044 /* ts A61111 */
00045 /** References a set of write parameters */
00046 struct burn_write_opts;
00047 
00048 /** Session format for normal audio or data discs */
00049 #define BURN_CDROM  0
00050 /** Session format for obsolete CD-I discs */
00051 #define BURN_CDI    0x10
00052 /** Session format for CDROM-XA discs */
00053 #define BURN_CDXA   0x20
00054 
00055 #define BURN_POS_END 100
00056 
00057 /** Mask for mode bits */
00058 #define BURN_MODE_BITS 127
00059 
00060 /** Track mode - mode 0 data
00061     0 bytes of user data.  it's all 0s.  mode 0.  get it?  HAH
00062 */
00063 #define BURN_MODE0      (1 << 0)
00064 /** Track mode - mode "raw" - all 2352 bytes supplied by app
00065     FOR DATA TRACKS ONLY!
00066 */
00067 #define BURN_MODE_RAW       (1 << 1)
00068 /** Track mode - mode 1 data
00069     2048 bytes user data, and all the LEC money can buy
00070 */
00071 #define BURN_MODE1      (1 << 2)
00072 /** Track mode - mode 2 data
00073     defaults to formless, 2336 bytes of user data, unprotected
00074     | with a data form if required.
00075 */
00076 #define BURN_MODE2      (1 << 3)
00077 /** Track mode modifier - Form 1, | with MODE2 for reasonable results
00078     2048 bytes of user data, 4 bytes of subheader
00079 */
00080 #define BURN_FORM1      (1 << 4)
00081 /** Track mode modifier - Form 2, | with MODE2 for reasonable results
00082     lots of user data.  not much LEC.
00083 */
00084 #define BURN_FORM2      (1 << 5)
00085 /** Track mode - audio
00086     2352 bytes per sector.  may be | with 4ch or preemphasis.
00087     NOT TO BE CONFUSED WITH BURN_MODE_RAW
00088     Audio data must be 44100Hz 16bit stereo with no riff or other header at
00089     beginning.  Extra header data will cause pops or clicks.  Audio data should
00090     also be in little-endian byte order.  Big-endian audio data causes static.
00091 */
00092 #define BURN_AUDIO      (1 << 6)
00093 /** Track mode modifier - 4 channel audio. */
00094 #define BURN_4CH        (1 << 7)
00095 /** Track mode modifier - Digital copy permitted, can be set on any track.*/
00096 #define BURN_COPY       (1 << 8)
00097 /** Track mode modifier - 50/15uS pre-emphasis */
00098 #define BURN_PREEMPHASIS    (1 << 9)
00099 /** Input mode modifier - subcodes present packed 16 */
00100 #define BURN_SUBCODE_P16    (1 << 10)
00101 /** Input mode modifier - subcodes present packed 96 */
00102 #define BURN_SUBCODE_P96    (1 << 11)
00103 /** Input mode modifier - subcodes present raw 96 */
00104 #define BURN_SUBCODE_R96    (1 << 12)
00105 
00106 /** Possible disc writing style/modes */
00107 enum burn_write_types
00108 {
00109     /** Packet writing.
00110           currently unsupported, (for DVD Incremental Streaming use TAO)
00111     */
00112     BURN_WRITE_PACKET,
00113 
00114     /** With CD:                     Track At Once recording
00115           2s gaps between tracks, no fonky lead-ins
00116 
00117         With sequential DVD-R[W]:    Incremental Streaming
00118         With DVD-RAM/+RW:            Random Writeable (used sequentially)
00119         With overwriteable DVD-RW:   Rigid Restricted Overwrite 
00120     */
00121     BURN_WRITE_TAO,
00122 
00123     /** With CD:                     Session At Once
00124           Block type MUST be BURN_BLOCK_SAO
00125           ts A70122: Currently not capable of mixing data and audio tracks.
00126 
00127         With sequential DVD-R[W]:    Disc-at-once, DAO
00128           Single session, single track, fixed size mandatory, (-dvd-compat)
00129     */
00130     BURN_WRITE_SAO,
00131 
00132     /** With CD: Raw disc at once recording.
00133           all subcodes must be provided by lib or user
00134           only raw block types are supported
00135     */
00136     BURN_WRITE_RAW,
00137 
00138     /** In replies this indicates that not any writing will work.
00139         As parameter for inquiries it indicates that no particular write
00140             mode shall is specified.
00141         Do not use for setting a write mode for burning. It won't work.
00142     */
00143     BURN_WRITE_NONE
00144 };
00145 
00146 /** Data format to send to the drive */
00147 enum burn_block_types
00148 {
00149     /** sync, headers, edc/ecc provided by lib/user */
00150     BURN_BLOCK_RAW0 = 1,
00151     /** sync, headers, edc/ecc and p/q subs provided by lib/user */
00152     BURN_BLOCK_RAW16 = 2,
00153     /** sync, headers, edc/ecc and packed p-w subs provided by lib/user */
00154     BURN_BLOCK_RAW96P = 4,
00155     /** sync, headers, edc/ecc and raw p-w subs provided by lib/user */
00156     BURN_BLOCK_RAW96R = 8,
00157     /** only 2048 bytes of user data provided by lib/user */
00158     BURN_BLOCK_MODE1 = 256,
00159     /** 2336 bytes of user data provided by lib/user */
00160     BURN_BLOCK_MODE2R = 512,
00161     /** 2048 bytes of user data provided by lib/user
00162         subheader provided in write parameters
00163         are we ever going to support this shit?  I vote no.
00164         (supposed to be supported on all drives...)
00165     */
00166     BURN_BLOCK_MODE2_PATHETIC = 1024,
00167     /** 2048 bytes of data + 8 byte subheader provided by lib/user
00168         hey, this is also dumb
00169     */
00170     BURN_BLOCK_MODE2_LAME = 2048,
00171     /** 2324 bytes of data provided by lib/user
00172         subheader provided in write parameters
00173         no sir, I don't like it.
00174     */
00175     BURN_BLOCK_MODE2_OBSCURE = 4096,
00176     /** 2332 bytes of data supplied by lib/user
00177         8 bytes sub header provided in write parameters
00178         this is the second least suck mode2, and is mandatory for
00179         all drives to support.
00180     */
00181     BURN_BLOCK_MODE2_OK = 8192,
00182     /** SAO block sizes are based on cue sheet, so use this. */
00183     BURN_BLOCK_SAO = 16384
00184 };
00185 
00186 /** Possible status' of the drive in regard to the disc in it. */
00187 enum burn_disc_status
00188 {
00189     /** The current status is not yet known */
00190     BURN_DISC_UNREADY,
00191     /** The drive holds a blank disc */
00192     BURN_DISC_BLANK,
00193     /** There is no disc at all in the drive */
00194     BURN_DISC_EMPTY,
00195     /** There is an incomplete disc in the drive */
00196     BURN_DISC_APPENDABLE,
00197     /** There is a disc with data on it in the drive */
00198     BURN_DISC_FULL,
00199 
00200     /* ts A61007 */
00201     /** The drive was not grabbed when the status was inquired */
00202     BURN_DISC_UNGRABBED,
00203 
00204     /* ts A61020 */
00205     /** The media seems not to be suitable for burning */
00206     BURN_DISC_UNSUITABLE
00207 };
00208 
00209 
00210 /** Possible data source return values */
00211 enum burn_source_status
00212 {
00213     /** The source is ok */
00214     BURN_SOURCE_OK,
00215     /** The source is at end of file */
00216     BURN_SOURCE_EOF,
00217     /** The source is unusable */
00218     BURN_SOURCE_FAILED
00219 };
00220 
00221 
00222 /** Possible busy states for a drive */
00223 enum burn_drive_status
00224 {
00225     /** The drive is not in an operation */
00226     BURN_DRIVE_IDLE,
00227     /** The library is spawning the processes to handle a pending
00228         operation (A read/write/etc is about to start but hasn't quite
00229         yet) */
00230     BURN_DRIVE_SPAWNING,
00231     /** The drive is reading data from a disc */
00232     BURN_DRIVE_READING,
00233     /** The drive is writing data to a disc */
00234     BURN_DRIVE_WRITING,
00235     /** The drive is writing Lead-In */
00236     BURN_DRIVE_WRITING_LEADIN,
00237     /** The drive is writing Lead-Out */
00238     BURN_DRIVE_WRITING_LEADOUT,
00239     /** The drive is erasing a disc */
00240     BURN_DRIVE_ERASING,
00241     /** The drive is being grabbed */
00242     BURN_DRIVE_GRABBING,
00243 
00244     /* ts A61102 */
00245     /** The drive gets written zeroes before the track payload data */
00246     BURN_DRIVE_WRITING_PREGAP,
00247     /** The drive is told to close a track (TAO only) */
00248     BURN_DRIVE_CLOSING_TRACK,
00249     /** The drive is told to close a session (TAO only) */
00250     BURN_DRIVE_CLOSING_SESSION,
00251 
00252     /* ts A61223 */
00253     /** The drive is formatting media */
00254     BURN_DRIVE_FORMATTING
00255 
00256 };
00257 
00258     
00259 /** Information about a track on a disc - this is from the q sub channel of the
00260     lead-in area of a disc.  The documentation here is very terse.
00261     See a document such as mmc3 for proper information.
00262 
00263     CAUTION : This structure is prone to future extension !
00264 
00265     Do not restrict your application to unsigned char with any counter like
00266     "session", "point", "pmin", ...
00267     Do not rely on the current size of a burn_toc_entry. 
00268 
00269     ts A70201 : DVD extension, see below
00270 */
00271 struct burn_toc_entry
00272 {
00273     /** Session the track is in */
00274     unsigned char session;
00275     /** Type of data.  for this struct to be valid, it must be 1 */
00276     unsigned char adr;
00277     /** Type of data in the track */
00278     unsigned char control;
00279     /** Zero.  Always.  Really. */
00280     unsigned char tno;
00281     /** Track number or special information */
00282     unsigned char point;
00283     unsigned char min;
00284     unsigned char sec;
00285     unsigned char frame;
00286     unsigned char zero;
00287     /** Track start time minutes for normal tracks */
00288     unsigned char pmin;
00289     /** Track start time seconds for normal tracks */
00290     unsigned char psec;
00291     /** Track start time frames for normal tracks */
00292     unsigned char pframe;
00293 
00294     /* Indicates wether extension data are valid and eventually override
00295        older elements in this structure:
00296          bit0= DVD extension is valid
00297     */
00298     unsigned char extensions_valid;  
00299 
00300     /* ts A70201 : DVD extension.
00301        If invalid the members are guaranteed to be 0. */
00302     /* Tracks and session numbers are 16 bit. Here are the high bytes. */
00303     unsigned char session_msb;
00304     unsigned char point_msb;
00305     /* pmin, psec, and pframe may be too small if DVD extension is valid */
00306     int start_lba; 
00307     /* min, sec, and frame may be too small if DVD extension is valid */
00308     int track_blocks;
00309     
00310 };
00311 
00312 
00313 /** Data source for tracks */
00314 struct burn_source {
00315     /** Reference count for the data source. Should be 1 when a new source
00316             is created.  Increment it to take a reference for yourself. Use
00317             burn_source_free to destroy your reference to it. */
00318     int refcount;
00319 
00320     /** Read data from the source */
00321     int (*read)(struct burn_source *,
00322                                        unsigned char *buffer,
00323                                        int size);
00324 
00325     /** Read subchannel data from the source (NULL if lib generated) */
00326     int (*read_sub)(struct burn_source *,
00327                                            unsigned char *buffer,
00328                                            int size);
00329 
00330     /** Get the size of the source's data */
00331     off_t (*get_size)(struct burn_source *);
00332 
00333     /** Set the size of the source's data */
00334     int (*set_size)(struct burn_source *source, off_t size);
00335 
00336     /** Clean up the source specific data */
00337     void (*free_data)(struct burn_source *);
00338 
00339     /** Next source, for when a source runs dry and padding is disabled
00340         THIS IS AUTOMATICALLY HANDLED, DO NOT TOUCH
00341     */
00342     struct burn_source *next;
00343 
00344     /** Source specific data */
00345     void *data;
00346 };
00347 
00348 
00349 /** Information on a drive in the system */
00350 struct burn_drive_info
00351 {
00352     /** Name of the vendor of the drive */
00353     char vendor[9];
00354     /** Name of the drive */
00355     char product[17];
00356     /** Revision of the drive */
00357     char revision[5];
00358     /** Location of the drive in the filesystem. */
00359     char location[17];
00360     /** This is currently the string which is used as persistent
00361         drive address. But be warned: there is NO GUARANTEE that this
00362         will stay so. Always use function  burn_drive_get_adr() to
00363         inquire a persistent address.       ^^^^^^ ALWAYS ^^^^^^ */
00364 
00365     /** Can the drive read DVD-RAM discs */
00366     unsigned int read_dvdram:1;
00367     /** Can the drive read DVD-R discs */
00368     unsigned int read_dvdr:1;
00369     /** Can the drive read DVD-ROM discs */
00370     unsigned int read_dvdrom:1;
00371     /** Can the drive read CD-R discs */
00372     unsigned int read_cdr:1;
00373     /** Can the drive read CD-RW discs */
00374     unsigned int read_cdrw:1;
00375 
00376     /** Can the drive write DVD-RAM discs */
00377     unsigned int write_dvdram:1;
00378     /** Can the drive write DVD-R discs */
00379     unsigned int write_dvdr:1;
00380     /** Can the drive write CD-R discs */
00381     unsigned int write_cdr:1;
00382     /** Can the drive write CD-RW discs */
00383     unsigned int write_cdrw:1;
00384 
00385     /** Can the drive simulate a write */
00386     unsigned int write_simulate:1;
00387 
00388     /** Can the drive report C2 errors */
00389     unsigned int c2_errors:1;
00390 
00391     /** The size of the drive's buffer (in kilobytes) */
00392     int buffer_size;
00393     /** 
00394      * The supported block types in tao mode.
00395      * They should be tested with the desired block type.
00396      * See also burn_block_types.
00397      */
00398     int tao_block_types;
00399     /** 
00400      * The supported block types in sao mode.
00401      * They should be tested with the desired block type.
00402      * See also burn_block_types.
00403      */
00404     int sao_block_types;
00405     /** 
00406      * The supported block types in raw mode.
00407      * They should be tested with the desired block type.
00408      * See also burn_block_types.
00409      */
00410     int raw_block_types;
00411     /** 
00412      * The supported block types in packet mode.
00413      * They should be tested with the desired block type.
00414      * See also burn_block_types.
00415      */
00416     int packet_block_types;
00417 
00418     /** The value by which this drive can be indexed when using functions
00419         in the library. This is the value to pass to all libbburn functions
00420         that operate on a drive. */
00421     struct burn_drive *drive;
00422 };
00423 
00424 
00425 /** Operation progress report. All values are 0 based indices. 
00426  * */
00427 struct burn_progress {
00428     /** The total number of sessions */
00429     int sessions;
00430     /** Current session.*/
00431     int session;
00432     /** The total number of tracks */
00433     int tracks;
00434     /** Current track. */
00435     int track;
00436     /** The total number of indices */
00437     int indices;
00438     /** Curent index. */
00439     int index;
00440     /** The starting logical block address */
00441     int start_sector;
00442     /** On write: The number of sectors.
00443         On blank: 0x10000 as upper limit for relative progress steps */
00444     int sectors;
00445     /** On write: The current sector being processed.
00446         On blank: Relative progress steps 0 to 0x10000 */
00447     int sector;
00448 
00449     /* ts A61023 */
00450     /** The capacity of the drive buffer */
00451     unsigned buffer_capacity;
00452     /** The free space in the drive buffer (might be slightly outdated) */
00453     unsigned buffer_available;
00454 
00455     /* ts A61119 */
00456     /** The number of bytes sent to the drive buffer */
00457     off_t buffered_bytes;
00458     /** The minimum number of buffered bytes. (Caution: Before surely
00459         one buffer size of bytes was processed, this value is 0xffffffff.) 
00460     */
00461     unsigned buffer_min_fill;
00462 };
00463 
00464 
00465 /* ts A61226 */
00466 /** Description of a speed capability as reported by the drive in conjunction
00467     with eventually loaded media. There can be more than one such object per
00468     drive. So they are chained via .next and .prev , where NULL marks the end
00469     of the chain. This list is set up by burn_drive_scan() and gets updated
00470     by burn_drive_grab().
00471     A copy may be obtained by burn_drive_get_speedlist() and disposed by
00472     burn_drive_free_speedlist().
00473     For technical background info see SCSI specs MMC and SPC:
00474     mode page 2Ah (from SPC 5Ah MODE SENSE) , mmc3r10g.pdf , 6.3.11 Table 364
00475     ACh GET PERFORMANCE, Type 03h , mmc5r03c.pdf , 6.8.5.3 Table 312
00476 */
00477 struct burn_speed_descriptor {
00478 
00479     /** Where this info comes from : 
00480         0 = misc , 1 = mode page 2Ah , 2 = ACh GET PERFORMANCE */
00481     int source;
00482 
00483     /** The media type that was current at the time of report
00484         -2 = state unknown, -1 = no media was loaded , else see
00485         burn_disc_get_profile() */
00486     int profile_loaded;
00487     char profile_name[80];
00488 
00489     /** The attributed capacity of appropriate media in logical block units
00490         i.e. 2352 raw bytes or 2048 data bytes. -1 = capacity unknown. */
00491     int end_lba;
00492 
00493     /** Speed is given in 1000 bytes/s , 0 = invalid. The numbers
00494         are supposed to be usable with burn_drive_set_speed() */
00495     int write_speed;
00496     int read_speed;
00497 
00498     /** Expert info from ACh GET PERFORMANCE and/or mode page 2Ah.
00499         Expect values other than 0 or 1 to get a meaning in future.*/
00500     /* Rotational control: 0 = CLV/default , 1 = CAV */
00501     int wrc;
00502     /* 1 = drive promises reported performance over full media */
00503     int exact;
00504     /* 1 = suitable for mixture of read and write */
00505     int mrw;
00506 
00507     /** List chaining. Use .next until NULL to iterate over the list */
00508     struct burn_speed_descriptor *prev;
00509     struct burn_speed_descriptor *next;
00510 };
00511 
00512 
00513 /** Initialize the library.
00514     This must be called before using any other functions in the library. It
00515     may be called more than once with no effect.
00516     It is possible to 'restart' the library by shutting it down and
00517     re-initializing it. This is necessary if you follow the older and
00518     more general way of accessing a drive via burn_drive_scan() and
00519     burn_drive_grab(). See burn_drive_scan_and_grab() with its strong
00520     urges and its explanations.
00521     @return Nonzero if the library was able to initialize; zero if
00522             initialization failed.
00523 */
00524 int burn_initialize(void);
00525 
00526 /** Shutdown the library.
00527     This should be called before exiting your application. Make sure that all
00528     drives you have grabbed are released <i>before</i> calling this.
00529 */
00530 void burn_finish(void);
00531 
00532 
00533 /* ts A61002 */
00534 /** Abort any running drive operation and finally call burn_finish().
00535     You MUST calm down the busy drive if an aborting event occurs during a
00536     burn run. For that you may call this function either from your own signal
00537     handling code or indirectly by activating the builtin signal handling:
00538       burn_set_signal_handling("my_app_name : ", NULL, 0);
00539     Else you may eventually call burn_drive_cancel() on the active drive and
00540     wait for it to assume state BURN_DRIVE_IDLE.
00541     @param patience Maximum number of seconds to wait for drives to finish
00542     @param pacifier_func If not NULL: a function to produce appeasing messages.
00543                          See burn_abort_pacifier() for an example.
00544     @param handle Opaque handle to be used with pacifier_func
00545     @return 1  ok, all went well
00546             0  had to leave a drive in unclean state
00547             <0 severe error, do no use libburn again
00548 */
00549 int burn_abort(int patience, 
00550                int (*pacifier_func)(void *handle, int patience, int elapsed),
00551                void *handle);
00552 
00553 /** A pacifier function suitable for burn_abort.
00554     @param handle If not NULL, a pointer to a text suitable for printf("%s")
00555     @param patience Maximum number of seconds to wait
00556     @param elapsed  Elapsed number of seconds
00557 */
00558 int burn_abort_pacifier(void *handle, int patience, int elapsed);
00559 
00560 
00561 /** ts A61006 : This is for development only. Not suitable for applications.
00562     Set the verbosity level of the library. The default value is 0, which means
00563     that nothing is output on stderr. The more you increase this, the more
00564     debug output should be displayed on stderr for you.
00565     @param level The verbosity level desired. 0 for nothing, higher positive
00566                  values for more information output.
00567 */
00568 void burn_set_verbosity(int level);
00569 
00570 /* ts A60813 */
00571 /** Set parameters for behavior on opening device files. To be called early
00572     after burn_initialize() and before any bus scan. But not mandatory at all.
00573     Parameter value 1 enables a feature, 0 disables.  
00574     Default is (1,0,0). Have a good reason before you change it.
00575     @param exclusive Linux only:
00576                      0 = no attempt to make drive access exclusive.
00577                      1 = Try to open only devices which are not marked as busy
00578                      and try to mark them busy if opened sucessfully. (O_EXCL)
00579                      There are kernels which simply don't care about O_EXCL.
00580                      Some have it off, some have it on, some are switchable.
00581                      2 = in case of a SCSI device, also try to open exclusively
00582                          the matching /dev/sr, /dev/scd and /dev/st .
00583                      One may select a device SCSI file family by adding
00584                       0 = default family
00585                       4 = /dev/sr%d
00586                       8 = /dev/scd%d
00587                      16 = /dev/sg%d
00588                      Do not use other values !
00589                      Add 32 to demand an exclusive lock by fcntl(,F_SETLK,)
00590                      after open() has succeeded.
00591     @param blocking  Try to wait for drives which do not open immediately but
00592                      also do not return an error as well. (O_NONBLOCK)
00593                      This might stall indefinitely with /dev/hdX hard disks.
00594     @param abort_on_busy  Unconditionally abort process when a non blocking
00595                           exclusive opening attempt indicates a busy drive.
00596                           Use this only after thorough tests with your app.
00597 */
00598 void burn_preset_device_open(int exclusive, int blocking, int abort_on_busy);
00599 
00600 
00601 /* ts A70223 */
00602 /** Allows the use of media types which are implemented in libburn but not yet
00603     tested. The list of those untested profiles is subject to change.
00604     Currently it contains: 0x15 "DVD-R/DL Sequential".
00605     If you really test such media, then please report the outcome on
00606     libburn-hackers@pykix.org
00607     If ever then this call should be done soon after burn_initialize() before
00608     any drive scanning.
00609     @param yes 1=allow all implemented profiles, 0=only tested media (default)
00610 */
00611 void burn_allow_untested_profiles(int yes);
00612 
00613 
00614 /* ts A60823 */
00615 /** Aquire a drive with known persistent address.This is the sysadmin friendly
00616     way to open one drive and to leave all others untouched. It bundles
00617     the following API calls to form a non-obtrusive way to use libburn:
00618       burn_drive_add_whitelist() , burn_drive_scan() , burn_drive_grab()
00619     You are *strongly urged* to use this call whenever you know the drive
00620     address in advance.
00621     If not, then you have to use directly above calls. In that case, you are
00622     *strongly urged* to drop any unintended drive which will be exclusively
00623     occupied and not closed by burn_drive_scan().
00624     This can be done by shutting down the library including a call to
00625     burn_finish(). You may later start a new libburn session and should then
00626     use the function described here with an address obtained after
00627     burn_drive_scan() via burn_drive_get_adr(&(drive_infos[driveno]), adr) .
00628     Another way is to drop the unwanted drives by burn_drive_info_forget().
00629     @param drive_infos On success returns a one element array with the drive
00630                   (cdrom/burner). Thus use with driveno 0 only. On failure
00631                   the array has no valid elements at all.
00632                   The returned array should be freed via burn_drive_info_free()
00633                   when it is no longer needed, and before calling a scan
00634                   function again.
00635                   This is a result from call burn_drive_scan(). See there.
00636                   Use with driveno 0 only.
00637     @param adr    The persistent address of the desired drive. Either obtained
00638                   by burn_drive_get_adr() or guessed skillfully by application
00639                   resp. its user.
00640     @param load   Nonzero to make the drive attempt to load a disc (close its
00641                   tray door, etc).
00642     @return       1 = success , 0 = drive not found , -1 = other error
00643 */    
00644 int burn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
00645                              char* adr, int load);
00646 
00647 
00648 /* ts A51221 */
00649 /** Maximum number of particularly permissible drive addresses */
00650 #define BURN_DRIVE_WHITELIST_LEN 255
00651 /** Add a device to the list of permissible drives. As soon as some entry is in
00652     the whitelist all non-listed drives are banned from scanning.
00653     @return 1 success, <=0 failure
00654 */
00655 int burn_drive_add_whitelist(char *device_address);
00656 
00657 /** Remove all drives from whitelist. This enables all possible drives. */
00658 void burn_drive_clear_whitelist(void);
00659 
00660 
00661 /** Scan for drives. This function MUST be called until it returns nonzero.
00662     No drives may be in use when this is called.
00663     All drive pointers are invalidated by using this function. Do NOT store
00664     drive pointers across calls to this function or death AND pain will ensue.
00665     After this call all drives depicted by the returned array are subject
00666     to eventual (O_EXCL) locking. See burn_preset_device_open(). This state
00667     ends either with burn_drive_info_forget() or with burn_drive_release().
00668     It is unfriendly to other processes on the system to hold drives locked
00669     which one does not definitely plan to use soon.
00670     @param drive_infos Returns an array of drive info items (cdroms/burners).
00671                   The returned array must be freed by burn_drive_info_free()
00672                   before burn_finish(), and also before calling this function
00673                   burn_drive_scan() again.
00674     @param n_drives Returns the number of drive items in drive_infos.
00675     @return 0 while scanning is not complete
00676             >0 when it is finished sucessfully,
00677             <0 when finished but failed.
00678 */
00679 int burn_drive_scan(struct burn_drive_info *drive_infos[],
00680             unsigned int *n_drives);
00681 
00682 /* ts A60904 : ticket 62, contribution by elmom */
00683 /** Release memory about a single drive and any exclusive lock on it.
00684     Become unable to inquire or grab it. Expect FATAL consequences if you try.
00685     @param drive_info pointer to a single element out of the array
00686                       obtained from burn_drive_scan() : &(drive_infos[driveno])
00687     @param force controls degree of permissible drive usage at the moment this
00688                  function is called, and the amount of automatically provided
00689                  drive shutdown : 
00690                   0= drive must be ungrabbed and BURN_DRIVE_IDLE
00691                   1= try to release drive resp. accept BURN_DRIVE_GRABBING 
00692                  Use these two only. Further values are to be defined.
00693     @return 1 on success, 2 if drive was already forgotten,
00694             0 if not permissible, <0 on other failures, 
00695 */
00696 int burn_drive_info_forget(struct burn_drive_info *drive_info, int force);
00697 
00698 
00699 /** When no longer needed, free a whole burn_drive_info array which was
00700     returned by burn_drive_scan().
00701     For freeing single drive array elements use burn_drive_info_forget().
00702 */
00703 void burn_drive_info_free(struct burn_drive_info drive_infos[]);
00704 
00705 
00706 /* ts A60823 */
00707 /** Maximum length+1 to expect with a persistent drive address string */
00708 #define BURN_DRIVE_ADR_LEN 1024
00709 
00710 /** Inquire the persistent address of the given drive.
00711     @param drive_info The drive to inquire. Usually some &(drive_infos[driveno])
00712     @param adr   An application provided array of at least BURN_DRIVE_ADR_LEN
00713                  characters size. The persistent address gets copied to it.
00714     @return >0 success , <=0 error (due to libburn internal problem)
00715 */
00716 int burn_drive_get_adr(struct burn_drive_info *drive_info, char adr[]);
00717 
00718 /* ts A60922 ticket 33 */
00719 /** Evaluate wether the given address would be a possible persistent drive
00720     address of libburn.
00721     @return 1 means yes, 0 means no
00722 */
00723 int burn_drive_is_enumerable_adr(char *adr);
00724 
00725 /* ts A60922 ticket 33 */
00726 /** Try to convert a given existing filesystem address into a persistent drive
00727     address. This succeeds with symbolic links or if a hint about the drive's
00728     system address can be read from the filesystem object and a matching drive
00729     is found.
00730     @param path The address of an existing file system object
00731     @param adr  An application provided array of at least BURN_DRIVE_ADR_LEN
00732                 characters size. The persistent address gets copied to it.
00733     @return     1 = success , 0 = failure , -1 = severe error
00734 */
00735 int burn_drive_convert_fs_adr(char *path, char adr[]);
00736 
00737 /* ts A60923 */
00738 /** Try to convert a given SCSI address of bus,host,channel,target,lun into
00739     a persistent drive address. If a SCSI address component parameter is < 0
00740     then it is not decisive and the first enumerated address which matches
00741     the >= 0 parameters is taken as result.
00742     Note: bus and (host,channel) are supposed to be redundant.
00743     @param bus_no "Bus Number" (something like a virtual controller)
00744     @param host_no "Host Number" (something like half a virtual controller)
00745     @param channel_no "Channel Number" (other half of "Host Number")
00746     @param target_no "Target Number" or "SCSI Id" (a device)
00747     @param lun_no "Logical Unit Number" (a sub device)
00748     @param adr  An application provided array of at least BURN_DRIVE_ADR_LEN
00749                 characters size. The persistent address gets copied to it.
00750     @return     1 = success , 0 = failure , -1 = severe error
00751 */
00752 int burn_drive_convert_scsi_adr(int bus_no, int host_no, int channel_no,
00753                  int target_no, int lun_no, char adr[]);
00754 
00755 /* ts A60923 - A61005 */
00756 /** Try to obtain bus,host,channel,target,lun from path. If there is an SCSI
00757     address at all, then this call should succeed with a persistent
00758     drive address obtained via burn_drive_get_adr(). It is also supposed to
00759     succeed with any device file of a (possibly emulated) SCSI device.
00760     @return     1 = success , 0 = failure , -1 = severe error
00761 */
00762 int burn_drive_obtain_scsi_adr(char *path, int *bus_no, int *host_no,
00763                 int *channel_no, int *target_no, int *lun_no);
00764 
00765 /** Grab a drive. This must be done before the drive can be used (for reading,
00766     writing, etc).
00767     @param drive The drive to grab. This is found in a returned
00768                  burn_drive_info struct.
00769     @param load Nonzero to make the drive attempt to load a disc (close its
00770                 tray door, etc).
00771     @return 1 if it was possible to grab the drive, else 0
00772 */
00773 int burn_drive_grab(struct burn_drive *drive, int load);
00774 
00775 
00776 /** Release a drive. This should not be done until the drive is no longer
00777     busy (see burn_drive_get_status).
00778     Linux: The drive is unlocked afterwards. (O_EXCL , F_SETLK).
00779     @param drive The drive to release.
00780     @param eject Nonzero to make the drive eject the disc in it.
00781 */
00782 void burn_drive_release(struct burn_drive *drive, int eject);
00783 
00784 
00785 /** Returns what kind of disc a drive is holding. This function may need to be
00786     called more than once to get a proper status from it. See burn_disc_status
00787     for details.
00788     @param drive The drive to query for a disc.
00789     @return The status of the drive, or what kind of disc is in it.
00790             Note: BURN_DISC_UNGRABBED indicates wrong API usage
00791 */
00792 enum burn_disc_status burn_disc_get_status(struct burn_drive *drive);
00793 
00794 
00795 /* ts A61020 */
00796 /** WARNING: This revives an old bug-like behavior that might be dangerous.
00797     Sets the drive status to BURN_DISC_BLANK if it is BURN_DISC_UNREADY
00798     or BURN_DISC_UNSUITABLE. Thus marking media as writable which actually
00799     failed to declare themselves either blank or (partially) filled.
00800     @return 1 drive status has been set , 0 = unsuitable drive status
00801 */
00802 int burn_disc_pretend_blank(struct burn_drive *drive);
00803 
00804 
00805 /* ts A61106 */
00806 /** WARNING: This overrides the safety measures against unsuitable media.
00807     Sets the drive status to BURN_DISC_FULL if it is BURN_DISC_UNREADY
00808     or BURN_DISC_UNSUITABLE. Thus marking media as blankable which actually
00809     failed to declare themselves either blank or (partially) filled.
00810 */
00811 int burn_disc_pretend_full(struct burn_drive *drive);
00812 
00813 
00814 /* ts A61021 */
00815 /** Reads ATIP information from inserted media. To be obtained via
00816     burn_drive_get_write_speed(), burn_drive_get_min_write_speed(),
00817     burn_drive_get_start_end_lba(). The drive must be grabbed for this call.
00818     @param drive The drive to query.
00819     @return 1=sucess, 0=no valid ATIP info read, -1 severe error
00820 */
00821 int burn_disc_read_atip(struct burn_drive *drive);
00822 
00823 
00824 /* ts A61020 */
00825 /** Returns start and end lba of the media which is currently inserted
00826     in the given drive. The drive has to be grabbed to have hope for reply.
00827     Shortcomming (not a feature): unless burn_disc_read_atip() was called 
00828     only blank media will return valid info.
00829     @param drive The drive to query.
00830     @param start_lba Returns the start lba value
00831     @param end_lba Returns the end lba value
00832     @param flag Bitfield for control purposes (unused yet, submit 0)
00833     @return 1 if lba values are valid , 0 if invalid
00834 */
00835 int burn_drive_get_start_end_lba(struct burn_drive *drive,
00836                                  int *start_lba, int *end_lba, int flag);
00837 
00838 /* ts A61110 */
00839 /** Read start lba and Next Writeable Address of a track from media.
00840     Usually a track lba is obtained from the result of burn_track_get_entry().
00841     This call retrieves an updated lba, eventual nwa, and can address the
00842     invisible track to come.
00843     The drive must be grabbed for this call. One may not issue this call
00844     during ongoing burn_disc_write() or burn_disc_erase().
00845     @param d The drive to query.
00846     @param o If not NULL: write parameters to be set on drive before query
00847     @param trackno 0=next track to come, >0 number of existing track
00848     @param lba return value: start lba
00849     @param nwa return value: Next Writeable Address
00850     @return 1=nwa is valid , 0=nwa is not valid , -1=error
00851 */
00852 int burn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o,
00853                 int trackno, int *lba, int *nwa);
00854 
00855 /* ts A70131 */
00856 /** Read start lba of the first track in the last complete session.
00857     This is the first parameter of mkisofs option -C. The second parameter
00858     is nwa as obtained by burn_disc_track_lba_nwa() with trackno 0.
00859     @param d The drive to query.
00860     @param start_lba returns the start address of that track
00861     @return <= 0 : failure, 1 = ok 
00862 */
00863 int burn_disc_get_msc1(struct burn_drive *d, int *start_lba);
00864 
00865 
00866 /* ts A70213 */
00867 /** Return the best possible estimation of the currently available capacity of
00868     the media. This might depend on particular write option settings. For
00869     inquiring the space with such a set of options, the drive has to be
00870     grabbed and BURN_DRIVE_IDLE. If not, then one will only get a canned value
00871     from the most recent automatic inquiry (e.g. during last drive grabbing).
00872     An eventual start address from burn_write_opts_set_start_byte() will be
00873     subtracted from the obtained capacity estimation. Negative results get
00874     defaulted to 0.
00875     @param d The drive to query.
00876     @param o If not NULL: write parameters to be set on drive before query
00877     @return number of most probably available free bytes
00878 */
00879 off_t burn_disc_available_space(struct burn_drive *d,
00880                                 struct burn_write_opts *o);
00881 
00882 
00883 /* ts A61202 */
00884 /** Tells the MMC Profile identifier of the loaded media. The drive must be
00885     grabbed in order to get a non-zero result.
00886     libburn currently writes only to profiles 0x09 "CD-R", 0x0a "CD-RW",
00887     0x11 "DVD-R", 0x12 "DVD-RAM", 0x13 "DVD-RW restricted overwrite",
00888     0x14 "DVD-RW Sequential Recording" or 0x1a "DVD+RW".
00889     If enabled by burn_allow_untested_profiles() it also writes to profile
00890     0x15 "DVD-R/DL Sequential Recording".
00891     @param d The drive where the media is inserted.
00892     @param pno Profile Number as of mmc5r03c.pdf, table 89
00893     @param name Profile Name (e.g "CD-RW", unknown profiles have empty name)
00894     @return 1 profile is valid, 0 no profile info available 
00895 */
00896 int burn_disc_get_profile(struct burn_drive *d, int *pno, char name[80]);
00897 
00898 /** Tells whether a disc can be erased or not
00899     @return Non-zero means erasable
00900 */
00901 int burn_disc_erasable(struct burn_drive *d);
00902 
00903 /** Returns the progress and status of a drive.
00904     @param drive The drive to query busy state for.
00905     @param p Returns the progress of the operation, NULL if you don't care
00906     @return the current status of the drive. See also burn_drive_status.
00907 */
00908 enum burn_drive_status burn_drive_get_status(struct burn_drive *drive,
00909                          struct burn_progress *p);
00910 
00911 /** Creates a write_opts struct for burning to the specified drive
00912     must be freed with burn_write_opts_free
00913     @param drive The drive to write with
00914     @return The write_opts, NULL on error
00915 */
00916 struct burn_write_opts *burn_write_opts_new(struct burn_drive *drive);
00917 
00918 /** Frees a write_opts struct created with burn_write_opts_new
00919     @param opts write_opts to free
00920 */
00921 void burn_write_opts_free(struct burn_write_opts *opts);
00922 
00923 /** Creates a read_opts struct for reading from the specified drive
00924     must be freed with burn_read_opts_free
00925     @param drive The drive to read from
00926     @return The read_opts
00927 */
00928 struct burn_read_opts *burn_read_opts_new(struct burn_drive *drive);
00929 
00930 /** Frees a read_opts struct created with burn_read_opts_new
00931     @param opts write_opts to free
00932 */
00933 void burn_read_opts_free(struct burn_read_opts *opts);
00934 
00935 /** Erase a disc in the drive. The drive must be grabbed successfully BEFORE
00936     calling this functions. Always ensure that the drive reports a status of
00937     BURN_DISC_FULL before calling this function. An erase operation is not
00938     cancellable, as control of the operation is passed wholly to the drive and
00939     there is no way to interrupt it safely.
00940     @param drive The drive with which to erase a disc.
00941     @param fast Nonzero to do a fast erase, where only the disc's headers are
00942                 erased; zero to erase the entire disc.
00943                 With DVD-RW, fast blanking yields media capable only of DAO.
00944 */
00945 void burn_disc_erase(struct burn_drive *drive, int fast);
00946 
00947 
00948 /* ts A70101 - A70112 */
00949 /** Format media for use with libburn. This currently applies to DVD-RW
00950     in state "Sequential Recording" (profile 0014h) which get formatted to
00951     state "Restricted Overwrite" (profile 0013h). DVD+RW can be "de-iced"
00952     by setting bit2 of flag. Other media cannot be formatted yet. 
00953     @param drive The drive with the disc to format.
00954     @param size The size in bytes to be used with the format command. It should
00955                 be divisible by 32*1024. The effect of this parameter may
00956                 depend on the media profile.
00957     @param flag Bitfield for control purposes:
00958                 bit0= after formatting, write the given number of zero-bytes
00959                       to the media and eventually perform preliminary closing.
00960                 bit1= insist in size 0 even if there is a better default known
00961                 bit2= format to maximum available size
00962                 bit3= -reserved-
00963                 bit4= enforce re-format of (partly) formatted media
00964                 bit7= MMC expert application mode (else libburn tries to
00965                       choose a suitable format type):
00966                       bit8 to bit15 contain the index of the format to use. See
00967                       burn_disc_get_formats(), burn_disc_get_format_descr().
00968                       Acceptable types are: 0x00, 0x10, 0x11, 0x13, 0x15, 0x26.
00969                       If bit7 is set, bit4 is set automatically.
00970 */
00971 void burn_disc_format(struct burn_drive *drive, off_t size, int flag);
00972 
00973 
00974 /* ts A70112 */
00975 /** Possible formatting status values */
00976 #define BURN_FORMAT_IS_UNFORMATTED 1
00977 #define BURN_FORMAT_IS_FORMATTED   2
00978 #define BURN_FORMAT_IS_UNKNOWN     3
00979 
00980 /** Inquire the formatting status, the associated sizes and the number of
00981     available formats.  The info is media specific and stems from MMC command
00982     23h READ FORMAT CAPACITY. See mmc5r03c.pdf 6.24 for background details.
00983     Media type can be determined via burn_disc_get_profile().
00984     @param drive The drive with the disc to format.
00985     @param status The current formatting status of the inserted media.
00986                   See BURN_FORMAT_IS_* macros. Note: "unknown" is the
00987                   legal status for quick formatted, yet unwritten DVD-RW.
00988     @param size The size in bytes associated with status.
00989                 unformatted: the maximum achievable size of the media
00990                 formatted:   the currently formatted capacity
00991                 unknown:     maximum capacity of drive or of media
00992     @param bl_sas Additional info "Block Length/Spare Area Size".
00993                   Expected to be constantly 2048 for non-BD media.
00994     @param num_formats The number of available formats. To be used with
00995                        burn_disc_get_format_descr() to obtain such a format
00996                        and eventually with burn_disc_format() to select one.
00997     @return 1 reply is valid , <=0 failure
00998 */
00999 int burn_disc_get_formats(struct burn_drive *drive, int *status, off_t *size,
01000                 unsigned *bl_sas, int *num_formats);
01001 
01002 /** Inquire parameters of an available media format.
01003     @param drive The drive with the disc to format.
01004     @param index The index of the format item. Beginning with 0 up to reply
01005                  parameter from burn_disc_get_formats() : num_formats - 1
01006     @param type  The format type.  See mmc5r03c.pdf, 6.5, 04h FORMAT UNIT.
01007                  0x00=full, 0x10=CD-RW/DVD-RW full, 0x11=CD-RW/DVD-RW grow,
01008                  0x15=DVD-RW quick, 0x13=DVD-RW quick grow,
01009                  0x26=DVD+RW background
01010     @param size  The maximum size in bytes achievable with this format.
01011     @param tdp   Type Dependent Parameter. See mmc5r03c.pdf.
01012     @return 1 reply is valid , <=0 failure
01013 */
01014 int burn_disc_get_format_descr(struct burn_drive *drive, int index,
01015                 int *type, off_t *size, unsigned *tdp);
01016 
01017 
01018 
01019 /* ts A61109 : this was and is defunct */
01020 /** Read a disc from the drive and write it to an fd pair. The drive must be
01021     grabbed successfully BEFORE calling this function. Always ensure that the
01022     drive reports a status of BURN_DISC_FULL before calling this function.
01023     @param drive The drive from which to read a disc.
01024     @param o The options for the read operation.
01025 */
01026 void burn_disc_read(struct burn_drive *drive, const struct burn_read_opts *o);
01027 
01028 
01029 
01030 /* ts A70222 */
01031 /** The length of a rejection reasons string for burn_precheck_write() and
01032     burn_write_opts_auto_write_type() .
01033 */
01034 #define BURN_REASONS_LEN 4096
01035 
01036 
01037 /* ts A70219 */
01038 /** Examines a completed setup for burn_disc_write() wether it is permissible
01039     with drive and media. This function is called by burn_disc_write() but
01040     an application might be interested in this check in advance.
01041     @param o The options for the writing operation.
01042     @param disc The descrition of the disc to be created
01043     @param reasons Eventually returns a list of rejection reason statements
01044     @param silent 1= do not issue error messages , 0= report problems
01045     @return 1 ok, -1= no recordable media detected, 0= other failure
01046 */
01047 int burn_precheck_write(struct burn_write_opts *o, struct burn_disc *disc,
01048                         char reasons[BURN_REASONS_LEN], int silent);
01049 
01050 /* <<< enabling switch for internal usage and trust in this function */
01051 #define Libburn_precheck_write_ruleS 1
01052 
01053 
01054 /** Write a disc in the drive. The drive must be grabbed successfully before
01055     calling this function. Always ensure that the drive reports a status of
01056     BURN_DISC_BLANK ot BURN_DISC_APPENDABLE before calling this function.
01057     Note: write_type BURN_WRITE_SAO is currently not capable of writing a mix
01058     of data and audio tracks. You must use BURN_WRITE_TAO for such sessions.
01059     To be set by burn_write_opts_set_write_type(). 
01060     @param o The options for the writing operation.
01061     @param disc The struct burn_disc * that described the disc to be created
01062 */
01063 void burn_disc_write(struct burn_write_opts *o, struct burn_disc *disc);
01064 
01065 /** Cancel an operation on a drive.
01066     This will only work when the drive's busy state is BURN_DRIVE_READING or
01067     BURN_DRIVE_WRITING.
01068     @param drive The drive on which to cancel the current operation.
01069 */
01070 void burn_drive_cancel(struct burn_drive *drive);
01071 
01072 
01073 /* ts A61223 */
01074 /** Inquire wether the most recent write run was successful. Reasons for
01075     non-success may be: rejection of burn parameters, abort during fatal errors
01076     during write, a call to burn_drive_cancel() by the application thread.
01077     @param d The drive to inquire.
01078     @return 1=burn seems to have went well, 0=burn failed 
01079 */
01080 int burn_drive_wrote_well(struct burn_drive *d);
01081 
01082 
01083 /** Convert a minute-second-frame (MSF) value to sector count
01084     @param m Minute component
01085     @param s Second component
01086     @param f Frame component
01087     @return The sector count
01088 */
01089 int burn_msf_to_sectors(int m, int s, int f);
01090 
01091 /** Convert a sector count to minute-second-frame (MSF)
01092     @param sectors The sector count
01093     @param m Returns the minute component
01094     @param s Returns the second component
01095     @param f Returns the frame component
01096 */
01097 void burn_sectors_to_msf(int sectors, int *m, int *s, int *f);
01098 
01099 /** Convert a minute-second-frame (MSF) value to an lba
01100     @param m Minute component
01101     @param s Second component
01102     @param f Frame component
01103     @return The lba
01104 */
01105 int burn_msf_to_lba(int m, int s, int f);
01106 
01107 /** Convert an lba to minute-second-frame (MSF)
01108     @param lba The lba
01109     @param m Returns the minute component
01110     @param s Returns the second component
01111     @param f Returns the frame component
01112 */
01113 void burn_lba_to_msf(int lba, int *m, int *s, int *f);
01114 
01115 /** Create a new disc */
01116 struct burn_disc *burn_disc_create(void);
01117 
01118 /** Delete disc and decrease the reference count on all its sessions
01119     @param d The disc to be freed
01120 */
01121 void burn_disc_free(struct burn_disc *d);
01122 
01123 /** Create a new session */
01124 struct burn_session *burn_session_create(void);
01125 
01126 /** Free a session (and decrease reference count on all tracks inside)
01127     @param s Session to be freed
01128 */
01129 void burn_session_free(struct burn_session *s);
01130 
01131 /** Add a session to a disc at a specific position, increasing the 
01132     sessions's reference count.
01133     @param d Disc to add the session to
01134     @param s Session to add to the disc
01135     @param pos position to add at (BURN_POS_END is "at the end")
01136     @return 0 for failure, 1 for success
01137 */
01138 int burn_disc_add_session(struct burn_disc *d, struct burn_session *s,
01139               unsigned int pos);
01140 
01141 /** Remove a session from a disc
01142     @param d Disc to remove session from
01143     @param s Session pointer to find and remove
01144 */
01145 int burn_disc_remove_session(struct burn_disc *d, struct burn_session *s);
01146 
01147 
01148 /** Create a track (for TAO recording, or to put in a session) */
01149 struct burn_track *burn_track_create(void);
01150 
01151 /** Free a track
01152     @param t Track to free
01153 */
01154 void burn_track_free(struct burn_track *t);
01155 
01156 /** Add a track to a session at specified position
01157     @param s Session to add to
01158     @param t Track to insert in session
01159     @param pos position to add at (BURN_POS_END is "at the end")
01160     @return 0 for failure, 1 for success
01161 */
01162 int burn_session_add_track(struct burn_session *s, struct burn_track *t,
01163                unsigned int pos);
01164 
01165 /** Remove a track from a session
01166     @param s Session to remove track from
01167     @param t Track pointer to find and remove
01168     @return 0 for failure, 1 for success
01169 */
01170 int burn_session_remove_track(struct burn_session *s, struct burn_track *t);
01171 
01172 
01173 /** Define the data in a track
01174     @param t the track to define
01175     @param offset The lib will write this many 0s before start of data
01176     @param tail The number of extra 0s to write after data
01177     @param pad 1 means the lib should pad the last sector with 0s if the
01178            track isn't exactly sector sized.  (otherwise the lib will
01179            begin reading from the next track)
01180     @param mode data format (bitfield)
01181 */
01182 void burn_track_define_data(struct burn_track *t, int offset, int tail,
01183                 int pad, int mode);
01184 
01185 
01186 /* ts A61024 */
01187 /** Define wether a track shall swap bytes of its input stream.
01188     @param t The track to change
01189     @param swap_source_bytes 0=do not swap, 1=swap byte pairs
01190     @return 1=success , 0=unacceptable value
01191 */
01192 int burn_track_set_byte_swap(struct burn_track *t, int swap_source_bytes);
01193 
01194 
01195 /** Set the ISRC details for a track
01196     @param t The track to change
01197     @param country the 2 char country code. Each character must be
01198            only numbers or letters.
01199     @param owner 3 char owner code. Each character must be only numbers
01200            or letters.
01201     @param year 2 digit year. A number in 0-99 (Yep, not Y2K friendly).
01202     @param serial 5 digit serial number. A number in 0-99999.
01203 */
01204 void burn_track_set_isrc(struct burn_track *t, char *country, char *owner,
01205              unsigned char year, unsigned int serial);
01206 
01207 /** Disable ISRC parameters for a track
01208     @param t The track to change
01209 */
01210 void burn_track_clear_isrc(struct burn_track *t);
01211 
01212 /** Hide the first track in the "pre gap" of the disc
01213     @param s session to change
01214     @param onoff 1 to enable hiding, 0 to disable
01215 */
01216 void burn_session_hide_first_track(struct burn_session *s, int onoff);
01217 
01218 /** Get the drive's disc struct - free when done
01219     @param d drive to query
01220     @return the disc struct or NULL on failure
01221 */
01222 struct burn_disc *burn_drive_get_disc(struct burn_drive *d);
01223 
01224 /** Set the track's data source
01225     @param t The track to set the data source for
01226     @param s The data source to use for the contents of the track
01227     @return An error code stating if the source is ready for use for
01228             writing the track, or if an error occured
01229     
01230 */
01231 enum burn_source_status burn_track_set_source(struct burn_track *t,
01232                           struct burn_source *s);
01233 
01234 
01235 /* ts A70218 */
01236 /** Set a default track size to be used only if the track turns out to be of
01237     unpredictable length and if the effective write type demands a fixed size.
01238     This can be useful to enable write types CD SAO or DVD DAO together with
01239     a track source like stdin. If the track source delivers fewer bytes than
01240     announced then the track will be padded up with zeros.
01241     @param t The track to change
01242     @param size The size to set
01243     @return 0=failure 1=sucess
01244 */
01245 int burn_track_set_default_size(struct burn_track *t, off_t size);
01246 
01247 /** Free a burn_source (decrease its refcount and maybe free it)
01248     @param s Source to free
01249 */
01250 void burn_source_free(struct burn_source *s);
01251 
01252 /** Creates a data source for an image file (and maybe subcode file) */
01253 struct burn_source *burn_file_source_new(const char *path,
01254                      const char *subpath);
01255 
01256 /** Creates a data source for an image file (a track) from an open
01257     readable filedescriptor, an eventually open readable subcodes file
01258     descriptor and eventually a fixed size in bytes.
01259     @param datafd The source of data.
01260     @param subfd The eventual source for subcodes. Not used if -1.
01261     @param size The eventual fixed size of eventually both fds. 
01262                 If this value is 0, the size will be determined from datafd.
01263 */
01264 struct burn_source *burn_fd_source_new(int datafd, int subfd, off_t size);
01265 
01266 
01267 /* ts A70328 */
01268 /** Sets a fixed track size after the data source object has already been
01269     created.
01270     @param t The track to poperate on
01271     @param size the number of bytes to use as track size
01272     @return <=0 indicates failure , >0 success
01273 */
01274 int burn_track_set_size(struct burn_track *t, off_t size);
01275 
01276 
01277 /** Tells how long a track will be on disc
01278     >>> NOTE: Not reliable with tracks of undefined length
01279 */
01280 int burn_track_get_sectors(struct burn_track *);
01281 
01282 
01283 /* ts A61101 */
01284 /** Tells how many source bytes have been read and how many data bytes have
01285     been written by the track during burn */
01286 int burn_track_get_counters(struct burn_track *t, 
01287                             off_t *read_bytes, off_t *written_bytes);
01288 
01289 
01290 /** Sets drive read and write speed
01291     @param d The drive to set speed for
01292     @param read Read speed in k/s (0 is max)
01293     @param write Write speed in k/s (0 is max)
01294 */
01295 void burn_drive_set_speed(struct burn_drive *d, int read, int write);
01296 
01297 /* these are for my debugging, they will disappear */
01298 void burn_structure_print_disc(struct burn_disc *d);
01299 void burn_structure_print_session(struct burn_session *s);
01300 void burn_structure_print_track(struct burn_track *t);
01301 
01302 /** Sets the write type for the write_opts struct.
01303     Note: write_type BURN_WRITE_SAO is currently not capable of writing a mix
01304     of data and audio tracks. You must use BURN_WRITE_TAO for such sessions.
01305     @param opts The write opts to change
01306     @param write_type The write type to use
01307     @param block_type The block type to use
01308     @return Returns 1 on success and 0 on failure.
01309 */
01310 int burn_write_opts_set_write_type(struct burn_write_opts *opts,
01311                    enum burn_write_types write_type,
01312                    int block_type);
01313 
01314 
01315 /* ts A70207 */
01316 /** As an alternative to burn_write_opts_set_write_type() this function tries
01317     to find a suitable write type and block type for a given write job
01318     described by opts and disc. To be used after all other setups have been
01319     made, i.e. immediately before burn_disc_write().
01320     @param opts The nearly complete write opts to change
01321     @param disc The already composed session and track model
01322     @param reasons This text string collects reasons for decision resp. failure
01323     @param flag Bitfield for control purposes:
01324                 bit0= do not choose type but check the one that is already set
01325                 bit1= do not issue error messages via burn_msgs queue
01326                       (is automatically set with bit0)
01327     @return Chosen write type. BURN_WRITE_NONE on failure.
01328 */
01329 enum burn_write_types burn_write_opts_auto_write_type(
01330           struct burn_write_opts *opts, struct burn_disc *disc,
01331           char reasons[BURN_REASONS_LEN], int flag);
01332 
01333 
01334 /** Supplies toc entries for writing - not normally required for cd mastering
01335     @param opts The write opts to change
01336     @param count The number of entries
01337     @param toc_entries
01338 */
01339 void burn_write_opts_set_toc_entries(struct burn_write_opts *opts,
01340                      int count,
01341                      struct burn_toc_entry *toc_entries);
01342 
01343 /** Sets the session format for a disc
01344     @param opts The write opts to change
01345     @param format The session format to set
01346 */
01347 void burn_write_opts_set_format(struct burn_write_opts *opts, int format);
01348 
01349 /** Sets the simulate value for the write_opts struct
01350     @param opts The write opts to change
01351     @param sim If non-zero, the drive will perform a simulation instead of a burn
01352     @return Returns 1 on success and 0 on failure.
01353 */
01354 int  burn_write_opts_set_simulate(struct burn_write_opts *opts, int sim);
01355 
01356 /** Controls buffer underrun prevention
01357     @param opts The write opts to change
01358     @param underrun_proof if non-zero, buffer underrun protection is enabled
01359     @return Returns 1 on success and 0 on failure.
01360 */
01361 int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts,
01362                        int underrun_proof);
01363 
01364 /** Sets whether to use opc or not with the write_opts struct
01365     @param opts The write opts to change
01366     @param opc If non-zero, optical power calibration will be performed at
01367                start of burn
01368      
01369 */
01370 void burn_write_opts_set_perform_opc(struct burn_write_opts *opts, int opc);
01371 
01372 void burn_write_opts_set_has_mediacatalog(struct burn_write_opts *opts, int has_mediacatalog);
01373 
01374 void burn_write_opts_set_mediacatalog(struct burn_write_opts *opts, unsigned char mediacatalog[13]);
01375 
01376 
01377 /* ts A61106 */
01378 /** Sets the multi flag which eventually marks the emerging session as not
01379     being the last one and thus creating a BURN_DISC_APPENDABLE media.
01380     @param multi 1=media will be appendable, 0=media will be closed (default) 
01381 */
01382 void burn_write_opts_set_multi(struct burn_write_opts *opts, int multi);
01383 
01384 
01385 /* ts A61222 */
01386 /** Sets a start address for writing to media and write modes which allow to
01387     choose this address at all (DVD+RW, DVD-RAM, formatted DVD-RW only for
01388     now). The address is given in bytes. If it is not -1 then a write run
01389     will fail if choice of start address is not supported or if the block
01390     alignment of the address is not suitable for media and write mode.
01391     (Alignment to 32 kB blocks is advised with DVD media.)
01392     @param opts The write opts to change
01393     @param value The address in bytes (-1 = start at default address)
01394 */
01395 void burn_write_opts_set_start_byte(struct burn_write_opts *opts, off_t value);
01396 
01397 
01398 /* ts A70213 */
01399 /** Caution: still immature and likely to change. Problems arose with
01400     sequential DVD-RW on one drive.
01401 
01402     Controls wether the whole available space of the media shall be filled up
01403     by the last track of the last session.
01404     @param opts The write opts to change
01405     @param fill_up_media If 1 : fill up by last track, if 0 = do not fill up
01406 */
01407 void burn_write_opts_set_fillup(struct burn_write_opts *opts,
01408                                 int fill_up_media);
01409 
01410 
01411 /* ts A70303 */
01412 /** Eventually makes libburn ignore the failure of some conformance checks:
01413     - the check wether CD write+block type is supported by the drive
01414     @param opts The write opts to change
01415     @param use_force 1=ignore above checks, 0=refuse work on failed check
01416 */
01417 void burn_write_opts_set_force(struct burn_write_opts *opts, int use_force);
01418 
01419 
01420 /** Sets whether to read in raw mode or not
01421     @param opts The read opts to change
01422     @param raw_mode If non-zero, reading will be done in raw mode, so that everything in the data tracks on the
01423             disc is read, including headers.
01424 */
01425 void burn_read_opts_set_raw(struct burn_read_opts *opts, int raw_mode);
01426 
01427 /** Sets whether to report c2 errors or not 
01428     @param opts The read opts to change
01429     @param c2errors If non-zero, report c2 errors.
01430 */
01431 void burn_read_opts_set_c2errors(struct burn_read_opts *opts, int c2errors);
01432 
01433 /** Sets whether to read subcodes from audio tracks or not
01434     @param opts The read opts to change
01435     @param subcodes_audio If non-zero, read subcodes from audio tracks on the disc.
01436 */
01437 void burn_read_opts_read_subcodes_audio(struct burn_read_opts *opts,
01438                     int subcodes_audio);
01439 
01440 /** Sets whether to read subcodes from data tracks or not 
01441     @param opts The read opts to change
01442     @param subcodes_data If non-zero, read subcodes from data tracks on the disc.
01443 */
01444 void burn_read_opts_read_subcodes_data(struct burn_read_opts *opts,
01445                        int subcodes_data);
01446 
01447 /** Sets whether to recover errors if possible
01448     @param opts The read opts to change
01449     @param hardware_error_recovery If non-zero, attempt to recover errors if possible.
01450 */
01451 void burn_read_opts_set_hardware_error_recovery(struct burn_read_opts *opts,
01452                         int hardware_error_recovery);
01453 
01454 /** Sets whether to report recovered errors or not
01455     @param opts The read opts to change
01456     @param report_recovered_errors If non-zero, recovered errors will be reported.
01457 */
01458 void burn_read_opts_report_recovered_errors(struct burn_read_opts *opts,
01459                         int report_recovered_errors);
01460 
01461 /** Sets whether blocks with unrecoverable errors should be read or not
01462     @param opts The read opts to change
01463     @param transfer_damaged_blocks If non-zero, blocks with unrecoverable errors will still be read.
01464 */
01465 void burn_read_opts_transfer_damaged_blocks(struct burn_read_opts *opts,
01466                         int transfer_damaged_blocks);
01467 
01468 /** Sets the number of retries to attempt when trying to correct an error
01469     @param opts The read opts to change
01470     @param hardware_error_retries The number of retries to attempt when correcting an error.
01471 */
01472 void burn_read_opts_set_hardware_error_retries(struct burn_read_opts *opts,
01473                            unsigned char hardware_error_retries);
01474 
01475 /** Gets the maximum write speed for a drive and eventually loaded media.
01476     The return value might change by the media type of already loaded media,
01477     again by call burn_drive_grab() and again by call burn_disc_read_atip(). 
01478     @param d Drive to query
01479     @return Maximum write speed in K/s
01480 */
01481 int burn_drive_get_write_speed(struct burn_drive *d);
01482 
01483 
01484 /* ts A61021 */
01485 /** Gets the minimum write speed for a drive and eventually loaded media.
01486     The return value might change by the media type of already loaded media, 
01487     again by call burn_drive_grab() and again by call burn_disc_read_atip().
01488     @param d Drive to query
01489     @return Minimum write speed in K/s
01490 */
01491 int burn_drive_get_min_write_speed(struct burn_drive *d);
01492 
01493 
01494 /** Gets the maximum read speed for a drive
01495     @param d Drive to query
01496     @return Maximum read speed in K/s
01497 */
01498 int burn_drive_get_read_speed(struct burn_drive *d);
01499 
01500 
01501 /* ts A61226 */
01502 /** Obtain a copy of the current speed descriptor list. The drive's list gets
01503     updated on various occasions such as burn_drive_grab() but the copy
01504     obtained here stays untouched. It has to be disposed via
01505     burn_drive_free_speedlist() when it is not longer needed. Speeds
01506     may appear several times in the list. The list content depends much on
01507     drive and media type. It seems that .source == 1 applies mostly to CD media
01508     whereas .source == 2 applies to any media.
01509     @param d Drive to query
01510     @param speed_list The copy. If empty, *speed_list gets returned as NULL.
01511     @return 1=success , 0=list empty , <0 severe error
01512 */
01513 int burn_drive_get_speedlist(struct burn_drive *d,
01514                              struct burn_speed_descriptor **speed_list);
01515 
01516 /* ts A61226 */
01517 /** Dispose a speed descriptor list copy which was obtained by
01518     burn_drive_get_speedlist().
01519     @param speed_list The list copy. *speed_list gets set to NULL.
01520     @return 1=list disposed , 0= *speedlist was already NULL
01521 */
01522 int burn_drive_free_speedlist(struct burn_speed_descriptor **speed_list);
01523 
01524 
01525 /* ts A70203 */
01526 /** The reply structure for burn_disc_get_multi_caps()
01527 */
01528 struct burn_multi_caps {
01529 
01530     /* Multi-session capability allows to keep the media appendable after
01531        writing a session. It also guarantees that the drive will be able
01532        to predict and use the appropriate Next Writeable Address to place
01533        the next session on the media without overwriting the existing ones.
01534        It does not guarantee that the selected write type is able to do
01535        an appending session after the next session. (E.g. CD SAO is capable
01536        of multi-session by keeping a disc appendable. But .might_do_sao
01537        will be 0 afterwards, when checking the appendable media.)
01538         1= media may be kept appendable by burn_write_opts_set_multi(o,1)
01539         0= media will not be appendable
01540     */
01541     int multi_session;
01542 
01543     /* Multi-track capability allows to write more than one track source
01544        during a single session. The written tracks can later be found in
01545        libburn's TOC model with their start addresses and sizes.
01546         1= multiple tracks per session are allowed
01547         0= only one track per session allowed
01548     */
01549     int multi_track;
01550 
01551     /* Start-address capability allows to set a non-zero address with
01552        burn_write_opts_set_start_byte(). Eventually this has to respect
01553        .start_alignment and .start_range_low, .start_range_high in this
01554        structure.
01555         1= non-zero start address is allowed
01556             0= only start address 0 is allowed (to depict the drive's own idea
01557                about the appropriate write start)
01558     */
01559     int start_adr;
01560 
01561     /** The alignment for start addresses.
01562         ( start_address % start_alignment ) must be 0.
01563     */
01564     off_t start_alignment;
01565 
01566     /** The lowest permissible start address.
01567     */
01568     off_t start_range_low;
01569 
01570     /** The highest addressable start address.
01571     */
01572     off_t start_range_high;
01573 
01574     /** Potential availability of write modes
01575          4= needs no size prediction, not to be chosen automatically
01576          3= needs size prediction, not to be chosen automatically
01577          2= available, no size prediction necessary
01578          1= available, needs exact size prediction
01579          0= not available
01580         With CD media (profiles 0x09 and 0x0a) check also the elements
01581         *_block_types of the according write mode.
01582     */
01583     int might_do_tao;
01584     int might_do_sao;
01585     int might_do_raw;
01586 
01587     /** Generally advised write mode.
01588         Not necessarily the one chosen by burn_write_opts_auto_write_type()
01589         because the burn_disc structure might impose particular demands.
01590     */
01591     enum burn_write_types advised_write_mode;
01592 
01593     /** Write mode as given by parameter wt of burn_disc_get_multi_caps().
01594     */
01595     enum burn_write_types selected_write_mode;
01596 
01597     /** Profile number which was current when the reply was generated */
01598     int current_profile;
01599 
01600     /** Wether the current profile indicates CD media. 1=yes, 0=no */
01601     int current_is_cd_profile;
01602 };
01603 
01604 /** Allocates a struct burn_multi_caps (see above) and fills it with values
01605     which are appropriate for the drive and the loaded media. The drive
01606     must be grabbed for this call. The returned structure has to be disposed
01607     via burn_disc_free_multi_caps() when no longer needed.
01608     @param d The drive to inquire
01609     @param wt With BURN_WRITE_NONE the best capabilities of all write modes
01610               get returned. If set to a write mode like BURN_WRITE_SAO the
01611               capabilities with that particular mode are returned and the
01612               return value is 0 if the desired mode is not possible.
01613     @param caps returns the info structure
01614     @param flag Bitfield for control purposes (unused yet, submit 0)
01615     @return < 0 : error , 0 : writing seems impossible , 1 : writing possible 
01616 */
01617 int burn_disc_get_multi_caps(struct burn_drive *d, enum burn_write_types wt,
01618              struct burn_multi_caps **caps, int flag);
01619 
01620 /** Removes from memory a multi session info structure which was returned by
01621     burn_disc_get_multi_caps(). The pointer *caps gets set to NULL.
01622     @param caps the info structure to dispose (note: pointer to pointer)
01623     @return 0 : *caps was already NULL, 1 : memory object was disposed
01624 */
01625 int burn_disc_free_multi_caps(struct burn_multi_caps **caps);
01626 
01627 
01628 /** Gets a copy of the toc_entry structure associated with a track
01629     @param t Track to get the entry from
01630     @param entry Struct for the library to fill out
01631 */
01632 void burn_track_get_entry(struct burn_track *t, struct burn_toc_entry *entry);
01633 
01634 /** Gets a copy of the toc_entry structure associated with a session's lead out
01635     @param s Session to get the entry from
01636     @param entry Struct for the library to fill out
01637 */
01638 void burn_session_get_leadout_entry(struct burn_session *s,
01639                                     struct burn_toc_entry *entry);
01640 
01641 /** Gets an array of all the sessions for the disc
01642     THIS IS NO LONGER VALID AFTER YOU ADD OR REMOVE A SESSION
01643     @param d Disc to get session array for
01644     @param num Returns the number of sessions in the array
01645     @return array of sessions
01646 */
01647 struct burn_session **burn_disc_get_sessions(struct burn_disc *d,
01648                                              int *num);
01649 
01650 int burn_disc_get_sectors(struct burn_disc *d);
01651 
01652 /** Gets an array of all the tracks for a session
01653     THIS IS NO LONGER VALID AFTER YOU ADD OR REMOVE A TRACK
01654     @param s session to get track array for
01655     @param num Returns the number of tracks in the array
01656     @return array of tracks
01657 */
01658 struct burn_track **burn_session_get_tracks(struct burn_session *s,
01659                                             int *num);
01660 
01661 int burn_session_get_sectors(struct burn_session *s);
01662 
01663 /** Gets the mode of a track
01664     @param track the track to query
01665     @return the track's mode
01666 */
01667 int burn_track_get_mode(struct burn_track *track);
01668 
01669 /** Returns whether the first track of a session is hidden in the pregap
01670     @param session the session to query
01671     @return non-zero means the first track is hidden
01672 */
01673 int burn_session_get_hidefirst(struct burn_session *session);
01674 
01675 /** Returns the library's version in its parts
01676     @param major The major version number
01677     @param minor The minor version number
01678     @param micro The micro version number
01679 */
01680 void burn_version(int *major, int *minor, int *micro);
01681 
01682 
01683 /* ts A60924 : ticket 74 */
01684 /** Control queueing and stderr printing of messages from libburn.
01685     Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT",
01686     "NOTE", "UPDATE", "DEBUG", "ALL".
01687     @param queue_severity Gives the minimum limit for messages to be queued.
01688                           Default: "NEVER". If you queue messages then you
01689                           must consume them by burn_msgs_obtain().
01690     @param print_severity Does the same for messages to be printed directly
01691                           to stderr. Default: "FATAL".
01692     @param print_id       A text prefix to be printed before the message.
01693     @return               >0 for success, <=0 for error
01694 
01695 */
01696 int burn_msgs_set_severities(char *queue_severity,
01697                              char *print_severity, char *print_id);
01698 
01699 /* ts A60924 : ticket 74 */
01700 #define BURN_MSGS_MESSAGE_LEN 4096
01701 
01702 /** Obtain the oldest pending libburn message from the queue which has at
01703     least the given minimum_severity. This message and any older message of
01704     lower severity will get discarded from the queue and is then lost forever.
01705     @param minimum_severity  may be one of "NEVER", "FATAL", "SORRY",
01706                       "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL".
01707                       To call with minimum_severity "NEVER" will discard the
01708                       whole queue.
01709     @param error_code Will become a unique error code as liste in
01710                       libburn/libdax_msgs.h
01711     @param msg_text   Must provide at least BURN_MSGS_MESSAGE_LEN bytes.
01712     @param os_errno   Will become the eventual errno related to the message
01713     @param severity   Will become the severity related to the message and
01714                       should provide at least 80 bytes.
01715     @return 1 if a matching item was found, 0 if not, <0 for severe errors
01716 */
01717 int burn_msgs_obtain(char *minimum_severity,
01718                      int *error_code, char msg_text[], int *os_errno,
01719                      char severity[]);
01720 
01721 
01722 /* ts A61002 */
01723 /* The prototype of a handler function suitable for burn_set_abort_handling().
01724    Such a function has to return -2 if it does not want the process to
01725    exit with value 1.
01726 */
01727 typedef int (*burn_abort_handler_t)(void *handle, int signum, int flag);
01728 
01729 /** Control builtin signal handling. See also burn_abort().
01730     @param handle Opaque handle eventually pointing to an application
01731                   provided memory object
01732     @param handler A function to be called on signals. It will get handle as
01733                   argument. It should finally call burn_abort(). See there.
01734     @param mode : 0 call handler(handle, signum, 0) on nearly all signals
01735                   1 enable system default reaction on all signals
01736                   2 try to ignore nearly all signals
01737                  10 like mode 2 but handle SIGABRT like with mode 0
01738     Arguments (text, NULL, 0) activate the builtin abort handler. It will
01739     eventually call burn_abort() and then perform exit(1). If text is not NULL
01740     then it is used as prefix for pacifier messages of burn_abort_pacifier().
01741 */
01742 void burn_set_signal_handling(void *handle, burn_abort_handler_t handler, 
01743                  int mode);
01744 
01745 #ifndef DOXYGEN
01746 
01747 BURN_END_DECLS
01748 
01749 #endif
01750 
01751 #endif /*LIBBURN_H*/

Generated on Sun Jun 10 09:11:50 2007 for libburn by  doxygen 1.5.1