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