Go to the documentation of this file.
9 #include "libavcodec/avcodec.h"
15 #define LOC QString("DVDDec: ")
92 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Need to generate frame @ %1 - %2 but no frame available!")
98 bool gotPacket =
false;
111 case DVDNAV_HOP_CHANNEL:
117 Reset(
true,
false,
false);
129 case DVDNAV_STILL_FRAME:
144 av_packet_ref(Pkt, storedPkt);
145 av_packet_unref(storedPkt);
151 case DVDNAV_NAV_PACKET:
157 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Unexpected DVD event - %1")
166 result = av_read_frame(Ctx, Pkt);
173 std::this_thread::yield();
188 AVStream *curstream =
m_ic->streams[Pkt->stream_index];
190 if ((curstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ||
191 (curstream->codecpar->codec_id == AV_CODEC_ID_DVD_NAV))
206 if (Pts != AV_NOPTS_VALUE)
214 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"DVD context missed! lba: %1, curpts: %2, nav end pts: %3")
248 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"Missing video. Jumping to sector %1")
249 .arg(lastVideoSector));
256 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Missing video frame and no previous frame available! lba: %1")
274 int64_t
pts = Pkt->pts;
276 if (
pts == AV_NOPTS_VALUE)
309 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"Found video packet, jumping back to sector %1")
325 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"SeqEnd @ %1 - require %2 frame(s)")
352 if (Curstream->codecpar->codec_id == AV_CODEC_ID_DVD_NAV)
411 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
412 QString(
"DVD Audio Track Map Stream id #%1, av_stream_idx %2, MPEG stream 0x%3, lang %4")
423 trackNo =
static_cast<int>(i);
438 std::map<int,uint> lang_sub_cnt;
439 std::map<int,int> stream2idx;
446 stream2idx[stream_id] =
static_cast<int>(n);
455 for (
uint i = 0; i < 32; ++i)
462 int lang_indx =
static_cast<int>(lang_sub_cnt[lang]++);
465 if (stream2idx.count(streamid) != 0)
466 trackNo = stream2idx[streamid];
472 filteredTracks.emplace_back(-1, lang,
static_cast<uint>(lang_indx),
473 streamid, 0, 0,
false,
false,
false);
479 filteredTracks.back().m_stream_id &= 0x1f;
480 filteredTracks.back().m_language = lang;
481 filteredTracks.back().m_language_index =
static_cast<uint>(lang_indx);
502 mpegstream = QString(
"0x%1").arg(
m_ic->streams[avidx]->id,0,16);
506 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
507 QString(
"DVD Subtitle Track Map Stream id #%1, av_stream_idx %2, MPEG #%3, lang %4")
513 if ((selectedStream != -1) && (stream.
m_stream_id == selectedStream))
514 track =
static_cast<int>(idx);
518 if (
auto * dvdplayer =
dynamic_cast<MythDVDPlayer*
>(
m_parent); dvdplayer && (track < 0 || track >= trackcount))
520 emit dvdplayer->DisableDVDSubtitles();
522 else if (track >= 0 && track < trackcount)
526 emit player->EnableSubtitles(
true);
581 for (
uint i = 0; i <
m_ic->nb_streams; i++)
583 AVStream *st =
m_ic->streams[i];
584 if (st && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
610 int current_speed = 0;
617 if (ffrewSkip == 1 || ffrewSkip == 0)
619 std::chrono::seconds diffTime = std::chrono::seconds(
static_cast<int>(ceil((DesiredFrame -
m_framesPlayed) /
m_fps)));
627 if (desiredTimePos < 0s)
629 return (desiredTimePos.count() * 90000LL);
631 return current_speed;
std::chrono::seconds GetCurrentTime(void) const
void UpdateFramesPlayed(void) override
uint32_t GetLBA(void) const
int GetTrack(uint Type) const
get the track the dvd should be playing.
bool AtNormalSpeed(void) const
std::array< StreamInfo, kTrackTypeCount > m_selectedTrack
~MythDVDDecoder() override
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
MythMediaBuffer * m_ringBuffer
MythDVDContext * m_returnContext
int GetNumFrames(void) const
Returns the duration of this VOBU in frames.
bool IsInMenu(void) const override
uint32_t m_lbaLastVideoPkt
QList< MythDVDContext * > m_contextList
bool DoRewindSeek(long long DesiredFrame) override
void CheckContext(int64_t Pts)
MythDVDContext * GetDVDContext(void)
int64_t GetEndPTS(void) const
float GetNextPlaySpeed(void) const
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QRecursiveMutex m_trackLock
int64_t GetSeqEndPTS(void) const
void ReleaseLastVideoPkt(void)
int32_t GetLastEvent(void) const
QString iso639_key_toName(int iso639_2)
Converts a canonical key to language name in English.
std::vector< StreamInfo > sinfo_vec_t
void DiscardVideoFrames(bool KeyFrame, bool Flushed)
Places frames in the available frames queue.
MythDVDContext * m_curContext
std::array< sinfo_vec_t, kTrackTypeCount > m_tracks
bool IsReadingBlocked(void)
bool ProcessDataPacket(AVStream *Curstream, AVPacket *Pkt, DecodeType Decodetype) override
@ kAudioTypeAudioDescription
long long DVDFindPosition(long long DesiredFrame)
AudioTrackType GetAudioTrackType(uint Index) override
int GetAudioTrackType(uint Index)
int GetAudioTrackNum(uint StreamId)
get the logical track index (into PGC_AST_CTL) of the element that maps the given physical stream id.
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...
int GetNumFramesPresent(void) const
Returns the number of video frames present in this VOBU.
int64_t GetStartPTS(void) const
Encapsulates playback context at any given moment.
bool PGCLengthChanged(void)
check if pgc length has changed
bool ProcessVideoPacket(AVStream *Stream, AVPacket *Pkt, bool &Retry) override
uint GetAudioLanguage(int Index)
get the audio language from the dvd
int GetAudioLanguage(uint AudioIndex, uint StreamIndex) override
virtual void ResetPosMap(void)
bool AudioStreamsChanged(void) const
MythDVDDecoder(MythPlayer *Parent, const ProgramInfo &PGInfo, PlayerFlags Flags)
bool ProcessVideoFrame(AVStream *Stream, AVFrame *Frame) override
virtual bool SyncPositionMap(void)
Updates the position map used for skipping frames.
uint32_t AdjustTimestamp(uint32_t Timestamp) const
uint32_t GetLBAPrevVideoFrame(void) const
Returns the logical block address of the previous VOBU containing video.
static constexpr uint32_t INVALID_LBA
static void ReleaseContext(MythDVDContext *&Context)
Holds information on recordings and videos.
void StreamChangeCheck(void) override
void PostProcessTracks(void) override
void SetFramesPlayed(uint64_t played)
AVPacket * m_lastVideoPkt
bool GetFrame(DecodeType Type, bool &Retry) override
Demux, preprocess and possibly decode a frame of video/audio.
void UnblockReading(void)
std::chrono::duration< CHRONO_TYPE, std::ratio< 1, 90000 > > pts
int8_t GetSubtitleTrackNum(uint StreamId)
get the logical subtitle track/stream number from the dvd
ISO 639-1 and ISO 639-2 support functions.
bool SectorSeek(uint64_t Sector)
void Reset(bool ResetVideoData, bool SeekReset, bool ResetFile) override
uint GetSubtitleLanguage(int Id)
Get the subtitle language from the dvd.
static int iso639_str3_to_key(const unsigned char *iso639_2)
int GetFFRewSkip(void) const
int ReadPacket(AVFormatContext *Ctx, AVPacket *Pkt, bool &StorePacket) override