19#include "dvdread/dvd_reader.h"
20#include "dvdread/dvd_udf.h"
22#define LOC QString("DVDStream: ")
60 size_t block_count,
unsigned char *data,
66 return (Length + (DVD_VIDEO_LB_LEN - 1)) / DVD_VIDEO_LB_LEN;
95 const QString root = Filename.section(
"/VIDEO_TS/", 0, 0);
96 const QString path = Filename.section(root, 1);
101 m_reader = DVDOpen(qPrintable(root));
104 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"DVDOpen(%1) failed").arg(Filename));
116 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"(%1) UDFFindFile(%2) failed").
131 QString name {
"VIDEO_TS/VIDEO_TS.VOB" };
132 uint32_t
start = UDFFindFile(
m_reader, qPrintable(name), &len);
133 if(
start != 0 && len != 0 )
136 const int kTitles = 100;
137 for (
int title = 1; title < kTitles; ++title)
140 name = QString(
"/VIDEO_TS/VTS_%1_0.VOB").arg(title,2,10,QChar(
'0'));
142 if(
start != 0 && len != 0 )
145 for (
int part = 1; part < 10; ++part)
148 name = QString(
"/VIDEO_TS/VTS_%1_%2.VOB").arg(title,2,10,QChar(
'0')).arg(part);
150 if(
start != 0 && len != 0 )
160 dvd_file_t *
file = DVDOpenFile(
m_reader, 0, DVD_READ_MENU_VOBS);
164 LOG(VB_GENERAL, LOG_ERR,
LOC +
"DVDOpenFile(VOBS_1) failed");
181 uint32_t block = Size / DVD_VIDEO_LB_LEN;
184 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SafeRead too small");
200 else if (m_pos < it->
Start())
201 b = it->Start() -
m_pos;
208 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SafeRead DVDReadBlocks error");
213 block -=
static_cast<uint>(ret);
215 return ret * DVD_VIDEO_LB_LEN;
218 (
static_cast<ptrdiff_t
>(ret) * DVD_VIDEO_LB_LEN);
221 b = it->End() -
m_pos;
222 b = std::min(b, block);
236 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SafeRead DVDReadBlocks error");
243 block -=
static_cast<uint>(ret2);
245 (
static_cast<ptrdiff_t
>(ret2) * DVD_VIDEO_LB_LEN);
253 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SafeRead DVDReadBlocks error");
261 return ret * DVD_VIDEO_LB_LEN;
269 if (SEEK_END == Whence)
275 auto block =
static_cast<uint32_t
>(Position / DVD_VIDEO_LB_LEN);
276 if (
static_cast<int64_t
>(block) * DVD_VIDEO_LB_LEN != Position)
278 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Seek not block aligned");
292 long long ret =
static_cast<long long>(
m_pos) * DVD_VIDEO_LB_LEN;
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
bool operator<(const BlockRange rhs) const
uint32_t Start(void) const
BlockRange(uint32_t Start, uint32_t Count, int Title)
QList< BlockRange > m_blocks
bool IsOpen(void) const override
long long SeekInternal(long long Position, int Whence) override
bool OpenFile(const QString &Filename, std::chrono::milliseconds Retry=0ms) override
long long GetReadPosition(void) const override
~MythDVDStream() override
MythDVDStream(const QString &Filename)
int SafeRead(void *Buffer, uint Size) override
static constexpr int DVDINPUT_NOFLAGS
Defines and flags.
int InternalUDFReadBlocksRaw(dvd_reader_t *device, uint32_t lb_number, size_t block_count, unsigned char *data, int encrypted)
static constexpr int DVDINPUT_READ_DECRYPT
static constexpr int DVDCSS_SEEK_KEY
uint32_t Len2Blocks(uint32_t Length)
Roundup bytes to DVD blocks.
dvd_reader_s dvd_reader_t
#define LOG(_MASK_, _LEVEL_, _QSTRING_)