/** * Copyright (c) 2005 Claudio Bustos * This code is hereby licensed for public consumption under the * GNU GPL v2. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "CdIo.h" Init_rb_cdio() { /** module CdIo */ mCdIo = rb_define_module("CdIo"); rb_define_module_function(mCdIo, "devices", rb_cdio_get_devices, -1); rb_define_module_function(mCdIo, "default_device", rb_cdio_get_default_device, -1); rb_define_module_function(mCdIo, "drive_cap_dev", rb_cdio_get_drive_cap_dev, 1); rb_define_module_function(mCdIo, "discmode_describe", rb_cdio_discmode_describe, 1); rb_define_module_function(mCdIo, "driver_describe", rb_cdio_driver_describe, 1); rb_define_module_function(mCdIo, "track_format_describe", rb_cdio_track_format_describe, 1); rb_define_module_function(mCdIo, "track_type_describe", rb_cdio_track_type_describe, 1); rb_define_module_function(mCdIo, "open", rb_cdio_open, -1); // is rb_define_module_function(mCdIo, "is_binfile", rb_cdio_is_binfile, 1); rb_define_module_function(mCdIo, "is_cuefile", rb_cdio_is_cuefile, 1); rb_define_module_function(mCdIo, "is_nrg", rb_cdio_is_nrg, 1); rb_define_module_function(mCdIo, "is_tocfile", rb_cdio_is_tocfile, 1); rb_define_module_function(mCdIo, "is_device", rb_cdio_is_device, -1); rb_define_module_function(mCdIo, "close_tray", rb_cdio_close_tray, 1); /** * class CdIo::Cd */ cCdIoCd = rb_define_class_under(mCdIo, "Cd", rb_cObject); rb_define_singleton_method(cCdIoCd, "new", rb_cdio_cd_new, -1); rb_define_method(cCdIoCd, "initialize", rb_cdio_cd_init, 2); int i; #define CDIO_ATTR 9 const char *attr[CDIO_ATTR] = { "device", "mcn", "driver_name", "driver_id", "first_track_num", "discmode", "num_tracks", "last_lsn", "joliet_level" }; for (i = 0; i < CDIO_ATTR; i++) { rb_define_attr(cCdIoCd, attr[i], 1, 0); } rb_define_method(cCdIoCd, "tracks", rb_cdio_cd_get_tracks, 0); rb_define_method(cCdIoCd, "first_track", rb_cdio_cd_get_first_track, 0); rb_define_method(cCdIoCd, "get_arg", rb_cdio_cd_get_arg, 1); rb_define_method(cCdIoCd, "is_cd?", rb_cdio_cd_is_cd, 0); rb_define_method(cCdIoCd, "is_dvd?", rb_cdio_cd_is_dvd, 0); rb_define_method(cCdIoCd, "freedb", rb_cdio_cd_get_freedb, 0); rb_define_method(cCdIoCd, "cdtext", rb_cdio_cd_get_cdtext, 0); // device methods rb_define_method(cCdIoCd, "drive_cap", rb_cdio_cd_get_drive_cap, 0); rb_define_method(cCdIoCd, "hwinfo", rb_cdio_cd_get_hwinfo, 0); rb_define_method(cCdIoCd, "close", rb_cdio_cd_close, 0); rb_define_method(cCdIoCd, "eject", rb_cdio_cd_eject, 0); // CdIo::CdDa module mCdIoCdda = rb_define_module_under(mCdIo, "Cdda"); rb_define_method(mCdIoCdda, "volume", rb_cdio_cdda_get_volume, 0); rb_define_method(mCdIoCdda, "volume=", rb_cdio_cdda_set_volume, 1); rb_define_method(mCdIoCdda, "play", rb_cdio_cdda_play, -1); rb_define_method(mCdIoCdda, "pause", rb_cdio_cdda_pause, 0); rb_define_method(mCdIoCdda, "resume", rb_cdio_cdda_resume, 0); rb_define_method(mCdIoCdda, "stop", rb_cdio_cdda_stop, 0); rb_define_method(mCdIoCdda, "subchannel", rb_cdio_cdda_subchannel, 0); rb_define_method(mCdIoCdda, "cddb_id", rb_cdio_cdda_cddb_id, 0); rb_define_method(mCdIoCdda, "cddb_matches",rb_cdio_cdda_cddb_matches,0); rb_define_method(mCdIoCdda, "cddb_fetch",rb_cdio_cdda_cddb_fetch,1); rb_define_method(mCdIoCdda,"artist",rb_cdio_cdda_artist,0); rb_define_method(mCdIoCdda,"title",rb_cdio_cdda_title,0); rb_define_method(mCdIoCdda,"year",rb_cdio_cdda_year,0); rb_define_method(mCdIoCdda,"length",rb_cdio_cdda_length,0); rb_define_method(mCdIoCdda,"genre",rb_cdio_cdda_genre,0); rb_define_method(mCdIoCdda,"category",rb_cdio_cdda_category,0); rb_define_method(mCdIoCdda,"extra_data",rb_cdio_cdda_extra_data,0); /** class CdIo::Tracks */ cCdIoTracks = rb_define_class_under(mCdIo, "Tracks", rb_cObject); rb_include_module(cCdIoTracks, rb_mEnumerable); rb_define_method(cCdIoTracks, "initialize", rb_cdio_tracks_init, 1); rb_define_method(cCdIoTracks, "each", rb_cdio_tracks_each, -1); rb_define_method(cCdIoTracks, "<=>", rb_cdio_tracks_diff, 2); rb_define_method(cCdIoTracks, "[]", rb_cdio_tracks_index, 1); rb_define_attr(cCdIoTracks, "cd", 1, 0); /** class CdIo::Track */ cCdIoTrack = rb_define_class_under(mCdIo, "Track", rb_cObject); rb_define_method(cCdIoTrack, "initialize", rb_cdio_track_init, 2); rb_define_method(cCdIoTrack, "green?", rb_cdio_track_green, 0); rb_define_method(cCdIoTrack, "cdtext", rb_cdio_track_get_cdtext, 0); /** :cd :number :format, :green, :lba,:lsn,min,sec,frames,:sec_count*/ #define CDIO_TRACK_ATTR 12 const char *attr2[CDIO_TRACK_ATTR] = { "cd", "number", "format", "lba", "lsn", "min", "sec", "frames", "msf", "sec_count", "track_type", "leadout" }; for (i = 0; i < CDIO_TRACK_ATTR; i++) { rb_define_attr(cCdIoTrack, attr2[i], 1, 0); } /** class CdIo::TrackIso9660 < CdIo::Track */ cCdIoTrackIso9660 = rb_define_class_under(mCdIo, "TrackIso9660", cCdIoTrack); char attr3[6][32] = { "system_id", "volume_id", "volumeset_id", "preparer_id", "publisher_id", "application_id" }; for (i = 0; i < 6; i++) { rb_define_attr(cCdIoTrackIso9660, attr3[i], 1, 0); } rb_define_method(cCdIoTrackIso9660, "initialize", rb_cdio_trackiso9660_init, 2); // class CdIo::TrackCdda cCdIoTrackCdda = rb_define_class_under(mCdIo, "TrackCdda", cCdIoTrack); // rb_define_method(cCdIoTrackCdda, "initialize", // rb_cdio_trackcdda_init, 2); rb_define_method(cCdIoTrackCdda, "play", rb_cdio_trackcdda_play, 0); rb_define_attr(cCdIoTrackCdda,"title",1,0); rb_define_attr(cCdIoTrackCdda,"artist",1,0); rb_define_attr(cCdIoTrackCdda,"extra_data",1,0); // exceptions mCdIoException = rb_define_module_under(mCdIo, "Exception"); eCdIoError = rb_define_class_under(mCdIoException, "Error", rb_eIOError); eCdIoUnsupported = rb_define_class_under(mCdIoException, "Unsupported", rb_eIOError); eCdIoUnitit = rb_define_class_under(mCdIoException, "Unitit", rb_eIOError); eCdIoNotPermitted = rb_define_class_under(mCdIoException, "NotPermitted", rb_eIOError); eCdIoBadParameter = rb_define_class_under(mCdIoException, "BadParameter", rb_eIOError); eCdIoBadPointer = rb_define_class_under(mCdIoException, "BadPointer", rb_eNoMemError); eCdIoNoDriver = rb_define_class_under(mCdIoException, "NoDriver", rb_eIOError); eCdIoCddbError = rb_define_class_under(mCdIoException, "CddbError",rb_eException); eCdIoCddbConn = rb_define_class_under(mCdIoException, "CddbConn", rb_eIOError); // const for DRIVER rb_define_const(mCdIo, "DRIVER_UNKNOWN", INT2FIX(DRIVER_UNKNOWN)); rb_define_const(mCdIo, "DRIVER_FREEBSD", INT2FIX(DRIVER_FREEBSD)); rb_define_const(mCdIo, "DRIVER_LINUX", INT2FIX(DRIVER_LINUX)); rb_define_const(mCdIo, "DRIVER_SOLARIS", INT2FIX(DRIVER_SOLARIS)); rb_define_const(mCdIo, "DRIVER_OSX", INT2FIX(DRIVER_OSX)); rb_define_const(mCdIo, "DRIVER_WIN32", INT2FIX(DRIVER_WIN32)); rb_define_const(mCdIo, "DRIVER_CDRDAO", INT2FIX(DRIVER_CDRDAO)); rb_define_const(mCdIo, "DRIVER_BINCUE", INT2FIX(DRIVER_BINCUE)); rb_define_const(mCdIo, "DRIVER_NRG", INT2FIX(DRIVER_NRG)); rb_define_const(mCdIo, "DRIVER_DEVICE", INT2FIX(DRIVER_DEVICE)); // const for CD types rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_DA", INT2FIX(CDIO_DISC_MODE_CD_DA)); rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_DATA", INT2FIX(CDIO_DISC_MODE_CD_DATA)); rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_XA", INT2FIX(CDIO_DISC_MODE_CD_XA)); rb_define_const(mCdIo, "CDIO_DISC_MODE_CD_MIXED", INT2FIX(CDIO_DISC_MODE_CD_MIXED)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_ROM", INT2FIX(CDIO_DISC_MODE_DVD_ROM)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_RAM", INT2FIX(CDIO_DISC_MODE_DVD_RAM)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_R", INT2FIX(CDIO_DISC_MODE_DVD_R)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_RW", INT2FIX(CDIO_DISC_MODE_DVD_RW)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_PR", INT2FIX(CDIO_DISC_MODE_DVD_PR)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_PRW", INT2FIX(CDIO_DISC_MODE_DVD_PRW)); rb_define_const(mCdIo, "CDIO_DISC_MODE_DVD_OTHER", INT2FIX(CDIO_DISC_MODE_DVD_OTHER)); rb_define_const(mCdIo, "CDIO_DISC_MODE_NO_INFO", INT2FIX(CDIO_DISC_MODE_NO_INFO)); rb_define_const(mCdIo, "CDIO_DISC_MODE_ERROR", INT2FIX(CDIO_DISC_MODE_ERROR)); rb_define_const(mCdIo, "TRACK_FORMAT_AUDIO", INT2FIX(TRACK_FORMAT_AUDIO)); rb_define_const(mCdIo, "TRACK_FORMAT_CDI", INT2FIX(TRACK_FORMAT_CDI)); /**< CD-i. How this is different from DATA below? */ rb_define_const(mCdIo, "TRACK_FORMAT_XA", INT2FIX(TRACK_FORMAT_XA)); /**< Mode2 of some sort */ rb_define_const(mCdIo, "TRACK_FORMAT_DATA", INT2FIX(TRACK_FORMAT_DATA)); /**< Mode1 of some sort */ rb_define_const(mCdIo, "TRACK_FORMAT_PSX", INT2FIX(TRACK_FORMAT_PSX)); rb_define_const(mCdIo, "TRACK_FORMAT_ERROR", INT2FIX(TRACK_FORMAT_ERROR)); /**< Dunno what is, or some other error. */ rb_define_const(mCdIo, "CDIO_CDROM_LEADOUT_TRACK", INT2FIX(CDIO_CDROM_LEADOUT_TRACK)); rb_define_const(mCdIoCdda,"SUB_ST_INVALID",INT2FIX(CDIO_MMC_READ_SUB_ST_INVALID)); rb_define_const(mCdIoCdda,"SUB_ST_PLAY",INT2FIX(CDIO_MMC_READ_SUB_ST_PLAY)); rb_define_const(mCdIoCdda,"SUB_ST_PAUSED",INT2FIX(CDIO_MMC_READ_SUB_ST_PAUSED)); rb_define_const(mCdIoCdda,"SUB_ST_COMPLETED",INT2FIX(CDIO_MMC_READ_SUB_ST_COMPLETED)); rb_define_const(mCdIoCdda,"SUB_ST_ERROR",INT2FIX(CDIO_MMC_READ_SUB_ST_ERROR)); rb_define_const(mCdIoCdda,"SUB_ST_NO_STATUS",INT2FIX(CDIO_MMC_READ_SUB_ST_NO_STATUS)); }