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