[vlc-devel] Smart selection CD devices (for VCD/CDDA, etc.)

R. Bernstein rocky at panix.com
Thu Oct 2 05:59:38 CEST 2003

A while back, someone asked about libcdio having a way to find what
plugin might be appropriate for a particular device or image
file. Sort of a "magic" for CD's. I mentioned (I think) that this
analysis was already in libcdio 0.63 and that although it could be put
into a front end, when it comes to vlc, or xine, understanding the best
way to do this in the front end not something I'm familiar with.

But having been involved with a couple of CDDA and VCD plugins, it
occurred to that one might want to work another way: scan the
available CD-ROM devices for a CD loaded in it that contains X (where
X is say a CDDA or VCD, or DVD). So recently I added the ability in
libcdio to return a *list* of CD-drives and in addition specify
"capabilities" that that list should fulfill.

Basically just two new routines were added to libcdio:

cdio_get_devices() and cdio_get_devices_with_cap(). The former is the
simpler of the two:
    Return an array of device names. If you want a list for
    specific device supply the appropriate driver,
    e.g. DRIVER_LINUX. However if you want a list for whatever devices
    are attached, give DRIVER_DEVICE, and if you want all possible
    devices, image drivers and hardware drivers give DRIVER_UNKNOWN.
    NULL is returned if we couldn't return a list of devices, or possibly
    driver[0] will be NULL. The end of the device list will be NULL. 
    The returned list is malloc'd. Free it with cdio_free_device_list().
  char ** cdio_get_devices (driver_id_t driver);

The second routine is perhaps more complicated, but has a bit more
  /*!  Return an array of device names in search_devices that have at
     least the capabilities listed by cap.  If search_devices is NULL,
     then we'll search all possible CD drives.
     If "any" is set false then every capability listed in the extended
     portion of capabilities (i.e. not the basic filesystem) must be
     satisfied. If "any" is set true, then if any of the capabilities
     matches, we call that a success.
     To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
     NULL is returned if we couldn't get a default device.
   char ** cdio_get_devices_with_cap (char* search_devices[],
	                cdio_fs_anal_t capabilities, bool any);
 So with this, one could either give one's own list of devices and ask
 if any of them has any/all of the capabilities in
 "capabilities". Alternatively one can leave search_devices NULL, and
 then internally cdio_get_devices() is called to get a list of all
 potential devices which is then further refined by the capability
 The type cdio_fs_anal_t really has two parts to it:
  - A filesystem part of which there can be only one and this includes
    the pseudo "filesystem" called here an "audio track"
 - an analysis part which is convenient to think of as independent
    attributes. Something like a SVCD has a number of these set: it has
    an ISO 9660 filesystem with an XA track, has CD-BRIDGE and CD-RTOS
    attributes and has some additional SVCD stuff. To test for a SVCD
    one could either test for inclusion of *all* of these components or
    just have the additional SVCD part depending on whether your
    program could tolerate variances or how rigorous you want to be.
I've implemented finding CD-DA and VCD media for the two
libcdio-enabled vlc plugins. This is done when no device is specified
and ~/.vlc/vlcrc is silent about what device to use. (The default
plugins in just return a failure in this situation).

Although the above routines are in libcdio CVS, I'm in the process of
making libcdio ready for release 0.64 and the vlc plugins should be
available in some way as part of that.

This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>

More information about the vlc-devel mailing list