1 /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */ 2 3 /* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens 4 Copyright (c) 2006 - 2021 Thomas Schmitt <scdbackup@gmx.net> 5 Provided under GPL version 2 or later. 6 7 This is the official API definition of libburn. 8 9 */ 10 /* Important: If you add a public API function then add its name to file 11 libburn/libburn.ver 12 */ 13 14 15 #ifndef LIBBURN_H 16 #define LIBBURN_H 17 18 /* 19 20 Applications must use 64 bit off_t. E.g. by defining 21 #define _LARGEFILE_SOURCE 22 #define _FILE_OFFSET_BITS 64 23 or take special precautions to interface with the library by 64 bit integers 24 where this .h files prescribe off_t. 25 26 To prevent 64 bit file i/o in the library would keep the application from 27 processing tracks of more than 2 GB size. 28 29 */ 30 #include <sys/types.h> 31 32 /* For struct timeval */ 33 #include <sys/time.h> 34 35 #ifndef DOXYGEN 36 37 #if defined(__cplusplus) 38 #define BURN_BEGIN_DECLS \ 39 namespace burn { \ 40 extern "C" { 41 #define BURN_END_DECLS \ 42 } \ 43 } 44 #else 45 #define BURN_BEGIN_DECLS 46 #define BURN_END_DECLS 47 #endif 48 49 BURN_BEGIN_DECLS 50 51 #endif 52 53 /** References a physical drive in the system */ 54 struct burn_drive; 55 56 /** References a whole disc */ 57 struct burn_disc; 58 59 /** References a single session on a disc */ 60 struct burn_session; 61 62 /** References a single track on a disc */ 63 struct burn_track; 64 65 /* ts A61111 */ 66 /** References a set of write parameters */ 67 struct burn_write_opts; 68 69 /** Session format for normal audio or data discs */ 70 #define BURN_CDROM 0 71 /** Session format for obsolete CD-I discs */ 72 #define BURN_CDI 0x10 73 /** Session format for CDROM-XA discs */ 74 #define BURN_CDXA 0x20 75 76 #define BURN_POS_END 100 77 78 /** Mask for mode bits */ 79 #define BURN_MODE_BITS 127 80 81 /** Track mode - mode 0 data 82 0 bytes of user data. it's all 0s. mode 0. get it? HAH 83 */ 84 #define BURN_MODE0 (1 << 0) 85 /** Track mode - mode "raw" - all 2352 bytes supplied by app 86 FOR DATA TRACKS ONLY! 87 */ 88 #define BURN_MODE_RAW (1 << 1) 89 /** Track mode - mode 1 data 90 2048 bytes user data, and all the LEC money can buy 91 */ 92 #define BURN_MODE1 (1 << 2) 93 /** Track mode - mode 2 data 94 defaults to formless, 2336 bytes of user data, unprotected 95 | with a data form if required. 96 */ 97 #define BURN_MODE2 (1 << 3) 98 /** Track mode modifier - Form 1, | with MODE2 for reasonable results 99 2048 bytes of user data, 4 bytes of subheader 100 */ 101 #define BURN_FORM1 (1 << 4) 102 /** Track mode modifier - Form 2, | with MODE2 for reasonable results 103 lots of user data. not much LEC. 104 */ 105 #define BURN_FORM2 (1 << 5) 106 /** Track mode - audio 107 2352 bytes per sector. may be | with 4ch or preemphasis. 108 NOT TO BE CONFUSED WITH BURN_MODE_RAW 109 Audio data must be 44100Hz 16bit stereo with no riff or other header at 110 beginning. Extra header data will cause pops or clicks. Audio data should 111 also be in little-endian byte order. Big-endian audio data causes static. 112 */ 113 #define BURN_AUDIO (1 << 6) 114 /** Track mode modifier - 4 channel audio. */ 115 #define BURN_4CH (1 << 7) 116 /** Track mode modifier - Digital copy permitted, can be set on any track.*/ 117 #define BURN_COPY (1 << 8) 118 /** Track mode modifier - 50/15uS pre-emphasis */ 119 #define BURN_PREEMPHASIS (1 << 9) 120 /** Input mode modifier - subcodes present packed 16 */ 121 #define BURN_SUBCODE_P16 (1 << 10) 122 /** Input mode modifier - subcodes present packed 96 */ 123 #define BURN_SUBCODE_P96 (1 << 11) 124 /** Input mode modifier - subcodes present raw 96 */ 125 #define BURN_SUBCODE_R96 (1 << 12) 126 127 /* ts B11230 */ 128 /** Track mode modifier - Serial Copy Management System, SAO only 129 If this is set and BURN_COPY is not set, then copying the emerging 130 track will be forbidden. 131 @since 1.2.0 132 */ 133 #define BURN_SCMS (1 << 13) 134 135 136 /** Possible disc writing style/modes */ 137 enum burn_write_types 138 { 139 /** Packet writing. 140 currently unsupported, (for DVD Incremental Streaming use TAO) 141 */ 142 BURN_WRITE_PACKET, 143 144 /** With CD: Track At Once recording 145 2s gaps between tracks, no fonky lead-ins 146 147 With sequential DVD-R[W]: Incremental Streaming 148 With DVD+R and BD-R: Track of open size 149 With DVD-RAM, DVD+RW, BD-RE: Random Writeable (used sequentially) 150 With overwritable DVD-RW: Rigid Restricted Overwrite 151 */ 152 BURN_WRITE_TAO, 153 154 /** With CD: Session At Once 155 Block type MUST be BURN_BLOCK_SAO 156 ts A70122: Currently not capable of mixing data and audio tracks. 157 158 With sequential DVD-R[W]: Disc-at-once, DAO 159 Single session, single track, fixed size mandatory, (-dvd-compat) 160 With other DVD or BD media: same as BURN_WRITE_TAO but may demand 161 that track size is known in advance. 162 */ 163 BURN_WRITE_SAO, 164 165 /** With CD: Raw disc at once recording. 166 all subcodes must be provided by lib or user 167 only raw block types are supported 168 With DVD and BD media: not supported. 169 170 ts A90901: This had been disabled because its implementation 171 relied on code from cdrdao which is not understood 172 currently. 173 A burn run will abort with "FATAL" error message 174 if this mode is attempted. 175 @since 0.7.2 176 ts A91016: Re-implemented according to ECMA-130 Annex A and B. 177 Now understood, explained and not stemming from cdrdao. 178 @since 0.7.4 179 */ 180 BURN_WRITE_RAW, 181 182 /** In replies this indicates that not any writing will work. 183 As parameter for inquiries it indicates that no particular write 184 mode shall is specified. 185 Do not use for setting a write mode for burning. It will not work. 186 */ 187 BURN_WRITE_NONE 188 }; 189 190 /** Data format to send to the drive */ 191 enum burn_block_types 192 { 193 /** sync, headers, edc/ecc provided by lib/user */ 194 BURN_BLOCK_RAW0 = 1, 195 /** sync, headers, edc/ecc and p/q subs provided by lib/user */ 196 BURN_BLOCK_RAW16 = 2, 197 /** sync, headers, edc/ecc and packed p-w subs provided by lib/user */ 198 BURN_BLOCK_RAW96P = 4, 199 /** sync, headers, edc/ecc and raw p-w subs provided by lib/user */ 200 BURN_BLOCK_RAW96R = 8, 201 /** only 2048 bytes of user data provided by lib/user */ 202 BURN_BLOCK_MODE1 = 256, 203 /** 2336 bytes of user data provided by lib/user */ 204 BURN_BLOCK_MODE2R = 512, 205 /** 2048 bytes of user data provided by lib/user 206 subheader provided in write parameters 207 are we ever going to support this shit? I vote no. 208 (supposed to be supported on all drives...) 209 */ 210 BURN_BLOCK_MODE2_PATHETIC = 1024, 211 /** 2048 bytes of data + 8 byte subheader provided by lib/user 212 hey, this is also dumb 213 */ 214 BURN_BLOCK_MODE2_LAME = 2048, 215 /** 2324 bytes of data provided by lib/user 216 subheader provided in write parameters 217 no sir, I don't like it. 218 */ 219 BURN_BLOCK_MODE2_OBSCURE = 4096, 220 /** 2332 bytes of data supplied by lib/user 221 8 bytes sub header provided in write parameters 222 this is the second least suck mode2, and is mandatory for 223 all drives to support. 224 */ 225 BURN_BLOCK_MODE2_OK = 8192, 226 /** SAO block sizes are based on cue sheet, so use this. */ 227 BURN_BLOCK_SAO = 16384 228 }; 229 230 /** Possible status of the drive in regard to the disc in it. */ 231 enum burn_disc_status 232 { 233 /** The current status is not yet known */ 234 BURN_DISC_UNREADY, 235 236 /** The drive holds a blank disc. It is ready for writing from scratch. 237 Unused multi-session media: 238 CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, BD-R 239 Blanked multi-session media (i.e. treated by burn_disc_erase()) 240 CD-RW, DVD-RW 241 Overwritable media with or without valid data 242 DVD-RAM, DVD+RW, formatted DVD-RW, BD-RE 243 */ 244 BURN_DISC_BLANK, 245 246 /** There is no disc at all in the drive */ 247 BURN_DISC_EMPTY, 248 249 /** There is an incomplete disc in the drive. It is ready for appending 250 another session. 251 Written but not yet closed multi-session media 252 CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, BD-R 253 */ 254 BURN_DISC_APPENDABLE, 255 256 /** There is a disc with data on it in the drive. It is usable only for 257 reading. 258 Written and closed multi-session media 259 CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, BD-R 260 Read-Only media 261 CD-ROM, DVD-ROM, BD-ROM 262 Note that many DVD-ROM drives report any written media 263 as Read-Only media and not by their real media types. 264 */ 265 BURN_DISC_FULL, 266 267 /* ts A61007 */ 268 /* @since 0.2.4 */ 269 /** The drive was not grabbed when the status was inquired */ 270 BURN_DISC_UNGRABBED, 271 272 /* ts A61020 */ 273 /* @since 0.2.6 */ 274 /** The media seems to be unsuitable for reading and for writing */ 275 BURN_DISC_UNSUITABLE 276 }; 277 278 279 /** Possible data source return values */ 280 enum burn_source_status 281 { 282 /** The source is ok */ 283 BURN_SOURCE_OK, 284 /** The source is at end of file */ 285 BURN_SOURCE_EOF, 286 /** The source is unusable */ 287 BURN_SOURCE_FAILED 288 }; 289 290 291 /** Possible busy states for a drive */ 292 enum burn_drive_status 293 { 294 /** The drive is not in an operation */ 295 BURN_DRIVE_IDLE, 296 /** The library is spawning the processes to handle a pending 297 operation (A read/write/etc is about to start but hasn't quite 298 yet) */ 299 BURN_DRIVE_SPAWNING, 300 /** The drive is reading data from a disc */ 301 BURN_DRIVE_READING, 302 /** The drive is writing data to a disc */ 303 BURN_DRIVE_WRITING, 304 /** The drive is writing Lead-In */ 305 BURN_DRIVE_WRITING_LEADIN, 306 /** The drive is writing Lead-Out */ 307 BURN_DRIVE_WRITING_LEADOUT, 308 /** The drive is erasing a disc */ 309 BURN_DRIVE_ERASING, 310 /** The drive is being grabbed */ 311 BURN_DRIVE_GRABBING, 312 313 /* ts A61102 */ 314 /* @since 0.2.6 */ 315 /** The drive gets written zeroes before the track payload data */ 316 BURN_DRIVE_WRITING_PREGAP, 317 /** The drive is told to close a track (TAO only) */ 318 BURN_DRIVE_CLOSING_TRACK, 319 /** The drive is told to close a session (TAO only) */ 320 BURN_DRIVE_CLOSING_SESSION, 321 322 /* ts A61223 */ 323 /* @since 0.3.0 */ 324 /** The drive is formatting media */ 325 BURN_DRIVE_FORMATTING, 326 327 /* ts A70822 */ 328 /* @since 0.4.0 */ 329 /** The drive is busy in synchronous read (if you see this then it 330 has been interrupted) */ 331 BURN_DRIVE_READING_SYNC, 332 /** The drive is busy in synchronous write (if you see this then it 333 has been interrupted) */ 334 BURN_DRIVE_WRITING_SYNC 335 336 }; 337 338 339 /** Information about a track on a disc - this is from the q sub channel of the 340 lead-in area of a disc. The documentation here is very terse. 341 See a document such as mmc3 for proper information. 342 343 CAUTION : This structure is prone to future extension ! 344 345 Do not restrict your application to unsigned char with any counter like 346 "session", "point", "pmin", ... 347 Do not rely on the current size of a burn_toc_entry. 348 349 */ 350 struct burn_toc_entry 351 { 352 /** Session the track is in */ 353 unsigned char session; 354 /** Type of data. for this struct to be valid, it must be 1 */ 355 unsigned char adr; 356 /** Type of data in the track */ 357 unsigned char control; 358 /** Zero. Always. Really. */ 359 unsigned char tno; 360 /** Track number or special information */ 361 unsigned char point; 362 unsigned char min; 363 unsigned char sec; 364 unsigned char frame; 365 unsigned char zero; 366 /** Track start time minutes for normal tracks */ 367 unsigned char pmin; 368 /** Track start time seconds for normal tracks */ 369 unsigned char psec; 370 /** Track start time frames for normal tracks */ 371 unsigned char pframe; 372 373 /* Indicates whether extension data are valid and eventually override 374 older elements in this structure: 375 bit0= DVD extension is valid @since 0.3.2 376 @since 0.5.2 : DVD extensions are made valid for CD too 377 bit1= LRA extension is valid @since 0.7.2 378 bit2= Track status bits extension is valid @since 1.2.8 379 */ 380 unsigned char extensions_valid; 381 382 /* ts A70201 : DVD extension. extensions_valid:bit0 383 If invalid the members are guaranteed to be 0. */ 384 /* @since 0.3.2 */ 385 /* Tracks and session numbers are 16 bit. Here are the high bytes. */ 386 unsigned char session_msb; 387 unsigned char point_msb; 388 /* pmin, psec, and pframe may be too small if DVD extension is valid */ 389 int start_lba; 390 /* min, sec, and frame may be too small if DVD extension is valid */ 391 int track_blocks; 392 393 /* ts A90909 : LRA extension. extensions_valid:bit1 */ 394 /* @since 0.7.2 */ 395 /* MMC-5 6.27.3.18 : The Last Recorded Address is valid for DVD-R, 396 DVD-R DL when LJRS = 00b, DVD-RW, HD DVD-R, and BD-R. 397 This would mean profiles: 0x11, 0x15, 0x13, 0x14, 0x51, 0x41, 0x42 398 */ 399 int last_recorded_address; 400 401 /* ts B30112 : Track status bits extension. extensions_valid:bit2 */ 402 /* @since 1.2.8 */ 403 /* Names as of READ TRACK INFORMATION, MMC-5 6.27.3 : 404 bit0 - bit3 = Track Mode 405 bit4 = Copy 406 bit5 = Damage 407 bit6 - bit7 = LJRS 408 bit8 - bit11 = Data Mode 409 bit12 = FP 410 bit13 = Packet/Inc 411 bit14 = Blank 412 bit15 = RT 413 bit16 = NWA_V 414 bit17 = LRA_V 415 */ 416 int track_status_bits; 417 418 }; 419 420 421 /** Data source interface for tracks. 422 This allows you to use arbitrary program code as provider of track input 423 data. 424 425 Objects compliant to this interface are either provided by the application 426 or by API calls of libburn: burn_fd_source_new() , burn_file_source_new(), 427 and burn_fifo_source_new(). 428 429 The API calls may use any file object as data source. Consider to feed 430 an eventual custom data stream asynchronously into a pipe(2) and to let 431 libburn handle the rest. 432 In this case the following rule applies: 433 Call burn_source_free() exactly once for every source obtained from 434 libburn API. You MUST NOT otherwise use or manipulate its components. 435 436 In general, burn_source objects can be freed as soon as they are attached 437 to track objects. The track objects will keep them alive and dispose them 438 when they are no longer needed. With a fifo burn_source it makes sense to 439 keep the own reference for inquiring its state while burning is in 440 progress. 441 442 --- 443 444 The following description of burn_source applies only to application 445 implemented burn_source objects. You need not to know it for API provided 446 ones. 447 448 If you really implement an own passive data producer by this interface, 449 then beware: it can do anything and it can spoil everything. 450 451 In this case the functions (*read), (*get_size), (*set_size), (*free_data) 452 MUST be implemented by the application and attached to the object at 453 creation time. 454 Function (*read_sub) is allowed to be NULL or it MUST be implemented and 455 attached. 456 457 burn_source.refcount MUST be handled properly: If not exactly as many 458 references are freed as have been obtained, then either memory leaks or 459 corrupted memory are the consequence. 460 All objects which are referred to by *data must be kept existent until 461 (*free_data) is called via burn_source_free() by the last referer. 462 */ 463 struct burn_source { 464 465 /** Reference count for the data source. MUST be 1 when a new source 466 is created and thus the first reference is handed out. Increment 467 it to take more references for yourself. Use burn_source_free() 468 to destroy your references to it. */ 469 int refcount; 470 471 472 /** Read data from the source. Semantics like with read(2), but MUST 473 either deliver the full buffer as defined by size or MUST deliver 474 EOF (return 0) or failure (return -1) at this call or at the 475 next following call. I.e. the only incomplete buffer may be the 476 last one from that source. 477 libburn will read a single sector by each call to (*read). 478 The size of a sector depends on BURN_MODE_*. The known range is 479 2048 to 2352. 480 481 If this call is reading from a pipe then it will learn 482 about the end of data only when that pipe gets closed on the 483 feeder side. So if the track size is not fixed or if the pipe 484 delivers less than the predicted amount or if the size is not 485 block aligned, then burning will halt until the input process 486 closes the pipe. 487 488 IMPORTANT: 489 If this function pointer is NULL, then the struct burn_source is of 490 version >= 1 and the job of .(*read)() is done by .(*read_xt)(). 491 See below, member .version. 492 */ 493 int (*read)(struct burn_source *, unsigned char *buffer, int size); 494 495 496 /** Read subchannel data from the source (NULL if lib generated) 497 WARNING: This is an obscure feature with CD raw write modes. 498 Unless you checked the libburn code for correctness in that aspect 499 you should not rely on raw writing with own subchannels. 500 ADVICE: Set this pointer to NULL. 501 */ 502 int (*read_sub)(struct burn_source *, unsigned char *buffer, int size); 503 504 505 /** Get the size of the source's data. Return 0 means unpredictable 506 size. If application provided (*get_size) might return 0, then 507 the application MUST provide a fully functional (*set_size). 508 */ 509 off_t (*get_size)(struct burn_source *); 510 511 512 /* ts A70125 : BROKE BINARY BACKWARD COMPATIBILITY AT libburn-0.3.1. */ 513 /* @since 0.3.2 */ 514 /** Program the reply of (*get_size) to a fixed value. It is advised 515 to implement this by a attribute off_t fixed_size; in *data . 516 The read() function does not have to take into respect this fake 517 setting. It is rather a note of libburn to itself. Eventually 518 necessary truncation or padding is done in libburn. Truncation 519 is usually considered a misburn. Padding is considered ok. 520 521 libburn is supposed to work even if (*get_size) ignores the 522 setting by (*set_size). But your application will not be able to 523 enforce fixed track sizes by burn_track_set_size() and possibly 524 even padding might be left out. 525 */ 526 int (*set_size)(struct burn_source *source, off_t size); 527 528 529 /** Clean up the source specific data. This function will be called 530 once by burn_source_free() when the last referer disposes the 531 source. 532 */ 533 void (*free_data)(struct burn_source *); 534 535 536 /** Next source, for when a source runs dry and padding is disabled 537 WARNING: This is an obscure feature. Set to NULL at creation and 538 from then on leave untouched and uninterpreted. 539 */ 540 struct burn_source *next; 541 542 543 /** Source specific data. Here the various source classes express their 544 specific properties and the instance objects store their individual 545 management data. 546 E.g. data could point to a struct like this: 547 struct app_burn_source 548 { 549 struct my_app *app_handle; 550 ... other individual source parameters ... 551 off_t fixed_size; 552 }; 553 554 Function (*free_data) has to be prepared to clean up and free 555 the struct. 556 */ 557 void *data; 558 559 560 /* ts A71222 : Supposed to be binary backwards compatible extension. */ 561 /* @since 0.4.2 */ 562 /** Valid only if above member .(*read)() is NULL. This indicates a 563 version of struct burn_source younger than 0. 564 From then on, member .version tells which further members exist 565 in the memory layout of struct burn_source. libburn will only touch 566 those announced extensions. 567 568 Versions: 569 0 has .(*read)() != NULL, not even .version is present. 570 1 has .version, .(*read_xt)(), .(*cancel)() 571 */ 572 int version; 573 574 /** This substitutes for (*read)() in versions above 0. */ 575 int (*read_xt)(struct burn_source *, unsigned char *buffer, int size); 576 577 /** Informs the burn_source that the consumer of data prematurely 578 ended reading. This call may or may not be issued by libburn 579 before (*free_data)() is called. 580 */ 581 int (*cancel)(struct burn_source *source); 582 }; 583 584 585 /** Information on a drive in the system */ 586 struct burn_drive_info 587 { 588 /** Name of the vendor of the drive */ 589 char vendor[9]; 590 /** Name of the drive */ 591 char product[17]; 592 /** Revision of the drive */ 593 char revision[5]; 594 595 /** Invalid: Was: "Location of the drive in the filesystem." */ 596 /** This string has no meaning any more. Once it stored the drive 597 device file address. Now always use function burn_drive_d_get_adr() 598 to inquire a device file address. ^^^^^ ALWAYS ^^^^^^^*/ 599 char location[17]; 600 601 /* NOTE: The capability to write particular media types is also 602 announced by their profile number being in the list returned 603 by burn_drive_get_all_profile(). This is the only way to 604 inquire types DVD-RW, DVD+R, DVD+R DL, DVD+RW, BD-R, BD-RE. 605 */ 606 /** Can the drive read DVD-RAM discs */ 607 unsigned int read_dvdram:1; 608 /** Can the drive read DVD-R discs */ 609 unsigned int read_dvdr:1; 610 /** Can the drive read DVD-ROM discs */ 611 unsigned int read_dvdrom:1; 612 /** Can the drive read CD-R discs */ 613 unsigned int read_cdr:1; 614 /** Can the drive read CD-RW discs */ 615 unsigned int read_cdrw:1; 616 617 /** Can the drive write DVD-RAM discs */ 618 unsigned int write_dvdram:1; 619 /** Can the drive write DVD-R discs */ 620 unsigned int write_dvdr:1; 621 /** Can the drive write CD-R discs */ 622 unsigned int write_cdr:1; 623 /** Can the drive write CD-RW discs */ 624 unsigned int write_cdrw:1; 625 626 /** Can the drive simulate a write */ 627 unsigned int write_simulate:1; 628 629 /** DEPRECATED: Can the drive report C2 errors */ 630 unsigned int c2_errors:1; 631 632 /** DEPRECATED: The size of the drive's buffer (in kilobytes) */ 633 int buffer_size; 634 635 636 /** 637 * The supported block types in tao mode. 638 * They should be tested with the desired block type. 639 * See also burn_block_types. 640 */ 641 int tao_block_types; 642 /** 643 * The supported block types in sao mode. 644 * They should be tested with the desired block type. 645 * See also burn_block_types. 646 */ 647 int sao_block_types; 648 /** 649 * The supported block types in raw mode. 650 * They should be tested with the desired block type. 651 * See also burn_block_types. 652 */ 653 int raw_block_types; 654 /** 655 * The supported block types in packet mode. 656 * They should be tested with the desired block type. 657 * See also burn_block_types. 658 */ 659 int packet_block_types; 660 661 /** The value by which this drive can be indexed when using functions 662 in the library. This is the value to pass to all libbburn functions 663 that operate on a drive. */ 664 struct burn_drive *drive; 665 }; 666 667 668 /** Operation progress report. All values are 0 based indices. 669 * */ 670 struct burn_progress { 671 /** The total number of sessions */ 672 int sessions; 673 /** Current session.*/ 674 int session; 675 /** The total number of tracks */ 676 int tracks; 677 /** Current track. */ 678 int track; 679 /** The total number of indices */ 680 int indices; 681 /** Current index. */ 682 int index; 683 /** The starting logical block address */ 684 int start_sector; 685 /** On write: The number of sectors. 686 On blank: 0x10000 as upper limit for relative progress steps */ 687 int sectors; 688 /** On write: The current sector being processed. 689 On blank: Relative progress steps 0 to 0x10000 */ 690 int sector; 691 692 /* ts A61023 */ 693 /* @since 0.2.6 */ 694 /** The capacity of the drive buffer */ 695 unsigned buffer_capacity; 696 /** The free space in the drive buffer (might be slightly outdated) */ 697 unsigned buffer_available; 698 699 /* ts A61119 */ 700 /* @since 0.2.6 */ 701 /** The number of bytes sent to the drive buffer */ 702 off_t buffered_bytes; 703 /** The minimum number of bytes stored in buffer during write. 704 (Caution: Before surely one buffer size of bytes was processed, 705 this value is 0xffffffff.) 706 */ 707 unsigned buffer_min_fill; 708 }; 709 710 711 /* ts A61226 */ 712 /* @since 0.3.0 */ 713 /** Description of a speed capability as reported by the drive in conjunction 714 with eventually loaded media. There can be more than one such object per 715 drive. So they are chained via .next and .prev , where NULL marks the end 716 of the chain. This list is set up by burn_drive_scan() and gets updated 717 by burn_drive_grab(). 718 A copy may be obtained by burn_drive_get_speedlist() and disposed by 719 burn_drive_free_speedlist(). 720 For technical background info see SCSI specs MMC and SPC: 721 mode page 2Ah (from SPC 5Ah MODE SENSE) , mmc3r10g.pdf , 6.3.11 Table 364 722 ACh GET PERFORMANCE, Type 03h , mmc5r03c.pdf , 6.8.5.3 Table 312 723 */ 724 struct burn_speed_descriptor { 725 726 /** Where this info comes from : 727 0 = misc 728 1 = mode page 2Ah 729 2 = ACh GET PERFORMANCE Type 03h 730 3 = ACh GET PERFORMANCE Type 00h Data Type 10h (read speed) 731 */ 732 int source; 733 734 /** The media type that was current at the time of report 735 -2 = state unknown, -1 = no media was loaded , else see 736 burn_disc_get_profile() */ 737 int profile_loaded; 738 char profile_name[80]; 739 740 /** The attributed capacity of appropriate media in logical block units 741 i.e. 2352 raw bytes or 2048 data bytes. -1 = capacity unknown. */ 742 int end_lba; 743 744 /** Speed is given in 1000 bytes/s , 0 = invalid. The numbers 745 are supposed to be usable with burn_drive_set_speed() */ 746 int write_speed; 747 int read_speed; 748 749 /** Expert info from ACh GET PERFORMANCE and/or mode page 2Ah. 750 Expect values other than 0 or 1 to get a meaning in future.*/ 751 /* Rotational control: 0 = CLV/default , 1 = CAV */ 752 int wrc; 753 /* 1 = drive promises reported performance over full media */ 754 int exact; 755 /* 1 = suitable for mixture of read and write */ 756 int mrw; 757 758 /** List chaining. Use .next until NULL to iterate over the list */ 759 struct burn_speed_descriptor *prev; 760 struct burn_speed_descriptor *next; 761 }; 762 763 764 /** Initialize the library. 765 This must be called before using any other functions in the library. It 766 may be called more than once with no effect. 767 It is possible to 'restart' the library by shutting it down and 768 re-initializing it. Once this was necessary if you follow the older and 769 more general way of accessing a drive via burn_drive_scan() and 770 burn_drive_grab(). See burn_drive_scan_and_grab() with its strong 771 urges and its explanations. 772 @return Nonzero if the library was able to initialize; zero if 773 initialization failed. 774 */ 775 int burn_initialize(void); 776 777 /** Shutdown the library. 778 This should be called before exiting your application. Make sure that all 779 drives you have grabbed are released <i>before</i> calling this. 780 */ 781 void burn_finish(void); 782 783 784 /* ts A61002 */ 785 /** Abort any running drive operation and eventually call burn_finish(). 786 787 You MUST shut down the busy drives if an aborting event occurs during a 788 burn run. For that you may call this function either from your own signal 789 handling code or indirectly by activating the built-in signal handling: 790 burn_set_signal_handling("my_app_name : ", NULL, 0); 791 Else you may eventually call burn_drive_cancel() on the active drives and 792 wait for them to assume state BURN_DRIVE_IDLE. 793 @param patience Maximum number of seconds to wait for drives to 794 finish. 795 @since 0.7.8 : 796 If this is -1, then only the cancel operations will 797 be performed and no burn_finish() will happen. 798 @param pacifier_func If not NULL: a function to produce appeasing messages. 799 See burn_abort_pacifier() for an example. 800 @param handle Opaque handle to be used with pacifier_func 801 @return 1 ok, all went well 802 0 had to leave a drive in unclean state 803 <0 severe error, do no use libburn again 804 @since 0.2.6 805 */ 806 int burn_abort(int patience, 807 int (*pacifier_func)(void *handle, int patience, int elapsed), 808 void *handle); 809 810 /** A pacifier function suitable for burn_abort. 811 @param handle If not NULL, a pointer to a text suitable for printf("%s") 812 @param patience Maximum number of seconds to wait 813 @param elapsed Elapsed number of seconds 814 */ 815 int burn_abort_pacifier(void *handle, int patience, int elapsed); 816 817 818 /** ts A61006 : This is for development only. Not suitable for applications. 819 Set the verbosity level of the library. The default value is 0, which means 820 that nothing is output on stderr. The more you increase this, the more 821 debug output should be displayed on stderr for you. 822 @param level The verbosity level desired. 0 for nothing, higher positive 823 values for more information output. 824 */ 825 void burn_set_verbosity(int level); 826 827 /* ts A91111 */ 828 /** Enable or disable logging of SCSI commands. 829 This call can be made at any time - even before burn_initialize(). 830 It is in effect for all active drives and currently not very thread 831 safe for multiple drives. 832 @param flag Bitfield for control purposes. The default is 0. 833 bit0= log to file /tmp/libburn_sg_command_log 834 bit1= log to stderr 835 bit2= flush output after each line 836 @since 0.7.4 837 */ 838 void burn_set_scsi_logging(int flag); 839 840 /* ts A60813 */ 841 /** Set parameters for behavior on opening device files. To be called early 842 after burn_initialize() and before any bus scan. But not mandatory at all. 843 Parameter value 1 enables a feature, 0 disables. 844 Default is (1,0,0). Have a good reason before you change it. 845 @param exclusive 846 0 = no attempt to make drive access exclusive. 847 1 = Try to open only devices which are not marked as busy 848 and try to mark them busy if opened successfully. (O_EXCL 849 on GNU/Linux , flock(LOCK_EX) on FreeBSD.) 850 2 = in case of a SCSI device, also try to open exclusively 851 the matching /dev/sr, /dev/scd and /dev/st . 852 One may select a device SCSI file family by adding 853 0 = default family 854 4 = /dev/sr%d 855 8 = /dev/scd%d 856 16 = /dev/sg%d 857 Do not use other values ! 858 Add 32 to demand on GNU/Linux an exclusive lock by 859 fcntl(,F_SETLK,) after open() has succeeded. 860 @param blocking Try to wait for drives which do not open immediately but 861 also do not return an error as well. (O_NONBLOCK) 862 This might stall indefinitely with /dev/hdX hard disks. 863 @param abort_on_busy Unconditionally abort process when a non blocking 864 exclusive opening attempt indicates a busy drive. 865 Use this only after thorough tests with your app. 866 @since 0.2.2 867 */ 868 void burn_preset_device_open(int exclusive, int blocking, int abort_on_busy); 869 870 871 /* ts A70223 */ 872 /** Allows the use of media types which are implemented in libburn but not yet 873 tested. The list of those untested profiles is subject to change. 874 - Currently no media types are under test reservation - 875 If you really test such media, then please report the outcome on 876 libburn-hackers@pykix.org 877 If ever then this call should be done soon after burn_initialize() before 878 any drive scanning. 879 @param yes 1=allow all implemented profiles, 0=only tested media (default) 880 @since 0.3.4 881 */ 882 void burn_allow_untested_profiles(int yes); 883 884 885 /* ts A60823 */ 886 /** Acquire a drive with known device file address. 887 888 This is the sysadmin friendly way to open one drive and to leave all 889 others untouched. It bundles the following API calls to form a 890 non-obtrusive way to use libburn: 891 burn_drive_add_whitelist() , burn_drive_scan() , burn_drive_grab() 892 You are *strongly urged* to use this call whenever you know the drive 893 address in advance. 894 895 If not, then you have to use directly above calls. In that case, you are 896 *strongly urged* to drop any unintended drive which will be exclusively 897 occupied and not closed by burn_drive_scan(). 898 This can be done by shutting down the library including a call to 899 burn_finish(). You may later start a new libburn session and should then 900 use the function described here with an address obtained after 901 burn_drive_scan() via burn_drive_d_get_adr(drive_infos[driveno].drive,adr). 902 Another way is to drop the unwanted drives by burn_drive_info_forget(). 903 904 Operating on multiple drives: 905 906 Different than with burn_drive_scan() it is allowed to call 907 burn_drive_scan_and_grab() without giving up any other scanned drives. So 908 this call can be used to get a collection of more than one acquired drives. 909 The attempt to acquire the same drive twice will fail, though. 910 911 Pseudo-drives: 912 913 burn_drive_scan_and_grab() is able to acquire virtual drives which will 914 accept options much like a MMC burner drive. Many of those options will not 915 cause any effect, though. The address of a pseudo-drive begins with 916 prefix "stdio:" followed by a path. 917 Examples: "stdio:/tmp/pseudo_drive" , "stdio:/dev/null" , "stdio:-" 918 919 If the path is empty, the result is a null-drive = drive role 0. 920 It pretends to have loaded no media and supports no reading or writing. 921 922 If the path leads to an existing regular file, or to a not yet existing 923 file, or to an existing block device, then the result is a random access 924 stdio-drive capable of reading and writing = drive role 2. 925 926 If the path leads to an existing file of any type other than directory, 927 then the result is a sequential write-only stdio-drive = drive role 3. 928 929 The special address form "stdio:/dev/fd/{number}" is interpreted literally 930 as reference to open file descriptor {number}. This address form coincides 931 with real files on some systems, but it is in fact hardcoded in libburn. 932 Special address "stdio:-" means stdout = "stdio:/dev/fd/1". 933 The role of such a drive is determined by the file type obtained via 934 fstat({number}). 935 936 Roles 2 and 3 perform all their eventual data transfer activities on a file 937 via standard i/o functions open(2), lseek(2), read(2), write(2), close(2). 938 The media profile is reported as 0xffff. Write space information from those 939 media is not necessarily realistic. 940 941 The capabilities of role 2 resemble DVD-RAM but it can simulate writing. 942 If the path does not exist in the filesystem yet, it is attempted to create 943 it as a regular file as soon as write operations are started. 944 945 The capabilities of role 3 resemble a blank DVD-R. Nevertheless each 946 burn_disc_write() run may only write a single track. 947 948 One may distinguish pseudo-drives from MMC drives by call 949 burn_drive_get_drive_role(). 950 951 @param drive_infos On success returns a one element array with the drive 952 (cdrom/burner). Thus use with driveno 0 only. On failure 953 the array has no valid elements at all. 954 The returned array should be freed via burn_drive_info_free() 955 when it is no longer needed. 956 This is a result from call burn_drive_scan(). See there. 957 Use with driveno 0 only. 958 @param adr The device file address of the desired drive. Either once 959 obtained by burn_drive_d_get_adr() or composed skillfully by 960 application or its user. E.g. "/dev/sr0". 961 Consider to preprocess it by burn_drive_convert_fs_adr(). 962 @param load Nonzero to make the drive attempt to load a disc (close its 963 tray door, etc). 964 @return 1 = success , 0 = drive not found , -1 = other error 965 @since 0.2.2 966 */ 967 int burn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], 968 char* adr, int load); 969 970 971 /* ts A51221 */ 972 /* @since 0.2.2 */ 973 /** Maximum number of particularly permissible drive addresses */ 974 #define BURN_DRIVE_WHITELIST_LEN 255 975 976 /** Add a device to the list of permissible drives. As soon as some entry is in 977 the whitelist all non-listed drives are banned from scanning. 978 @return 1 success, <=0 failure 979 @since 0.2.2 980 */ 981 int burn_drive_add_whitelist(char *device_address); 982 983 /** Remove all drives from whitelist. This enables all possible drives. */ 984 void burn_drive_clear_whitelist(void); 985 986 987 /** Scan for drives. This function MUST be called until it returns nonzero. 988 In case of re-scanning: 989 All pointers to struct burn_drive and all struct burn_drive_info arrays 990 are invalidated by using this function. Do NOT store drive pointers across 991 calls to this function ! 992 To avoid invalid pointers one MUST free all burn_drive_info arrays 993 by burn_drive_info_free() before calling burn_drive_scan() a second time. 994 If there are drives left, then burn_drive_scan() will refuse to work. 995 996 After this call all drives depicted by the returned array are subject 997 to eventual (O_EXCL) locking. See burn_preset_device_open(). This state 998 ends either with burn_drive_info_forget() or with burn_drive_release(). 999 It is unfriendly to other processes on the system to hold drives locked 1000 which one does not definitely plan to use soon. 1001 @param drive_infos Returns an array of drive info items (cdroms/burners). 1002 The returned array must be freed by burn_drive_info_free() 1003 before burn_finish(), and also before calling this function 1004 burn_drive_scan() again. 1005 @param n_drives Returns the number of drive items in drive_infos. 1006 @return 0 while scanning is not complete 1007 >0 when it is finished successfully, 1008 <0 when finished but failed. 1009 */ 1010 int burn_drive_scan(struct burn_drive_info *drive_infos[], 1011 unsigned int *n_drives); 1012 1013 /* ts A60904 : ticket 62, contribution by elmom */ 1014 /** Release memory about a single drive and any exclusive lock on it. 1015 Become unable to inquire or grab it. Expect FATAL consequences if you try. 1016 @param drive_info pointer to a single element out of the array 1017 obtained from burn_drive_scan() : &(drive_infos[driveno]) 1018 @param force controls degree of permissible drive usage at the moment this 1019 function is called, and the amount of automatically provided 1020 drive shutdown : 1021 0= drive must be ungrabbed and BURN_DRIVE_IDLE 1022 1= try to release drive even if in state BURN_DRIVE_GRABBING 1023 Use these two only. Further values are to be defined. 1024 @return 1 on success, 2 if drive was already forgotten, 1025 0 if not permissible, <0 on other failures, 1026 @since 0.2.2 1027 */ 1028 int burn_drive_info_forget(struct burn_drive_info *drive_info, int force); 1029 1030 1031 /** When no longer needed, free a whole burn_drive_info array which was 1032 returned by burn_drive_scan(). 1033 For freeing single drive array elements use burn_drive_info_forget(). 1034 */ 1035 void burn_drive_info_free(struct burn_drive_info drive_infos[]); 1036 1037 1038 /* ts A60823 */ 1039 /* @since 0.2.2 */ 1040 /** Maximum length+1 to expect with a drive device file address string */ 1041 #define BURN_DRIVE_ADR_LEN 1024 1042 1043 /* ts A70906 */ 1044 /** Inquire the device file address of the given drive. 1045 @param drive The drive to inquire. 1046 @param adr An application provided array of at least BURN_DRIVE_ADR_LEN 1047 characters size. The device file address gets copied to it. 1048 @return >0 success , <=0 error (due to libburn internal problem) 1049 @since 0.4.0 1050 */ 1051 int burn_drive_d_get_adr(struct burn_drive *drive, char adr[]); 1052 1053 /* A60823 */ 1054 /** Inquire the device file address of a drive via a given drive_info object. 1055 (Note: This is a legacy call.) 1056 @param drive_info The drive to inquire.Usually some &(drive_infos[driveno]) 1057 @param adr An application provided array of at least BURN_DRIVE_ADR_LEN 1058 characters size. The device file address gets copied to it. 1059 @return >0 success , <=0 error (due to libburn internal problem) 1060 @since 0.2.6 1061 */ 1062 int burn_drive_get_adr(struct burn_drive_info *drive_info, char adr[]); 1063 1064 1065 /* ts A60922 ticket 33 */ 1066 /** Evaluate whether the given address would be a drive device file address 1067 which could be listed by a run of burn_drive_scan(). No check is made 1068 whether a device file with this address exists or whether it leads 1069 to a usable MMC drive. 1070 @return 1 means yes, 0 means no 1071 @since 0.2.6 1072 */ 1073 int burn_drive_is_enumerable_adr(char *adr); 1074 1075 /* ts A60922 ticket 33 */ 1076 /** Try to convert a given existing filesystem address into a drive device file 1077 address. This succeeds with symbolic links or if a hint about the drive's 1078 system address can be read from the filesystem object and a matching drive 1079 is found. 1080 @param path The address of an existing file system object 1081 @param adr An application provided array of at least BURN_DRIVE_ADR_LEN 1082 characters size. The device file address gets copied to it. 1083 @return 1 = success , 0 = failure , -1 = severe error 1084 @since 0.2.6 1085 */ 1086 int burn_drive_convert_fs_adr(char *path, char adr[]); 1087 1088 /* ts A60923 */ 1089 /** Try to convert a given SCSI address of bus,host,channel,target,lun into 1090 a drive device file address. If a SCSI address component parameter is < 0 1091 then it is not decisive and the first enumerated address which matches 1092 the >= 0 parameters is taken as result. 1093 Note: bus and (host,channel) are supposed to be redundant. 1094 @param bus_no "Bus Number" (something like a virtual controller) 1095 @param host_no "Host Number" (something like half a virtual controller) 1096 @param channel_no "Channel Number" (other half of "Host Number") 1097 @param target_no "Target Number" or "SCSI Id" (a device) 1098 @param lun_no "Logical Unit Number" (a sub device) 1099 @param adr An application provided array of at least BURN_DRIVE_ADR_LEN 1100 characters size. The device file address gets copied to it. 1101 @return 1 = success , 0 = failure , -1 = severe error 1102 @since 0.2.6 1103 */ 1104 int burn_drive_convert_scsi_adr(int bus_no, int host_no, int channel_no, 1105 int target_no, int lun_no, char adr[]); 1106 1107 /* ts B10728 */ 1108 /** Try to convert a given drive device file address into the address of a 1109 symbolic link that points to this drive address. 1110 Modern GNU/Linux systems may shuffle drive addresses from boot to boot. 1111 The udev daemon is supposed to create links which always point to the 1112 same drive, regardless of its system address. 1113 This call tries to find such links. 1114 @param dev_adr Should contain a drive address as returned by 1115 burn_drive_scan(). 1116 @param link_adr An application provided array of at least 1117 BURN_DRIVE_ADR_LEN characters size. The found link 1118 address gets copied to it. 1119 @param dir_adr The address of the directory where to look for links. 1120 Normally: "/dev" 1121 @param templ An array of pointers to name templates, which 1122 links have to match. A symbolic link in dir_adr matches 1123 a name template if it begins by that text. E.g. 1124 link address "/dev/dvdrw1" matches template "dvdrw". 1125 If templ is NULL, then the default array gets used: 1126 {"dvdrw", "cdrw", "dvd", "cdrom", "cd"} 1127 If several links would match, then a link will win, 1128 which matches the template with the lowest array index. 1129 Among these candidates, the one with the lowest strcmp() 1130 rank will be chosen as link_adr. 1131 @param num_templ Number of array elements in templ. 1132 @param flag Bitfield for control purposes. Unused yet. Submit 0. 1133 @return <0 severe error, 0 failed to search, 2 nothing found 1134 1 success, link_adr is valid 1135 @since 1.1.4 1136 */ 1137 int burn_lookup_device_link(char *dev_adr, char link_adr[], 1138 char *dir_adr, char **templ, int num_templ, int flag); 1139 1140 /* ts A60923 - A61005 */ 1141 /** Try to obtain bus,host,channel,target,lun from path. If there is an SCSI 1142 address at all, then this call should succeed with a drive device file 1143 address obtained via burn_drive_d_get_adr(). It is also supposed to 1144 succeed with any device file of a (possibly emulated) SCSI device. 1145 @return 1 = success , 0 = failure , -1 = severe error 1146 @since 0.2.6 1147 */ 1148 int burn_drive_obtain_scsi_adr(char *path, int *bus_no, int *host_no, 1149 int *channel_no, int *target_no, int *lun_no); 1150 1151 /** Grab a drive. This must be done before the drive can be used (for reading, 1152 writing, etc). 1153 @param drive The drive to grab. This is found in a returned 1154 burn_drive_info struct. 1155 @param load Nonzero to make the drive attempt to load a disc (close its 1156 tray door, etc). 1157 @return 1 if it was possible to grab the drive, else 0 1158 */ 1159 int burn_drive_grab(struct burn_drive *drive, int load); 1160 1161 /* ts B00114 */ 1162 /* Probe available CD write modes and block types. In earlier versions this 1163 was done unconditionally on drive examination or aquiration. But it is 1164 lengthy and obtrusive, up to spoiling burn runs on the examined drives. 1165 So now this probing is omitted by default. All drives which announce to be 1166 capable of CD or DVD writing, get blindly attributed the capability for 1167 SAO and TAO. Applications which are interested in RAW modes or want to 1168 rely on the traditional write mode information, may use this call. 1169 @param drive_info drive object to be inquired 1170 @return >0 indicates success, <=0 means failure 1171 @since 0.7.6 1172 */ 1173 int burn_drive_probe_cd_write_modes(struct burn_drive_info *drive_info); 1174 1175 /* ts A90824 */ 1176 /** Calm down or alert a drive. Some drives stay alert after reading for 1177 quite some time. This saves time with the startup for the next read 1178 operation but also causes noise and consumes extra energy. It makes 1179 sense to calm down the drive if no read operation is expected for the 1180 next few seconds. The drive will get alert automatically if operations 1181 are required. 1182 @param d The drive to influence. 1183 @param flag Bitfield for control purposes 1184 bit0= become alert (else start snoozing) 1185 This is not mandatory for further drive operations 1186 @return 1= success , 0= drive role not suitable for calming 1187 @since 0.7.0 1188 */ 1189 int burn_drive_snooze(struct burn_drive *d, int flag); 1190 1191 1192 /** Re-assess drive and media status. This should be done after a drive 1193 underwent a status change and shall be further used without intermediate 1194 burn_drive_release(), burn_drive_grab(). E.g. after blanking or burning. 1195 @param d The already grabbed drive to re-assess. 1196 @param flag Unused yet. Submit 0. 1197 @return 1 success , <= 0 could not determine drive and media state 1198 @since 1.1.8 1199 */ 1200 int burn_drive_re_assess(struct burn_drive *d, int flag); 1201 1202 1203 /** Release a drive. This should not be done until the drive is no longer 1204 busy (see burn_drive_get_status). 1205 @param drive The drive to release. 1206 @param eject Nonzero to make the drive eject the disc in it. 1207 */ 1208 void burn_drive_release(struct burn_drive *drive, int eject); 1209 1210 1211 /* ts A70918 */ 1212 /** Like burn_drive_release() but keeping the drive tray closed and its 1213 eject button disabled. This physically locked drive state will last until 1214 the drive is grabbed again and released via burn_drive_release(). 1215 Programs like eject, cdrecord, growisofs will break that ban too. 1216 @param d The drive to release and leave locked. 1217 @param flag Bitfield for control purposes (unused yet, submit 0) 1218 @return 1 means success, <=0 means failure 1219 @since 0.4.0 1220 */ 1221 int burn_drive_leave_locked(struct burn_drive *d, int flag); 1222 1223 1224 /** Returns what kind of disc a drive is holding. This function may need to be 1225 called more than once to get a proper status from it. See burn_disc_status 1226 for details. 1227 @param drive The drive to query for a disc. 1228 @return The status of the drive, or what kind of disc is in it. 1229 Note: BURN_DISC_UNGRABBED indicates wrong API usage 1230 */ 1231 enum burn_disc_status burn_disc_get_status(struct burn_drive *drive); 1232 1233 1234 /* ts A61020 */ 1235 /** WARNING: This revives an old bug-like behavior that might be dangerous. 1236 Sets the drive status to BURN_DISC_BLANK if it is BURN_DISC_UNREADY 1237 or BURN_DISC_UNSUITABLE. Thus marking media as writable which actually 1238 failed to declare themselves either blank or (partially) filled. 1239 @return 1 drive status has been set , 0 = unsuitable drive status 1240 @since 0.2.6 1241 */ 1242 int burn_disc_pretend_blank(struct burn_drive *drive); 1243 1244 1245 /* ts A61106 */ 1246 /** WARNING: This overrides the safety measures against unsuitable media. 1247 Sets the drive status to BURN_DISC_FULL if it is BURN_DISC_UNREADY 1248 or BURN_DISC_UNSUITABLE. Thus marking media as blankable which actually 1249 failed to declare themselves either blank or (partially) filled. 1250 @since 0.2.6 1251 */ 1252 int burn_disc_pretend_full(struct burn_drive *drive); 1253 1254 1255 /* ts B31110 */ 1256 /** WARNING: This overrides the safety measures against unsuitable media. 1257 Sets the drive status to BURN_DISC_FULL unconditionally. 1258 @since 1.3.4 1259 */ 1260 int burn_disc_pretend_full_uncond(struct burn_drive *drive); 1261 1262 1263 /* ts B51016 */ 1264 /** Returns the Drive Serial Number as of MMC feature 108h. 1265 @param d The drive to inquire. 1266 @param sno Returns the bytes of the serial number. A trailing 0-byte 1267 is appended for convenience. MMC specifies ASCII 0x20 to 1268 0x7h as possible byte values. But given drive firmware 1269 habits there is no warranty that *sno contains no other 1270 byte values. 1271 Submit *sno as NULL or pointing to free()-able memory. 1272 Apply free() to *sno when no longer needed. 1273 @param sno_len Returns the number of valid bytes in returned *sno, 1274 not counting the appended trailing 0. 1275 @return 1= success (but maybe *sno_len is 0), <= 0 severe failure 1276 @since 1.4.2 1277 */ 1278 int burn_drive_get_serial_no(struct burn_drive *d, char **sno, int *sno_len); 1279 1280 1281 /* ts B51016 */ 1282 /** Returns the Media Serial Number as of MMC feature 109h and command ABh 1283 READ MEDIA SERIAL NUMBER. 1284 1285 Note: This call will return an empty result unless the macro 1286 Libburn_enable_scsi_cmd_ABh 1287 is defined at compile time. 1288 This is because the command READ MEDIA SERIAL NUMBER demands 1289 superuser authority on Linux, because no medium with serial number 1290 could be tested yet, and because this command made one of the test 1291 drives unusable until power cycle when it was executed despite 1292 feature 109h was not announced as "current". 1293 1294 @param d The drive to inquire. 1295 @param sno Returns the bytes of the serial number. A trailing 0-byte 1296 is appended for convenience. There is no warranty that 1297 *sno contains only non-zero printable bytes. 1298 Submit *sno as NULL or pointing to free()-able memory. 1299 Apply free() to *sno when no longer needed. 1300 @param sno_len Returns the number of valid bytes in returned *sno, 1301 not counting the appended trailing 0. 1302 @return 1= success (but maybe *sno_len is 0), <= 0 severe failure 1303 @since 1.4.2 1304 */ 1305 int burn_drive_get_media_sno(struct burn_drive *d, char **sno, int *sno_len); 1306 1307 1308 /* ts A61021 */ 1309 /** Reads ATIP information from inserted media. To be obtained via 1310 burn_drive_get_write_speed(), burn_drive_get_min_write_speed(), 1311 burn_drive_get_start_end_lba(). The drive must be grabbed for this call. 1312 @param drive The drive to query. 1313 @return 1=success, 0=no valid ATIP info read, -1 severe error 1314 @since 0.2.6 1315 */ 1316 int burn_disc_read_atip(struct burn_drive *drive); 1317 1318 1319 /* ts B70206 */ 1320 /** Tells whether a BD-R medium with Pseudo Overwrite (POW) formatting is in 1321 the drive. Such a formatting may have been applied by dvd+rw-tools. It 1322 prevents sequential multi-session. 1323 libburn will refuse to write to such a medium. 1324 @param drive The drive to query. 1325 @return 1 if BD-R Pseudo Overwrite , 0 if not BD-R or not POW 1326 @since 1.4.8 1327 */ 1328 int burn_drive_get_bd_r_pow(struct burn_drive *drive); 1329 1330 1331 /* ts A61020 */ 1332 /** Returns start and end lba of the media which is currently inserted 1333 in the given drive. The drive has to be grabbed to have hope for reply. 1334 Shortcoming (not a feature): unless burn_disc_read_atip() was called 1335 only blank media will return valid info. 1336 @param drive The drive to query. 1337 @param start_lba Returns the start lba value 1338 @param end_lba Returns the end lba value 1339 @param flag Bitfield for control purposes (unused yet, submit 0) 1340 @return 1 if lba values are valid , 0 if invalid 1341 @since 0.2.6 1342 */ 1343 int burn_drive_get_start_end_lba(struct burn_drive *drive, 1344 int *start_lba, int *end_lba, int flag); 1345 1346 1347 /* ts A90902 */ 1348 /** Guess the manufacturer name of CD media from the ATIP addresses of lead-in 1349 and lead-out. (Currently only lead-in is interpreted. Lead-out may in 1350 future be used to identify the media type in more detail.) 1351 The parameters of this call should be obtained by burn_disc_read_atip(d), 1352 burn_drive_get_start_end_lba(d, &start_lba, &end_lba, 0), 1353 burn_lba_to_msf(start_lba, &m_li, &s_li, &f_li) and 1354 burn_lba_to_msf(end_lba, &m_lo, &s_lo, &f_lo). 1355 @param m_li "minute" part of ATIP lead-in or start_lba 1356 @param s_li "second" of lead-in or start_lba 1357 @param f_li "frame" of lead-in 1358 @param m_lo "minute" part of ATIP lead-out 1359 @param s_lo "second" of lead-out 1360 @param f_lo "frame" of lead-out 1361 @param flag Bitfield for control purposes, 1362 bit0= append a text "(aka ...)" to reply if other brands or 1363 vendor names are known. 1364 @return Printable text or NULL on memory shortage. 1365 Dispose by free() when no longer needed. 1366 @since 0.7.2 1367 */ 1368 char *burn_guess_cd_manufacturer(int m_li, int s_li, int f_li, 1369 int m_lo, int s_lo, int f_lo, int flag); 1370 1371 /* ts A90909 */ 1372 /** Retrieve some media information which is mainly specific to CD. For other 1373 media only the bits in reply parameter valid are supposed to be meaningful. 1374 @param d The drive to query. 1375 @param disc_type A string saying either "CD-DA or CD-ROM", or "CD-I", 1376 or ""CD-ROM XA", or "undefined". 1377 @param disc_id A 32 bit number read from the media. (Meaning unclear yet) 1378 @param bar_code 8 hex digits from a barcode on media read by the drive 1379 (if the drive has a bar code reader built in). 1380 @param app_code The Host Application Code which must be set in the Write 1381 Parameters Page if the media is not unrestricted (URU==0). 1382 @param valid Replies bits which indicate the validity of other reply 1383 parameters or the state of certain CD info bits: 1384 bit0= disc_type is valid 1385 bit1= disc_id is valid 1386 bit2= bar_code is valid 1387 bit3= disc_app_code is valid 1388 bit4= Disc is unrestricted (URU bit, 51h READ DISC INFO) 1389 This seems to be broken with my drives. The bit is 1390 0 and the validity bit for disc_app_code is 0 too. 1391 bit5= Disc is nominally erasable (Erasable bit) 1392 This will be set with overwritable media which 1393 libburn normally considers to be unerasable blank. 1394 @return 1 success, <= 0 an error occurred 1395 @since 0.7.2 1396 */ 1397 int burn_disc_get_cd_info(struct burn_drive *d, char disc_type[80], 1398 unsigned int *disc_id, char bar_code[9], int *app_code, 1399 int *valid); 1400 1401 /* ts B11201 */ 1402 /** Read the array of CD-TEXT packs from the Lead-in of an audio CD. 1403 Each pack consists of 18 bytes, of which 4 are header. 12 bytes are pieces 1404 of 0-terminated texts or binary data. 2 bytes hold a CRC. 1405 For a description of the format of the array, see file doc/cdtext.txt. 1406 @param d The drive to query. 1407 @param text_packs Will point to an allocated memory buffer with CD-TEXT. 1408 It will only contain text packs, and not be prepended 1409 by the TOC header of four bytes, which gets stored with 1410 file cdtext.dat by cdrecord -vv -toc. (The first two of 1411 these bytes are supposed to hold the number of CD-TEXT 1412 bytes + 2. The other two bytes are supposed to be 0.) 1413 Dispose this buffer by free(), when no longer needed. 1414 @param num_packs Will tell the number of text packs, i.e. the number of 1415 bytes in text_packs divided by 18. 1416 @param flag Bitfield for control purposes, 1417 Unused yet. Submit 0. 1418 @return 1 success, 0= no CD-TEXT found, < 0 an error occurred 1419 @since 1.2.0 1420 */ 1421 int burn_disc_get_leadin_text(struct burn_drive *d, 1422 unsigned char **text_packs, int *num_packs, 1423 int flag); 1424 1425 /* ts B00924 */ 1426 /** Read the current usage of the eventual BD Spare Area. This area gets 1427 reserved on BD media during formatting. During writing it is used to 1428 host replacements of blocks which failed the checkread immediately after 1429 writing. 1430 This call applies only to recordable BD media. I.e. profiles 0x41 to 0x43. 1431 @param d The drive to query. 1432 @param alloc_blocks Returns the number of blocks reserved as Spare Area 1433 @param free_blocks Returns the number of yet unused blocks in that area 1434 @param flag Bitfield for control purposes (unused yet, submit 0) 1435 @return 1 = reply prarameters are valid, 1436 <=0 = reply is invalid (e.g. because no BD profile) 1437 @since 0.8.8 1438 */ 1439 int burn_disc_get_bd_spare_info(struct burn_drive *d, 1440 int *alloc_blocks, int *free_blocks, int flag); 1441 1442 /* ts B10801 */ 1443 /** Retrieve some media information which is mainly specific to media of 1444 the DVD-R family: DVD-R , DVD-RW , DVD-R DL , HD DVD-R 1445 Currently the information cannot be retrieved from other media types. 1446 @param d The drive to query. 1447 @param disk_category returns DVD Book to which the media complies 1448 @param book_name returns a pointer to the book name of disk_category. 1449 This memory is static. Do not alter or free it ! 1450 @param part_version returns the Media Version in the DVD Book 1451 @param num_layers returns the number of media layers 1452 @param num_blocks returns the number of blocks between pysical start 1453 and physical end of the media 1454 @param flag Bitfield for control purposes (unused yet, submit 0) 1455 @return 1 = reply prarameters are valid, 1456 <=0 = reply is invalid (e.g. because no DVD-R) 1457 @since 1.1.4 1458 */ 1459 int burn_disc_get_phys_format_info(struct burn_drive *d, int *disk_category, 1460 char **book_name, int *part_version, int *num_layers, 1461 int *num_blocks, int flag); 1462 1463 /* ts A61110 */ 1464 /** Read start lba and Next Writeable Address of a track from media. 1465 Usually a track lba is obtained from the result of burn_track_get_entry(). 1466 This call retrieves an updated lba, eventual nwa, and can address the 1467 invisible track to come. 1468 The drive must be grabbed for this call. One may not issue this call 1469 during ongoing burn_disc_write() or burn_disc_erase(). 1470 @param d The drive to query. 1471 @param o If not NULL: write parameters to be set on drive before query 1472 @param trackno 0=next track to come, >0 number of existing track 1473 The first existing track on a CD may have a number higher 1474 than 1. Use burn_session_get_start_tno() to inquire this 1475 start number. 1476 @param lba return value: start lba 1477 @param nwa return value: Next Writeable Address 1478 @return 1=nwa is valid , 0=nwa is not valid , -1=error 1479 @since 0.2.6 1480 */ 1481 int burn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o, 1482 int trackno, int *lba, int *nwa); 1483 1484 /* ts B10525 */ 1485 /** Tells whether a previous attempt to determine the Next Writeable Address 1486 of the upcoming track reveiled that the READ TRACK INFORMATION Damage Bit 1487 is set for this track and that no valid writable address is available. 1488 See MMC-5 6.27.3.7 Damage Bit, 6.27.3.11 NWA_V (NWA valid) 1489 @param d The drive to query. 1490 @param flag Bitfield for control purposes (unused yet, submit 0) 1491 @return 0= Looks ok: Damage Bit is not set, NWA_V is set 1492 1= Damaged and theoretically writable (NWA_V is set) 1493 2= Not writable: NWA_V is not set 1494 3= Damaged and not writable (NWA_V is not set), 1495 @since 1.1.0 1496 */ 1497 int burn_disc_next_track_is_damaged(struct burn_drive *d, int flag); 1498 1499 /* ts B10527 */ 1500 /** Try to close the last track and session of media which have bit0 set in 1501 the return value of call burn_disc_next_track_is_damaged(). 1502 Whether it helps depends much on the reason why the media is reported 1503 as damaged by the drive. 1504 This call works only for profiles 0x09 CD-R, 0x0a CD-RW, 0x11 DVD-R, 1505 0x14 DVD-RW sequential, 0x1b DVD+R, 0x2b DVD+R DL, 0x41 BD-R sequential. 1506 Note: After writing it is advised to give up the drive and to grab it again 1507 in order to learn about its view on the new media state. 1508 @param o Write options created by burn_write_opts_new() and 1509 manipulated by burn_write_opts_set_multi(). 1510 burn_write_opts_set_write_type() should be set to 1511 BURN_WRITE_TAO, burn_write_opts_set_simulate() should be 1512 set to 0. 1513 @param flag Bitfield for control purposes 1514 bit0= force close, even if no damage was seen 1515 @return <=0 media not marked as damaged, or media type not suitable, 1516 or closing attempted but failed 1517 1= attempt finished without error indication 1518 @since 1.1.0 1519 */ 1520 int burn_disc_close_damaged(struct burn_write_opts *o, int flag); 1521 1522 1523 /* ts A70131 */ 1524 /** Read start lba of the first track in the last complete session. 1525 This is the first parameter of mkisofs option -C. The second parameter 1526 is nwa as obtained by burn_disc_track_lba_nwa() with trackno 0. 1527 @param d The drive to query. 1528 @param start_lba returns the start address of that track 1529 @return <= 0 : failure, 1 = ok 1530 @since 0.3.2 1531 */ 1532 int burn_disc_get_msc1(struct burn_drive *d, int *start_lba); 1533 1534 1535 /* ts A70213 */ 1536 /** Return the best possible estimation of the currently available capacity of 1537 the media. This might depend on particular write option settings. For 1538 inquiring the space with such a set of options, the drive has to be 1539 grabbed and BURN_DRIVE_IDLE. If not, then one will only get a canned value 1540 from the most recent automatic inquiry (e.g. during last drive grabbing). 1541 An eventual start address from burn_write_opts_set_start_byte() will be 1542 taken into respect with the capacity estimation. Negative results get 1543 defaulted to 0. 1544 If the drive is actually a file in a large filesystem or a large block 1545 device, then the capacity is curbed to a maximum of 0x7ffffff0 blocks 1546 = 4 TB - 32 KB. 1547 @param d The drive to query. 1548 @param o If not NULL: write parameters to be set on drive before query 1549 @return number of most probably available free bytes 1550 @since 0.3.4 1551 */ 1552 off_t burn_disc_available_space(struct burn_drive *d, 1553 struct burn_write_opts *o); 1554 1555 /* ts A61202 */ 1556 /** Tells the MMC Profile identifier of the loaded media. The drive must be 1557 grabbed in order to get a non-zero result. 1558 libburn currently writes only to profiles 1559 0x09 "CD-R" 1560 0x0a "CD-RW" 1561 0x11 "DVD-R sequential recording" 1562 0x12 "DVD-RAM" 1563 0x13 "DVD-RW restricted overwrite" 1564 0x14 "DVD-RW sequential recording", 1565 0x15 "DVD-R/DL sequential recording", 1566 0x1a "DVD+RW" 1567 0x1b "DVD+R", 1568 0x2b "DVD+R/DL", 1569 0x41 "BD-R sequential recording", 1570 0x43 "BD-RE", 1571 0xffff "stdio file" 1572 Note: 0xffff is not a MMC profile but a libburn invention. 1573 Read-only are the profiles 1574 0x08 "CD-ROM", 1575 0x10 "DVD-ROM", 1576 0x40 "BD-ROM", 1577 Read-only for now is this BD-R profile (testers wanted) 1578 0x42 "BD-R random recording" 1579 Empty drives are supposed to report 1580 0x00 "" 1581 @param d The drive where the media is inserted. 1582 @param pno Profile Number. See also mmc5r03c.pdf, table 89 1583 @param name Profile Name (see above list, unknown profiles have empty name) 1584 @return 1 profile is valid, 0 no profile info available 1585 @since 0.3.0 1586 */ 1587 int burn_disc_get_profile(struct burn_drive *d, int *pno, char name[80]); 1588 1589 1590 /* ts A90903 : API */ 1591 /** Obtain product id and standards defined media codes. 1592 The product id is a printable string which is supposed to be the same 1593 for identical media but should vary with non-identical media. Some media 1594 cannot provide such an id at all. 1595 The pair (profile_number, product_id) should be the best id to identify 1596 media with identical product specifications. 1597 The reply parameters media_code1 and media_code2 can be used with 1598 burn_guess_manufacturer() 1599 The reply parameters have to be disposed by free() when no longer needed. 1600 @param d The drive where the media is inserted. 1601 @param product_id Reply: Printable text depicting manufacturer and 1602 eventually media id. 1603 @param media_code1 Reply: The eventual manufacturer identification as read 1604 from DVD/BD media or a text "XXmYYsZZf" from CD media 1605 ATIP lead-in. 1606 @param media_code2 The eventual media id as read from DVD+/BD media or a 1607 text "XXmYYsZZf" from CD ATIP lead-out. 1608 @param book_type Book type text for DVD and BD. 1609 Caution: is NULL with CD, even if return value says ok. 1610 @param flag Bitfield for control purposes 1611 bit0= do not escape " _/" (not suitable for 1612 burn_guess_manufacturer()) 1613 @return 1= ok, product_id and media codes are valid, 1614 0= no product id_available, reply parameters are NULL 1615 <0= error 1616 @since 0.7.2 1617 */ 1618 int burn_disc_get_media_id(struct burn_drive *d, 1619 char **product_id, char **media_code1, char **media_code2, 1620 char **book_type, int flag); 1621 1622 1623 /* ts A90904 */ 1624 /** Guess the name of a manufacturer by profile number, manufacturer code 1625 and media code. The profile number can be obtained by 1626 burn_disc_get_profile(), the other two parameters can be obtained as 1627 media_code1 and media_code2 by burn_disc_get_media_id(). 1628 @param profile_no Profile number (submit -1 if not known) 1629 @param manuf_code Manufacturer code from media (e.g. "RICOHJPN") 1630 @param media_code Media ID code from media (e.g. "W11") 1631 @param flag Bitfield for control purposes, submit 0 1632 @return Printable text or NULL on memory shortage. 1633 If the text begins with "Unknown " then no item of the 1634 manufacturer list matched the codes. 1635 Dispose by free() when no longer needed. 1636 @since 0.7.2 1637 */ 1638 char *burn_guess_manufacturer(int profile_no, 1639 char *manuf_code, char *media_code, int flag); 1640 1641 1642 /** Tells whether a disc can be erased or not 1643 @param d The drive to inquire. 1644 @return Non-zero means erasable 1645 */ 1646 int burn_disc_erasable(struct burn_drive *d); 1647 1648 /** Returns the progress and status of a drive. 1649 @param drive The drive to query busy state for. 1650 @param p Returns the progress of the operation, NULL if you don't care 1651 @return the current status of the drive. See also burn_drive_status. 1652 */ 1653 enum burn_drive_status burn_drive_get_status(struct burn_drive *drive, 1654 struct burn_progress *p); 1655 1656 /** Creates a write_opts struct for burning to the specified drive. 1657 The returned object must later be freed with burn_write_opts_free(). 1658 @param drive The drive to write with 1659 @return The write_opts, NULL on error 1660 */ 1661 struct burn_write_opts *burn_write_opts_new(struct burn_drive *drive); 1662 1663 1664 /* ts A70901 */ 1665 /** Inquires the drive associated with a burn_write_opts object. 1666 @param opts object to inquire 1667 @return pointer to drive 1668 @since 0.4.0 1669 */ 1670 struct burn_drive *burn_write_opts_get_drive(struct burn_write_opts *opts); 1671 1672 1673 /** Frees a write_opts struct created with burn_write_opts_new 1674 @param opts write_opts to free 1675 */ 1676 void burn_write_opts_free(struct burn_write_opts *opts); 1677 1678 /** Creates a read_opts struct for reading from the specified drive 1679 must be freed with burn_read_opts_free 1680 @param drive The drive to read from 1681 @return The read_opts 1682 */ 1683 struct burn_read_opts *burn_read_opts_new(struct burn_drive *drive); 1684 1685 /** Frees a read_opts struct created with burn_read_opts_new 1686 @param opts write_opts to free 1687 */ 1688 void burn_read_opts_free(struct burn_read_opts *opts); 1689 1690 /** Erase a disc in the drive. The drive must be grabbed successfully BEFORE 1691 calling this functions. Always ensure that the drive reports a status of 1692 BURN_DISC_FULL before calling this function. An erase operation is not 1693 cancellable, as control of the operation is passed wholly to the drive and 1694 there is no way to interrupt it safely. 1695 @param drive The drive with which to erase a disc. 1696 Only drive roles 1 (MMC) and 5 (stdio random write-only) 1697 support erasing. 1698 @param fast Nonzero to do a fast erase, where only the disc's headers are 1699 erased; zero to erase the entire disc. 1700 With DVD-RW, fast blanking yields media capable only of DAO. 1701 */ 1702 void burn_disc_erase(struct burn_drive *drive, int fast); 1703 1704 1705 /* ts A70101 - A70417 */ 1706 /** Format media for use with libburn. This currently applies to DVD-RW 1707 in state "Sequential Recording" (profile 0014h) which get formatted to 1708 state "Restricted Overwrite" (profile 0013h). DVD+RW can be "de-iced" 1709 by setting bit4 of flag. DVD-RAM and BD-RE may get formatted initially 1710 or re-formatted to adjust their Defect Management. 1711 This function usually returns while the drive is still in the process 1712 of formatting. The formatting is done, when burn_drive_get_status() 1713 returns BURN_DRIVE_IDLE. This may be immediately after return or may 1714 need several thousand seconds to occur. 1715 @param drive The drive with the disc to format. 1716 @param size The size in bytes to be used with the format command. It should 1717 be divisible by 32*1024. The effect of this parameter may 1718 depend on the media profile and on parameter flag. 1719 @param flag Bitfield for control purposes: 1720 bit0= after formatting, write the given number of zero-bytes 1721 to the media and eventually perform preliminary closing. 1722 bit1+2: size mode 1723 0 = use parameter size as far as it makes sense 1724 1 = insist in size 0 even if there is a better default known 1725 (on DVD-RAM or BD-R identical to size mode 0, 1726 i.e. they never get formatted with payload size 0) 1727 2 = without bit7: format to maximum available size 1728 with bit7 : take size from indexed format descriptor 1729 3 = without bit7: format to default size 1730 with bit7 : take size from indexed format descriptor 1731 bit3= -reserved- 1732 bit4= enforce re-format of (partly) formatted media 1733 bit5= try to disable eventual defect management 1734 bit6= try to avoid lengthy media certification 1735 bit7, bit8 to bit15 = 1736 bit7 enables MMC expert application mode (else libburn 1737 tries to choose a suitable format type): 1738 If it is set then bit8 to bit15 contain the index of 1739 the format to use. See burn_disc_get_formats(), 1740 burn_disc_get_format_descr(). 1741 Acceptable types are: 0x00, 0x01, 0x10, 0x11, 0x13, 1742 0x15, 0x26, 0x30, 0x31, 0x32. 1743 If bit7 is set, then bit4 is set automatically. 1744 bit16= enable POW on blank BD-R 1745 @since 0.3.0 1746 */ 1747 void burn_disc_format(struct burn_drive *drive, off_t size, int flag); 1748 1749 1750 /* ts A70112 */ 1751 /* @since 0.3.0 */ 1752 /** Possible formatting status values */ 1753 #define BURN_FORMAT_IS_UNFORMATTED 1 1754 #define BURN_FORMAT_IS_FORMATTED 2 1755 #define BURN_FORMAT_IS_UNKNOWN 3 1756 1757 /* ts A70112 */ 1758 /** Inquire the formatting status, the associated sizes and the number of 1759 available formats. The info is media specific and stems from MMC command 1760 23h READ FORMAT CAPACITY. See mmc5r03c.pdf 6.24 for background details. 1761 Media type can be determined via burn_disc_get_profile(). 1762 @param drive The drive with the disc to format. 1763 @param status The current formatting status of the inserted media. 1764 See BURN_FORMAT_IS_* macros. Note: "unknown" is the 1765 legal status for quick formatted, yet unwritten DVD-RW. 1766 @param size The size in bytes associated with status. 1767 unformatted: the maximum achievable size of the media 1768 formatted: the currently formatted capacity 1769 unknown: maximum capacity of drive or of media 1770 @param bl_sas Additional info "Block Length/Spare Area Size". 1771 Expected to be constantly 2048 for non-BD media. 1772 @param num_formats The number of available formats. To be used with 1773 burn_disc_get_format_descr() to obtain such a format 1774 and eventually with burn_disc_format() to select one. 1775 @return 1 reply is valid , <=0 failure 1776 @since 0.3.0 1777 */ 1778 int burn_disc_get_formats(struct burn_drive *drive, int *status, off_t *size, 1779 unsigned *bl_sas, int *num_formats); 1780 1781 /* ts A70112 */ 1782 /** Inquire parameters of an available media format. 1783 @param drive The drive with the disc to format. 1784 @param index The index of the format item. Beginning with 0 up to reply 1785 parameter from burn_disc_get_formats() : num_formats - 1 1786 @param type The format type. See mmc5r03c.pdf, 6.5, 04h FORMAT UNIT. 1787 0x00=full, 0x10=CD-RW/DVD-RW full, 0x11=CD-RW/DVD-RW grow, 1788 0x15=DVD-RW quick, 0x13=DVD-RW quick grow, 1789 0x26=DVD+RW background, 0x30=BD-RE with spare areas, 1790 0x31=BD-RE without spare areas 1791 @param size The maximum size in bytes achievable with this format. 1792 @param tdp Type Dependent Parameter. See mmc5r03c.pdf. 1793 @return 1 reply is valid , <=0 failure 1794 @since 0.3.0 1795 */ 1796 int burn_disc_get_format_descr(struct burn_drive *drive, int index, 1797 int *type, off_t *size, unsigned *tdp); 1798 1799 1800 1801 /* ts A61109 : this was and is defunct */ 1802 /** Read a disc from the drive and write it to an fd pair. The drive must be 1803 grabbed successfully BEFORE calling this function. Always ensure that the 1804 drive reports a status of BURN_DISC_FULL before calling this function. 1805 @param drive The drive from which to read a disc. 1806 @param o The options for the read operation. 1807 */ 1808 void burn_disc_read(struct burn_drive *drive, const struct burn_read_opts *o); 1809 1810 1811 1812 /* ts A70222 */ 1813 /* @since 0.3.4 */ 1814 /** The length of a rejection reasons string for burn_precheck_write() and 1815 burn_write_opts_auto_write_type() . 1816 */ 1817 #define BURN_REASONS_LEN 4096 1818 1819 1820 /* ts A70219 */ 1821 /** Examines a completed setup for burn_disc_write() whether it is permissible 1822 with drive and media. This function is called by burn_disc_write() but 1823 an application might be interested in this check in advance. 1824 @param o The options for the writing operation. 1825 @param disc The description of the disc to be created 1826 @param reasons Eventually returns a list of rejection reason statements 1827 @param silent 1= do not issue error messages , 0= report problems 1828 @return 1 ok, -1= no recordable media detected, 0= other failure 1829 @since 0.3.4 1830 */ 1831 int burn_precheck_write(struct burn_write_opts *o, struct burn_disc *disc, 1832 char reasons[BURN_REASONS_LEN], int silent); 1833 1834 1835 /** Write a disc in the drive. The drive must be grabbed successfully before 1836 calling this function. Always ensure that the drive reports a status of 1837 BURN_DISC_BLANK ot BURN_DISC_APPENDABLE before calling this function. 1838 Note: write_type BURN_WRITE_SAO is currently not capable of writing a mix 1839 of data and audio tracks. You must use BURN_WRITE_TAO for such sessions. 1840 To be set by burn_write_opts_set_write_type(). 1841 Note: This function is not suitable for overwriting data in the middle of 1842 a valid data area because it is allowed to append trailing data. 1843 For exact random access overwriting use burn_random_access_write(). 1844 Note: After writing it is advised to give up the drive and to grab it again 1845 in order to learn about its view on the new media state. 1846 Note: Before mounting the written media it might be necessary to eject 1847 and reload in order to allow the operating system to notice the new 1848 media state. 1849 @param o The options for the writing operation. 1850 @param disc The struct burn_disc * that described the disc to be created 1851 */ 1852 void burn_disc_write(struct burn_write_opts *o, struct burn_disc *disc); 1853 1854 1855 /* ts A90227 */ 1856 /** Control stream recording during the write run and eventually set the start 1857 LBA for stream recording. 1858 Stream recording is set from struct burn_write_opts when the write run 1859 gets started. See burn_write_opts_set_stream_recording(). 1860 The call described here can be used later to override this setting and 1861 to program automatic switching at a given LBA. It also affects subsequent 1862 calls to burn_random_access_write(). 1863 @param drive The drive which performs the write operation. 1864 @param recmode -1= disable stream recording 1865 0= leave setting as is 1866 1= enable stream recording 1867 @param start The LBA where actual stream recording shall start. 1868 (0 means unconditional stream recording) 1869 @param flag Bitfield for control purposes (unused yet, submit 0). 1870 @return 1=success , <=0 failure 1871 @since 0.6.4 1872 */ 1873 int burn_drive_set_stream_recording(struct burn_drive *drive, int recmode, 1874 int start, int flag); 1875 1876 1877 /* ts B60730 */ 1878 /** Enable or disable use of the Immed bit with long running SCSI commands. 1879 If the Immed bit is used, then those SCSI commands end early and leave 1880 the drive in not-ready state. libburn then tries periodically whether 1881 the drive became ready again. Only then it assumes the command to be 1882 completely done. 1883 The default setting may depend on the operating system on which libburn 1884 was compiled. 1885 @param drive The drive which will be affected. 1886 @param enable 1= use Immed bit. 1887 0= use no Immed bit. Affected commands can last very long. 1888 @return 1=success , <=0 failure 1889 @since 1.4.6 1890 */ 1891 int burn_drive_set_immed(struct burn_drive *drive, int enable); 1892 1893 1894 /* ts B60730 */ 1895 /** Inquire the current setting of usage of the Immed bit. Either the still set 1896 system dependent default or the value set by call burn_drive_set_immed(). 1897 @return The current value. 1898 @since 1.4.6 1899 */ 1900 int burn_drive_get_immed(struct burn_drive *drive); 1901 1902 1903 /** Cancel an operation on a drive. 1904 This will only work when the drive's busy state is BURN_DRIVE_READING or 1905 BURN_DRIVE_WRITING. 1906 @param drive The drive on which to cancel the current operation. 1907 */ 1908 void burn_drive_cancel(struct burn_drive *drive); 1909 1910 1911 /* ts A61223 */ 1912 /** Inquire whether the most recent asynchronous media job was successful. 1913 This applies to burn_disc_erase(), burn_disc_format(), burn_disc_write(). 1914 Reasons for non-success may be: rejection of burn parameters, abort due to 1915 fatal errors during write, blank or format, a call to burn_drive_cancel() 1916 by the application thread. 1917 @param d The drive to inquire. 1918 @return 1=burn seems to have went well, 0=burn failed 1919 @since 0.2.6 1920 */ 1921 int burn_drive_wrote_well(struct burn_drive *d); 1922 1923 1924 /* ts B31023 */ 1925 /** Inquire whether a write error occurred which is suspected to have happened 1926 due to a false report about DVD-RW capability to be written in write type 1927 BURN_WRITE_TAO. 1928 @param d The drive to inquire. 1929 @return 1= it seems that BURN_WRITE_TAO on DVD-RW caused error, 1930 0= it does not seem so 1931 @since 1.3.4 1932 */ 1933 int burn_drive_was_feat21_failure(struct burn_drive *d); 1934 1935 1936 /** Convert a minute-second-frame (MSF) value to sector count 1937 @param m Minute component 1938 @param s Second component 1939 @param f Frame component 1940 @return The sector count 1941 */ 1942 int burn_msf_to_sectors(int m, int s, int f); 1943 1944 /** Convert a sector count to minute-second-frame (MSF) 1945 @param sectors The sector count 1946 @param m Returns the minute component 1947 @param s Returns the second component 1948 @param f Returns the frame component 1949 */ 1950 void burn_sectors_to_msf(int sectors, int *m, int *s, int *f); 1951 1952 /** Convert a minute-second-frame (MSF) value to an lba 1953 @param m Minute component 1954 @param s Second component 1955 @param f Frame component 1956 @return The lba 1957 */ 1958 int burn_msf_to_lba(int m, int s, int f); 1959 1960 /** Convert an lba to minute-second-frame (MSF) 1961 @param lba The lba 1962 @param m Returns the minute component 1963 @param s Returns the second component 1964 @param f Returns the frame component 1965 */ 1966 void burn_lba_to_msf(int lba, int *m, int *s, int *f); 1967 1968 /** Create a new disc 1969 @return Pointer to a burn_disc object or NULL on failure. 1970 */ 1971 struct burn_disc *burn_disc_create(void); 1972 1973 /** Delete disc and decrease the reference count on all its sessions 1974 @param d The disc to be freed 1975 */ 1976 void burn_disc_free(struct burn_disc *d); 1977 1978 /** Create a new session 1979 @return Pointer to a burn_session object or NULL on failure. 1980 */ 1981 struct burn_session *burn_session_create(void); 1982 1983 /** Free a session (and decrease reference count on all tracks inside) 1984 @param s Session to be freed 1985 */ 1986 void burn_session_free(struct burn_session *s); 1987 1988 /** Add a session to a disc at a specific position, increasing the 1989 sessions's reference count. 1990 @param d Disc to add the session to 1991 @param s Session to add to the disc 1992 @param pos position to add at (BURN_POS_END is "at the end") 1993 @return 0 for failure, 1 for success 1994 */ 1995 int burn_disc_add_session(struct burn_disc *d, struct burn_session *s, 1996 unsigned int pos); 1997 1998 /** Remove a session from a disc 1999 @param d Disc to remove session from 2000 @param s Session pointer to find and remove 2001 */ 2002 int burn_disc_remove_session(struct burn_disc *d, struct burn_session *s); 2003 2004 2005 /* ts B11219 */ 2006 /** Read a CDRWIN cue sheet file and equip the session object by tracks and 2007 CD-TEXT according to the content of the file. 2008 For a description of CDRWIN file format see 2009 http://digitalx.org/cue-sheet/syntax/ 2010 Fully supported commands are: 2011 CATALOG , CDTEXTFILE , FLAGS , INDEX , ISRC , PERFORMER , 2012 POSTGAP , PREGAP , REM , SONGWRITER , TITLE 2013 Further supported commands introduced by cdrecord (usage like PERFORMER): 2014 ARRANGER , COMPOSER , MESSAGE 2015 Partly supported commands are: 2016 FILE which supports only types BINARY , MOTOROLA , WAVE 2017 TRACK which supports only datatypes AUDIO , MODE1/2048 2018 Unsupported types of FILE or TRACK lead to failure of the call. 2019 libburn does not yet support mixing of AUDIO and MODE1/2048. So this call 2020 will fail if such a mix is found. 2021 CD-TEXT information is allowed only if all tracks are of datatype AUDIO. 2022 Empty lines and lines which start by '#' are ignored. 2023 @param session Session where to attach tracks. It must not yet have 2024 tracks or else this call will fail. 2025 @param path Filesystem address of the CDRWIN cue sheet file. 2026 Normally with suffix .cue 2027 @param fifo_size Number of bytes in fifo. This will be rounded up by 2028 the block size of the track mode. <= 0 means no fifo. 2029 @param fifo Returns a reference to the burn_source object that 2030 was installed as fifo between FILE and the track 2031 burn sources. One may use this to inquire the fifo 2032 state. Dispose it by burn_source_free() when no longer 2033 needed. It is permissible to pass this parameter to 2034 libburn as NULL, in order to immediately drop ownership 2035 on the fifo. 2036 @param text_packs Returns pre-formatted CD-TEXT packs resulting from 2037 cue sheet command CDTEXTFILE. To be used with call 2038 burn_write_opts_set_leadin_text(). 2039 It is permissible to pass this parameter to libburn 2040 as NULL, in order to disable CDTEXTFILE. 2041 @param num_packs Returns the number of 18 byte records in text_packs. 2042 @param flag Bitfield for control purposes. 2043 bit0= Do not attach CD-TEXT information to session and 2044 tracks. Do not load text_packs. 2045 bit1= Do not use media catalog string of session or ISRC 2046 strings of tracks for writing to Q sub-channel. 2047 @return > 0 indicates success, <= 0 indicates failure 2048 @since 1.2.0 2049 */ 2050 int burn_session_by_cue_file(struct burn_session *session, 2051 char *path, int fifo_size, struct burn_source **fifo, 2052 unsigned char **text_packs, int *num_packs, int flag); 2053 2054 2055 /** Create a track */ 2056 struct burn_track *burn_track_create(void); 2057 2058 /** Free a track 2059 @param t Track to free 2060 */ 2061 void burn_track_free(struct burn_track *t); 2062 2063 /** Add a track to a session at specified position 2064 @param s Session to add to 2065 @param t Track to insert in session 2066 @param pos position to add at (BURN_POS_END is "at the end") 2067 @return 0 for failure, 1 for success 2068 */ 2069 int burn_session_add_track(struct burn_session *s, struct burn_track *t, 2070 unsigned int pos); 2071 2072 /** Remove a track from a session 2073 @param s Session to remove track from 2074 @param t Track pointer to find and remove 2075 @return 0 for failure, 1 for success 2076 */ 2077 int burn_session_remove_track(struct burn_session *s, struct burn_track *t); 2078 2079 2080 /* ts B20107 */ 2081 /** Set the number which shall be written as CD track number with the first 2082 track of the session. The following tracks will then get written with 2083 consecutive CD track numbers. The resulting number of the last track 2084 must not exceed 99. The lowest possible start number is 1, which is also 2085 the default. This setting applies only to CD SAO writing. 2086 @param session The session to be manipulated 2087 @param tno A number between 1 and 99 2088 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2089 @return > 0 indicates success, <= 0 indicates failure 2090 @since 1.2.0 2091 */ 2092 int burn_session_set_start_tno(struct burn_session *session, int tno, 2093 int flag); 2094 2095 /* ts B20108 */ 2096 /** Inquire the CD track start number, as set by default or by 2097 burn_session_set_start_tno(). 2098 @param session The session to be inquired 2099 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2100 @return > 0 is the currently set CD track start number 2101 <= 0 indicates failure 2102 @since 1.2.0 2103 */ 2104 int burn_session_get_start_tno(struct burn_session *session, int flag); 2105 2106 2107 2108 /* ts B11206 */ 2109 /** Set the Character Codes, the Copyright bytes, and the Language Codes 2110 for CD-TEXT blocks 0 to 7. They will be used in the block summaries 2111 of text packs which get generated from text or binary data submitted 2112 by burn_session_set_cdtext() and burn_track_set_cdtext(). 2113 Character Code value can be 2114 0x00 = ISO-8859-1 2115 0x01 = 7 bit ASCII 2116 0x80 = MS-JIS (japanesei Kanji, double byte characters) 2117 Copyright byte value can be 2118 0x00 = not copyrighted 2119 0x03 = copyrighted 2120 Language Code value will typically be 0x09 = English or 0x69 = Japanese. 2121 See below macros BURN_CDTEXT_LANGUAGES_0X00 and BURN_CDTEXT_LANGUAGES_0X45, 2122 but be aware that many of these codes have never been seen on CD, and that 2123 many of them do not have a character representation among the above 2124 Character Codes. 2125 Default is 0x09 = English for block 0 and 0x00 = Unknown for block 1 to 7. 2126 Copyright and Character Code are 0x00 for all blocks by default. 2127 See also file doc/cdtext.txt, "Format of a CD-TEXT packs array", 2128 "Pack type 0x8f". 2129 2130 Parameter value -1 leaves the current setting of the session parameter 2131 unchanged. 2132 @param s Session where to change settings 2133 @param char_codes Character Codes for block 0 to 7 2134 @param copyrights Copyright bytes for block 0 to 7 2135 @param languages Language Codes for block 0 to 7 2136 @param flag Bitfiled for control purposes. Unused yet. Submit 0. 2137 @return <=0 failure, > 0 success 2138 @since 1.2.0 2139 */ 2140 int burn_session_set_cdtext_par(struct burn_session *s, 2141 int char_codes[8], int copyrights[8], 2142 int languages[8], int flag); 2143 2144 /** This is the first list of languages sorted by their Language codes, 2145 which start at 0x00. They stem from from EBU Tech 3264, appendix 3. 2146 E.g. language 0x00 is "Unknown", 0x08 is "German", 0x10 is "Frisian", 2147 0x18 is "Latvian", 0x20 is "Polish", 0x28 is "Swedish", 0x2b is "Wallon". 2148 See also file doc/cdtext.txt. 2149 @since 1.2.0 2150 */ 2151 #define BURN_CDTEXT_LANGUAGES_0X00 \ 2152 "Unknown", "Albanian", "Breton", "Catalan", \ 2153 "Croatian", "Welsh", "Czech", "Danish", \ 2154 "German", "English", "Spanish", "Esperanto", \ 2155 "Estonian", "Basque", "Faroese", "French", \ 2156 "Frisian", "Irish", "Gaelic", "Galician", \ 2157 "Icelandic", "Italian", "Lappish", "Latin", \ 2158 "Latvian", "Luxembourgian", "Lithuanian", "Hungarian", \ 2159 "Maltese", "Dutch", "Norwegian", "Occitan", \ 2160 "Polish", "Portuguese", "Romanian", "Romansh", \ 2161 "Serbian", "Slovak", "Slovenian", "Finnish", \ 2162 "Swedish", "Turkish", "Flemish", "Wallon" 2163 2164 /** This is the second list of languages sorted by their Language codes, 2165 which start at 0x45. They stem from from EBU Tech 3264, appendix 3. 2166 E.g. language 0x45 is "Zulu", 0x50 is "Sranan Tongo", 0x58 is "Pushtu", 2167 0x60 is "Moldavian", 0x68 is "Kannada", 0x70 is "Greek", 0x78 is "Bengali", 2168 0x7f is "Amharic". 2169 See also file doc/cdtext.txt. 2170 @since 1.2.0 2171 */ 2172 #define BURN_CDTEXT_LANGUAGES_0X45 \ 2173 "Zulu", "Vietnamese", "Uzbek", \ 2174 "Urdu", "Ukrainian", "Thai", "Telugu", \ 2175 "Tatar", "Tamil", "Tadzhik", "Swahili", \ 2176 "Sranan Tongo", "Somali", "Sinhalese", "Shona", \ 2177 "Serbo-croat", "Ruthenian", "Russian", "Quechua", \ 2178 "Pushtu", "Punjabi", "Persian", "Papamiento", \ 2179 "Oriya", "Nepali", "Ndebele", "Marathi", \ 2180 "Moldavian", "Malaysian", "Malagasay", "Macedonian", \ 2181 "Laotian", "Korean", "Khmer", "Kazakh", \ 2182 "Kannada", "Japanese", "Indonesian", "Hindi", \ 2183 "Hebrew", "Hausa", "Gurani", "Gujurati", \ 2184 "Greek", "Georgian", "Fulani", "Dari", \ 2185 "Churash", "Chinese", "Burmese", "Bulgarian", \ 2186 "Bengali", "Bielorussian", "Bambora", "Azerbaijani", \ 2187 "Assamese", "Armenian", "Arabic", "Amharic" 2188 2189 /* This is the list of empty languages names between 0x30 and 0x44. 2190 Together the three macros fill an array of 128 char pointers. 2191 static char *languages[] = { 2192 BURN_CDTEXT_LANGUAGES_0X00, 2193 BURN_CDTEXT_FILLER, 2194 BURN_CDTEXT_LANGUAGES_0X45 2195 }; 2196 */ 2197 #define BURN_CDTEXT_FILLER \ 2198 "", "", "", "", \ 2199 "", "", "", "", \ 2200 "", "", "", "", \ 2201 "", "", "", "", \ 2202 "", "", "", "", \ 2203 "", "", "", "", \ 2204 "" 2205 2206 /* ts B11206 */ 2207 /** Obtain the current settings as of burn_session_set_cdtext_par() 2208 @param s Session which to inquire 2209 @param char_codes Will return Character Codes for block 0 to 7 2210 @param copyrights Will return Copyright bytes for block 0 to 7 2211 @param block_languages Will return Language Codes for block 0 to 7 2212 @param flag Bitfiled for control purposes. Unused yet. Submit 0. 2213 @return <=0 failure, reply invalid, > 0 success, reply valid 2214 @since 1.2.0 2215 */ 2216 int burn_session_get_cdtext_par(struct burn_session *s, 2217 int char_codes[8], int copyrights[8], 2218 int block_languages[8], int flag); 2219 2220 2221 /* ts B11206 */ 2222 /** Attach text or binary data as CD-TEXT attributes to a session. 2223 They can be used to generate CD-TEXT packs by burn_cdtext_from_session() 2224 or to write CD-TEXT packs into the lead-in of a CD SAO session. 2225 The latter happens only if no array of CD-TEXT packs is attached to 2226 the write options by burn_write_opts_set_leadin_text(). 2227 For details of the CD-TEXT format and of the payload content, see file 2228 doc/cdtext.txt . 2229 @param s Session where to attach CD-TEXT attribute 2230 @param block Number of the language block in which the attribute 2231 shall appear. Possible values: 0 to 7. 2232 @param pack_type Pack type number. 0x80 to 0x8e. Used if pack_type_name 2233 is NULL or empty text. Else submit 0 and a name. 2234 Pack type 0x8f is generated automatically and may not 2235 be set by applications. 2236 @param pack_type_name The pack type by name. Defined names are: 2237 0x80 = "TITLE" 0x81 = "PERFORMER" 2238 0x82 = "SONGWRITER" 0x83 = "COMPOSER" 2239 0x84 = "ARRANGER" 0x85 = "MESSAGE" 2240 0x86 = "DISCID" 0x87 = "GENRE" 2241 0x88 = "TOC" 0x89 = "TOC2" 2242 0x8d = "CLOSED" 0x8e = "UPC_ISRC" 2243 Names are recognized uppercase and lowercase. 2244 @param payload Text or binary bytes. The data will be copied to 2245 session-internal memory. 2246 Pack types 0x80 to 0x85 contain 0-terminated cleartext 2247 encoded according to the block's Character Code. 2248 If double byte characters are used, then two 0-bytes 2249 terminate the cleartext. 2250 Pack type 0x86 is 0-terminated ASCII cleartext. 2251 Pack type 0x87 consists of two byte big-endian 2252 Genre code (see below BURN_CDTEXT_GENRE_LIST), and 2253 0-terminated ASCII cleartext of genre description. 2254 Pack type 0x88 mirrors the session table-of-content. 2255 Pack type 0x89 is not understood yet. 2256 Pack types 0x8a to 0x8c are reserved. 2257 Pack type 0x8d contains ISO-8859-1 cleartext which is 2258 not to be shown by commercial audio CD players. 2259 Pack type 0x8e is ASCII cleartext with UPC/EAN code. 2260 @param length Number of bytes in payload. Including terminating 2261 0-bytes. 2262 @param flag Bitfield for control purposes. 2263 bit0= payload contains double byte characters 2264 (with character code 0x80 MS-JIS japanese Kanji) 2265 @return > 0 indicates success , <= 0 is failure 2266 @since 1.2.0 2267 */ 2268 int burn_session_set_cdtext(struct burn_session *s, int block, 2269 int pack_type, char *pack_type_name, 2270 unsigned char *payload, int length, int flag); 2271 2272 2273 /** This is the list of Genres sorted by their Genre codes. 2274 E.g. genre code 0x0000 is "No Used", 0x0008 is "Dance, 0x0010 is "Musical", 2275 0x0018 is "Rhythm & Blues", 0x001b is "World Music". 2276 See also file doc/cdtext.txt. 2277 @since 1.2.0 2278 */ 2279 #define BURN_CDTEXT_GENRE_LIST \ 2280 "Not Used", "Not Defined", "Adult Contemporary", "Alternative Rock", \ 2281 "Childrens Music", "Classical", "Contemporary Christian", "Country", \ 2282 "Dance", "Easy Listening", "Erotic", "Folk", \ 2283 "Gospel", "Hip Hop", "Jazz", "Latin", \ 2284 "Musical", "New Age", "Opera", "Operetta", \ 2285 "Pop Music", "Rap", "Reggae", "Rock Music", \ 2286 "Rhythm & Blues", "Sound Effects", "Spoken Word", "World Music" 2287 2288 /* The number of genre names in BURN_CDTEXT_GENRE_LIST. 2289 */ 2290 #define BURN_CDTEXT_NUM_GENRES 28 2291 2292 2293 /* ts B11206 */ 2294 /** Obtain a CD-TEXT attribute that was set by burn_session_set_cdtext() 2295 @param s Session to inquire 2296 @param block Number of the language block to inquire. 2297 @param pack_type Pack type number to inquire. Used if pack_type_name 2298 is NULL or empty text. Else submit 0 and a name. 2299 Pack type 0x8f is generated automatically and may not 2300 be inquire in advance. Use burn_cdtext_from_session() 2301 to generate all packs including type 0x8f packs. 2302 @param pack_type_name The pack type by name. 2303 See above burn_session_set_cdtext(). 2304 @param payload Will return a pointer to text or binary bytes. 2305 Not a copy of data. Do not free() this address. 2306 If no text attribute is attached for pack type and 2307 block, then payload is returned as NULL. The return 2308 value will not indicate error in this case. 2309 @param length Will return the number of bytes pointed to by payload. 2310 Including terminating 0-bytes. 2311 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2312 @return 1 single byte char, 2 double byte char, <=0 error 2313 @since 1.2.0 2314 */ 2315 int burn_session_get_cdtext(struct burn_session *s, int block, 2316 int pack_type, char *pack_type_name, 2317 unsigned char **payload, int *length, int flag); 2318 2319 2320 /* ts B11215 */ 2321 /** Read a Sony CD-TEXT Input Sheet Version 0.7T file and attach its text 2322 attributes to the given session and its tracks for the given CD-TEXT 2323 block number. This overrides previous settings made by 2324 burn_session_set_cdtext(), burn_track_set_cdtext(), burn_track_set_isrc(), 2325 burn_session_set_start_tno(). It can later be overridden by said function 2326 calls. 2327 The media catalog number from purpose specifier "UPC / EAN" gets into 2328 effect only if burn_write_opts_set_has_mediacatalog() is set to 0. 2329 The format of a v07t sheet file is documented in doc/cdtext.txt. 2330 @param session Session where to attach CD-TEXT attributes 2331 @param path Local filesystem address of the sheet file which 2332 shall be read and interpreted. 2333 @param block Number of the language block in which the attributes 2334 shall appear. Possible values: 0 to 7. 2335 @param flag Bitfield for control purposes. 2336 bit0= Permission to read multiple blocks from the 2337 given sheet file. Each block is supposed to begin 2338 by a line "Input Sheet Version = 0.7T". Therefore 2339 this permission is only valid if the input file 2340 begins by such a line. 2341 @since 1.3.2 2342 bit1= Do not use media catalog string of session or ISRC 2343 strings of tracks for writing to Q sub-channel. 2344 @since 1.2.0 2345 @return > 0 indicates success and the number of interpreted 2346 blocks (1 if not flag bit0 is set). 2347 <= 0 indicates failure 2348 @since 1.2.0 2349 */ 2350 int burn_session_input_sheet_v07t(struct burn_session *session, 2351 char *path, int block, int flag); 2352 2353 2354 /* ts B11210 */ 2355 /** Produce an array of CD-TEXT packs that could be submitted to 2356 burn_write_opts_set_leadin_text(), or stored as *.cdt file, 2357 or submitted to burn_make_input_sheet_v07t(). 2358 For a description of the format of the array, see file doc/cdtext.txt. 2359 The input data stem from burn_session_set_cdtext_par(), 2360 burn_session_set_cdtext(), and burn_track_set_cdtext(). 2361 @param s Session from which to produce CD-TEXT packs. 2362 @param text_packs Will return the buffer with the CD-TEXT packs. 2363 Dispose by free() when no longer needed. 2364 @param num_packs Will return the number of 18 byte text packs. 2365 @param flag Bitfield for control purposes. 2366 bit0= do not return generated CD-TEXT packs, 2367 but check whether production would work and 2368 indicate the number of packs by the call return 2369 value. This happens also if 2370 (text_packs == NULL || num_packs == NULL). 2371 @return Without flag bit0: > 0 is success, <= 0 failure 2372 With flag bit0: > 0 is number of packs, 2373 0 means no packs will be generated, 2374 < 0 means failure 2375 @since 1.2.0 2376 */ 2377 int burn_cdtext_from_session(struct burn_session *s, 2378 unsigned char **text_packs, int *num_packs, 2379 int flag); 2380 2381 2382 /* ts B30519 */ 2383 /** Convert an array of CD-TEXT packs into the text format of 2384 Sony CD-TEXT Input Sheet Version 0.7T . 2385 2386 @param text_packs Array of bytes which form CD-TEXT packs of 18 bytes 2387 each. For a description of the format of the array, 2388 see file doc/cdtext.txt. 2389 No header of 4 bytes must be prepended which would 2390 tell the number of pack bytes + 2. 2391 This parameter may be NULL if the currently attached 2392 array of packs shall be removed. 2393 @param num_packs The number of 18 byte packs in text_packs. 2394 @param start_tno The start number of track counting, if known from 2395 CD table-of-content or other sources. 2396 Submit 0 to enable the attempt to read it and the 2397 track_count from pack type 0x8f. 2398 @param track_count The number of tracks, if known from CD table-of-content 2399 or orther sources. 2400 @param result Will return the buffer with Sheet text. 2401 Dispose by free() when no longer needed. 2402 It will be filled by the text for the v07t sheet file 2403 plus a trailing 0-byte. (Be aware that double-byte 2404 characters might contain 0-bytes, too.) 2405 Each CD-TEXT language block starts by the line 2406 "Input Sheet Version = 0.7T" 2407 and a "Remarks" line that tells the block number. 2408 @param char_code Returns the character code of the pack array: 2409 0x00 = ISO-8859-1 2410 0x01 = 7 bit ASCII 2411 0x80 = MS-JIS (japanese Kanji, double byte characters) 2412 The presence of a code value that is not in this list 2413 will cause this function to fail. 2414 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2415 @return > 0 tells the number of valid text bytes in result. 2416 This does not include the trailing 0-byte. 2417 <= 0 indicates failure. 2418 @since 1.3.2 2419 */ 2420 int burn_make_input_sheet_v07t(unsigned char *text_packs, int num_packs, 2421 int start_tno, int track_count, 2422 char **result, int *char_code, int flag); 2423 2424 2425 /* ts B11206 */ 2426 /** Remove all CD-TEXT attributes of the given block from the session. 2427 They were attached by burn_session_set_cdtext(). 2428 @param s Session where to remove the CD-TEXT attribute 2429 @param block Number of the language block in which the attribute 2430 shall appear. Possible values: 0 to 7. 2431 -1 causes text packs of all blocks to be removed. 2432 @return > 0 is success, <= 0 failure 2433 @since 1.2.0 2434 */ 2435 int burn_session_dispose_cdtext(struct burn_session *s, int block); 2436 2437 2438 /* ts B11221*/ 2439 /** Read an array of CD-TEXT packs from a file. This array should be suitable 2440 for burn_write_opts_set_leadin_text(). 2441 The function tolerates and removes 4-byte headers as produced by 2442 cdrecord -vv -toc, if this header tells the correct number of bytes which 2443 matches the file size. If no 4-byte header is present, then the function 2444 tolerates and removes a trailing 0-byte as of Sony specs. 2445 @param path Filesystem address of the CD-TEXT pack file. 2446 Normally with suffix .cdt or .dat 2447 @param text_packs Will return the buffer with the CD-TEXT packs. 2448 Dispose by free() when no longer needed. 2449 @param num_packs Will return the number of 18 byte text packs. 2450 @param flag Bitfield for control purposes. Unused yet.Submit 0. 2451 @return 0 is success, <= 0 failure 2452 @since 1.2.0 2453 */ 2454 int burn_cdtext_from_packfile(char *path, unsigned char **text_packs, 2455 int *num_packs, int flag); 2456 2457 2458 /** Define the data in a track 2459 @param t the track to define 2460 @param offset The lib will write this many 0s before start of data 2461 @param tail The number of extra 0s to write after data 2462 @param pad 1 means the lib should pad the last sector with 0s if the 2463 track isn't exactly sector sized. (otherwise the lib will 2464 begin reading from the next track) 2465 @param mode data format (bitfield) 2466 */ 2467 void burn_track_define_data(struct burn_track *t, int offset, int tail, 2468 int pad, int mode); 2469 2470 2471 /* ts B11206 */ 2472 /** Attach text or binary data as CD-TEXT attributes to a track. 2473 The payload will be used to generate CD-TEXT packs by 2474 burn_cdtext_from_session() or to write CD-TEXT packs into the lead-in 2475 of a CD SAO session. This happens if the CD-TEXT attribute of the session 2476 gets generated, which has the same block number and pack type. In this 2477 case, each track should have such a CD-TEXT attribute, too. 2478 See burn_session_set_cdtext(). 2479 Be cautious not to exceed the maximum number of 253 payload packs per 2480 language block. Use burn_cdtext_from_session() to learn whether a valid 2481 array of CD-TEXT packs can be generated from your attributes. 2482 @param t Track where to attach CD-TEXT attribute. 2483 @param block Number of the language block in which the attribute 2484 shall appear. Possible values: 0 to 7. 2485 @param pack_type Pack type number. 0x80 to 0x85 or 0x8e. Used if 2486 pack_type_name is NULL or empty text. Else submit 0 2487 and a name. 2488 @param pack_type_name The pack type by name. Applicable names are: 2489 0x80 = "TITLE" 0x81 = "PERFORMER" 2490 0x82 = "SONGWRITER" 0x83 = "COMPOSER" 2491 0x84 = "ARRANGER" 0x85 = "MESSAGE" 2492 0x8e = "UPC_ISRC" 2493 @param payload 0-terminated cleartext. If double byte characters 2494 are used, then two 0-bytes terminate the cleartext. 2495 @param length Number of bytes in payload. Including terminating 2496 0-bytes. 2497 @param flag Bitfield for control purposes. 2498 bit0= payload contains double byte characters 2499 (with character code 0x80 MS-JIS japanese Kanji) 2500 @return > 0 indicates success , <= 0 is failure 2501 @since 1.2.0 2502 */ 2503 int burn_track_set_cdtext(struct burn_track *t, int block, 2504 int pack_type, char *pack_type_name, 2505 unsigned char *payload, int length, int flag); 2506 2507 /* ts B11206 */ 2508 /** Obtain a CD-TEXT attribute that was set by burn_track_set_cdtext(). 2509 @param t Track to inquire 2510 @param block Number of the language block to inquire. 2511 @param pack_type Pack type number to inquire. Used if pack_type_name 2512 is NULL or empty text. Else submit 0 and a name. 2513 @param pack_type_name The pack type by name. 2514 See above burn_track_set_cdtext(). 2515 @param payload Will return a pointer to text bytes. 2516 Not a copy of data. Do not free() this address. 2517 If no text attribute is attached for pack type and 2518 block, then payload is returned as NULL. The return 2519 value will not indicate error in this case. 2520 @param length Will return the number of bytes pointed to by payload. 2521 Including terminating 0-bytes. 2522 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2523 @return 1=single byte char , 2= double byte char , <=0 error 2524 @since 1.2.0 2525 */ 2526 int burn_track_get_cdtext(struct burn_track *t, int block, 2527 int pack_type, char *pack_type_name, 2528 unsigned char **payload, int *length, int flag); 2529 2530 /* ts B11206 */ 2531 /** Remove all CD-TEXT attributes of the given block from the track. 2532 They were attached by burn_track_set_cdtext(). 2533 @param t Track where to remove the CD-TEXT attribute. 2534 @param block Number of the language block in which the attribute 2535 shall appear. Possible values: 0 to 7. 2536 -1 causes text packs of all blocks to be removed. 2537 @return > 0 is success, <= 0 failure 2538 @since 1.2.0 2539 */ 2540 int burn_track_dispose_cdtext(struct burn_track *t, int block); 2541 2542 2543 /* ts A90910 */ 2544 /** Activates CD XA compatibility modes. 2545 libburn currently writes data only in CD mode 1. Some programs insist in 2546 sending data with additional management bytes. These bytes have to be 2547 stripped in order to make the input suitable for BURN_MODE1. 2548 @param t The track to manipulate 2549 @param value 0= no conversion 2550 1= strip 8 byte sector headers of CD-ROM XA mode 2 form 1 2551 see MMC-5 4.2.3.8.5.3 Block Format for Mode 2 form 1 Data 2552 all other values are reserved 2553 @return 1=success , 0=unacceptable value 2554 @since 0.7.2 2555 */ 2556 int burn_track_set_cdxa_conv(struct burn_track *t, int value); 2557 2558 2559 /** Set the ISRC details for a track. When writing to CD media, ISRC will get 2560 written into the Q sub-channel. 2561 @param t The track to change 2562 @param country the 2 char country code. Each character must be 2563 only numbers or letters. 2564 @param owner 3 char owner code. Each character must be only numbers 2565 or letters. 2566 @param year 2 digit year. A number in 0-99 (Yep, not Y2K friendly). 2567 @param serial 5 digit serial number. A number in 0-99999. 2568 */ 2569 void burn_track_set_isrc(struct burn_track *t, char *country, char *owner, 2570 unsigned char year, unsigned int serial); 2571 2572 /* ts B11226 */ 2573 /** Set the composed ISRC string for a track. This is an alternative to 2574 burn_track_set_isrc(). 2575 @param t The track to be manipulated 2576 @param isrc 12 characters which are composed from ISRC details. 2577 Format is CCOOOYYSSSSS, terminated by a 0-byte: 2578 Country, Owner, Year(decimal digits), Serial(decimal digits). 2579 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2580 @return > 0 indicates success, <= 0 means failure 2581 @since 1.2.0 2582 */ 2583 int burn_track_set_isrc_string(struct burn_track *t, char isrc[13], int flag); 2584 2585 /** Disable ISRC parameters for a track 2586 @param t The track to change 2587 */ 2588 void burn_track_clear_isrc(struct burn_track *t); 2589 2590 2591 /* ts B20103 */ 2592 /** Define an index start address within a track. The index numbers inside a 2593 track have to form sequence starting at 0 or 1 with no gaps up to the 2594 highest number used. They affect only writing of CD SAO sessions. 2595 The first index start address of a track must be 0. 2596 Blocks between index 0 and index 1 are considered to be located before the 2597 track start as of the table-of-content. 2598 @param t The track to be manipulated 2599 @param index_number A number between 0 and 99 2600 @param relative_lba The start address relative to the start of the 2601 burn_source of the track. It will get mapped to the 2602 appropriate absolute block address. 2603 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2604 @return > 0 indicates success, <= 0 means failure 2605 @since 1.2.0 2606 */ 2607 int burn_track_set_index(struct burn_track *t, int index_number, 2608 unsigned int relative_lba, int flag); 2609 2610 /* ts B20103 */ 2611 /** Remove all index start addresses and reset to the default indexing of 2612 CD SAO sessions. This means index 0 of track 1 reaches from LBA -150 2613 to LBA -1. Index 1 of track 1 reaches from LBA 0 to track end. Index 1 2614 of track 2 follows immediately. The same happens for all further tracks 2615 after the end of their predecessor. 2616 @param t The track to be manipulated 2617 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2618 @return > 0 indicates success, <= 0 means failure 2619 @since 1.2.0 2620 */ 2621 int burn_track_clear_indice(struct burn_track *t, int flag); 2622 2623 2624 /* ts B20110 */ 2625 /** Define whether a pre-gap shall be written before the track and how many 2626 sectors this pre-gap shall have. A pre-gap is written in the range of track 2627 index 0 and contains zeros (audio silence). No bytes from the track source 2628 will be read for writing the pre-gap. 2629 This setting affects only CD SAO write runs. 2630 The first track automatically gets a pre-gap of at least 150 sectors. Its 2631 size may be enlarged by this call. Further pre-gaps are demanded by MMC 2632 for tracks which follow tracks of a different mode. (But Mode mixing in 2633 CD SAO sessions is currently not supported by libburn.) 2634 @param t The track to change 2635 @param size Number of sectors in the pre-gap. 2636 -1 disables pre-gap, except for the first track. 2637 libburn allows 0, but MMC does not propose this. 2638 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2639 @return > 0 indicates success, <= 0 means failure 2640 @since 1.2.0 2641 */ 2642 int burn_track_set_pregap_size(struct burn_track *t, int size, int flag); 2643 2644 /* ts B20111 */ 2645 /** Define whether a post-gap shall be written at the end of the track and 2646 how many sectors this gap shall have. A post-gap occupies the range of 2647 an additional index of the track. It contains zeros. No bytes from the 2648 track source will be read for writing the post-gap. 2649 This setting affects only CD SAO write runs. 2650 MMC prescribes to add a post-gap to a data track which is followed by 2651 a non-data track. (But libburn does not yet support mixed mode CD SAO 2652 sessions.) 2653 @param t The track to change 2654 @param size Number of sectors in the post-gap. 2655 -1 disables post-gap. 2656 libburn allows 0, but MMC does not propose this. 2657 @param flag Bitfield for control purposes. Unused yet. Submit 0. 2658 @return > 0 indicates success, <= 0 means failure 2659 @since 1.2.0 2660 */ 2661 int burn_track_set_postgap_size(struct burn_track *t, int size, int flag); 2662 2663 2664 /* ts A61024 */ 2665 /** Define whether a track shall swap bytes of its input stream. 2666 @param t The track to change 2667 @param swap_source_bytes 0=do not swap, 1=swap byte pairs 2668 @return 1=success , 0=unacceptable value 2669 @since 0.2.6 2670 */ 2671 int burn_track_set_byte_swap(struct burn_track *t, int swap_source_bytes); 2672 2673 2674 /** Hide the first track in the "pre gap" of the disc 2675 @param s session to change 2676 @param onoff 1 to enable hiding, 0 to disable 2677 */ 2678 void burn_session_hide_first_track(struct burn_session *s, int onoff); 2679 2680 /** Get the drive's disc struct - free when done 2681 @param d drive to query 2682 @return the disc struct or NULL on failure 2683 */ 2684 struct burn_disc *burn_drive_get_disc(struct burn_drive *d); 2685 2686 /** Set the track's data source 2687 @param t The track to set the data source for 2688 @param s The data source to use for the contents of the track 2689 @return An error code stating if the source is ready for use for 2690 writing the track, or if an error occurred 2691 2692 */ 2693 enum burn_source_status burn_track_set_source(struct burn_track *t, 2694 struct burn_source *s); 2695 2696 2697 /* ts A70218 */ 2698 /** Set a default track size to be used only if the track turns out to be of 2699 unpredictable length and if the effective write type demands a fixed size. 2700 This can be useful to enable write types CD SAO or DVD DAO together with 2701 a track source like stdin. If the track source delivers fewer bytes than 2702 announced then the track will be padded up with zeros. 2703 @param t The track to change 2704 @param size The size to set 2705 @return 0=failure 1=success 2706 @since 0.3.4 2707 */ 2708 int burn_track_set_default_size(struct burn_track *t, off_t size); 2709 2710 /** Free a burn_source (decrease its refcount and maybe free it) 2711 @param s Source to free 2712 */ 2713 void burn_source_free(struct burn_source *s); 2714 2715 /** Creates a data source for an image file (and maybe subcode file) 2716 @param path The file address for the main channel payload. 2717 @param subpath Eventual address for subchannel data. Only used in exotic 2718 raw write modes. Submit NULL for normal tasks. 2719 @return Pointer to a burn_source object, NULL indicates failure 2720 */ 2721 struct burn_source *burn_file_source_new(const char *path, 2722 const char *subpath); 2723 2724 2725 /* ts A91122 : An interface to open(O_DIRECT) or similar OS tricks. */ 2726 2727 /** Opens a file with eventual acceleration preparations which may depend 2728 on the operating system and on compile time options of libburn. 2729 You may use this call instead of open(2) for opening file descriptors 2730 which shall be handed to burn_fd_source_new(). 2731 This should only be done for tracks with BURN_BLOCK_MODE1 (2048 bytes 2732 per block). 2733 2734 If you use this call then you MUST allocate the buffers which you use 2735 with read(2) by call burn_os_alloc_buffer(). Read sizes MUST be a multiple 2736 of a safe buffer amount. Else you risk that track data get altered during 2737 transmission. 2738 burn_disk_write() will allocate a suitable read/write buffer for its own 2739 operations. A fifo created by burn_fifo_source_new() will allocate 2740 suitable memory for its buffer if called with flag bit0 and a multiple 2741 of a safe buffer amount. 2742 @param path The file address to open 2743 @param open_flags The flags as of man 2 open. Normally just O_RDONLY. 2744 @param flag Bitfield for control purposes (unused yet, submit 0). 2745 @return A file descriptor as of open(2). Finally to be disposed 2746 by close(2). 2747 -1 indicates failure. 2748 @since 0.7.4 2749 */ 2750 int burn_os_open_track_src(char *path, int open_flags, int flag); 2751 2752 /** Allocate a memory area that is suitable for reading with a file descriptor 2753 opened by burn_os_open_track_src(). 2754 @param amount Number of bytes to allocate. This should be a multiple 2755 of the operating system's i/o block size. 32 KB is 2756 guaranteed by libburn to be safe. 2757 @param flag Bitfield for control purposes (unused yet, submit 0). 2758 @return The address of the allocated memory, or NULL on failure. 2759 A non-NULL return value has finally to be disposed via 2760 burn_os_free_buffer(). 2761 @since 0.7.4 2762 */ 2763 void *burn_os_alloc_buffer(size_t amount, int flag); 2764 2765 /** Dispose a memory area which was obtained by burn_os_alloc_buffer(), 2766 @param buffer Memory address to be freed. 2767 @param amount The number of bytes which was allocated at that 2768 address. 2769 @param flag Bitfield for control purposes (unused yet, submit 0). 2770 @return 1 success , <=0 failure 2771 @since 0.7.4 2772 */ 2773 int burn_os_free_buffer(void *buffer, size_t amount, int flag); 2774 2775 2776 /** Creates a data source for an image file (a track) from an open 2777 readable filedescriptor, an eventually open readable subcodes file 2778 descriptor and eventually a fixed size in bytes. 2779 @param datafd The source of data. 2780 @param subfd The eventual source of subchannel data. Only used in exotic 2781 raw write modes. Submit -1 for normal tasks. 2782 @param size The eventual fixed size of eventually both fds. 2783 If this value is 0, the size will be determined from datafd. 2784 @return Pointer to a burn_source object, NULL indicates failure 2785 */ 2786 struct burn_source *burn_fd_source_new(int datafd, int subfd, off_t size); 2787 2788 2789 /* ts B00922 */ 2790 /** Creates an offset source which shall provide a byte interval of a stream 2791 to its consumer. It is supposed to be chain-linked with other offset 2792 sources which serve neighboring consumers. The chronological sequence 2793 of consumers and the sequence of offset sources must match. The intervals 2794 of the sources must not overlap. 2795 2796 A chain of these burn_source objects may be used to feed multiple tracks 2797 from one single stream of input bytes. 2798 Each of the offset sources will skip the bytes up to its start address and 2799 provide the prescribed number of bytes to the track. Skipping takes into 2800 respect the bytes which have been processed by eventual predecessors in the 2801 chain. 2802 Important: It is not allowed to free an offset source before its successor 2803 has ended its work. Best is to keep them all until all tracks 2804 are done. 2805 2806 @param inp The burn_source object from which to read stream data. 2807 E.g. created by burn_file_source_new(). 2808 @param prev The eventual offset source object which shall read data from 2809 inp before the new offset source will begin its own work. 2810 This must either be a result of burn_offst_source_new() or 2811 it must be NULL. 2812 @param start The byte address where to start reading bytes for the 2813 consumer. inp bytes may get skipped to reach this address. 2814 @param size The number of bytes to be delivered to the consumer. 2815 If size is <= 0 then it may be set later by a call of method 2816 set_size(). If it is >= 0, then it can only be changed if 2817 flag bit0 was set with burn_offst_source_new(). 2818 @param flag Bitfield for control purposes 2819 bit0 = Prevent set_size() from overriding interval sizes > 0. 2820 If such a size is already set, then the new one will 2821 only affect the reply of get_size(). 2822 See also above struct burn_source. 2823 @since 1.2.0 2824 @return Pointer to a burn_source object, later to be freed by 2825 burn_source_free(). NULL indicates failure. 2826 @since 0.8.8 2827 */ 2828 struct burn_source *burn_offst_source_new( 2829 struct burn_source *inp, struct burn_source *prev, 2830 off_t start, off_t size, int flag); 2831 2832 /* ts A70930 */ 2833 /** Creates a fifo which acts as proxy for an already existing data source. 2834 The fifo provides a ring buffer which shall smoothen the data stream 2835 between burn_source and writer thread. Each fifo serves only for one 2836 data source. It may be attached to one track as its only data source 2837 by burn_track_set_source(), or it may be used as input for other burn 2838 sources. 2839 A fifo starts its life in "standby" mode with no buffer space allocated. 2840 As soon as its consumer requires bytes, the fifo establishes a worker 2841 thread and allocates its buffer. After input has ended and all buffer 2842 content is consumed, the buffer space gets freed and the worker thread 2843 ends. This happens asynchronously. So expect two buffers and worker threads 2844 to exist for a short time between tracks. Be modest in your size demands if 2845 multiple tracks are to be expected. 2846 @param inp The burn_source for which the fifo shall act as proxy. 2847 It can be disposed by burn_source_free() immediately 2848 after this call. 2849 @param chunksize The size in bytes of a chunk. 2850 Use 2048 for sources suitable for BURN_BLOCK_MODE1, 2851 2352 for sources which deliver for BURN_BLOCK_AUDIO, 2852 2056 for sources which shall get treated by 2853 burn_track_set_cdxa_conv(track, 1). 2854 Some variations of burn_source might work only with 2855 a particular chunksize. E.g. libisofs demands 2048. 2856 @param chunks The number of chunks to be allocated in ring buffer. 2857 This value must be >= 2. 2858 @param flag Bitfield for control purposes: 2859 bit0= The read method of inp is capable of delivering 2860 arbitrary amounts of data per call. Not only one 2861 sector. 2862 Suitable for inp from burn_file_source_new() 2863 and burn_fd_source_new() if not the fd has 2864 exotic limitations on read size. 2865 You MUST use this on inp which uses an fd opened 2866 with burn_os_open_track_src(). 2867 Better do not use with other inp types. 2868 @since 0.7.4 2869 @return A pointer to the newly created burn_source. 2870 Later both burn_sources, inp and the returned fifo, have 2871 to be disposed by calling burn_source_free() for each. 2872 inp can be freed immediately, the returned fifo may be 2873 kept as handle for burn_fifo_inquire_status(). 2874 @since 0.4.0 2875 */ 2876 struct burn_source *burn_fifo_source_new(struct burn_source *inp, 2877 int chunksize, int chunks, int flag); 2878 2879 /* ts A71003 */ 2880 /** Inquires state and fill parameters of a fifo burn_source which was created 2881 by burn_fifo_source_new() . Do not use with other burn_source variants. 2882 @param fifo The fifo object to inquire 2883 @param size The total size of the fifo 2884 @param free_bytes The current free capacity of the fifo 2885 @param status_text Returns a pointer to a constant text, see below 2886 @return <0 reply invalid, >=0 fifo status code: 2887 bit0+1=input status, bit2=consumption status, i.e: 2888 0="standby" : data processing not started yet 2889 1="active" : input and consumption are active 2890 2="ending" : input has ended without error 2891 3="failing" : input had error and ended, 2892 4="unused" : ( consumption has ended before processing start ) 2893 5="abandoned" : consumption has ended prematurely 2894 6="ended" : consumption has ended without input error 2895 7="aborted" : consumption has ended after input error 2896 @since 0.4.0 2897 */ 2898 int burn_fifo_inquire_status(struct burn_source *fifo, int *size, 2899 int *free_bytes, char **status_text); 2900 2901 /* ts A91125 */ 2902 /** Inquire various counters which reflect the fifo operation. 2903 @param fifo The fifo object to inquire 2904 @param total_min_fill The minimum number of bytes in the fifo. Beginning 2905 from the moment when fifo consumption is enabled. 2906 @param interval_min_fill The minimum byte number beginning from the moment 2907 when fifo consumption is enabled or from the 2908 most recent moment when burn_fifo_next_interval() 2909 was called. 2910 @param put_counter The number of data transactions into the fifo. 2911 @param get_counter The number of data transactions out of the fifo. 2912 @param empty_counter The number of times the fifo was empty. 2913 @param full_counter The number of times the fifo was full. 2914 @since 0.7.4 2915 */ 2916 void burn_fifo_get_statistics(struct burn_source *fifo, 2917 int *total_min_fill, int *interval_min_fill, 2918 int *put_counter, int *get_counter, 2919 int *empty_counter, int *full_counter); 2920 2921 /* ts A91125 */ 2922 /** Inquire the fifo minimum fill counter for intervals and reset that counter. 2923 @param fifo The fifo object to inquire 2924 @param interval_min_fill The minimum number of bytes in the fifo. Beginning 2925 from the moment when fifo consumption is enabled 2926 or from the most recent moment when 2927 burn_fifo_next_interval() was called. 2928 @since 0.7.4 2929 */ 2930 void burn_fifo_next_interval(struct burn_source *fifo, int *interval_min_fill); 2931 2932 /* ts A80713 */ 2933 /** Obtain a preview of the first input data of a fifo which was created 2934 by burn_fifo_source_new(). The data will later be delivered normally to 2935 the consumer track of the fifo. 2936 bufsize may not be larger than the fifo size (chunk_size * chunks) - 32k. 2937 This call will succeed only if data consumption by the track has not 2938 started yet, i.e. best before the call to burn_disc_write(). 2939 It will start the worker thread of the fifo with the expectable side 2940 effects on the external data source. Then it waits either until enough 2941 data have arrived or until it becomes clear that this will not happen. 2942 The call may be repeated with increased bufsize. It will always yield 2943 the bytes beginning from the first one in the fifo. 2944 @param fifo The fifo object to start and to inquire 2945 @param buf Pointer to memory of at least bufsize bytes where to 2946 deliver the peeked data. 2947 @param bufsize Number of bytes to peek from the start of the fifo data 2948 @param flag Bitfield for control purposes (unused yet, submit 0). 2949 @return <0 on severe error, 0 if not enough data, 1 if bufsize bytes read 2950 @since 0.5.0 2951 */ 2952 int burn_fifo_peek_data(struct burn_source *fifo, char *buf, int bufsize, 2953 int flag); 2954 2955 /* ts A91125 */ 2956 /** Start the fifo worker thread and wait either until the requested number 2957 of bytes have arrived or until it becomes clear that this will not happen. 2958 Filling will go on asynchronously after burn_fifo_fill() returned. 2959 This call and burn_fifo_peek_data() do not disturb each other. 2960 @param fifo The fifo object to start 2961 @param fill Number of bytes desired. Expect to get return 1 if 2962 at least fifo size - 32k were read. 2963 @param flag Bitfield for control purposes. 2964 bit0= fill fifo to maximum size 2965 @return <0 on severe error, 0 if not enough data, 2966 1 if desired amount or fifo full 2967 @since 0.7.4 2968 */ 2969 int burn_fifo_fill(struct burn_source *fifo, int fill, int flag); 2970 2971 2972 /* ts A70328 */ 2973 /** Sets a fixed track size after the data source object has already been 2974 created. 2975 @param t The track to operate on 2976 @param size the number of bytes to use as track size 2977 @return <=0 indicates failure , >0 success 2978 @since 0.3.6 2979 */ 2980 int burn_track_set_size(struct burn_track *t, off_t size); 2981 2982 2983 /** Tells how many sectors a track will have on disc, or already has on 2984 disc. This includes offset, payload, tail, and post-gap, but not pre-gap. 2985 The result is NOT RELIABLE with tracks of undefined length 2986 */ 2987 int burn_track_get_sectors(struct burn_track *); 2988 2989 2990 /* ts A61101 */ 2991 /** Tells how many source bytes have been read and how many data bytes have 2992 been written by the track during burn. 2993 @param t The track to inquire 2994 @param read_bytes Number of bytes read from the track source 2995 @param written_bytes Number of bytes written to track 2996 @since 0.2.6 2997 */ 2998 int burn_track_get_counters(struct burn_track *t, 2999 off_t *read_bytes, off_t *written_bytes); 3000 3001 3002 /** Sets drive read and write speed. 3003 Note: "k" is 1000, not 1024. 3004 1xCD = 176.4 k/s, 1xDVD = 1385 k/s, 1xBD = 4496 k/s. 3005 Fractional speeds should be rounded up. Like 4xCD = 706. 3006 @param d The drive to set speed for 3007 @param read Read speed in k/s (0 is max, -1 is min). 3008 @param write Write speed in k/s (0 is max, -1 is min). 3009 */ 3010 void burn_drive_set_speed(struct burn_drive *d, int read, int write); 3011 3012 3013 /* ts C00822 */ 3014 /** Sets drive read and write speed using the "Exact" bit of SCSI command 3015 SET STREAMING. This command will be used even if a CD medium is present. 3016 MMC specifies that with the Exact bit the desired speed settings shall 3017 either be obeyed by the drive exactly, or that the drive shall indicate 3018 failure and not accept the settings. 3019 But many drives reply no error and nevertheless adjust their read speed 3020 only coarsly or ignore the setting after a few MB of fast read attempts. 3021 3022 The call parameters have the same meaning as with burn_drive_set_speed(). 3023 @param d The drive to set speed for. It must be a role 1 drive. 3024 @param read Read speed in k/s (0 is max, -1 is min). 3025 @param write Write speed in k/s (0 is max, -1 is min). 3026 @return 1=success , 0=failure 3027 @since 1.5.4 3028 */ 3029 int burn_drive_set_speed_exact(struct burn_drive *d, int read, int write); 3030 3031 3032 /* ts C00822 */ 3033 /** Waits until the time has elapsed since the given previous time to transmit 3034 the given byte count with the given speed in KB/second (KB = 1000 bytes). 3035 This call may be used between random access read operations like 3036 burn_read_data() in order to force a slower speed than the drive is 3037 willing to use if it gets read requests as fast as it delivers data. 3038 3039 The parameter us_corr carries microseconds of time deviations from one 3040 call to the next one. Such deviations may happen because of small 3041 inexactnesses of the sleeper function and because of temporary delays 3042 in the data supply so that sleeping for a negative time span would have 3043 been necessary. The next call will reduce or enlarge its own sleeping 3044 period by this value. 3045 3046 @param kb_per_second the desired speed in 1000 bytes per second. 3047 Supplied by the caller. 3048 @max_corr the maximum backlog in microseconds which shall 3049 be compensated by the next call. Supplied by the 3050 caller. Not more than 1 billion = 1000 seconds. 3051 @param prev_time time keeper updated by burn_nominal_slowdown(). 3052 The caller provides the memory and elsewise should 3053 carry it unchanged from call to call. 3054 @param us_corr updated by burn_nominal_slowdown(). See above. 3055 The caller provides the memory and elsewise should 3056 carry it unchanged from call to call. 3057 @param b_since_prev byte count since the previous call. This number 3058 has to be counted and supplied by the caller. 3059 @param flag Bitfield for control purposes: 3060 bit0= initialize *prev_time and *us_corr, 3061 ignore other parameters, do not wait 3062 @return 2=no wait because no usable kb_per_second , 1=success , 0=failure 3063 @since 1.5.4 3064 */ 3065 int burn_nominal_slowdown(int kb_per_second, int max_corr, 3066 struct timeval *prev_time, 3067 int *us_corr, off_t b_since_prev, int flag); 3068 3069 3070 /* ts A70711 */ 3071 /** Controls the behavior with writing when the drive buffer is suspected to 3072 be full. To check and wait for enough free buffer space before writing 3073 will move the task of waiting from the operating system's device driver 3074 to libburn. While writing is going on and waiting is enabled, any write 3075 operation will be checked whether it will fill the drive buffer up to 3076 more than max_percent. If so, then waiting will happen until the buffer 3077 fill is predicted with at most min_percent. 3078 Thus: if min_percent < max_percent then transfer rate will oscillate. 3079 This may allow the driver to operate on other devices, e.g. a disk from 3080 which to read the input for writing. On the other hand, this checking might 3081 reduce maximum throughput to the drive or even get misled by faulty buffer 3082 fill replies from the drive. 3083 If a setting parameter is < 0, then this setting will stay unchanged 3084 by the call. 3085 Known burner or media specific pitfalls: 3086 To have max_percent larger than the burner's best reported buffer fill has 3087 the same effect as min_percent==max_percent. Some burners do not report 3088 their full buffer with all media types. Some are not suitable because 3089 they report their buffer fill with delay. Some do not go to full speed 3090 unless their buffer is full. 3091 3092 @param d The drive to control 3093 @param enable 0= disable , 1= enable waiting , (-1 = do not change setting) 3094 @param min_usec Shortest possible sleeping period (given in micro seconds) 3095 @param max_usec Longest possible sleeping period (given in micro seconds) 3096 @param timeout_sec If a single write has to wait longer than this number 3097 of seconds, then waiting gets disabled and mindless 3098 writing starts. A value of 0 disables this timeout. 3099 @param min_percent Minimum of desired buffer oscillation: 25 to 100 3100 @param max_percent Maximum of desired buffer oscillation: 25 to 100 3101 @return 1=success , 0=failure 3102 @since 0.3.8 3103 */ 3104 int burn_drive_set_buffer_waiting(struct burn_drive *d, int enable, 3105 int min_usec, int max_usec, int timeout_sec, 3106 int min_percent, int max_percent); 3107 3108 /* ts B61116 */ 3109 /** Control the write simulation mode before or after burn_write_opts get 3110 into effect. 3111 Beginning with version 1.4.8 a burn run by burn_disc_write() brings the 3112 burn_drive object in the simulation state as set to the burn_write_opts 3113 by burn_write_opts_set_simulate(). This state is respected by call 3114 burn_random_access_write() until a new call of burn_disc_write() happens 3115 or until burn_drive_reset_simulate() is called. 3116 This call may only be made when burn_drive_get_status() returns 3117 BURN_DRIVE_IDLE. 3118 3119 @param d The drive to control 3120 @param simulate 1 enables simulation, 0 enables real writing 3121 @return 1=success , 0=failure 3122 @since 1.4.8 3123 */ 3124 int burn_drive_reset_simulate(struct burn_drive *d, int simulate); 3125 3126 3127 /* these are for my [Derek Foreman's ?] debugging, they will disappear */ 3128 /* ts B11012 : 3129 Of course, API symbols will not disappear. But these functions are of 3130 few use, as they only print DEBUG messages. 3131 */ 3132 void burn_structure_print_disc(struct burn_disc *d); 3133 void burn_structure_print_session(struct burn_session *s); 3134 void burn_structure_print_track(struct burn_track *t); 3135 3136 /** Sets the write type for the write_opts struct. 3137 Note: write_type BURN_WRITE_SAO is currently not capable of writing a mix 3138 of data and audio tracks. You must use BURN_WRITE_TAO for such sessions. 3139 @param opts The write opts to change 3140 @param write_type The write type to use 3141 @param block_type The block type to use 3142 @return Returns 1 on success and 0 on failure. 3143 */ 3144 int burn_write_opts_set_write_type(struct burn_write_opts *opts, 3145 enum burn_write_types write_type, 3146 int block_type); 3147 3148 3149 /* ts A70207 */ 3150 /** As an alternative to burn_write_opts_set_write_type() this function tries 3151 to find a suitable write type and block type for a given write job 3152 described by opts and disc. To be used after all other setups have been 3153 made, i.e. immediately before burn_disc_write(). 3154 @param opts The nearly complete write opts to change 3155 @param disc The already composed session and track model 3156 @param reasons This text string collects reasons for decision or failure 3157 @param flag Bitfield for control purposes: 3158 bit0= do not choose type but check the one that is already set 3159 bit1= do not issue error messages via burn_msgs queue 3160 (is automatically set with bit0) 3161 @return Chosen write type. BURN_WRITE_NONE on failure. 3162 @since 0.3.2 3163 */ 3164 enum burn_write_types burn_write_opts_auto_write_type( 3165 struct burn_write_opts *opts, struct burn_disc *disc, 3166 char reasons[BURN_REASONS_LEN], int flag); 3167 3168 3169 /** Supplies toc entries for writing - not normally required for cd mastering 3170 @param opts The write opts to change 3171 @param count The number of entries 3172 @param toc_entries 3173 */ 3174 void burn_write_opts_set_toc_entries(struct burn_write_opts *opts, 3175 int count, 3176 struct burn_toc_entry *toc_entries); 3177 3178 /** Sets the session format for a disc 3179 @param opts The write opts to change 3180 @param format The session format to set 3181 */ 3182 void burn_write_opts_set_format(struct burn_write_opts *opts, int format); 3183 3184 /** Sets the simulate value for the write_opts struct . 3185 This corresponds to the Test Write bit in MMC mode page 05h. Several media 3186 types do not support this. See struct burn_multi_caps.might_simulate for 3187 actual availability of this feature. 3188 If the media is suitable, the drive will perform burn_disc_write() as a 3189 simulation instead of effective write operations. This means that the 3190 media content and burn_disc_get_status() stay unchanged. 3191 Note: With stdio-drives, the target file gets eventually created, opened, 3192 lseeked, and closed, but not written. So there are effects on it. 3193 Note: Up to version 1.4.6 the call burn_random_access_write() after 3194 burn_disc_write() did not simulate because it does not get any 3195 burn_write_opts and the drive did not memorize the simulation state. 3196 This has changed now. burn_random_access_write() will not write after 3197 a simulated burn run. 3198 Use burn_drive_reset_simulate(drive, 0) if you really want to end 3199 simulation before you call burn_disc_write() with new write options. 3200 @param opts The write opts to change 3201 @param sim Non-zero enables simulation, 0 enables real writing 3202 @return Returns 1 on success and 0 on failure. 3203 */ 3204 int burn_write_opts_set_simulate(struct burn_write_opts *opts, int sim); 3205 3206 /** Controls buffer underrun prevention. This is only needed with CD media 3207 and possibly with old DVD-R drives. All other media types are not 3208 vulnerable to burn failure due to buffer underrun. 3209 @param opts The write opts to change 3210 @param underrun_proof if non-zero, buffer underrun protection is enabled 3211 @return Returns 1 if the drive announces to be capable of underrun 3212 prevention, 3213 Returns 0 if not. 3214 */ 3215 int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts, 3216 int underrun_proof); 3217 3218 /** Sets whether to use opc or not with the write_opts struct 3219 @param opts The write opts to change 3220 @param opc If non-zero, optical power calibration will be performed at 3221 start of burn 3222 3223 */ 3224 void burn_write_opts_set_perform_opc(struct burn_write_opts *opts, int opc); 3225 3226 3227 /** The Q sub-channel of a CD may contain a Media Catalog Number of 13 decimal 3228 digits. This call sets the string of digits, but does not yet activate it 3229 for writing. 3230 @param opts The write opts to change 3231 @param mediacatalog The 13 decimal digits as ASCII bytes. I.e. '0' = 0x30. 3232 */ 3233 void burn_write_opts_set_mediacatalog(struct burn_write_opts *opts, 3234 unsigned char mediacatalog[13]); 3235 3236 /** This call activates the Media Catalog Number for writing. The digits of 3237 that number have to be set by call burn_write_opts_set_mediacatalog(). 3238 @param opts The write opts to change 3239 @param has_mediacatalog 1= activate writing of catalog to Q sub-channel 3240 0= deactivate it 3241 */ 3242 void burn_write_opts_set_has_mediacatalog(struct burn_write_opts *opts, 3243 int has_mediacatalog); 3244 3245 3246 /* ts A61106 */ 3247 /** Sets the multi flag which eventually marks the emerging session as not 3248 being the last one and thus creating a BURN_DISC_APPENDABLE media. 3249 Note: DVD-R[W] in write mode BURN_WRITE_SAO are not capable of this. 3250 DVD-R DL are not capable of this at all. 3251 libburn will refuse to write if burn_write_opts_set_multi() is 3252 enabled under such conditions. 3253 @param opts The option object to be manipulated 3254 @param multi 1=media will be appendable, 0=media will be closed (default) 3255 @since 0.2.6 3256 */ 3257 void burn_write_opts_set_multi(struct burn_write_opts *opts, int multi); 3258 3259 3260 /* ts B31024 */ 3261 /** Set the severity to be used with write error messages which are potentially 3262 caused by not using write type BURN_WRITE_SAO on fast blanked DVD-RW. 3263 3264 Normally the call burn_write_opts_auto_write_type() can prevent such 3265 errors by looking for MMC feature 21h "Incremental Streaming Writable" 3266 which anounnces the capability for BURN_WRITE_TAO and multi session. 3267 Regrettable many drives announce feature 21h even if they only can do 3268 BURN_WRITE_SAO. This mistake becomes obvious by an early write error. 3269 3270 If you plan to call burn_drive_was_feat21_failure() and to repeat the 3271 burn attempt with BURN_WRITE_SAO, then set the severity of the error 3272 message low enough, so that the application does not see reason to abort. 3273 3274 @param opts The option object to be manipulated 3275 @param severity Severity as with burn_msgs_set_severities(). 3276 "ALL" or empty text means the default severity that 3277 is attributed to other kinds of write errors. 3278 */ 3279 void burn_write_opts_set_fail21h_sev(struct burn_write_opts *opts, 3280 char *severity); 3281 3282 /* ts B11204 */ 3283 /** Submit an array of CD-TEXT packs which shall be written to the Lead-in 3284 of a SAO write run on CD. 3285 @param opts The option object to be manipulated 3286 @param text_packs Array of bytes which form CD-TEXT packs of 18 bytes 3287 each. For a description of the format of the array, 3288 see file doc/cdtext.txt. 3289 No header of 4 bytes must be prepended which would 3290 tell the number of pack bytes + 2. 3291 This parameter may be NULL if the currently attached 3292 array of packs shall be removed. 3293 @param num_packs The number of 18 byte packs in text_packs. 3294 This parameter may be 0 if the currently attached 3295 array of packs shall be removed. 3296 @param flag Bitfield for control purposes. 3297 bit0= do not verify checksums 3298 bit1= repair mismatching checksums 3299 bit2= repair checksums if they are 00 00 with each pack 3300 @return 1 on success, <= 0 on failure 3301 @since 1.2.0 3302 */ 3303 int burn_write_opts_set_leadin_text(struct burn_write_opts *opts, 3304 unsigned char *text_packs, 3305 int num_packs, int flag); 3306 3307 3308 /* ts A61222 */ 3309 /** Sets a start address for writing to media and write modes which are able 3310 to choose this address at all (for now: DVD+RW, DVD-RAM, formatted DVD-RW). 3311 now). The address is given in bytes. If it is not -1 then a write run 3312 will fail if choice of start address is not supported or if the block 3313 alignment of the address is not suitable for media and write mode. 3314 Alignment to 32 kB blocks is supposed to be safe with DVD media. 3315 Call burn_disc_get_multi_caps() can obtain the necessary media info. See 3316 resulting struct burn_multi_caps elements .start_adr , .start_alignment , 3317 .start_range_low , .start_range_high . 3318 @param opts The write opts to change 3319 @param value The address in bytes (-1 = start at default address) 3320 @since 0.3.0 3321 */ 3322 void burn_write_opts_set_start_byte(struct burn_write_opts *opts, off_t value); 3323 3324 3325 /* ts A70213 */ 3326 /** Caution: still immature and likely to change. Problems arose with 3327 sequential DVD-RW on one drive. 3328 3329 Controls whether the whole available space of the media shall be filled up 3330 by the last track of the last session. 3331 @param opts The write opts to change 3332 @param fill_up_media If 1 : fill up by last track, if 0 = do not fill up 3333 @since 0.3.4 3334 */ 3335 void burn_write_opts_set_fillup(struct burn_write_opts *opts, 3336 int fill_up_media); 3337 3338 3339 /* ts A70303 */ 3340 /** Eventually makes libburn ignore the failure of some conformance checks: 3341 - the check whether CD write+block type is supported by the drive 3342 - the check whether the media profile supports simulated burning 3343 @param opts The write opts to change 3344 @param use_force 1=ignore above checks, 0=refuse work on failed check 3345 @since 0.3.4 3346 */ 3347 void burn_write_opts_set_force(struct burn_write_opts *opts, int use_force); 3348 3349 3350 /* ts A80412 */ 3351 /** Eventually makes use of the more modern write command AAh WRITE12 and 3352 sets the Streaming bit. With DVD-RAM and BD this can override the 3353 traditional slowdown to half nominal speed. But if it speeds up writing 3354 then it also disables error management and correction. Weigh your 3355 priorities. This affects the write operations of burn_disc_write() 3356 and subsequent calls of burn_random_access_write(). 3357 @param opts The write opts to change 3358 @param value 0=use 2Ah WRITE10, 1=use AAh WRITE12 with Streaming bit 3359 @since 0.6.4: 3360 >=16 use WRITE12 but not before the LBA given by value 3361 @since 0.4.6 3362 */ 3363 void burn_write_opts_set_stream_recording(struct burn_write_opts *opts, 3364 int value); 3365 3366 /* ts A91115 */ 3367 /** Overrides the write chunk size for DVD and BD media which is normally 3368 determined according to media type and setting of stream recording. 3369 A chunk size of 64 KB may improve throughput with bus systems which show 3370 latency problems. 3371 @param opts The write opts to change 3372 @param obs Number of bytes which shall be sent by a single write command. 3373 0 means automatic size, 32768 and 65336 are the only other 3374 accepted sizes for now. 3375 @since 0.7.4 3376 */ 3377 void burn_write_opts_set_dvd_obs(struct burn_write_opts *opts, int obs); 3378 3379 3380 /* ts B20406 */ 3381 /** Overrides the automatic decision whether to pad up the last write chunk to 3382 its full size. This applies to DVD, BD and stdio: pseudo-drives. 3383 Note: This override may get enabled fixely already at compile time by 3384 defining macro Libburn_dvd_always_obs_paD . 3385 @param opts The write opts to change 3386 @param pad 1 means to pad up in any case, 0 means automatic decision. 3387 @since 1.2.4 3388 */ 3389 void burn_write_opts_set_obs_pad(struct burn_write_opts *opts, int pad); 3390 3391 3392 /* ts A91115 */ 3393 /** Sets the rhythm by which stdio pseudo drives force their output data to 3394 be consumed by the receiving storage device. This forcing keeps the memory 3395 from being clogged with lots of pending data for slow devices. 3396 @param opts The write opts to change 3397 @param rhythm Number of 2KB output blocks after which fsync(2) is 3398 performed. 3399 -1 means no fsync() 3400 0 means default 3401 1 means fsync() only at end, @since 1.3.8 (noop before 1.3.8) 3402 elsewise the value must be >= 32. 3403 Default is currently 8192 = 16 MB. 3404 @since 0.7.4 3405 */ 3406 void burn_write_opts_set_stdio_fsync(struct burn_write_opts *opts, int rhythm); 3407 3408 3409 /** Sets whether to read in raw mode or not 3410 @param opts The read opts to change 3411 @param raw_mode If non-zero, reading will be done in raw mode, so that everything in the data tracks on the 3412 disc is read, including headers. 3413 */ 3414 void burn_read_opts_set_raw(struct burn_read_opts *opts, int raw_mode); 3415 3416 /** Sets whether to report c2 errors or not 3417 @param opts The read opts to change 3418 @param c2errors If non-zero, report c2 errors. 3419 */ 3420 void burn_read_opts_set_c2errors(struct burn_read_opts *opts, int c2errors); 3421 3422 /** Sets whether to read subcodes from audio tracks or not 3423 @param opts The read opts to change 3424 @param subcodes_audio If non-zero, read subcodes from audio tracks on the disc. 3425 */ 3426 void burn_read_opts_read_subcodes_audio(struct burn_read_opts *opts, 3427 int subcodes_audio); 3428 3429 /** Sets whether to read subcodes from data tracks or not 3430 @param opts The read opts to change 3431 @param subcodes_data If non-zero, read subcodes from data tracks on the disc. 3432 */ 3433 void burn_read_opts_read_subcodes_data(struct burn_read_opts *opts, 3434 int subcodes_data); 3435 3436 /** Sets whether to recover errors if possible 3437 @param opts The read opts to change 3438 @param hardware_error_recovery If non-zero, attempt to recover errors if possible. 3439 */ 3440 void burn_read_opts_set_hardware_error_recovery(struct burn_read_opts *opts, 3441 int hardware_error_recovery); 3442 3443 /** Sets whether to report recovered errors or not 3444 @param opts The read opts to change 3445 @param report_recovered_errors If non-zero, recovered errors will be reported. 3446 */ 3447 void burn_read_opts_report_recovered_errors(struct burn_read_opts *opts, 3448 int report_recovered_errors); 3449 3450 /** Sets whether blocks with unrecoverable errors should be read or not 3451 @param opts The read opts to change 3452 @param transfer_damaged_blocks If non-zero, blocks with unrecoverable errors will still be read. 3453 */ 3454 void burn_read_opts_transfer_damaged_blocks(struct burn_read_opts *opts, 3455 int transfer_damaged_blocks); 3456 3457 /** Sets the number of retries to attempt when trying to correct an error 3458 @param opts The read opts to change 3459 @param hardware_error_retries The number of retries to attempt when correcting an error. 3460 */ 3461 void burn_read_opts_set_hardware_error_retries(struct burn_read_opts *opts, 3462 unsigned char hardware_error_retries); 3463 3464 3465 /* ts A90815 */ 3466 /** Gets the list of profile codes supported by the drive. 3467 Profiles depict the feature sets which constitute media types. For 3468 known profile codes and names see burn_disc_get_profile(). 3469 @param d is the drive to query 3470 @param num_profiles returns the number of supported profiles 3471 @param profiles returns the profile codes 3472 @param is_current returns the status of the corresponding profile code: 3473 1= current, i.e. the matching media is loaded 3474 0= not current, i.e. the matching media is not loaded 3475 @return always 1 for now 3476 @since 0.7.0 3477 */ 3478 int burn_drive_get_all_profiles(struct burn_drive *d, int *num_profiles, 3479 int profiles[64], char is_current[64]); 3480 3481 3482 /* ts A90815 */ 3483 /** Obtains the profile name associated with a profile code. 3484 @param profile_code the profile code to be translated 3485 @param name returns the profile name (e.g. "DVD+RW") 3486 @return 1= known profile code , 0= unknown profile code 3487 @since 0.7.0 3488 */ 3489 int burn_obtain_profile_name(int profile_code, char name[80]); 3490 3491 3492 /* ts B90414 */ 3493 /** Obtains the list of SCSI Feature Codes from feature descriptors which 3494 were obtained from the drive when it was most recently acquired or 3495 re-assessed. 3496 @param d Drive to query 3497 @param count Returns the number of allocated elements in feature_codes 3498 @param feature_codes Returns the allocated array of feature codes. 3499 If returned *feature_codes is not NULL, dispose it 3500 by free() when it is no longer needed. 3501 @since 1.5.2 3502 */ 3503 void burn_drive_get_feature_codes(struct burn_drive *d, 3504 int *count, unsigned int **feature_codes); 3505 3506 /* ts B90414 */ 3507 /** Obtains the fields and data of a particular feature which were obtained 3508 from the drive when it was last acquired or re-assessed. See MMC specs 3509 for full detail. 3510 @param d Drive to query 3511 @param feature_code A number as learned by burn_drive_get_feature_codes() 3512 @param flags Returns byte 2 of the feature descriptor: 3513 bit0= Current 3514 bit1= Persistent 3515 bit2-5= Version 3516 @param additional_length Returns byte 3 of descriptor. 3517 This is the size of feature_data. 3518 @param feature_data Returns further bytes of descriptor. 3519 If returned *feature_data is not NULL, dispose it 3520 by free() when it is no longer needed. 3521 @param feature_text Returns text representation of the feature descriptor: 3522 Code +/- : Name : Version,P/N : Hex bytes : Parsed info 3523 Current features are marked by "+", others by "-". 3524 Persistent features are marked by "P", others by "N". 3525 feature_text may be submitted as NULL. In this case 3526 no text is generated and returned. 3527 If returned *feature_text is not NULL, dispose it 3528 by free() when it is no longer needed. 3529 @return 0 feature descriptor is not present 3530 -1 out of memory 3531 >0 success 3532 @since 1.5.2 3533 */ 3534 int burn_drive_get_feature(struct burn_drive *d, unsigned int feature_code, 3535 unsigned char *flags, 3536 unsigned char *additional_length, 3537 unsigned char **feature_data, 3538 char **feature_text); 3539 3540 3541 /** Gets the maximum write speed for a drive and eventually loaded media. 3542 The return value might change by the media type of already loaded media, 3543 again by call burn_drive_grab() and again by call burn_disc_read_atip(). 3544 @param d Drive to query 3545 @return Maximum write speed in K/s 3546 */ 3547 int burn_drive_get_write_speed(struct burn_drive *d); 3548 3549 3550 /* ts A61021 */ 3551 /** Gets the minimum write speed for a drive and eventually loaded media. 3552 The return value might change by the media type of already loaded media, 3553 again by call burn_drive_grab() and again by call burn_disc_read_atip(). 3554 @param d Drive to query 3555 @return Minimum write speed in K/s 3556 @since 0.2.6 3557 */ 3558 int burn_drive_get_min_write_speed(struct burn_drive *d); 3559 3560 3561 /** Gets the maximum read speed for a drive 3562 @param d Drive to query 3563 @return Maximum read speed in K/s 3564 */ 3565 int burn_drive_get_read_speed(struct burn_drive *d); 3566 3567 3568 /* ts A61226 */ 3569 /** Obtain a copy of the current speed descriptor list. The drive's list gets 3570 updated on various occasions such as burn_drive_grab() but the copy 3571 obtained here stays untouched. It has to be disposed via 3572 burn_drive_free_speedlist() when it is not longer needed. Speeds 3573 may appear several times in the list. The list content depends much on 3574 drive and media type. It seems that .source == 1 applies mostly to CD media 3575 whereas .source == 2 applies to any media. 3576 @param d Drive to query 3577 @param speed_list The copy. If empty, *speed_list gets returned as NULL. 3578 @return 1=success , 0=list empty , <0 severe error 3579 @since 0.3.0 3580 */ 3581 int burn_drive_get_speedlist(struct burn_drive *d, 3582 struct burn_speed_descriptor **speed_list); 3583 3584 /* ts A70713 */ 3585 /** Look up the fastest speed descriptor which is not faster than the given 3586 speed_goal. If it is 0, then the fastest one is chosen among the 3587 descriptors with the highest end_lba. If it is -1 then the slowest speed 3588 descriptor is chosen regardless of end_lba. Parameter flag decides whether 3589 the speed goal means write speed or read speed. 3590 @param d Drive to query 3591 @param speed_goal Upper limit for speed, 3592 0=search for maximum speed , -1 search for minimum speed 3593 @param best_descr Result of the search, NULL if no match 3594 @param flag Bitfield for control purposes 3595 bit0= look for best read speed rather than write speed 3596 bit1= look for any source type (else look for source==2 first 3597 and for any other source type only with CD media) 3598 @return >0 indicates a valid best_descr, 0 = no valid best_descr 3599 @since 0.3.8 3600 */ 3601 int burn_drive_get_best_speed(struct burn_drive *d, int speed_goal, 3602 struct burn_speed_descriptor **best_descr, int flag); 3603 3604 3605 /* ts A61226 */ 3606 /** Dispose a speed descriptor list copy which was obtained by 3607 burn_drive_get_speedlist(). 3608 @param speed_list The list copy. *speed_list gets set to NULL. 3609 @return 1=list disposed , 0= *speedlist was already NULL 3610 @since 0.3.0 3611 */ 3612 int burn_drive_free_speedlist(struct burn_speed_descriptor **speed_list); 3613 3614 3615 /* ts A70203 */ 3616 /* @since 0.3.2 */ 3617 /** The reply structure for burn_disc_get_multi_caps() 3618 */ 3619 struct burn_multi_caps { 3620 3621 /* Multi-session capability can keep the media appendable after 3622 writing a session. It also guarantees that the drive will be able 3623 to predict and use the appropriate Next Writeable Address to place 3624 the next session on the media without overwriting the existing ones. 3625 It does not guarantee that the selected write type is able to do 3626 an appending session after the next session. (E.g. CD SAO is capable 3627 of multi-session by keeping a disc appendable. But .might_do_sao 3628 will be 0 afterwards, when checking the appendable media.) 3629 1= media may be kept appendable by burn_write_opts_set_multi(o,1) 3630 0= media will not be appendable 3631 */ 3632 int multi_session; 3633 3634 /* Multi-track capability can write more than one track source 3635 during a single session. The written tracks can later be found in 3636 libburn's TOC model with their start addresses and sizes. 3637 1= multiple tracks per session are allowed 3638 0= only one track per session allowed 3639 */ 3640 int multi_track; 3641 3642 /* Start-address capability can set a non-zero address with 3643 burn_write_opts_set_start_byte(). Eventually this has to respect 3644 .start_alignment and .start_range_low, .start_range_high in this 3645 structure. 3646 1= non-zero start address is allowed 3647 0= only start address 0 is allowed (to depict the drive's own idea 3648 about the appropriate write start) 3649 */ 3650 int start_adr; 3651 3652 /** The alignment for start addresses. 3653 ( start_address % start_alignment ) must be 0. 3654 */ 3655 off_t start_alignment; 3656 3657 /** The lowest permissible start address. 3658 */ 3659 off_t start_range_low; 3660 3661 /** The highest addressable start address. 3662 */ 3663 off_t start_range_high; 3664 3665 /** Potential availability of write modes 3666 4= needs no size prediction, not to be chosen automatically 3667 3= needs size prediction, not to be chosen automatically 3668 2= available, no size prediction necessary 3669 1= available, needs exact size prediction 3670 0= not available 3671 With CD media (profiles 0x09 and 0x0a) check also the elements 3672 *_block_types of the according write mode. 3673 */ 3674 int might_do_tao; 3675 int might_do_sao; 3676 int might_do_raw; 3677 3678 /** Generally advised write mode. 3679 Not necessarily the one chosen by burn_write_opts_auto_write_type() 3680 because the burn_disc structure might impose particular demands. 3681 */ 3682 enum burn_write_types advised_write_mode; 3683 3684 /** Write mode as given by parameter wt of burn_disc_get_multi_caps(). 3685 */ 3686 enum burn_write_types selected_write_mode; 3687 3688 /** Profile number which was current when the reply was generated */ 3689 int current_profile; 3690 3691 /** Whether the current profile indicates CD media. 1=yes, 0=no */ 3692 int current_is_cd_profile; 3693 3694 /* ts A70528 */ 3695 /* @since 0.3.8 */ 3696 /** Whether the current profile is able to perform simulated write */ 3697 int might_simulate; 3698 }; 3699 3700 /** Allocates a struct burn_multi_caps (see above) and fills it with values 3701 which are appropriate for the drive and the loaded media. The drive 3702 must be grabbed for this call. The returned structure has to be disposed 3703 via burn_disc_free_multi_caps() when no longer needed. 3704 @param d The drive to inquire 3705 @param wt With BURN_WRITE_NONE the best capabilities of all write modes 3706 get returned. If set to a write mode like BURN_WRITE_SAO the 3707 capabilities with that particular mode are returned and the 3708 return value is 0 if the desired mode is not possible. 3709 @param caps returns the info structure 3710 @param flag Bitfield for control purposes (unused yet, submit 0) 3711 @return < 0 : error , 0 : writing seems impossible , 1 : writing possible 3712 @since 0.3.2 3713 */ 3714 int burn_disc_get_multi_caps(struct burn_drive *d, enum burn_write_types wt, 3715 struct burn_multi_caps **caps, int flag); 3716 3717 /** Removes from memory a multi session info structure which was returned by 3718 burn_disc_get_multi_caps(). The pointer *caps gets set to NULL. 3719 @param caps the info structure to dispose (note: pointer to pointer) 3720 @return 0 : *caps was already NULL, 1 : memory object was disposed 3721 @since 0.3.2 3722 */ 3723 int burn_disc_free_multi_caps(struct burn_multi_caps **caps); 3724 3725 3726 /** Gets a copy of the toc_entry structure associated with a track 3727 @param t Track to get the entry from 3728 @param entry Struct for the library to fill out 3729 */ 3730 void burn_track_get_entry(struct burn_track *t, struct burn_toc_entry *entry); 3731 3732 /** Gets a copy of the toc_entry structure associated with a session's lead out 3733 @param s Session to get the entry from 3734 @param entry Struct for the library to fill out 3735 */ 3736 void burn_session_get_leadout_entry(struct burn_session *s, 3737 struct burn_toc_entry *entry); 3738 3739 /** Gets an array of all complete sessions for the disc 3740 THIS IS NO LONGER VALID AFTER YOU ADD OR REMOVE A SESSION 3741 The result array contains *num + burn_disc_get_incomplete_sessions() 3742 elements. All above *num are incomplete sessions. 3743 Typically there is at most one incomplete session with one empty track. 3744 DVD+R and BD-R seem support more than one track with even readable data. 3745 @param d Disc to get session array for 3746 @param num Returns the number of sessions in the array 3747 @return array of sessions 3748 */ 3749 struct burn_session **burn_disc_get_sessions(struct burn_disc *d, 3750 int *num); 3751 3752 /* ts B30112 */ 3753 /* @since 1.2.8 */ 3754 /** Obtains the number of incomplete sessions which are recorded in the 3755 result array of burn_disc_get_sessions() after the complete sessions. 3756 See above. 3757 @param d Disc object to inquire 3758 @return Number of incomplete sessions 3759 */ 3760 int burn_disc_get_incomplete_sessions(struct burn_disc *d); 3761 3762 3763 int burn_disc_get_sectors(struct burn_disc *d); 3764 3765 /** Gets an array of all the tracks for a session 3766 THIS IS NO LONGER VALID AFTER YOU ADD OR REMOVE A TRACK 3767 @param s session to get track array for 3768 @param num Returns the number of tracks in the array 3769 @return array of tracks 3770 */ 3771 struct burn_track **burn_session_get_tracks(struct burn_session *s, 3772 int *num); 3773 3774 int burn_session_get_sectors(struct burn_session *s); 3775 3776 /** Gets the mode of a track 3777 @param track the track to query 3778 @return the track's mode 3779 */ 3780 int burn_track_get_mode(struct burn_track *track); 3781 3782 /** Returns whether the first track of a session is hidden in the pregap 3783 @param session the session to query 3784 @return non-zero means the first track is hidden 3785 */ 3786 int burn_session_get_hidefirst(struct burn_session *session); 3787 3788 /** Returns the library's version in its parts. 3789 This is the runtime counterpart of the three build time macros 3790 burn_header_version_* below. 3791 @param major The major version number 3792 @param minor The minor version number 3793 @param micro The micro version number 3794 */ 3795 void burn_version(int *major, int *minor, int *micro); 3796 3797 3798 /* ts A80129 */ 3799 /* @since 0.4.4 */ 3800 /** These three release version numbers tell the revision of this header file 3801 and of the API it describes. They are memorized by applications at build 3802 time. 3803 Immediately after burn_initialize() an application should do this check: 3804 burn_version(&major, &minor, µ); 3805 if(major > burn_header_version_major 3806 || (major == burn_header_version_major 3807 && (minor > burn_header_version_minor 3808 || (minor == burn_header_version_minor 3809 && micro >= burn_header_version_micro)))) { 3810 ... Young enough. Go on with program run .... 3811 } else { 3812 ... Too old. Do not use this libburn version ... 3813 } 3814 3815 */ 3816 #define burn_header_version_major 1 3817 #define burn_header_version_minor 5 3818 #define burn_header_version_micro 4 3819 /** Note: 3820 Above version numbers are also recorded in configure.ac because libtool 3821 wants them as parameters at build time. 3822 For the library compatibility check, BURN_*_VERSION in configure.ac 3823 are not decisive. Only the three numbers above do matter. 3824 */ 3825 /** Usage discussion: 3826 3827 Some developers of the libburnia project have differing 3828 opinions how to ensure the compatibility of libraries 3829 and applications. 3830 3831 It is about whether to use at compile time and at runtime 3832 the version numbers isoburn_header_version_* provided here. 3833 Thomas Schmitt advises to use them. 3834 Vreixo Formoso advises to use other means. 3835 3836 At compile time: 3837 3838 Vreixo Formoso advises to leave proper version matching 3839 to properly programmed checks in the the application's 3840 build system, which will eventually refuse compilation. 3841 3842 Thomas Schmitt advises to use the macros defined here 3843 for comparison with the application's requirements of 3844 library revisions and to eventually break compilation. 3845 3846 Both advises are combinable. I.e. be master of your 3847 build system and have #if checks in the source code 3848 of your application, nevertheless. 3849 3850 At runtime (via *_is_compatible()): 3851 3852 Vreixo Formoso advises to compare the application's 3853 requirements of library revisions with the runtime 3854 library. This is to enable runtime libraries which are 3855 young enough for the application but too old for 3856 the lib*.h files seen at compile time. 3857 3858 Thomas Schmitt advises to compare the header 3859 revisions defined here with the runtime library. 3860 This is to enforce a strictly monotonous chain 3861 of revisions from app to header to library, 3862 at the cost of excluding some older libraries. 3863 3864 These two advises are mutually exclusive. 3865 3866 */ 3867 3868 /* ts A91226 */ 3869 /** Obtain the id string of the SCSI transport interface. 3870 This interface may be a system specific adapter module of libburn or 3871 an adapter to a supporting library like libcdio. 3872 @param flag Bitfield for control puposes, submit 0 for now 3873 @return A pointer to the id string. Do not alter the string content. 3874 @since 0.7.6 3875 */ 3876 char *burn_scsi_transport_id(int flag); 3877 3878 /* ts A60924 : ticket 74 */ 3879 /** Control queueing and stderr printing of messages from libburn. 3880 Severity may be one of "NEVER", "ABORT", "FATAL", "FAILURE", "SORRY", 3881 "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL". 3882 @param queue_severity Gives the minimum limit for messages to be queued. 3883 Default: "NEVER". If you queue messages then you 3884 must consume them by burn_msgs_obtain(). 3885 @param print_severity Does the same for messages to be printed directly 3886 to stderr. Default: "FATAL". 3887 @param print_id A text prefix to be printed before the message. 3888 @return >0 for success, <=0 for error 3889 @since 0.2.6 3890 */ 3891 int burn_msgs_set_severities(char *queue_severity, 3892 char *print_severity, char *print_id); 3893 3894 /* ts A60924 : ticket 74 */ 3895 /* @since 0.2.6 */ 3896 #define BURN_MSGS_MESSAGE_LEN 4096 3897 3898 /** Obtain the oldest pending libburn message from the queue which has at 3899 least the given minimum_severity. This message and any older message of 3900 lower severity will get discarded from the queue and is then lost forever. 3901 @param minimum_severity may be one of "NEVER", "ABORT", "FATAL", 3902 "FAILURE", "SORRY", "WARNING", "HINT", "NOTE", "UPDATE", 3903 "DEBUG", "ALL". 3904 To call with minimum_severity "NEVER" will discard the 3905 whole queue. 3906 @param error_code Will become a unique error code as listed in 3907 libburn/libdax_msgs.h 3908 @param msg_text Must provide at least BURN_MSGS_MESSAGE_LEN bytes. 3909 @param os_errno Will become the eventual errno related to the message 3910 @param severity Will become the severity related to the message and 3911 should provide at least 80 bytes. 3912 @return 1 if a matching item was found, 0 if not, <0 for severe errors 3913 @since 0.2.6 3914 */ 3915 int burn_msgs_obtain(char *minimum_severity, 3916 int *error_code, char msg_text[], int *os_errno, 3917 char severity[]); 3918 3919 3920 /* ts A70922 */ 3921 /** Submit a message to the libburn queueing system. It will be queued or 3922 printed as if it was generated by libburn itself. 3923 @param error_code The unique error code of your message. 3924 Submit 0 if you do not have reserved error codes within 3925 the libburnia project. 3926 @param msg_text Not more than BURN_MSGS_MESSAGE_LEN characters of 3927 message text. 3928 @param os_errno Eventual errno related to the message. Submit 0 if 3929 the message is not related to a operating system error. 3930 @param severity One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING", 3931 "HINT", "NOTE", "UPDATE", "DEBUG". Defaults to "FATAL". 3932 @param d An eventual drive to which the message shall be related. 3933 Submit NULL if the message is not specific to a 3934 particular drive object. 3935 @return 1 if message was delivered, <=0 if failure 3936 @since 0.4.0 3937 */ 3938 int burn_msgs_submit(int error_code, char msg_text[], int os_errno, 3939 char severity[], struct burn_drive *d); 3940 3941 3942 /* ts A71016 */ 3943 /** Convert a severity name into a severity number, which gives the severity 3944 rank of the name. 3945 @param severity_name A name as with burn_msgs_submit(), e.g. "SORRY". 3946 @param severity_number The rank number: the higher, the more severe. 3947 @param flag Bitfield for control purposes (unused yet, submit 0) 3948 @return >0 success, <=0 failure 3949 @since 0.4.0 3950 */ 3951 int burn_text_to_sev(char *severity_name, int *severity_number, int flag); 3952 3953 3954 /* ts A80202 */ 3955 /** Convert a severity number into a severity name 3956 @param severity_number The rank number: the higher, the more severe. 3957 @param severity_name A name as with burn_msgs_submit(), e.g. "SORRY". 3958 @param flag Bitfield for control purposes (unused yet, submit 0) 3959 @return >0 success, <=0 failure 3960 @since 0.4.4 3961 */ 3962 int burn_sev_to_text(int severity_number, char **severity_name, int flag); 3963 3964 3965 /* ts B21214 */ 3966 /** Return a blank separated list of severity names. Sorted from low 3967 to high severity. 3968 @param flag Bitfield for control purposes (unused yet, submit 0) 3969 @return A constant string with the severity names 3970 @since 1.2.6 3971 */ 3972 char *burn_list_sev_texts(int flag); 3973 3974 3975 /* ts A70915 */ 3976 /** Replace the messenger object handle of libburn by a compatible handle 3977 obtained from a related library. 3978 See also: libisofs, API function iso_get_messenger(). 3979 @param messenger The foreign but compatible message handle. 3980 @return 1 : success, <=0 : failure 3981 @since 0.4.0 3982 */ 3983 int burn_set_messenger(void *messenger); 3984 3985 3986 /* ts A61002 */ 3987 /* @since 0.2.6 */ 3988 /** The prototype of a handler function suitable for burn_set_signal_handling() 3989 Such a function has to return -2 if it does not want the process to 3990 exit with value 1. 3991 */ 3992 typedef int (*burn_abort_handler_t)(void *handle, int signum, int flag); 3993 3994 /** Control built-in signal handling. Either by setting an own handler or 3995 by activating the built-in signal handler. 3996 3997 A function parameter handle of NULL activates the built-in abort handler. 3998 Depending on mode it may cancel all drive operations, wait for all drives 3999 to become idle, exit(1). It may also prepare function 4000 burn_drive_get_status() for waiting and performing exit(1). 4001 Parameter handle may be NULL or a text that shall be used as prefix for 4002 pacifier messages of burn_abort_pacifier(). Other than with an application 4003 provided handler, the prefix char array does not have to be kept existing 4004 until the eventual signal event. 4005 Before version 0.7.8 only action 0 was available. I.e. the built-in handler 4006 waited for the drives to become idle and then performed exit(1) directly. 4007 But during burn_disc_write() onto real CD or DVD, FreeBSD 8.0 pauses the 4008 other threads until the signal handler returns. 4009 The new actions try to avoid this deadlock. It is advised to use action 3 4010 at least during burn_disc_write(), burn_disc_erase(), burn_disc_format(): 4011 burn_set_signal_handling(text, NULL, 0x30); 4012 and to call burn_is_aborting(0) when the drive is BURN_DRIVE_IDLE. 4013 If burn_is_aborting(0) returns 1, then call burn_abort() and exit(1). 4014 4015 @param handle Opaque handle eventually pointing to an application 4016 provided memory object 4017 @param handler A function to be called on signals, if the handling bits 4018 in parameter mode are set 0. 4019 It will get parameter handle as argument. flag will be 0. 4020 It should finally call burn_abort(). See there. 4021 If the handler function returns 2 or -2, then the wrapping 4022 signal handler of libburn will return and let the program 4023 continue its operations. Any other return value causes 4024 exit(1). 4025 @param mode : bit0 - bit3: Handling of received signals: 4026 0 Install libburn wrapping signal handler, which will call 4027 handler(handle, signum, 0) on nearly all signals 4028 1 Enable system default reaction on all signals 4029 2 Try to ignore nearly all signals 4030 10 like mode 2 but handle SIGABRT like with mode 0 4031 bit4 - bit7: With handler == NULL : 4032 Action of built-in handler. "control thread" is the one 4033 which called burn_set_signal_handling(). 4034 All actions activate receive mode 2 to ignore further 4035 signals. 4036 0 Same as 1 (for pre-0.7.8 backward compatibility) 4037 @since 0.7.8 4038 1 Catch the control thread in abort handler, call 4039 burn_abort() with a patience value > 0 and 4040 finally exit(1). Does not always work with FreeBSD. 4041 2 Call burn_abort() with patience -1 and return from 4042 handler. When the control thread calls 4043 burn_drive_get_status(), then call burn_abort() 4044 with patience 1 instead, and finally exit(1). 4045 Does not always work with FreeBSD. 4046 3 Call burn_abort() with patience -1, return from handler. 4047 It is duty of the application to detect a pending abort 4048 condition by calling burn_is_aborting() and to wait for 4049 all drives to become idle. E.g. by calling burn_abort() 4050 with patience >0. 4051 4 Like 3, but without calling burn_abort() with -1. Only 4052 the indicator of burn_is_aborting() gets set. 4053 bit8: @since 1.3.2 4054 try to ignore SIGPIPE (regardless of bit0 - bit3) 4055 4056 @since 0.2.6 4057 */ 4058 void burn_set_signal_handling(void *handle, burn_abort_handler_t handler, 4059 int mode); 4060 4061 4062 /* ts B00304 */ 4063 /* Inquire whether the built-in abort handler was triggered by a signal. 4064 This has to be done to detect pending abort handling if signal handling 4065 was set to the built-in handler and action was set to 2 or 3. 4066 @param flag Bitfield for control purposes (unused yet, submit 0) 4067 @return 0 = no abort was triggered 4068 >0 = action that was triggered (action 0 is reported as 1) 4069 @since 0.7.8 4070 */ 4071 int burn_is_aborting(int flag); 4072 4073 4074 /* ts A70811 */ 4075 /** Write data in random access mode. 4076 The drive must be grabbed successfully before calling this function which 4077 circumvents usual libburn session processing and rather writes data without 4078 preparations or finalizing. This will work only with overwritable media 4079 which are also suitable for burn_write_opts_set_start_byte(). The same 4080 address alignment restrictions as with this function apply. I.e. for DVD 4081 it is best to align to 32 KiB blocks (= 16 LBA units). The amount of data 4082 to be written is subject to the same media dependent alignment rules. 4083 Again, 32 KiB is most safe. 4084 Call burn_disc_get_multi_caps() can obtain the necessary media info. See 4085 resulting struct burn_multi_caps elements .start_adr , .start_alignment , 4086 .start_range_low , .start_range_high . 4087 Other than burn_disc_write() this is a synchronous call which returns 4088 only after the write transaction has ended (successfully or not). So it is 4089 wise not to transfer giant amounts of data in a single call. 4090 Important: Data have to fit into the already formatted area of the media. 4091 4092 If the burn_drive object is in simulation mode, then no actual write 4093 operation or synchronization of the drive buffer will happen. 4094 See burn_drive_reset_simulate(). 4095 4096 @param d The drive to which to write 4097 @param byte_address The start address of the write in byte 4098 (1 LBA unit = 2048 bytes) (do respect media alignment) 4099 @param data The bytes to be written 4100 @param data_count The number of those bytes (do respect media alignment) 4101 data_count == 0 is permitted (e.g. to flush the 4102 drive buffer without further data transfer). 4103 @param flag Bitfield for control purposes: 4104 bit0 = flush the drive buffer after eventual writing 4105 @return 1=successful , <=0 : number of transferred bytes * -1 4106 @since 0.4.0 4107 */ 4108 int burn_random_access_write(struct burn_drive *d, off_t byte_address, 4109 char *data, off_t data_count, int flag); 4110 4111 4112 /* ts A81215 */ 4113 /** Inquire the maximum amount of readable data. 4114 On DVD and BD it is supposed that all LBAs in the range from 0 to 4115 capacity - 1 can be read via burn_read_data() although some of them may 4116 never have been recorded. With multi-session CD there have to be 4117 expected unreadable TAO Run-out blocks. 4118 If tracks are recognizable then it is better to only read LBAs which 4119 are part of some track and on CD to be cautious about the last two blocks 4120 of each track which might be TAO Run-out blocks. 4121 If the drive is actually a large file or block device, then the capacity 4122 is curbed to a maximum of 0x7ffffff0 blocks = 4 TB - 32 KB. 4123 @param d The drive from which to read 4124 @param capacity Will return the result if valid 4125 @param flag Bitfield for control purposes: Unused yet, submit 0. 4126 @return 1=successful , <=0 an error occurred 4127 @since 0.6.0 4128 */ 4129 int burn_get_read_capacity(struct burn_drive *d, int *capacity, int flag); 4130 4131 4132 /* ts A70812 */ 4133 /** Read data in random access mode. 4134 The drive must be grabbed successfully before calling this function. 4135 With all currently supported drives and media the byte_address has to 4136 be aligned to 2048 bytes. Only data tracks with 2048 bytes per sector 4137 can be read this way. I.e. not CD-audio, not CD-video-stream ... 4138 This is a synchronous call which returns only after the full read job 4139 has ended (successfully or not). So it is wise not to read giant amounts 4140 of data in a single call. 4141 @param d The drive from which to read 4142 @param byte_address The start address of the read in byte (aligned to 2048) 4143 @param data A memory buffer capable of taking data_size bytes 4144 @param data_size The amount of data to be read. This does not have to 4145 be aligned to any block size. 4146 @param data_count The amount of data actually read (interesting on error) 4147 The counted bytes are supposed to be valid. 4148 @param flag Bitfield for control purposes: 4149 bit0= - reserved - 4150 bit1= do not submit error message if read error 4151 bit2= on error do not try to read a second time 4152 with single block steps. 4153 @since 0.5.2 4154 bit3= return -2 on permission denied error rather than 4155 issuing a warning message. 4156 @since 1.0.6 4157 bit4= return -3 on SCSI error 4158 5 64 00 ILLEGAL MODE FOR THIS TRACK 4159 and prevent this error from being reported as 4160 event message. Do not retry reading in this case. 4161 (Useful to try the last two blocks of a CD 4162 track which might be non-data because of TAO.) 4163 @since 1.2.6 4164 bit5= issue messages with severity DEBUG if they would 4165 be suppressed by bit1. 4166 @since 1.4.0 4167 @return 1=successful , <=0 an error occurred 4168 with bit3: -2= permission denied error 4169 @since 0.4.0 4170 */ 4171 int burn_read_data(struct burn_drive *d, off_t byte_address, 4172 char data[], off_t data_size, off_t *data_count, int flag); 4173 4174 4175 /* ts B21119 */ 4176 /** Read CD audio sectors in random access mode. 4177 The drive must be grabbed successfully before calling this function. 4178 Only CD audio tracks with 2352 bytes per sector can be read this way. 4179 I.e. not data tracks, not CD-video-stream, ... 4180 4181 Note that audio data do not have exact block addressing. If you read a 4182 sequence of successive blocks then you will get a seamless stream 4183 of data. But the actual start and end position of this audio stream 4184 will differ by a few dozens of milliseconds, depending on individual 4185 CD and individual drive. 4186 Expect leading and trailing zeros, as well as slight truncation. 4187 4188 @param d The drive from which to read. 4189 It must be a real MMC drive (i.e. not a stdio file) 4190 and it must have a CD loaded (i.e. not DVD or BD). 4191 @param sector_no The sector number (Logical Block Address) 4192 It may be slightly below 0, depending on drive and 4193 medium. -150 is a lower limit. 4194 @param data A memory buffer capable of taking data_size bytes 4195 @param data_size The amount of data to be read. This must be aligned 4196 to full multiples of 2352. 4197 @param data_count The amount of data actually read (interesting on error) 4198 @param flag Bitfield for control purposes: 4199 bit0= - reserved - 4200 bit1= do not submit error message if read error 4201 bit2= on error do not try to read a second time 4202 with single block steps. 4203 bit3= Enable DAP : "flaw obscuring mechanisms like 4204 audio data mute and interpolate" 4205 bit4= return -3 on SCSI error 4206 5 64 00 ILLEGAL MODE FOR THIS TRACK 4207 and prevent this error from being reported as 4208 event message. Do not retry reading in this case. 4209 (Useful to try the last two blocks of a CD 4210 track which might be non-audio because of TAO.) 4211 bit5= issue messages with severity DEBUG if they would 4212 be suppressed by bit1. 4213 @since 1.4.0 4214 @return 1=successful , <=0 an error occurred 4215 with bit3: -2= permission denied error 4216 @since 1.2.6 4217 */ 4218 int burn_read_audio(struct burn_drive *d, int sector_no, 4219 char data[], off_t data_size, off_t *data_count, int flag); 4220 4221 4222 /* ts B30522 */ 4223 /** Extract an interval of audio sectors from CD and store it as a WAVE 4224 audio file on hard disk. 4225 4226 @param drive The drive from which to read. 4227 @param start_sector The logical block address of the first audio sector 4228 which shall be read. 4229 @param sector_count The number of audio sectors to be read. 4230 Each sector consists of 2352 bytes. 4231 @param target_path The address of the file where to store the extracted 4232 audio data. Will be opened O_WRONLY | O_CREAT. 4233 The file name should have suffix ".wav". 4234 @param flag Bitfield for control purposes: 4235 bit0= Report about progress by UPDATE messages 4236 bit3= Enable DAP : "flaw obscuring mechanisms like 4237 audio data mute and interpolate" 4238 @since 1.3.2 4239 */ 4240 int burn_drive_extract_audio(struct burn_drive *drive, 4241 int start_sector, int sector_count, 4242 char *target_path, int flag); 4243 4244 4245 /* ts B30522 */ 4246 /** Extract all audio sectors of a track from CD and store them as a WAVE 4247 audio file on hard disk. 4248 4249 @param drive The drive from which to read. 4250 @param track The track which shall be extracted. 4251 @param target_path The address of the file where to store the extracted 4252 audio data. Will be opened O_WRONLY | O_CREAT. 4253 The file name should have suffix ".wav". 4254 @param flag Bitfield for control purposes: 4255 bit0= Report about progress by UPDATE messages 4256 bit3= Enable DAP : "flaw obscuring mechanisms like 4257 audio data mute and interpolate" 4258 @since 1.3.2 4259 */ 4260 int burn_drive_extract_audio_track(struct burn_drive *drive, 4261 struct burn_track *track, 4262 char *target_path, int flag); 4263 4264 4265 /* ts A70904 */ 4266 /** Inquire whether the drive object is a real MMC drive or a pseudo-drive 4267 created by a stdio: address. 4268 @param d The drive to inquire 4269 @return 0= null-drive 4270 1= real MMC drive 4271 2= stdio-drive, random access, read-write 4272 3= stdio-drive, sequential, write-only 4273 4= stdio-drive, random access, read-only 4274 (only if enabled by burn_allow_drive_role_4()) 4275 5= stdio-drive, random access, write-only 4276 (only if enabled by burn_allow_drive_role_4()) 4277 @since 0.4.0 4278 */ 4279 int burn_drive_get_drive_role(struct burn_drive *d); 4280 4281 4282 /* ts B10312 */ 4283 /** Allow drive role 4 "random access read-only" 4284 and drive role 5 "random access write-only". 4285 By default a random access file assumes drive role 2 "read-write" 4286 regardless whether it is actually readable or writeable. 4287 If enabled, random-access file objects which recognizably permit no 4288 writing will be classified as role 4 and those which permit no reading 4289 will get role 5. 4290 Candidates are drive addresses of the form stdio:/dev/fd/# , where # is 4291 the integer number of an open file descriptor. If this descriptor was 4292 opened read-only or write-only, then it gets role 4 or role 5, 4293 respectively. 4294 Other paths may get tested by an attempt to open them for read-write 4295 (role 2) or read-only (role 4) or write-only (role 5). See bit1. 4296 @param allowed Bitfield for control purposes: 4297 bit0= Enable roles 4 and 5 for drives which get 4298 acquired after this call 4299 bit1= with bit0: 4300 Test whether the file can be opened for 4301 read-write, read-only, or write-only. 4302 Classify as roles 2, 4, 5. 4303 bit2= with bit0 and bit1: 4304 Classify files which cannot be opened at all 4305 as role 0 : useless dummy. 4306 Else classify as role 2. 4307 bit3= Classify non-empty role 5 drives as 4308 BURN_DISC_APPENDABLE with Next Writeable Address 4309 after the end of the file. It is nevertheless 4310 possible to change this address by call 4311 burn_write_opts_set_start_byte(). 4312 @since 1.0.6 4313 */ 4314 void burn_allow_drive_role_4(int allowed); 4315 4316 4317 /* ts A70923 */ 4318 /** Find out whether a given address string would lead to the given drive 4319 object. This should be done in advance for track source addresses 4320 with parameter drive_role set to 2. 4321 Although a real MMC drive should hardly exist as two drive objects at 4322 the same time, this can easily happen with stdio-drives. So if more than 4323 one drive is used by the application, then this gesture is advised: 4324 burn_drive_d_get_adr(d2, adr2); 4325 if (burn_drive_equals_adr(d1, adr2, burn_drive_get_drive_role(d2))) 4326 ... Both drive objects point to the same storage facility ... 4327 4328 @param d1 Existing drive object 4329 @param adr2 Address string to be tested. Prefix "stdio:" overrides 4330 parameter drive_role2 by either 0 or 2 as appropriate. 4331 The string must be shorter than BURN_DRIVE_ADR_LEN. 4332 @param drive_role2 Role as burn_drive_get_drive_role() would attribute 4333 to adr2 if it was a drive. Use value 2 for checking track 4334 sources or pseudo-drive addresses without "stdio:". 4335 Use 1 for checking drive addresses including those with 4336 prefix "stdio:". 4337 @return 1= adr2 leads to d1 , 0= adr2 seems not to lead to d1, 4338 -1 = adr2 is bad 4339 @since 0.4.0 4340 */ 4341 int burn_drive_equals_adr(struct burn_drive *d1, char *adr2, int drive_role2); 4342 4343 4344 4345 /* 4346 Audio track data extraction facility. 4347 */ 4348 4349 /* Maximum size for address paths and fmt_info strings */ 4350 #define LIBDAX_AUDIOXTR_STRLEN 4096 4351 4352 4353 /** Extractor object encapsulating intermediate states of extraction. 4354 The clients of libdax_audioxtr shall only allocate pointers to this 4355 struct and get a storage object via libdax_audioxtr_new(). 4356 Appropriate initial value for the pointer is NULL. 4357 */ 4358 struct libdax_audioxtr; 4359 4360 4361 /** Open an audio file, check whether suitable, create extractor object. 4362 @param xtr Opaque handle to extractor. Gets attached extractor object. 4363 @param path Address of the audio file to extract. "-" is stdin (but might 4364 be not suitable for all futurely supported formats). 4365 @param flag Bitfield for control purposes (unused yet, submit 0) 4366 @return >0 success 4367 0 unsuitable format 4368 -1 severe error 4369 -2 path not found 4370 @since 0.2.4 4371 */ 4372 int libdax_audioxtr_new(struct libdax_audioxtr **xtr, char *path, int flag); 4373 4374 4375 /** Obtain identification parameters of opened audio source. 4376 @param xtr Opaque handle to extractor 4377 @param fmt Gets pointed to the audio file format id text: ".wav" , ".au" 4378 @param fmt_info Gets pointed to a format info text telling parameters 4379 @param num_channels e.g. 1=mono, 2=stereo, etc 4380 @param sample_rate e.g. 11025, 44100 4381 @param bits_per_sample e.g. 8= 8 bits per sample, 16= 16 bits ... 4382 @param msb_first Byte order of samples: 0= Intel = Little Endian 4383 1= Motorola = Big Endian 4384 @param flag Bitfield for control purposes (unused yet, submit 0) 4385 @return >0 success, <=0 failure 4386 @since 0.2.4 4387 */ 4388 int libdax_audioxtr_get_id(struct libdax_audioxtr *xtr, 4389 char **fmt, char **fmt_info, 4390 int *num_channels, int *sample_rate, 4391 int *bits_per_sample, int *msb_first, int flag); 4392 4393 4394 /** Obtain a prediction about the extracted size based on internal information 4395 of the formatted file. 4396 @param o Opaque handle to extractor 4397 @param size Gets filled with the predicted size 4398 @param flag Bitfield for control purposes (unused yet, submit 0) 4399 @return 1 prediction was possible , 0 no prediction could be made 4400 @since 0.2.4 4401 */ 4402 int libdax_audioxtr_get_size(struct libdax_audioxtr *o, off_t *size, int flag); 4403 4404 4405 /** Obtain next buffer full of extracted data in desired format (only raw audio 4406 for now). 4407 @param xtr Opaque handle to extractor 4408 @param buffer Gets filled with extracted data 4409 @param buffer_size Maximum number of bytes to be filled into buffer 4410 @param flag Bitfield for control purposes 4411 bit0= do not stop at predicted end of data 4412 @return >0 number of valid buffer bytes, 4413 0 End of file 4414 -1 operating system reports error 4415 -2 usage error by application 4416 @since 0.2.4 4417 */ 4418 int libdax_audioxtr_read(struct libdax_audioxtr *xtr, 4419 char buffer[], int buffer_size, int flag); 4420 4421 4422 /** Try to obtain a file descriptor which will deliver extracted data 4423 to normal calls of read(2). This may fail because the format is 4424 unsuitable for that, but WAVE (.wav) is ok. If this call succeeds the xtr 4425 object will have forgotten its file descriptor and libdax_audioxtr_read() 4426 will return a usage error. One may use *fd after libdax_audioxtr_destroy() 4427 and will have to close it via close(2) when done with it. 4428 @param o Opaque handle to extractor 4429 @param fd Returns the file descriptor number 4430 @param flag Bitfield for control purposes 4431 bit0= do not dup(2) and close(2) but hand out original fd 4432 @return 1 success, 0 cannot hand out fd , -1 severe error 4433 @since 0.2.4 4434 */ 4435 int libdax_audioxtr_detach_fd(struct libdax_audioxtr *o, int *fd, int flag); 4436 4437 4438 /** Clean up after extraction and destroy extractor object. 4439 @param xtr Opaque handle to extractor, *xtr is allowed to be NULL, 4440 *xtr is set to NULL by this function 4441 @param flag Bitfield for control purposes (unused yet, submit 0) 4442 @return 1 = destroyed object, 0 = was already destroyed 4443 @since 0.2.4 4444 */ 4445 int libdax_audioxtr_destroy(struct libdax_audioxtr **xtr, int flag); 4446 4447 4448 #ifndef DOXYGEN 4449 4450 BURN_END_DECLS 4451 4452 #endif 4453 4454 4455 /* ts A91205 */ 4456 /* The following experiments may be interesting in future: 4457 */ 4458 4459 /* Perform OPC explicitly. 4460 # define Libburn_pioneer_dvr_216d_with_opC 1 4461 */ 4462 4463 /* Load mode page 5 and modify it rather than composing from scratch. 4464 # define Libburn_pioneer_dvr_216d_load_mode5 1 4465 */ 4466 4467 /* Inquire drive events and react by reading configuration or starting unit. 4468 # define Libburn_pioneer_dvr_216d_get_evenT 1 4469 */ 4470 4471 /* ts A91112 */ 4472 /* Do not probe CD modes but declare only data and audio modes supported. 4473 For other modes or real probing one has to call 4474 burn_drive_probe_cd_write_modes(). 4475 4476 */ 4477 #define Libburn_dummy_probe_write_modeS 1 4478 4479 /* ts B30112 */ 4480 /* Handle DVD+R with reserved tracks in incomplete first session 4481 by loading info about the incomplete session into struct burn_disc 4482 */ 4483 #define Libburn_disc_with_incomplete_sessioN 1 4484 4485 4486 /* Early experimental: 4487 Do not define Libburn_develop_quality_scaN unless you want to work 4488 towards a usable implementation. 4489 If it gets enabled, then the call must be published in libburn/libburn.ver 4490 */ 4491 #ifdef Libburn_develop_quality_scaN 4492 4493 /* ts B21108 */ 4494 /* Experiments mit quality scan command F3 on Optiarc drive */ 4495 int burn_nec_optiarc_rep_err_rate(struct burn_drive *d, 4496 int start_lba, int rate_period, int flag); 4497 4498 #endif /* Libburn_develop_quality_scaN */ 4499 4500 4501 /* Linux 3.16 problems with ABh Read Media Serial Number: 4502 - as normal user lets ioctl(SG_IO) return -1 and errno = EFAULT 4503 - as superuser renders LG BH16NS40 unusable until power cycle 4504 #de fine Libburn_enable_scsi_cmd_ABh yes 4505 #de fine Libburn_enable_scsi_cmd_ABh_pretend_currenT yes 4506 */ 4507 4508 4509 #endif /*LIBBURN_H*/ 4510