Conoscere il numero di titoli e di capitoli presenti in un DVD video con le funzioni del API di libdvdread
Da Gambas-it.org - Wikipedia.
Versione del 7 lug 2020 alle 08:03 di Vuott (Discussione | contributi)
Usando alcune funzioni esterne della libreria "libdvdread" è possibile conoscere quanti titoli e quanti capitoli sono presenti un un disco DVD video.
Per fruire in Gambas delle risorse di libdvdread bisognerà avere installata nel sistema la libreria condivisa: "libdvdread.so.7.0.0".
Mostriamo di seguito un breve codice esemplificativo:
Library "libdvdread:7.0.0" Public Struct ifo_handle_t file_ As Pointer vmgi_mat As Pointer tt_srpt As Pointer first_play_pgc As Pointer ptl_mait As Pointer vts_atrt As Pointer txtdt_mgi As Pointer pgci_ut As Pointer menu_c_adt As Pointer menu_vobu_admap As Pointer vtsi_mat As Pointer vts_ptt_srpt As Pointer vts_pgcit As Pointer vts_tmapt As Pointer vts_c_adt As Pointer vts_vobu_admap As Pointer End Struct Public Struct tt_srpt_t nr_of_srpts As Short zero_1 As Short last_byte As Integer title As Pointer End Struct Public Struct title_info_t pb_ty As Byte nr_of_angles As Byte nr_of_ptts As Short parental_id As Short title_set_nr As Byte vts_ttn As Byte title_set_sector As Integer End Struct ' dvd_reader_t* DVDOpen (const char * path) ' Opens a block device of a DVD-ROM file, or an image file, or a directory name for a mounted DVD or HD copy of a DVD. Private Extern DVDOpen(path As String) As Pointer ' ifo_handle_t * ifoOpen (dvd_reader_t *dvd, int title) ' Opens an IFO and reads in all the data for the IFO file corresponding to the given title. Private Extern ifoOpen(dvd_reader_t As Pointer, title As Integer) As Ifo_handle_t ' void ifoClose(ifo_handle_t * ifofile) ' Cleans up the IFO information. Private Extern ifoClose(ifofile As Ifo_handle_t) ' void DVDClose (dvd_reader_t *dvd) ' Closes and cleans up the DVD reader object. Private Extern DVDClose(dvd_reader_t As Pointer) Public Sub Main() Dim dvd As Pointer Dim ifo As Ifo_handle_t Dim tt_srpt As Tt_srpt_t Dim title As Title_info_t Dim i as Integer ' Apre il disco. E' necessario individuare l'esatto device ! dvd = DVDOpen("/dev/dvd") ' ...oppure in taluni casi potrebbe essere, ad esempio, "/dev/sr0" If dvd == 0 Then Error.Raise("Impossibile aprire il DVD: nessun dvd trovato !") ' Carica il gestore video per cercare informazioni relative ai titoli sul disco: ifo = ifoOpen(dvd, 0) If IsNull(ifo) Then DVDClose(dvd) Error.Raise("Impossibile aprire il gestore video e leggere il file principale IFO !") Endif tt_srpt = ifo.tt_srpt ' NOTA Print "Sono presenti nel DVD-Video "; tt_srpt.nr_of_srpts; " titoli.\n" For i = 0 To tt_srpt.nr_of_srpts - 1 Print "TITOLO "; i + 1; ":" title = tt_srpt.title + (i * 12) Print " in VTS: "; title.title_set_nr; " [TTN "; title.vts_ttn; "]" Print " il titolo ha "; title.nr_of_ptts; " capitoli\n" Next ' Va in chiusura: ifoClose(ifo) DVDClose(dvd) End