|
|
(7 versioni intermedie di uno stesso utente non sono mostrate) |
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.4.1.2''".
| |
− | | |
− | | |
− | Mostriamo di seguito un creve codice esemplificativo:
| |
− | '''Private''' a As Byte = 1
| |
− |
| |
− |
| |
− | Library "libdvdread:4.1.2"
| |
− |
| |
− | <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)
| |
− |
| |
− |
| |
− | '''Private''' Enum DVD_READ_INFO_FILE = 0, DVD_READ_INFO_BACKUP_FILE, DVD_READ_MENU_VOBS, DVD_READ_TITLE_VOBS
| |
− |
| |
− |
| |
− | '''Public''' Sub Main()
| |
− |
| |
− | Dim dvd, dvdR, p As Pointer
| |
− | Dim b As Byte
| |
− | Dim sh, s1, s2 As Short
| |
− | Dim pstm As Stream
| |
− |
| |
− |
| |
− | <FONT color=gray>' ''Apre il disco:''</font>
| |
− | dvd = DVDOpen("/dev/dvd")
| |
− | If IsNull(dvd) Then Error.Raise("Impossibile aprire il DVD: nessun dvd trovato !")
| |
− |
| |
− |
| |
− | dvdR = DVDOpenFile(dvd, 0, DVD_READ_MENU_VOBS)
| |
− | If IsNull(dvdR) Then Error.Raise("Impossibile aprire il file !")
| |
− |
| |
− |
| |
− | p = Alloc(2048)
| |
− |
| |
− | <FONT color=gray>' ''Carica il gestore video per cercare informazioni relative ai titoli sul disco:''</font>
| |
− | p = ifoOpen(dvd, 0)
| |
− | If IsNull(p) Then Error.Raise("Impossibile aprire il gestore video e leggere il file principale IFO !")
| |
− |
| |
− |
| |
− | <FONT color=gray>' ''Dereferenziamo il "puntatore" mediante i "Memory-Stream" per estrapolare i dati ricercati:''</font>
| |
− | pstm = Memory p For Read
| |
− |
| |
− | Seek #pstm, 1184
| |
− | Read #pstm, s1
| |
− | Seek #pstm, 1218
| |
− | Read #pstm, s2
| |
− |
| |
− | If s1 + s2 > 0 Then
| |
− | Print "\n\nTitoli presenti: "; s1
| |
− | Print "\nTitolo Capitoli"
| |
− | For sh = 1218 To ((s1 - 1) * 12) + 1218 Step 12
| |
− | Seek #pstm, sh
| |
− | Read #pstm, b
| |
− | Print a, "", b
| |
− | Inc a
| |
− | Next
| |
− | Else
| |
− | Seek #pstm, 1200
| |
− | Read #pstm, s1
| |
− | Print "\n\nTitoli presenti: "; s1
| |
− | Print "\nTitolo Capitoli"
| |
− | For sh = 1234 To ((s1 - 1) * 12) + 1234 Step 12
| |
− | Seek #pstm, sh
| |
− | Read #pstm, b
| |
− | Print a, "", b
| |
− | Inc a
| |
− | 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 Il sito del API di dvdread4]
| |