FFmpegfs Fuse Multi Media Filesystem 2.16
dvdio.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2024 by Norbert Schlia (nschlia@oblivion-software.de)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 * On Debian systems, the complete text of the GNU General Public License
19 * Version 3 can be found in `/usr/share/common-licenses/GPL-3'.
20 */
21
34#ifndef DVDIO_H
35#define DVDIO_H
36
37#pragma once
38
39#ifdef USE_LIBDVD
40
41#include "fileio.h"
42
43#include <array>
44
45#include <dvdread/ifo_read.h>
46
49class DvdIO : public FileIO
50{
58 enum class DSITYPE
59 {
60 CONTINUE,
61 EOF_CHAPTER,
62 EOF_TITLE
63 };
64
65public:
69 explicit DvdIO();
73 virtual ~DvdIO();
74
79 virtual VIRTUALTYPE type() const override;
84 virtual size_t bufsize() const override;
85
92 virtual int openio(LPVIRTUALFILE virtualfile) override;
104 virtual size_t readio(void *data, size_t size) override;
109 virtual int error() const override;
114 virtual int64_t duration() const override;
119 virtual size_t size() const override;
124 virtual size_t tell() const override;
139 virtual int seek(int64_t offset, int whence) override;
144 virtual bool eof() const override;
148 virtual void closeio() override;
149
150private:
155 void pvt_close();
156
162 bool is_nav_pack(const unsigned char *buffer) const;
170 bool get_packet_size(const uint8_t *p, size_t peek, size_t *size) const;
177 int get_pes_id(const uint8_t *buffer, size_t size) const;
185 size_t demux_pes(uint8_t *out, const uint8_t *in, size_t len) const;
194 DSITYPE handle_DSI(void *_dsi_pack, size_t *cur_output_size, unsigned int * next_block, uint8_t *data);
198 void next_cell();
202 void rewind();
203
204protected:
205 dvd_reader_t * m_dvd;
206 dvd_file_t * m_dvd_title;
207 ifo_handle_t * m_vmg_file;
208 ifo_handle_t * m_vts_file;
209 pgc_t * m_cur_pgc;
215 unsigned int m_cur_block;
216 bool m_is_eof;
218 size_t m_rest_size;
219 size_t m_rest_pos;
220 size_t m_cur_pos;
227 std::array<unsigned char, 1024 * DVD_VIDEO_LB_LEN> m_data;
228 std::array<unsigned char, 1024 * DVD_VIDEO_LB_LEN> m_buffer;
230 int64_t m_duration;
231 size_t m_size;
232};
233#endif // USE_LIBDVD
234
235#endif // DVDIO_H
DVD I/O class.
Definition: dvdio.h:50
bool m_is_eof
true if at "end of file", i.e, end of chapter or title
Definition: dvdio.h:216
bool get_packet_size(const uint8_t *p, size_t peek, size_t *size) const
return the size of the next packet
Definition: dvdio.cc:236
int m_cur_cell
Current cell.
Definition: dvdio.h:212
int m_errno
errno of last operation
Definition: dvdio.h:217
virtual VIRTUALTYPE type() const override
Get type of the virtual file.
Definition: dvdio.cc:75
bool m_goto_next_cell
If logc needs to go to next cell before next read.
Definition: dvdio.h:214
bool m_full_title
If true, ignore m_chapter_no and provide full track.
Definition: dvdio.h:222
void rewind()
Rewind to start of stream.
Definition: dvdio.cc:721
virtual int seek(int64_t offset, int whence) override
Seek to position in file.
Definition: dvdio.cc:734
virtual size_t size() const override
Get the file size.
Definition: dvdio.cc:711
size_t m_size
Size of virtual file.
Definition: dvdio.h:231
DSITYPE handle_DSI(void *_dsi_pack, size_t *cur_output_size, unsigned int *next_block, uint8_t *data)
Handle DSI (Data Search Information) packet.
Definition: dvdio.cc:439
void pvt_close()
Close virtual file. Non-virtual version to be safely called from constructor/destructor.
Definition: dvdio.cc:802
ifo_handle_t * m_vmg_file
DVD video manager handle.
Definition: dvdio.h:207
bool is_nav_pack(const unsigned char *buffer) const
Do a rough check if this is really a navigation packet.
Definition: dvdio.cc:831
std::array< unsigned char, 1024 *DVD_VIDEO_LB_LEN > m_buffer
Buffer for data extracted from VOB file.
Definition: dvdio.h:228
size_t m_rest_size
Rest bytes in buffer.
Definition: dvdio.h:218
int m_title_idx
Track index (track number - 1)
Definition: dvdio.h:223
virtual void closeio() override
Close virtual file.
Definition: dvdio.cc:797
virtual size_t bufsize() const override
Get the ideal buffer size.
Definition: dvdio.cc:80
void next_cell()
Goto next DVD cell.
Definition: dvdio.cc:530
int64_t m_duration
Track/chapter duration, in AV_TIME_BASE fractional seconds.
Definition: dvdio.h:230
DSITYPE
Type of a DSI block.
Definition: dvdio.h:59
DvdIO()
Create DvdIO object.
Definition: dvdio.cc:42
virtual int openio(LPVIRTUALFILE virtualfile) override
Open a virtual file.
Definition: dvdio.cc:85
int m_next_cell
Next cell to be processed.
Definition: dvdio.h:213
int get_pes_id(const uint8_t *buffer, size_t size) const
return the id of a Packetized Elementary Stream (PES) (should be valid)
Definition: dvdio.cc:284
virtual bool eof() const override
Check if at end of file.
Definition: dvdio.cc:792
virtual size_t readio(void *data, size_t size) override
Read data from file.
Definition: dvdio.cc:552
virtual int error() const override
Get last error.
Definition: dvdio.cc:701
int m_chapter_idx
Chapter index (chapter number - 1)
Definition: dvdio.h:224
size_t m_cur_pos
Current position in virtual file.
Definition: dvdio.h:220
ifo_handle_t * m_vts_file
DVD video title stream handle.
Definition: dvdio.h:208
dvd_reader_t * m_dvd
DVD reader handle.
Definition: dvdio.h:205
pgc_t * m_cur_pgc
Current program chain.
Definition: dvdio.h:209
dvd_file_t * m_dvd_title
DVD title handle.
Definition: dvdio.h:206
virtual ~DvdIO()
Free DvdIO object.
Definition: dvdio.cc:70
int m_angle_idx
Selected angle index (angle number -1)
Definition: dvdio.h:225
size_t m_rest_pos
Position in buffer.
Definition: dvdio.h:219
unsigned int m_cur_block
Current processing block.
Definition: dvdio.h:215
std::array< unsigned char, 1024 *DVD_VIDEO_LB_LEN > m_data
Buffer for readio() data.
Definition: dvdio.h:227
int m_end_cell
End cell (of title)
Definition: dvdio.h:211
int m_start_cell
Start cell.
Definition: dvdio.h:210
virtual size_t tell() const override
Get current read position.
Definition: dvdio.cc:716
size_t demux_pes(uint8_t *out, const uint8_t *in, size_t len) const
Extract only the interesting portion of the VOB input stream.
Definition: dvdio.cc:388
virtual int64_t duration() const override
Get the duration of the file, in AV_TIME_BASE fractional seconds.
Definition: dvdio.cc:706
Base class for I/O.
Definition: fileio.h:260
LPVIRTUALFILE virtualfile()
Get virtual file object.
Definition: fileio.cc:113
FileIO class.
VIRTUALTYPE
Virtual file types enum.
Definition: fileio.h:92
Virtual file definition.
Definition: fileio.h:123