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