|
|
Riga 1: |
Riga 1: |
− | Usando alcune poche funzioni esterne della libreria "''libdvdread4''" è possibile conoscere quanti titoli e quanti capitoli sono presenti un un disco DVD video.
| + | #redirect[[Conoscere_il_numero_di_titoli_e_di_capitoli_presenti_in_un_DVD_video_con_le_funzioni_del_API_di_libdvdread]] |
− | | |
− | Per fruire delle risorse di ''libdvdread4'' bisognerà avere installata nel sistema la libreria attualmente: "''libdvdread.so.7.0.0''".
| |
− | | |
− | | |
− | Mostriamo di seguito un breve codice esemplificativo:
| |
− | Library "libdvdread:7.0.0"
| |
− |
| |
− | Private Enum DVD_READ_INFO_FILE = 0, DVD_READ_INFO_BACKUP_FILE, DVD_READ_MENU_VOBS, DVD_READ_TITLE_VOBS
| |
− |
| |
− | <FONT color=gray>' ''dvd_reader_t* DVDOpen (const char *)''
| |
− | ' ''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.''</font>
| |
− | Private Extern DVDOpen(fldvd As String) As Pointer
| |
− |
| |
− | <FONT color=gray>' ''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.''</font>
| |
− | Private Extern ifoOpen(dvd_reader_t As Pointer, title As Integer) As Pointer 'Ifo_handle_t
| |
− |
| |
− | <FONT color=gray>' ''dvd_file_t * DVDOpenFile (dvd_reader_t *, int, dvd_read_domain_t)''
| |
− | ' ''Opens a file on the DVD given the title number and domain.''</font>
| |
− | Private Extern DVDOpenFile(dvd_reader_t As Pointer, dvdI As Integer, dvd_readI As Integer) As Pointer
| |
− |
| |
− | <FONT color=gray>' ''void ifoClose(ifo_handle_t * ifofile)''
| |
− | ' ''Cleans up the IFO information.''</font>
| |
− | Private Extern ifoClose(ifop As Pointer)
| |
− |
| |
− | <FONT color=gray>' ''void DVDCloseFile(dvd_file_t * )''
| |
− | ' ''Closes a file and frees the associated structure.''</font>
| |
− | Private Extern DVDCloseFile(dvd_file_t As Pointer)
| |
− |
| |
− | <FONT color=gray>' ''void DVDClose (dvd_reader_t *dvd)''
| |
− | ' ''Closes and cleans up the DVD reader object.''</font>
| |
− | Private Extern DVDClose(dvd_reader_t As Pointer)
| |
− |
| |
− |
| |
− | '''Public''' Sub Main()
| |
− |
| |
− | Dim dvd, dvdR, p As Pointer
| |
− | Dim a, b As Byte
| |
− | Dim s1, s2 As Short
| |
− | Dim i as Integer
| |
− |
| |
− | <FONT color=gray>' ''Apre il disco. E' necessario individuare l'esatto device !''</font>
| |
− | dvd = DVDOpen("/dev/dvd") <FONT color=gray>' ''...oppure in taluni casi potrebbe essere, ad esempio, "/dev/sr0"''</font>
| |
− | If dvd = 0 Then Error.Raise("Impossibile aprire il DVD: nessun dvd trovato !")
| |
− |
| |
− | dvdR = DVDOpenFile(dvd, 0, DVD_READ_MENU_VOBS)
| |
− | If dvdR = 0 Then Error.Raise("Impossibile aprire il file !")
| |
− |
| |
− | <FONT color=gray>' ''Carica il gestore video per cercare informazioni relative ai titoli sul disco:''</font>
| |
− | p = ifoOpen(dvd, 0)
| |
− | If p = 0 Then Error.Raise("Impossibile aprire il gestore video e leggere il file principale IFO !")
| |
− |
| |
− | <FONT color=gray>' ''Dereferenziamo il "puntatore" per estrapolare i dati ricercati:''</font>
| |
− | s1 = Short@(p + 1184)
| |
− | s2 = Short@(p + 1218)
| |
− |
| |
− | If s1 + s2 > 0 Then
| |
− | Print "\n\nTitoli presenti: "; s1
| |
− | Print "\nTitolo Capitoli"
| |
− | For i = 1218 To ((s1 - 1) * 12) + 1218 Step 12
| |
− | Inc a
| |
− | b = Byte@(p + i)
| |
− | Print a; " "; b
| |
− | Next
| |
− | Else
| |
− | s1 = Short@(p + 1200)
| |
− | Print "\n\nTitoli presenti: "; s1
| |
− | Print "\nTitolo Capitoli"
| |
− | For i = 1234 To ((s1 - 1) * 12) + 1234 Step 12
| |
− | Inc a
| |
− | b = Byte@(p + i)
| |
− | Print a; " "; b
| |
− | Next
| |
− | Endif
| |
− | Print
| |
− |
| |
− |
| |
− | <FONT color=gray>' ''Va in chiusura:''</font>
| |
− | ifoClose(p)
| |
− | DVDCloseFile(dvdR)
| |
− | DVDClose(dvd)
| |
− |
| |
− | '''End'''
| |
− | | |
− | | |
− | | |
− | | |
− | =Riferimenti=
| |
− | * http://code.mythtv.org/doxygen/dvd__reader_8c.html
| |