1 /*!
2    \file info.h
3    \brief  Interface for higher-level libvcdinfo. See also inf.h
4 
5     Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@gnu.org>
6 
7  \verbatim
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Foundation
20     Software, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  \endverbatim
22 */
23 /*
24    Things here refer to higher-level structures usually accessed via
25    vcdinfo_t. For lower-level access which generally use
26    structures other than vcdinfo_t, see inf.h
27 */
28 
29 
30 #ifndef _VCD_INFO_H
31 #define _VCD_INFO_H
32 
33 #include <libvcd/version.h>
34 #include <libvcd/types.h>
35 #include <libvcd/files.h>
36 
37 /* We don't want to pull in cdio's config */
38 #define __CDIO_CONFIG_H__
39 #include <cdio/cdio.h>
40 #include <cdio/iso9660.h>
41 #include <cdio/ds.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 
47 /*========== Move somewhere else? ================*/
48 
49 /*! maximum # characters in an album id. */
50 #define MAX_ALBUM_LEN 16
51 
52 /*! maximum # of selections allowed in a PBC selection list. */
53 #define MAX_PBC_SELECTIONS 99
54 
55 #define MIN_ENCODED_TRACK_NUM 100
56 #define MIN_ENCODED_SEGMENT_NUM 1000
57 #define MAX_ENCODED_SEGMENT_NUM 2979
58 
59 /*!
60   Invalid LBA, Note: VCD player uses the fact that this is a very high
61   value.
62  */
63 #define VCDINFO_NULL_LBA          CDIO_INVALID_LBA
64 
65 /*!
66   Invalid LSN, Note: VCD player uses the fact that this is a very high
67   value.
68  */
69 #define VCDINFO_NULL_LSN          VCDINFO_NULL_LBA
70 
71 /*========== End move somewhere else? ================*/
72 
73 /*!
74   Portion of uint16_t which determines whether offset is
75   rejected or not.
76 */
77 #define VCDINFO_REJECTED_MASK (0x8000)
78 
79 /*!
80   Portion of uint16_t which contains the offset.
81 */
82 #define VCDINFO_OFFSET_MASK (VCDINFO_REJECTED_MASK-1)
83 
84 /*!
85   Portion of uint16_t which contains the lid.
86 */
87 #define VCDINFO_LID_MASK    (VCDINFO_REJECTED_MASK-1)
88 
89 /*!
90   Constant for invalid track number
91 */
92 #define VCDINFO_INVALID_TRACK   0xFF
93 
94 /*!
95   Constant for invalid LID offset.
96 */
97 #define VCDINFO_INVALID_OFFSET  0xFFFF
98 
99 /*!
100   Constant for ending or "leadout" track.
101 */
102 #define VCDINFO_LEADOUT_TRACK  0xaa
103 
104 /*!
105   Constant for invalid sequence entry.
106 */
107 #define VCDINFO_INVALID_ENTRY  0xFFFF
108 
109 /*!
110   Constant for invalid LID.
111   FIXME: player needs these to be the same.
112   VCDimager code requres 0 for an UNINITIALIZED LID.
113 
114 */
115 #define VCDINFO_INVALID_LID  VCDINFO_INVALID_ENTRY
116 #define VCDINFO_UNINIT_LID   0
117 
118 /*!
119   Constant for invalid itemid
120 */
121 #define VCDINFO_INVALID_ITEMID  0xFFFF
122 
123 /*!
124   Constant for invalid audio type
125 */
126 #define VCDINFO_INVALID_AUDIO_TYPE  4
127 
128 /*!
129   Constant for invalid base selection number (BSN)
130 */
131 #define VCDINFO_INVALID_BSN  200
132 
133 /*! The number of sectors allocated in a Video CD segment is a fixed: 150.
134 
135    NOTE: The actual number of sectors used is often less and can sometimes
136    be gleaned by looking at the correspoinding ISO 9660 file entry (or
137    by scanning the MPEG segment which may be slow).
138    Some media players get confused by or complain about padding at the end
139    a segment.
140 */
141 #define VCDINFO_SEGMENT_SECTOR_SIZE 150
142 
143   /*! Opaque type used in most routines below. */
144   typedef struct _VcdInfo vcdinfo_obj_t;
145 
146   /** A list of all the different kinds of things a segment can represent.
147       See enum in vcd_files_private.h */
148   typedef enum {
149     VCDINFO_FILES_VIDEO_NOSTREAM    = 0,
150     VCDINFO_FILES_VIDEO_NTSC_STILL  = 1,
151     VCDINFO_FILES_VIDEO_NTSC_STILL2 = 2,   /**< NTCS lo+hires*/
152     VCDINFO_FILES_VIDEO_NTSC_MOTION = 3,
153     VCDINFO_FILES_VIDEO_PAL_STILL   = 5,
154     VCDINFO_FILES_VIDEO_PAL_STILL2  = 6,   /**< PAL lo+hires*/
155     VCDINFO_FILES_VIDEO_PAL_MOTION  = 7,
156     VCDINFO_FILES_VIDEO_INVALID     = 8
157   } vcdinfo_video_segment_type_t;
158 
159   /*!
160     Used in working with LOT - list of offsets and lid's
161   */
162   typedef struct {
163     uint8_t type;
164     lid_t lid;
165     uint16_t offset;
166     bool in_lot;   /**< This offset is listed in LOT. */
167     bool ext;      /**< True if entry comes from offset_x_list. */
168   } vcdinfo_offset_t;
169 
170   /*!
171     The kind of entry associated with an selection-item id
172     See corresponding enum item_type_t in lib/pbc.h. */
173   typedef enum {
174     VCDINFO_ITEM_TYPE_TRACK,
175     VCDINFO_ITEM_TYPE_ENTRY,
176     VCDINFO_ITEM_TYPE_SEGMENT,
177     VCDINFO_ITEM_TYPE_LID,
178     VCDINFO_ITEM_TYPE_SPAREID2,
179     VCDINFO_ITEM_TYPE_NOTFOUND
180   } vcdinfo_item_enum_t;
181 
182   typedef struct {
183     uint16_t num;
184     vcdinfo_item_enum_t type;
185   } vcdinfo_itemid_t;
186 
187   typedef enum {
188     VCDINFO_OPEN_ERROR,          /**< Error */
189     VCDINFO_OPEN_VCD,            /**< Is a VCD of some sort */
190     VCDINFO_OPEN_OTHER           /**< Is not VCD, but something else */
191   } vcdinfo_open_return_t;
192 
193   typedef struct
194   {
195 
196     psd_descriptor_types descriptor_type;
197     /* Only one of pld or psd is used below. Not all
198        C compiler accept the anonymous unions commented out below. */
199     /* union  { */
200     PsdPlayListDescriptor_t *pld;
201     PsdSelectionListDescriptor_t *psd;
202     /* }; */
203 
204   } PsdListDescriptor_t;
205 
206   /* For backwards compatibility. Don't use PsdListDescriptor. */
207 #define PsdListDescriptor PsdListDescriptor_t
208 
209   /*!
210     Return the number of audio channels implied by "audio_type".
211     0 is returned on error.
212   */
213   unsigned int
214   vcdinfo_audio_type_num_channels(const vcdinfo_obj_t *p_vcdinfo,
215 				  unsigned int audio_type);
216 
217   /*!
218     Return a string describing an audio type.
219   */
220   const char * vcdinfo_audio_type2str(const vcdinfo_obj_t *p_vcdinfo,
221 				      unsigned int audio_type);
222 
223   /*!
224     Note first i_seg is 0!
225   */
226   const char *
227   vcdinfo_ogt2str(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg);
228 
229   /*!
230     Note first i_seg is 0!
231   */
232   const char *
233   vcdinfo_video_type2str(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg);
234 
235   const char *
236   vcdinfo_pin2str (uint16_t itemid);
237 
238   /*!
239     \brief Classify i_itemid into the kind of item it is: track #, entry #,
240     segment #.
241     \param i_itemid is set to contain this classifcation an the converted
242     entry number.
243     \param p_itemid returned value.
244   */
245   void
246   vcdinfo_classify_itemid (uint16_t i_itemid,
247 			   /*out*/ vcdinfo_itemid_t *p_itemid);
248 
249   /*!
250     Return a string containing the VCD album id, or NULL if there is
251     some problem in getting this.
252   */
253   const char *
254   vcdinfo_get_album_id(const vcdinfo_obj_t *p_vcdinfo);
255 
256   /*!
257     Return the VCD application ID.
258     NULL is returned if there is some problem in getting this.
259   */
260   char *
261   vcdinfo_get_application_id(vcdinfo_obj_t *p_vcdinfo);
262 
263   /*! Return the selection number of the area that a point is enclosed in.
264      In short we return < 0 on an error of some kind.
265      If the VCD contains no extended selection list return -1.
266      If we are not in an extended selection list LID, return -2.
267      If there no area encloses the point return -3
268 
269      max_x, max_y are the  maximum values that x and y can take on.
270      They would be the largest coordinate in the screen coordinate space.
271      For example they might be 352, 240 (for VCD) or 704, 480 for SVCD NTSC,
272      or 704, 576.
273   */
274   int
275   vcdinfo_get_area_selection(const vcdinfo_obj_t *p_vcdinfo,
276                              lid_t lid, int16_t x, int16_t y,
277 			     uint16_t max_x, uint16_t max_y);
278   /*!
279     Return a pointer to the cdio structure for the CD image opened or
280     NULL if error.
281   */
282   CdIo_t *
283   vcdinfo_get_cd_image (const vcdinfo_obj_t *p_vcdinfo);
284 
285   /*!
286     Return a string containing the default VCD device if none is specified.
287     This might be something like "/dev/cdrom" on Linux or
288     "/vol/dev/aliases/cdrom0" on Solaris,  or maybe "VIDEOCD.CUE" for
289     if bin/cue I/O routines are in effect.
290 
291     Return NULL we can't get this information.
292   */
293   char *
294   vcdinfo_get_default_device (const vcdinfo_obj_t *p_vcdinfo);
295 
296   /*!
297     \brief Get default LID offset.
298 
299     Return the LID offset associated with a the "default" entry of the
300     passed-in LID parameter. Note "default" entries are associated with
301     PSDs that are (extended) selection lists.
302 
303     \return VCDINFO_INVALID_OFFSET is returned on error, or if the LID
304     is not a selection list or no "default" entry. Otherwise the LID
305     offset is returned.
306   */
307   uint16_t
308   vcdinfo_get_default_offset(const vcdinfo_obj_t *p_vcdinfo, lid_t lid);
309 
310   /*!
311     Return number of sector units in of an entry. 0 is returned if
312     i_entry is invalid.
313   */
314   uint32_t
315   vcdinfo_get_entry_sect_count (const vcdinfo_obj_t *p_vcdinfo,
316 				unsigned int i_entry);
317 
318   /*!  Return the starting LBA (logical block address) for sequence
319     i_entry in obj.  VCDINFO_NULL_LBA is returned if there is no entry.
320     The first entry number is 0.
321   */
322   lba_t
323   vcdinfo_get_entry_lba(const vcdinfo_obj_t *p_vcdinfo, unsigned int i_entry);
324 
325   /*!  Return the starting LSN (logical sector number) for sequence
326     i_entry in obj.  VCDINFO_NULL_LSN is returned if there is no entry.
327     The first entry number is 0.
328   */
329   lsn_t
330   vcdinfo_get_entry_lsn(const vcdinfo_obj_t *p_vcdinfo, unsigned int i_entry);
331 
332   /*!  Return the starting MSF (minutes/secs/frames) for sequence
333     i_entry in obj.  NULL is returned if there is no entry.
334     The first entry number is 0.
335   */
336   const msf_t *
337   vcdinfo_get_entry_msf(const vcdinfo_obj_t *p_vcdinfo, unsigned int i_entry);
338 
339   /*!
340     Get the VCD format (VCD 1.0 VCD 1.1, SVCD, ... for this object.
341     The type is also set inside obj.
342     The first entry number is 0.
343   */
344   vcd_type_t
345   vcdinfo_get_format_version (const vcdinfo_obj_t *p_vcdinfo);
346 
347   /*!
348     Return a string giving VCD format (VCD 1.0 VCD 1.1, SVCD, ...
349     for this object.
350   */
351   const char *
352   vcdinfo_get_format_version_str (const vcdinfo_obj_t *p_vcdinfo);
353 
354   EntriesVcd_t * vcdinfo_get_entriesVcd (vcdinfo_obj_t *p_vcdinfo);
355 
356   InfoVcd_t    * vcdinfo_get_infoVcd (vcdinfo_obj_t *p_vcdinfo);
357 
358   /*!
359     \brief Get default or multi-default LID.
360 
361     Return the LID offset associated with a the "default" entry of the
362     passed-in LID parameter. Note "default" entries are associated
363     with PSDs that are (extended) selection lists. If the "default"
364     is a multi-default, we use i_entry to find the proper
365     "default" LID. Otherwise this routine is exactly like
366     vcdinfo_get_default_offset with the exception of requiring an
367     additional "i_entry" parameter.
368 
369     \return VCDINFO_INVALID_LID is returned on error, or if the LID
370     is not a selection list or no "default" entry. Otherwise the LID
371     offset is returned.
372   */
373   lid_t
374   vcdinfo_get_multi_default_lid(const vcdinfo_obj_t *p_vcdinfo, lid_t lid,
375 				lsn_t lsn);
376 
377   /*!
378     \brief Get default or multi-default LID offset.
379 
380     Return the LID offset associated with a the "default" entry of the
381     passed-in LID parameter. Note "default" entries are associated
382     with PSDs that are (extended) selection lists. If the "default"
383     is a multi-default, we use i_entry to find the proper
384     "default" offset. Otherwise this routine is exactly like
385     vcdinfo_get_default_offset with the exception of requiring an
386     additional "i_entry" parameter.
387 
388     \return VCDINFO_INVALID_OFFSET is returned on error, or if the LID
389     is not a selection list or no "default" entry. Otherwise the LID
390     offset is returned.
391   */
392   uint16_t
393   vcdinfo_get_multi_default_offset(const vcdinfo_obj_t *p_vcdinfo, lid_t lid,
394 				   unsigned int selection);
395 
396   /*!
397 
398     \brief Get ISO 9660 Primary Volume Descriptor (PVD) for a VCDinfo
399     object.
400   */
401   iso9660_pvd_t * vcdinfo_get_pvd (vcdinfo_obj_t *p_vcdinfo);
402 
403   void * vcdinfo_get_scandata (vcdinfo_obj_t *p_vcdinfo);
404 
405   void * vcdinfo_get_searchDat (vcdinfo_obj_t *p_vcdinfo);
406 
407   void * vcdinfo_get_tracksSVD (vcdinfo_obj_t *p_vcdinfo);
408 
409   /*!
410     Get the LOT pointer.
411   */
412   LotVcd_t *
413   vcdinfo_get_lot(const vcdinfo_obj_t *p_vcdinfo);
414 
415   /*!
416     Get the extended LOT pointer.
417   */
418   LotVcd_t *
419   vcdinfo_get_lot_x(const vcdinfo_obj_t *p_vcdinfo);
420 
421   /*!
422     Return Number of LIDs.
423   */
424   lid_t
425   vcdinfo_get_num_LIDs (const vcdinfo_obj_t *p_vcdinfo);
426 
427   /*!
428     Return the audio type for a given track.
429     VCDINFO_INVALID_AUDIO_TYPE is returned on error.
430   */
431   unsigned int
432   vcdinfo_get_num_audio_channels(unsigned int audio_type);
433 
434   /*!
435     Return the number of entries in the VCD.
436   */
437   unsigned int
438   vcdinfo_get_num_entries(const vcdinfo_obj_t *p_vcdinfo);
439 
440   /*!
441     Return the number of segments in the VCD.
442   */
443   segnum_t
444   vcdinfo_get_num_segments(const vcdinfo_obj_t *p_vcdinfo);
445 
446   /*!
447     Return the highest track number in the current medium.
448 
449     Because we track start numbering at 0 (which is the ISO 9660 track
450     containing Video CD naviagion and disk information), this is one
451     less than the number of tracks.
452 
453     If there are no tracks, we return -1.
454   */
455   unsigned int
456   vcdinfo_get_num_tracks(const vcdinfo_obj_t *p_vcdinfo);
457 
458   /*!
459     Get the VCD info list.
460   */
461   CdioList_t *vcdinfo_get_offset_list(const vcdinfo_obj_t *p_vcdinfo);
462 
463   /*!
464     Get the VCD info extended offset list.
465   */
466   CdioList_t *vcdinfo_get_offset_x_list(const vcdinfo_obj_t *p_vcdinfo);
467 
468   /*!
469     Get the VCD info offset multiplier.
470   */
471   unsigned int vcdinfo_get_offset_mult(const vcdinfo_obj_t *p_vcdinfo);
472 
473   /*!
474     Get entry in offset list for the item that has offset. This entry
475     has for example the LID. NULL is returned on error.
476   */
477   vcdinfo_offset_t *
478   vcdinfo_get_offset_t (const vcdinfo_obj_t *p_vcdinfo, unsigned int offset);
479 
480   /*!
481     Return a string containing the VCD preparer id with trailing
482     blanks removed, or NULL if there is some problem in getting this.
483   */
484   char *
485   vcdinfo_get_preparer_id(const vcdinfo_obj_t *p_vcdinfo);
486 
487   /*!
488     Get the PSD.
489   */
490   uint8_t *vcdinfo_get_psd(const vcdinfo_obj_t *p_vcdinfo);
491 
492   /*!
493     Get the extended PSD.
494   */
495   uint8_t *vcdinfo_get_psd_x(const vcdinfo_obj_t *p_vcdinfo);
496 
497   /*!
498     Return number of bytes in PSD.
499   */
500   uint32_t vcdinfo_get_psd_size (const vcdinfo_obj_t *p_vcdinfo);
501 
502   /*!
503     Return number of bytes in the extended PSD.
504   */
505   uint32_t vcdinfo_get_psd_x_size (const vcdinfo_obj_t *p_vcdinfo);
506 
507   /*!
508     Return a string containing the VCD publisher id with trailing
509     blanks removed, or NULL if there is some problem in getting this.
510   */
511   char * vcdinfo_get_publisher_id(const vcdinfo_obj_t *p_vcdinfo);
512 
513   /**
514    \brief Get return offset for a given LID.
515    \return  VCDINFO_INVALID_OFFSET is returned on error or if LID has no
516    "return" entry. Otherwise the LID offset is returned.
517    */
518   lid_t
519   vcdinfo_get_return_offset(const vcdinfo_obj_t *p_vcdinfo, lid_t lid);
520 
521   /*!
522     Return the audio type for a given segment.
523     VCDINFO_INVALID_AUDIO_TYPE is returned on error.
524   */
525   unsigned int
526   vcdinfo_get_seg_audio_type(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg);
527 
528   /*!
529     Return true if this segment is supposed to continue to the next one,
530     (is part of an "item" or listing in the ISO 9660 filesystem).
531   */
532   bool vcdinfo_get_seg_continue(const vcdinfo_obj_t *p_vcdinfo,
533 				segnum_t i_seg);
534 
535   /*!  Return the starting LBA (logical block address) for segment
536     i_entry in obj.  VCDINFO_NULL_LBA is returned if there is no entry.
537 
538     Note first i_seg is 0.
539   */
540   lba_t
541   vcdinfo_get_seg_lba(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg);
542 
543   /*!  Return the starting LSN (logical sector number) for segment
544     i_entry in obj.  VCDINFO_NULL_LBA is returned if there is no entry.
545 
546     Note first i_seg is 0.
547   */
548   lsn_t
549   vcdinfo_get_seg_lsn(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg);
550 
551   /*!  Return the starting MSF (minutes/secs/frames) for segment
552     i_entry in obj.  NULL is returned if there is no entry.
553 
554     Note first i_seg is 0.
555   */
556   const msf_t *
557   vcdinfo_get_seg_msf(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg);
558 
559   /*! Return the x-y resolution for a given segment.
560     Note first i_seg is 0.
561   */
562   void
563   vcdinfo_get_seg_resolution(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg,
564 			     /*out*/ uint16_t *max_x, /*out*/ uint16_t *max_y);
565 
566   /*!
567     Return the number of sectors for segment
568     i_entry in obj.  0 is returned if there is no entry.
569 
570     Use this routine to figure out the actual number of bytes a physical
571     region of a disk or CD takes up for a segment.
572 
573     If an item has been broken up into a number of "continued" segments,
574     we will report the item size for the first segment and 0 for the
575     remaining ones. We may revisit this decision later.
576   */
577   uint32_t
578   vcdinfo_get_seg_sector_count(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg);
579 
580   /*!
581     Return a string containing the VCD system id with trailing
582     blanks removed, or NULL if there is some problem in getting this.
583   */
584   char *
585   vcdinfo_get_system_id(const vcdinfo_obj_t *p_vcdinfo);
586 
587   /*!
588     Return the track number for entry n in obj.
589 
590     In contrast to libcdio we start numbering at 0 which is the
591     ISO9660 and metadata information for the Video CD. Thus track
592     1 is the first track the first complete MPEG track generally.
593   */
594   track_t
595   vcdinfo_get_track(const vcdinfo_obj_t *p_vcdinfo,
596 		    const unsigned int i_entry);
597 
598   /*!
599     Return the audio type for a given track.
600     VCDINFO_INVALID_AUDIO_TYPE is returned on error.
601 
602     Note: track 1 is usually the first track.
603   */
604   unsigned int
605   vcdinfo_get_track_audio_type(const vcdinfo_obj_t *p_vcdinfo,
606 			       track_t i_track);
607 
608   /*!
609     Return the starting LBA (logical block address) for track number
610     i_track in obj.
611 
612     The IS0-9660 filesystem track has number 0. Tracks associated
613     with playable entries numbers start at 1.
614 
615     The "leadout" track is specified either by
616     using i_track LEADOUT_TRACK or the total tracks+1.
617     VCDINFO_NULL_LBA is returned on failure.
618   */
619   lba_t
620   vcdinfo_get_track_lba(const vcdinfo_obj_t *p_vcdinfo, track_t i_track);
621 
622   /*!
623     Return the starting LSN (logical sector number) for track number
624     i_track in obj.
625 
626     The IS0-9660 filesystem track has number 0. Tracks associated
627     with playable entries numbers start at 1.
628 
629     The "leadout" track is specified either by
630     using i_track LEADOUT_TRACK or the total tracks+1.
631     VCDINFO_NULL_LBA is returned on failure.
632   */
633   lsn_t
634   vcdinfo_get_track_lsn(const vcdinfo_obj_t *p_vcdinfo, track_t i_track);
635 
636   /*!
637     Return the starting MSF (minutes/secs/frames) for track number
638     i_track in obj.
639 
640     The IS0-9660 filesystem track has number 0. Tracks associated
641     with playable entries numbers start at 1.
642 
643     The "leadout" track is specified either by
644     using i_track LEADOUT_TRACK or the total tracks+1.
645     VCDINFO_NULL_LSN is returned on failure.
646   */
647 
648   /*!
649     Return the ending LSN for track number
650     i_track in cdio.  VCDINFO_NULL_LSN is returned on error.
651   */
652   lsn_t vcdinfo_get_track_last_lsn(const vcdinfo_obj_t *p_vcdinfo,
653 				   track_t i_track);
654 
655   int
656   vcdinfo_get_track_msf(const vcdinfo_obj_t *p_vcdinfo, track_t i_track,
657 			uint8_t *min, uint8_t *sec, uint8_t *frame);
658 
659   /*!
660     Return the size in sectors for track n.
661 
662     The IS0-9660 filesystem track has number 1. Tracks associated
663     with playable entries numbers start at 2.
664 
665     FIXME: Whether we count the track pregap sectors is a bit haphazard.
666     We should add a parameter to indicate whether this is wanted or not.
667   */
668   unsigned int
669   vcdinfo_get_track_sect_count(const vcdinfo_obj_t *p_vcdinfo,
670 			       const track_t i_track);
671 
672   /*!
673     Return size in bytes for track number for entry n in obj.
674 
675     The IS0-9660 filesystem track has number 0. Tracks associated
676     with playable entries numbers start at 1.
677 
678     FIXME: Do we count the track pregap sectors is a bit haphazard.
679     We should add a parameter to indicate whether this is wanted or not.
680   */
681   unsigned int
682   vcdinfo_get_track_size(const vcdinfo_obj_t *p_vcdinfo, track_t i_track);
683 
684   /*!
685     \brief Get the kind of video stream segment of segment i_seg in obj.
686     \return VCDINFO_FILES_VIDEO_INVALID is returned if on error or
687     p_vcdinfo_obj is null. Otherwise the enumeration type.
688 
689     Note first i_seg is 0!
690   */
691   vcdinfo_video_segment_type_t
692   vcdinfo_get_video_type(const vcdinfo_obj_t *p_vcdinfo, segnum_t i_seg);
693 
694   /*!
695     \brief Get the kind of VCD that obj refers to.
696   */
697   vcd_type_t
698   vcdinfo_get_VCD_type(const vcdinfo_obj_t *p_vcdinfo);
699 
700   /*!
701     Return the VCD volume count - the number of CD's in the collection.
702     O is returned if there is some problem in getting this.
703   */
704   unsigned int
705   vcdinfo_get_volume_count(const vcdinfo_obj_t *p_vcdinfo);
706 
707   /*!
708     Return the VCD ID.
709     NULL is returned if there is some problem in getting this.
710   */
711   const char *
712   vcdinfo_get_volume_id(const vcdinfo_obj_t *p_vcdinfo);
713 
714   /*!
715     Return the VCD volumeset ID.
716     NULL is returned if there is some problem in getting this.
717   */
718   const char *
719   vcdinfo_get_volumeset_id(const vcdinfo_obj_t *p_vcdinfo);
720 
721   /*!
722     Return the VCD volume num - the number of the CD in the collection.
723     This is a number between 1 and the volume count.
724     O is returned if there is some problem in getting this.
725   */
726   unsigned int
727   vcdinfo_get_volume_num(const vcdinfo_obj_t *p_vcdinfo);
728 
729   int vcdinfo_get_wait_time (uint16_t wtime);
730 
731   /*!
732     Return true if there is playback control.
733   */
734   bool vcdinfo_has_pbc (const vcdinfo_obj_t *p_vcdinfo);
735 
736   /*!
737     Return true if VCD has "extended attributes" (XA). Extended attributes
738     add meta-data attributes to a entries of file describing the file.
739     See also cdio_get_xa_attr_str() which returns a string similar to
740     a string you might get on a Unix filesystem listing ("ls").
741   */
742   bool vcdinfo_has_xa(const vcdinfo_obj_t *p_vcdinfo);
743 
744   /*!
745     Add one to the MSF.
746   */
747   void vcdinfo_inc_msf (uint8_t *min, uint8_t *sec, int8_t *frame);
748 
749   /*!
750     Convert minutes, seconds and frame (MSF components) into a
751     logical block address (or LBA).
752     See also msf_to_lba which uses msf_t as its single parameter.
753   */
754   void
755   vcdinfo_lba2msf (lba_t lba, uint8_t *min, uint8_t *sec, uint8_t *frame);
756 
757   /*!
758     Get the item id for a given list ID.
759     VCDINFO_REJECTED_MASK is returned on error or if obj is NULL.
760   */
761   uint16_t
762   vcdinfo_lid_get_itemid(const vcdinfo_obj_t *p_vcdinfo, lid_t lid);
763 
764   /*!
765     \brief Get offset i_entry for a given LID.
766     \return VCDINFO_INVALID_OFFSET is returned if obj on error or obj
767     is NULL. Otherwise the LID offset is returned.
768   */
769   uint16_t vcdinfo_lid_get_offset(const vcdinfo_obj_t *p_vcdinfo, lid_t lid,
770 				  unsigned int i_entry);
771 
772   /*!
773     Get the PSD Selection List Descriptor for a given lid.
774     False is returned if not found.
775   */
776   bool vcdinfo_lid_get_pxd(const vcdinfo_obj_t *p_vcdinfo,
777 			   PsdListDescriptor_t *pxd, lid_t lid);
778 
779   /*!  Return the entry number closest and before the given LSN.
780   */
781   unsigned int
782   vcdinfo_lsn_get_entry(const vcdinfo_obj_t *p_vcdinfo, lsn_t lsn);
783 
784   /*!
785     Convert minutes, seconds and frame (MSF components) into a
786     logical sector number (or LSN).
787   */
788   lsn_t vcdinfo_msf2lsn (uint8_t min, uint8_t sec, int8_t frame);
789 
790   const char *
791   vcdinfo_ofs2str (const vcdinfo_obj_t *p_vcdinfo, unsigned int offset,
792 		   bool ext);
793 
794   /*!
795     Calls recursive routine to populate obj->offset_list or obj->offset_x_list
796     by going through LOT.
797 
798     Returns false if there was some error.
799   */
800   bool vcdinfo_visit_lot (vcdinfo_obj_t *p_vcdinfo, bool extended);
801 
802   bool vcdinfo_read_psd (vcdinfo_obj_t *p_vcdinfo);
803 
804   /*!
805     \fn vcdinfo_selection_get_lid(const vcdinfo_obj_t *p_vcdinfo, lid_t lid,
806                                      unsigned int selection);
807     \brief Get the "default" lid of a selection for a given lid.
808 
809     Return the LID offset associated with a the selection number of the
810     passed-in LID parameter.
811 
812     \return VCDINFO_INVALID_LID is returned if obj on error or obj
813     is NULL. Otherwise the LID offset is returned.
814   */
815   lid_t vcdinfo_selection_get_lid(const vcdinfo_obj_t *p_vcdinfo, lid_t lid,
816 				  unsigned int selection);
817 
818   /*!
819     \fn uint16_t vcdinfo_selection_get_offset(const vcdinfo_obj_t *p_vcdinfo,
820                                               lid_t lid,
821                                               unsigned int selection);
822     \brief Get offset of a selection for a given LID.
823 
824     Return the LID offset associated with a the selection number of the
825     passed-in LID parameter.
826 
827     \return VCDINFO_INVALID_OFFSET is returned if obj on error or obj
828     is NULL. Otherwise the LID offset is returned.
829   */
830   uint16_t vcdinfo_selection_get_offset(const vcdinfo_obj_t *p_vcdinfo,
831 					lid_t lid, unsigned int selection);
832 
833   /*!
834     Change trailing blanks in str to nulls.  Str has a maximum size of
835     n characters.
836   */
837   const char * vcdinfo_strip_trail (const char str[], size_t n);
838 
839   /*!  Return the entry number for the given track.
840   */
841   unsigned int
842   vcdinfo_track_get_entry(const vcdinfo_obj_t *p_vcdinfo, track_t i_track);
843 
844   /*!
845     Initialize the vcdinfo structure "obj". Should be done before other
846     routines using obj are called.
847   */
848   bool vcdinfo_init(vcdinfo_obj_t *p_vcdinfo);
849 
850   /*!
851     Set up vcdinfo structure "obj" for reading from a particular
852     medium. This should be done before after initialization but before
853     any routines that need to retrieve data.
854 
855     source_name is the device or file to use for inspection, and
856     source_type indicates what driver to use or class of drivers in the
857     case of DRIVER_DEVICE.
858     access_mode gives the CD access method for reading should the driver
859     allow for more than one kind of access method (e.g. MMC versus ioctl
860     on GNU/Linux)
861 
862     If source_name is NULL we'll fill in the appropriate default device
863     name for the given source_type. However if in addtion source_type is
864     DRIVER_UNKNOWN, then we'll scan for a drive containing a VCD.
865 
866     VCDINFO_OPEN_VCD is returned if everything went okay;
867     VCDINFO_OPEN_ERROR if there was an error and VCDINFO_OPEN_OTHER if the
868     medium is something other than a VCD.
869 
870     Only if VCDINFO_OPEN_VCD is returned, the caller needs free the
871     vcdinfo_obj_t.
872  */
873   vcdinfo_open_return_t
874   vcdinfo_open(vcdinfo_obj_t **p_obj, char *source_name[],
875 	       driver_id_t source_type, const char access_mode[]);
876 
877 
878   /*!
879     Dispose of any resources associated with the vcdinfo structure.
880     Call this when "p_vcdinfo" it isn't needed anymore.
881 
882     True is returned is everything went okay, and false if not.
883   */
884   bool vcdinfo_close(vcdinfo_obj_t *p_vcdinfo);
885 
886   /*!
887     Return true if offset is "rejected". That is shouldn't be displayed
888     in a list of entries.
889   */
890   bool vcdinfo_is_rejected(uint16_t offset);
891 
892 #ifdef __cplusplus
893 }
894 #endif /* __cplusplus */
895 
896 /* Include lower-level access as well. */
897 #include <libvcd/inf.h>
898 
899 /** Deprecated */
900 #define vcdinfo_msf2lba cdio_msf3_to_lba
901 
902 #endif /*_VCD_INFO_H*/
903