38#include <libbluray/bluray.h>
48 , m_end_pos(AV_NOPTS_VALUE)
53 , m_duration(AV_NOPTS_VALUE)
75 const char *bdpath =
nullptr;
78 char *keyfile =
nullptr;
79 BLURAY_TITLE_INFO *ti;
83 bdpath =
path().c_str();
106 m_bd = bd_open(bdpath, keyfile);
113 title_count = bd_get_titles(
m_bd, TITLES_RELEVANT, 0);
114 if (title_count == 0)
141 if (chapter_end >= ti->chapter_count)
157 m_duration =
static_cast<int64_t
>(ti->duration * AV_TIME_BASE / 90000);
161 BLURAY_TITLE_CHAPTER *chapter = &ti->chapters[
m_chapter_idx];
162 m_duration =
static_cast<int64_t
>(chapter->duration * AV_TIME_BASE / 90000);
165 bd_free_title_info(ti);
177 size_t result_len = 0;
199 int maxsize =
sizeof(
m_data);
213 size_t bytes =
static_cast<size_t>(res);
220 std::memcpy(data,
m_data, result_len);
228 std::memcpy(data,
m_data, result_len);
252 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.
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.
uint8_t m_data[192 *1024]
Buffer for readio() data.
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.
Various FFmpegfs utility functions.
VIRTUALTYPE
Virtual file types enum.
@ VIRTUALTYPE_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.