Go to the documentation of this file.
9 #include "libavcodec/avcodec.h"
15 #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;
113 case DVDNAV_HOP_CHANNEL:
119 Reset(
true,
false,
false);
131 case DVDNAV_STILL_FRAME:
146 av_packet_ref(Pkt, storedPkt);
147 av_packet_unref(storedPkt);
153 case DVDNAV_NAV_PACKET:
159 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Unexpected DVD event - %1")
168 result = av_read_frame(Ctx, Pkt);
175 std::this_thread::yield();
190 AVStream *curstream =
m_ic->streams[Pkt->stream_index];
192 if ((curstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ||
193 (curstream->codecpar->codec_id == AV_CODEC_ID_DVD_NAV))
208 if (Pts != AV_NOPTS_VALUE)
216 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"DVD context missed! lba: %1, curpts: %2, nav end pts: %3")
250 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"Missing video. Jumping to sector %1")
251 .
arg(lastVideoSector));
258 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Missing video frame and no previous frame available! lba: %1")
276 int64_t
pts = Pkt->pts;
278 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 int lang_indx =
static_cast<int>(lang_sub_cnt[lang]++);
469 if (stream2idx.count(streamid) != 0)
470 trackNo = stream2idx[streamid];
476 filteredTracks.push_back(
StreamInfo(-1, lang,
static_cast<uint>(lang_indx),
477 streamid, 0, 0,
false,
false,
false));
483 filteredTracks.back().m_stream_id &= 0x1f;
484 filteredTracks.back().m_language = lang;
485 filteredTracks.back().m_language_index =
static_cast<uint>(lang_indx);
506 mpegstream = QString(
"0x%1").arg(
m_ic->streams[avidx]->id,0,16);
510 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
511 QString(
"DVD Subtitle Track Map Stream id #%1, av_stream_idx %2, MPEG #%3, lang %4")
517 if ((selectedStream != -1) && (stream.
m_stream_id == selectedStream))
518 track =
static_cast<int>(idx);
522 if (
auto * dvdplayer =
dynamic_cast<MythDVDPlayer*
>(
m_parent); dvdplayer && (track < 0 || track >= trackcount))
524 emit dvdplayer->DisableDVDSubtitles();
526 else if (track >= 0 && track < trackcount)
530 emit player->EnableSubtitles(
true);
585 for (
uint i = 0; i <
m_ic->nb_streams; i++)
587 AVStream *st =
m_ic->streams[i];
588 if (st && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
614 int current_speed = 0;
621 if (ffrewSkip == 1 || ffrewSkip == 0)
623 std::chrono::seconds diffTime = std::chrono::seconds(
static_cast<int>(ceil((DesiredFrame -
m_framesPlayed) /
m_fps)));
631 if (desiredTimePos < 0s)
633 return (desiredTimePos.count() * 90000LL);
635 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
arg(title).arg(filename).arg(doDelete))
float GetNextPlaySpeed(void) const
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
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 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