37#include <libbluray/bluray.h>
47 , m_end_pos(AV_NOPTS_VALUE)
52 , m_duration(AV_NOPTS_VALUE)
76 BLURAY_TITLE_INFO *ti;
101 m_bd = bd_open(
path().c_str(),
nullptr);
109 title_count = bd_get_titles(
m_bd, TITLES_RELEVANT, 0);
110 if (title_count == 0)
137 if (chapter_end >= ti->chapter_count)
153 m_duration =
static_cast<int64_t
>(ti->duration * AV_TIME_BASE / 90000);
157 BLURAY_TITLE_CHAPTER *chapter = &ti->chapters[
m_chapter_idx];
158 m_duration =
static_cast<int64_t
>(chapter->duration * AV_TIME_BASE / 90000);
161 bd_free_title_info(ti);
173 size_t result_len = 0;
195 int maxsize =
sizeof(
m_data);
202 int res = bd_read(
m_bd,
m_data.data(), maxsize);
209 size_t bytes =
static_cast<size_t>(res);
216 std::memcpy(data,
m_data.data(), result_len);
224 std::memcpy(data,
m_data.data(), result_len);
248 return static_cast<size_t>(
static_cast<int64_t
>(bd_tell(
m_bd)) -
m_start_pos);
struct bluray BLURAY
Forward declaration of libbluray handle.
virtual size_t readio(void *data, size_t size) override
Read data from file.
std::array< uint8_t, 192 *1024 > m_data
Buffer for readio() data.
int64_t m_cur_pos
Current position in virtual file.
size_t m_rest_pos
Position in buffer.
int64_t m_end_pos
End offset in bytes (not including this byte)
int64_t m_duration
Track/chapter duration, in AV_TIME_BASE fractional seconds.
virtual int seek(int64_t offset, int whence) override
Seek to position in file.
virtual int error() const override
Get last error.
BlurayIO()
Create BlurayIO object.
BLURAY * m_bd
Blu-ray disk handle.
virtual ~BlurayIO()
Free BlurayIO object.
unsigned m_angle_idx
Selected angle index (angle number -1)
uint32_t m_title_idx
Track index (track number - 1)
bool m_full_title
If true, ignore m_chapter_no and provide full track.
virtual int openio(LPVIRTUALFILE virtualfile) override
Open a virtual file.
size_t m_rest_size
Rest bytes in buffer.
virtual size_t bufsize() const override
Get the ideal buffer size.
unsigned m_chapter_idx
Chapter index (chapter number - 1)
virtual size_t size() const override
Get the file size.
void pvt_close()
Close virtual file. Non-virtual version to be safely called from constructor/destructor.
virtual bool eof() const override
Check if at end of file.
virtual void closeio() override
Close virtual file.
int64_t m_start_pos
Start offset in bytes.
virtual int64_t duration() const override
Get the duration of the file, in AV_TIME_BASE fractional seconds.
virtual size_t tell() const override
Get current read position.
virtual VIRTUALTYPE type() const override
Get type of the virtual file.
const std::string & path() const
Path to source file (without file name)
LPVIRTUALFILE virtualfile()
Get virtual file object.
void set_virtualfile(LPVIRTUALFILE virtualfile)
Set the virtual file object.
static void warning(const T filename, const std::string &format_string, Args &&...args)
Write warning level log entry.
static void debug(const T filename, const std::string &format_string, Args &&...args)
Write debug level log entry.
static void error(const T filename, const std::string &format_string, Args &&...args)
Write error level log entry.
VIRTUALTYPE
Virtual file types enum.
@ BLURAY
Blu-ray disk file.
Provide various log facilities to stderr, disk or syslog.
unsigned m_chapter_no
Chapter number (1...n)
uint32_t m_title_no
Track number (1...n)
unsigned m_angle_no
Selected angle number (1...n)
bool m_full_title
If true, ignore m_chapter_no and provide full track.
struct VIRTUALFILE::BLURAY_CHAPTER m_bluray
Blu-ray title/chapter info.
int64_t m_duration
Track/chapter duration, in AV_TIME_BASE fractional seconds.