./rb_cdio.def.rb in rb_cdio-0.1.1 vs ./rb_cdio.def.rb in rb_cdio-0.2.0
- old
+ new
@@ -1,26 +1,67 @@
#!/bin/env ruby
# = rb_cdio
-# This package create bindings to the library libcdio
+# Create bindings to the library libcdio and libcddb(optional).
+# You can retrieve information about Cd and images. If you have
+# library libcddb installed, you can retrieve information like artist and titles
+# for CD-DA.
#
# == Version
# :include:VERSION
#
# == Changelog
# :include:ChangeLog.txt
#
+# == Download
+#
+# http://rb-cdio.rubyforge.org
+#
+# == Example of use
+# CdIo.devices
+# ==>["/dev/cdrom", "/dev/dvd"]
+# cd=CdIo.default_device
+# ==>"/dev/cdrom"
+# CdIo.drive_cap_dev(cd)
+# ==>{"misc"=>{"close_tray"=>true, "media_changed"=>false, "select_disk"=>false, "lock"=>true, "multi_session"=>true, "eject"=>true, "reset"=>false, "select_speed"=>false, "file"=>false}, "read"=>{"mode2_form1"=>true, "dvd-rw"=>false, "audio"=>true, "mode2_form2"=>true, "c2_errs"=>false, "dvd-r"=>false, "mcn"=>true, "cd-da"=>true, "dvd-rom"=>false, "isrc"=>true, "cd-r"=>true, "dvd-ram"=>false, "dvr+r"=>false, "cd+g"=>false, "dvd+rw"=>false, "cd-rw"=>true}, "write"=>{"dvd-rw"=>false, "cd"=>false, "dvd-r"=>false, "burn_proof"=>false, "dvd+r"=>false, "cd-r"=>false, "dvd"=>false, "dvd-ram"=>false, "dvd+rw"=>false, "mount_rainier"=>false, "cd-rw"=>false}}
+# CdIo.driver_describe(CdIo::DRIVER_LINUX)
+# ==>"GNU/Linux ioctl and MMC driver"
+# CdIo.discmode_describe(CdIo::CDIO_DISC_MODE_CD_DA)
+# ==>"CD-DA"
+# CdIo.track_format_describe(CdIo::TRACK_FORMAT_XA)
+# ==>"XA"
+# cdo=CdIo.open(cd)
+# ==>#<CdIo::Cd:0xb7d2a91c>
+# cdo.cdtext
+# ==>nil
+# cdo.tracks.each do |track|
+# track.number
+# track
+# end
+# ==>[#<CdIo::TrackIso9660:0xb7cde440 @leadout=false, @min=0, @cd=#<CdIo::Cd:0xb7d2a91c>, @sec_count=311872, @frames=0, @lsn=0, @format=3, @track_type=3, @msf="00:02:00", @number=1, @sec=2, @lba=150>]
+# cdo.tracks[CdIo::CDIO_CDROM_LEADOUT_TRACK];
+# cdo.is_cd?
+# ==>true
+# cdo.is_dvd?
+# ==>false
+# cdo.drive_cap
+# ==>{"misc"=>{"close_tray"=>true, "media_changed"=>false, "select_disk"=>false, "lock"=>true, "multi_session"=>true, "eject"=>true, "reset"=>false, "select_speed"=>false, "file"=>false}, "read"=>{"mode2_form1"=>true, "dvd-rw"=>false, "audio"=>true, "mode2_form2"=>true, "c2_errs"=>false, "dvd-r"=>false, "mcn"=>true, "cd-da"=>true, "dvd-rom"=>false, "isrc"=>true, "cd-r"=>true, "dvd-ram"=>false, "dvr+r"=>false, "cd+g"=>false, "dvd+rw"=>false, "cd-rw"=>true}, "write"=>{"dvd-rw"=>false, "cd"=>false, "dvd-r"=>false, "burn_proof"=>false, "dvd+r"=>false, "cd-r"=>false, "dvd"=>false, "dvd-ram"=>false, "dvd+rw"=>false, "mount_rainier"=>false, "cd-rw"=>false}}
+# cdo.hwinfo
+# ==>{"revision"=>"1.00", "vendor"=>"HL-DT-ST", "model"=>"CD-ROM GCR-8520B"}
+# cdo.joliet_level
+# ==>0
# = Module CdIo
# The module CdIo defines constants, classes and methods
# to retrieve information of Cd devices and images,
# using the libcdio library.
#
#
# The name of the constants are the same of libcdio, so theirs values
-# can change on different OS and versions of the library
+# can change on different OS and versions of the libcdio library
module CdIo
+ CDIO_CDROM_LEADOUT_TRACK=170
CDIO_DISC_MODE_CD_DA=0
CDIO_DISC_MODE_CD_DATA=1
CDIO_DISC_MODE_CD_MIXED=3
CDIO_DISC_MODE_CD_XA=2
CDIO_DISC_MODE_DVD_OTHER=10
@@ -30,30 +71,26 @@
CDIO_DISC_MODE_DVD_RAM=5
CDIO_DISC_MODE_DVD_ROM=4
CDIO_DISC_MODE_DVD_RW=7
CDIO_DISC_MODE_ERROR=12
CDIO_DISC_MODE_NO_INFO=11
- # Driver for a .bin or .cue file
- DRIVER_BINCUE=8
- DRIVER_CDRDAO=7
- # Driver for a device (cd or dvd)
- DRIVER_DEVICE=10
- DRIVER_FREEBSD=2
- DRIVER_LINUX=3
- DRIVER_NRG=9
- DRIVER_OSX=5
- DRIVER_SOLARIS=4
+ DRIVER_BINCUE=9
+ DRIVER_CDRDAO=8
+ DRIVER_DEVICE=11
+ DRIVER_FREEBSD=3
+ DRIVER_LINUX=4
+ DRIVER_NRG=10
+ DRIVER_OSX=6
+ DRIVER_SOLARIS=5
DRIVER_UNKNOWN=0
- DRIVER_WIN32=6
+ DRIVER_WIN32=7
TRACK_FORMAT_AUDIO=0
TRACK_FORMAT_CDI=1
TRACK_FORMAT_DATA=3
TRACK_FORMAT_ERROR=5
TRACK_FORMAT_PSX=4
TRACK_FORMAT_XA=2
- # The number for the leadout track of a cd
- CDIO_CDROM_LEADOUT_TRACK=170
# Returns all active devices (with a cd or dvd inside)
#
# CdIo.get_devices #=> ["/dev/cdrom"]
def CdIo.devices
end
@@ -99,12 +136,30 @@
#
# CdIo.open() {|cd| p cd} #=><CdIo::Cd:0xb7d85f7c>
#
def CdIo.open(device=nil,driver=nil,&block)
end
+ module Exception
+ class Error < IoError
+ end
+ class Unsupported < IoError
+ end
+ class NotPermitted < IoError
+ end
+ class BadParameter < IoError
+ end
+ class BadPointer < IoError
+ end
+ class NoDriver < IoError
+ end
+ class CddbError < Exception
+ end
+ class CddbConn < IoError
+ end
+ end
class Cd
- attr_reader :device, :mcn, :driver_name, :driver_id, :first_track_num, :disc_mode, :num_tracks, :stat_size, :cddb_id
+ attr_reader :device, :mcn, :driver_name, :driver_id, :first_track_num, :disc_mode, :num_tracks, :last_lsn, :joliet_level
#
# Create a new Cd::CdIo object.
# The first argument is an String for a device or a cue/bin/toc/nrg file
# The seconf argument is the constant for a Driver (default CdIo::DRIVER_UNKNOWN)
# * CdIo::Cd.new()
@@ -142,10 +197,88 @@
# Closes the device.
# Actually, do nothing :P
def close
end
end
+ # module with extra methods to extends a normal Cd
+ module Cdda
+ # get the volume in an array.
+ #
+ # cd.volume
+ # ==> [255, 255, 0, 0]
+ def volume
+ end
+ # set the volume. You have to put an array
+ #
+ # cd.volume=[255,255,0,0]
+ def volume=(vol_set)
+ end
+ # play cd tracks. Returns an array with the first and the last track to play
+ # Ex.: cd with 11 tracks:
+ #
+ # cd.play
+ # ==> [1,11]
+ # cd.play(1)
+ # ==> [1,1]
+ # cd.play(2,20)
+ # ==> [2,11]
+ def play
+ end
+ # pause the reproduction of cd
+ def pause
+ end
+ # resume the reproduction of cd after a pause
+ def resume
+ end
+ # stop the reproduction of the cd
+ def stop
+ end
+ # get subchannel information of reproduction of the cd
+ #
+ # cd.subchannel
+ # ==> {"control"=>0, "rel_addr"=>"00:00:02", "abs_addr"=>"00:02:02", "format"=>212, "audio_status_desc"=>"no_status", "track"=>1, "audio_status"=>21, "index"=>1, "address"=>6}
+ def subchannel
+ end
+ # get the cddb key for the cd, in hex format
+ #
+ # cd.cddb_id
+ # ==> "9609630b"
+ def cddb_id
+ end
+ # get matches for cddb in an array.
+ # Requires <b>libcddb</b>
+ #
+ # cd.cddb_matches
+ # ==> [{"artist"=>"Seru Giran", "category"=>"rock", "title"=>"Peperina", "id"=>"2466865419", "length"=>"2403", "year"=>"0", "genre"=>"rock"}, {"artist"=>"Seru Giran", "category"=>"rock", "title"=>"Peperina", "id"=>"2517197579", "length"=>"2403", "year"=>"0", "genre"=>"rock"}]
+ def cddb_matches
+ end
+ # Get the match number x on cddb. Add information for the cd
+ # and the tracks
+ # Requires <b>libcddb</b>
+ #
+ # cd.cddb_fetch(1)
+ # ==> true
+ # t=cd.tracks[1]
+ # puts t.number.to_s+"-"+t.artist+"-"+t.title
+ # ==> 1-Seru Giran-Peperina
+ #
+ #
+ def cddb_fetch(match)
+ end
+ def artist
+ end
+ def title
+ end
+ def category
+ end
+ def genre
+ end
+ def length
+ end
+ def extra_data
+ end
+ end
# Provides access to the tracks of a CdIo::Cd object
class Tracks
# Returns a CdIo::Tracks object por a given CdIo::Cd
include Enumerable
def initialize(cd)
@@ -181,7 +314,15 @@
end
# Representation of a Iso 9660 Track for a CdIo::Cd object.
# Have some extra attributes, like system_id, volume_id....
class TrackIso9660 < Track
attr_reader :system_id, :volume_id, :volumeset_id, :preparer_id, :publisher_id, :application_id
+ end
+ class TrackCdda < Track
+ def play
+ end
+ def artist
+ end
+ def title
+ end
end
end