11#include "libavcodec/avcodec.h"
17#define LOC QString("DVDDec: ")
94 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Need to generate frame @ %1 - %2 but no frame available!")
100 bool gotPacket =
false;
107 result = av_read_frame(Ctx, Pkt);
109 std::this_thread::yield();
116 case DVDNAV_HOP_CHANNEL:
122 Reset(
true,
false,
false);
134 case DVDNAV_STILL_FRAME:
149 av_packet_ref(Pkt, storedPkt);
150 av_packet_unref(storedPkt);
156 case DVDNAV_NAV_PACKET:
162 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Unexpected DVD event - %1")
170 result = av_read_frame(Ctx, Pkt);
177 std::this_thread::yield();
192 AVStream *curstream =
m_ic->streams[Pkt->stream_index];
194 if ((curstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ||
195 (curstream->codecpar->codec_id == AV_CODEC_ID_DVD_NAV))
210 if (Pts != AV_NOPTS_VALUE)
218 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"DVD context missed! lba: %1, curpts: %2, nav end pts: %3")
252 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"Missing video. Jumping to sector %1")
253 .arg(lastVideoSector));
260 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Missing video frame and no previous frame available! lba: %1")
278 int64_t
pts = Pkt->pts;
280 if (
pts == AV_NOPTS_VALUE)
313 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"Found video packet, jumping back to sector %1")
329 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"SeqEnd @ %1 - require %2 frame(s)")
356 if (Curstream->codecpar->codec_id == AV_CODEC_ID_DVD_NAV)
415 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
416 QString(
"DVD Audio Track Map Stream id #%1, av_stream_idx %2, MPEG stream 0x%3, lang %4")
427 trackNo =
static_cast<int>(i);
442 std::map<int,uint> lang_sub_cnt;
443 std::map<int,int> stream2idx;
450 stream2idx[stream_id] =
static_cast<int>(n);
459 for (
uint i = 0; i < 32; ++i)
466 uint lang_indx = lang_sub_cnt[lang]++;
469 if (stream2idx.count(streamid) != 0)
470 trackNo = stream2idx[streamid];
476 filteredTracks.emplace_back(-1, streamid, lang, lang_indx);
482 filteredTracks.back().m_stream_id &= 0x1f;
483 filteredTracks.back().m_language = lang;
484 filteredTracks.back().m_language_index = lang_indx;
505 mpegstream = QString(
"0x%1").arg(
m_ic->streams[avidx]->id,0,16);
509 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
510 QString(
"DVD Subtitle Track Map Stream id #%1, av_stream_idx %2, MPEG #%3, lang %4")
516 if ((selectedStream != -1) && (stream.
m_stream_id == selectedStream))
517 track =
static_cast<int>(idx);
521 if (
auto * dvdplayer =
dynamic_cast<MythDVDPlayer*
>(
m_parent); dvdplayer && (track < 0 || track >= trackcount))
523 emit dvdplayer->DisableDVDSubtitles();
525 else if (track >= 0 && track < trackcount)
529 emit player->EnableSubtitles(
true);
584 for (
uint i = 0; i <
m_ic->nb_streams; i++)
586 AVStream *st =
m_ic->streams[i];
587 if (st && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
613 int current_speed = 0;
620 if (ffrewSkip == 1 || ffrewSkip == 0)
622 std::chrono::seconds diffTime = std::chrono::seconds(
static_cast<int>(ceil((DesiredFrame -
m_framesPlayed) /
m_fps)));
630 if (desiredTimePos < 0s)
632 return (desiredTimePos.count() * 90000LL);
634 return current_speed;
MythMediaBuffer * m_ringBuffer
QRecursiveMutex m_trackLock
virtual void ResetPosMap(void)
std::array< sinfo_vec_t, kTrackTypeCount > m_tracks
virtual bool SyncPositionMap(void)
Updates the position map used for skipping frames.
std::array< StreamInfo, kTrackTypeCount > m_selectedTrack
int GetAudioTrackNum(uint StreamId)
get the logical track index (into PGC_AST_CTL) of the element that maps the given physical stream id.
uint GetSubtitleLanguage(int Id)
Get the subtitle language from the dvd.
int GetTrack(uint Type) const
get the track the dvd should be playing.
int32_t GetLastEvent(void) const
bool SectorSeek(uint64_t Sector)
uint32_t AdjustTimestamp(uint32_t Timestamp) const
uint GetAudioLanguage(int Index)
get the audio language from the dvd
int8_t GetSubtitleTrackNum(uint StreamId)
get the logical subtitle track/stream number from the dvd
std::chrono::seconds GetCurrentTime(void) const
bool PGCLengthChanged(void)
check if pgc length has changed
bool AudioStreamsChanged(void) const
int GetAudioTrackType(uint Index)
MythDVDContext * GetDVDContext(void)
void UnblockReading(void)
bool IsReadingBlocked(void)
Encapsulates playback context at any given moment.
int GetNumFramesPresent(void) const
Returns the number of video frames present in this VOBU.
int64_t GetEndPTS(void) const
uint32_t GetLBA(void) const
uint32_t GetLBAPrevVideoFrame(void) const
Returns the logical block address of the previous VOBU containing video.
int64_t GetSeqEndPTS(void) const
int GetNumFrames(void) const
Returns the duration of this VOBU in frames.
int64_t GetStartPTS(void) const
uint32_t m_lbaLastVideoPkt
void CheckContext(int64_t Pts)
bool GetFrame(DecodeType Type, bool &Retry) override
Demux, preprocess and possibly decode a frame of video/audio.
~MythDVDDecoder() override
MythDVDContext * m_returnContext
long long DVDFindPosition(long long DesiredFrame)
int GetAudioLanguage(uint AudioIndex, uint StreamIndex) override
bool ProcessVideoFrame(AVCodecContext *codecContext, AVStream *Stream, AVFrame *Frame) override
QList< MythDVDContext * > m_contextList
MythDVDDecoder(MythPlayer *Parent, const ProgramInfo &PGInfo, PlayerFlags Flags)
bool DoRewindSeek(long long DesiredFrame) override
bool ProcessDataPacket(AVStream *Curstream, AVPacket *Pkt, DecodeType Decodetype) override
int ReadPacket(AVFormatContext *Ctx, AVPacket *Pkt, bool &StorePacket) override
MythDVDContext * m_curContext
void PostProcessTracks(void) override
void Reset(bool ResetVideoData, bool SeekReset, bool ResetFile) override
void UpdateFramesPlayed(void) override
void StreamChangeCheck(void) override
static void ReleaseContext(MythDVDContext *&Context)
AudioTrackType GetAudioTrackType(uint Index) override
void DoFastForwardSeek(long long DesiredFrame, bool &NeedFlush) override
Seeks to the keyframe just before the desiredFrame if exact seeks is enabled, or the frame just after...
AVPacket * m_lastVideoPkt
bool ProcessVideoPacket(AVCodecContext *codecContext, AVStream *Stream, AVPacket *Pkt, bool &Retry) override
void ReleaseLastVideoPkt(void)
bool IsInMenu(void) const override
float GetNextPlaySpeed(void) const
void SetFramesPlayed(uint64_t played)
bool AtNormalSpeed(void) const
void DiscardVideoFrames(bool KeyFrame, bool Flushed)
Places frames in the available frames queue.
int GetFFRewSkip(void) const
Holds information on recordings and videos.
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
@ kAudioTypeAudioDescription
std::vector< StreamInfo > sinfo_vec_t
QString iso639_key_toName(int iso639_2)
Converts a canonical key to language name in English.
ISO 639-1 and ISO 639-2 support functions.
static int iso639_str3_to_key(const unsigned char *iso639_2)
static constexpr uint32_t INVALID_LBA
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
std::chrono::duration< CHRONO_TYPE, std::ratio< 1, 90000 > > pts