MythTV  master
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
MythMediaBuffer Class Referenceabstract

#include <mythmediabuffer.h>

Inheritance diagram for MythMediaBuffer:
Inheritance graph
[legend]
Collaboration diagram for MythMediaBuffer:
Collaboration graph
[legend]

Public Member Functions

 ~MythMediaBuffer () override=0
 Deletes. More...
 
MythBufferType GetType () const
 
void SetOldFile (bool Old)
 Tell RingBuffer if this is an old file or not. More...
 
void UpdateRawBitrate (uint RawBitrate)
 Set the raw bit rate, to allow RingBuffer adjust effective bitrate. More...
 
void UpdatePlaySpeed (float PlaySpeed)
 Set the play speed, to allow RingBuffer adjust effective bitrate. More...
 
void EnableBitrateMonitor (bool Enable)
 
void SetBufferSizeFactors (bool EstBitrate, bool Matroska)
 Tells RingBuffer that the raw bitrate may be inaccurate and the underlying container is matroska, both of which may require a larger buffer size. More...
 
void SetWaitForWrite (void)
 
QString GetSafeFilename (void)
 
QString GetFilename (void) const
 
QString GetSubtitleFilename (void) const
 
QString GetLastError (void) const
 
bool GetCommsError (void) const
 
void ResetCommsError (void)
 
bool GetStopReads (void) const
 
QString GetDecoderRate (void)
 
QString GetStorageRate (void)
 
QString GetAvailableBuffer (void)
 
uint GetBufferSize (void) const
 
bool IsNearEnd (double Framerate, uint Frames) const
 
long long GetWritePosition (void) const
 Returns how far into a ThreadedFileWriter file we have written. More...
 
long long GetRealFileSize (void) const
 
bool IsDisc (void) const
 
bool IsDVD (void) const
 
bool IsBD (void) const
 
const MythDVDBufferDVD (void) const
 
MythDVDBufferDVD (void)
 
const MythBDBufferBD (void) const
 
MythBDBufferBD (void)
 
int Read (void *Buffer, int Count)
 This is the public method for reading from a file, it calls the appropriate read method if the file is remote or buffered, or a BD/DVD. More...
 
int Peek (void *Buffer, int Count)
 
void Reset (bool Full=false, bool ToAdjust=false, bool ResetInternal=false)
 Resets the read-ahead thread and our position in the file. More...
 
void Pause (void)
 Pauses the read-ahead thread. Calls StopReads(void). More...
 
void Unpause (void)
 Unpauses the read-ahead thread. Calls StartReads(void). More...
 
void WaitForPause (void)
 Waits for Pause(void) to take effect. More...
 
void Start (void)
 Starts the read-ahead thread. More...
 
void StopReads (void)
 
void StartReads (void)
 
long long Seek (long long Position, int Whence, bool HasLock=false)
 
long long SetAdjustFilesize (void)
 
int GetReadBufAvail (void) const
 Returns number of bytes available for reading from buffer. More...
 
bool SetReadInternalMode (bool Mode)
 
bool IsReadInternalMode (void) const
 
bool LiveMode (void) const
 Returns true if this RingBuffer has been assigned a LiveTVChain. More...
 
void SetLiveMode (LiveTVChain *Chain)
 Assigns a LiveTVChain to this RingBuffer. More...
 
void IgnoreLiveEOF (bool Ignore)
 Tells RingBuffer whether to ignore the end-of-file. More...
 
int Write (const void *Buffer, uint Count)
 Writes buffer to ThreadedFileWriter::Write(const void*,uint) More...
 
bool IsIOBound (void) const
 
void WriterFlush (void)
 Calls ThreadedFileWriter::Flush(void) More...
 
void Sync (void)
 Calls ThreadedFileWriter::Sync(void) More...
 
long long WriterSeek (long long Position, int Whence, bool HasLock=false)
 Calls ThreadedFileWriter::Seek(long long,int). More...
 
bool WriterSetBlocking (bool Lock=true)
 Calls ThreadedFileWriter::SetBlocking(bool) More...
 
virtual long long GetReadPosition (void) const =0
 
virtual bool IsOpen (void) const =0
 
virtual bool IsStreamed (void)
 
virtual bool IsSeekingAllowed (void)
 
virtual bool IsBookmarkAllowed (void)
 
virtual int BestBufferSize (void)
 
virtual bool StartFromBeginning (void)
 
virtual void IgnoreWaitStates (bool)
 
virtual bool IsInMenu (void) const
 
virtual bool IsInStillFrame (void) const
 
virtual bool IsInDiscMenuOrStillFrame (void) const
 
virtual bool HandleAction (const QStringList &, int64_t)
 
virtual bool OpenFile (const QString &Filename, uint Retry=static_cast< uint >(kDefaultOpenTimeout))=0
 
virtual bool ReOpen (const QString &="")
 

Static Public Member Functions

static MythMediaBufferCreate (const QString &Filename, bool Write, bool UseReadAhead=true, int Timeout=kDefaultOpenTimeout, bool StreamOnly=false)
 Creates a RingBuffer instance. More...
 
static QString BitrateToString (uint64_t Rate, bool Hz=false)
 
static void AVFormatInitNetwork (void)
 

Static Public Attributes

static const int kDefaultOpenTimeout = 2000
 
static const int kLiveTVOpenTimeout = 10000
 
static QMutex s_subExtLock
 
static QStringList s_subExt
 
static QStringList s_subExtNoCheck
 

Protected Member Functions

 MythMediaBuffer (MythBufferType Type)
 
void run (void) override
 Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead. More...
 
void CreateReadAheadBuffer (void)
 
void CalcReadAheadThresh (void)
 Calculates m_fillMin, m_fillThreshold, and m_readBlockSize from the estimated effective bitrate of the stream. More...
 
bool PauseAndWait (void)
 
int ReadPriv (void *Buffer, int Count, bool Peek)
 When possible reads from the read-ahead buffer, otherwise reads directly from the device. More...
 
int ReadDirect (void *Buffer, int Count, bool Peek)
 
bool WaitForReadsAllowed (void)
 
int WaitForAvail (int Count, int Timeout)
 
int ReadBufFree (void) const
 Returns number of bytes available for reading into buffer. More...
 
int ReadBufAvail (void) const
 Returns number of bytes available for reading from buffer. More...
 
void ResetReadAhead (long long NewInternal)
 Restart the read-ahead thread at the 'newinternal' position. More...
 
void KillReadAheadThread (void)
 Stops the read-ahead thread, and waits for it to stop. More...
 
uint64_t UpdateDecoderRate (uint64_t Latest=0)
 
uint64_t UpdateStorageRate (uint64_t Latest=0)
 
virtual int SafeRead (void *Buffer, uint Size)=0
 
virtual long long GetRealFileSizeInternal (void) const
 
virtual long long SeekInternal (long long Position, int Whence)=0
 
- Protected Member Functions inherited from MThread
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread. More...
 
 MThread (const QString &objectName)
 Standard constructor. More...
 
 MThread (const QString &objectName, QRunnable *runnable)
 Use this constructor if you want the default run() method to run the QRunnable's run() method instead of entering the Qt event loop. More...
 
virtual ~MThread ()
 
 MThread (const MThread &)=delete
 
MThreadoperator= (const MThread &)=delete
 
void RunProlog (void)
 Sets up a thread, call this if you reimplement run(). More...
 
void RunEpilog (void)
 Cleans up a thread's resources, call this if you reimplement run(). More...
 
QThread * qthread (void)
 Returns the thread, this will always return the same pointer no matter how often you restart the thread. More...
 
void setObjectName (const QString &name)
 
QString objectName (void) const
 
void setPriority (QThread::Priority priority)
 
QThread::Priority priority (void) const
 
bool isFinished (void) const
 
bool isRunning (void) const
 
void setStackSize (uint stackSize)
 
uint stackSize (void) const
 
void exit (int retcode=0)
 Use this to exit from the thread if you are using a Qt event loop. More...
 
void start (QThread::Priority p=QThread::InheritPriority)
 Tell MThread to start running the thread in the near future. More...
 
void terminate (void)
 Kill a thread unsafely. More...
 
void quit (void)
 calls exit(0) More...
 
bool wait (unsigned long time=ULONG_MAX)
 Wait for the MThread to exit, with a maximum timeout. More...
 

Protected Attributes

MythBufferType m_type
 
QReadWriteLock m_posLock
 
long long m_readPos { 0 }
 
long long m_writePos { 0 }
 
long long m_internalReadPos { 0 }
 
long long m_ignoreReadPos { -1 }
 
QReadWriteLock m_rbrLock
 
int m_rbrPos { 0 }
 
QReadWriteLock m_rbwLock
 
int m_rbwPos { 0 }
 
volatile bool m_stopReads {false}
 
QString m_safeFilename
 
QReadWriteLock m_rwLock
 
QString m_filename
 
QString m_subtitleFilename
 
QString m_lastError
 
ThreadedFileWriterm_tfw { nullptr }
 
int m_fd2 { -1 }
 
bool m_writeMode { false }
 
RemoteFilem_remotefile { nullptr }
 
uint m_bufferSize { BUFFER_SIZE_MINIMUM }
 
bool m_lowBuffers { false }
 
bool m_fileIsMatroska { false }
 
bool m_unknownBitrate { false }
 
bool m_startReadAhead { false }
 
char * m_readAheadBuffer { nullptr }
 
bool m_readAheadRunning { false }
 
bool m_reallyRunning { false }
 
bool m_requestPause { false }
 
bool m_paused { false }
 
bool m_ateof { false }
 
bool m_waitForWrite { false }
 
bool m_beingWritten { false }
 
bool m_readsAllowed { false }
 
bool m_readsDesired { false }
 
volatile bool m_recentSeek { true }
 
bool m_setSwitchToNext { false }
 
uint m_rawBitrate { 8000 }
 
float m_playSpeed { 1.0F }
 
int m_fillThreshold { 65536 }
 
int m_fillMin { -1 }
 
int m_readBlockSize { DEFAULT_CHUNK_SIZE}
 
int m_wantToRead { 0 }
 
int m_numFailures { 0 }
 
bool m_commsError { false }
 
bool m_oldfile { false }
 
LiveTVChainm_liveTVChain { nullptr }
 
bool m_ignoreLiveEOF { false }
 
long long m_readAdjust { 0 }
 
int m_readOffset { 0 }
 
bool m_readInternalMode { false }
 
bool m_bitrateMonitorEnabled { false }
 
QMutex m_decoderReadLock
 
QMap< qint64, uint64_t > m_decoderReads
 
QMutex m_storageReadLock
 
QMap< qint64, uint64_t > m_storageReads
 
QWaitCondition m_generalWait
 Condition to signal that the read ahead thread is running. More...
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prologExecuted {true}
 
bool m_epilogExecuted {true}
 

Private Attributes

bool m_bitrateInitialized { false }
 

Friends

class MythInteractiveBuffer
 

Additional Inherited Members

- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void sleep (unsigned long time)
 
static void msleep (unsigned long time)
 
static void usleep (unsigned long time)
 
static void ThreadSetup (const QString &name)
 This is to be called on startup in those few threads that haven't been ported to MThread. More...
 
static void ThreadCleanup (void)
 This is to be called on exit in those few threads that haven't been ported to MThread. More...
 
static void Cleanup (void)
 This will print out all the running threads, call exit(1) on each and then wait up to 5 seconds total for all the threads to exit. More...
 
static void GetAllThreadNames (QStringList &list)
 
static void GetAllRunningThreadNames (QStringList &list)
 
- Static Protected Attributes inherited from MThread
static const int kDefaultStartTimeout
 

Detailed Description

Definition at line 49 of file mythmediabuffer.h.

Constructor & Destructor Documentation

◆ ~MythMediaBuffer()

MythMediaBuffer::~MythMediaBuffer ( )
overridepure virtual

Deletes.

Note
Classes inheriting from RingBuffer must implement a destructor that calls KillReadAheadThread(). We can not do that here because this would leave pure virtual functions without implementations during destruction.

Definition at line 241 of file mythmediabuffer.cpp.

◆ MythMediaBuffer()

MythMediaBuffer::MythMediaBuffer ( MythBufferType  Type)
explicitprotected

Definition at line 203 of file mythmediabuffer.cpp.

Member Function Documentation

◆ Create()

MythMediaBuffer * MythMediaBuffer::Create ( const QString &  Filename,
bool  Write,
bool  UseReadAhead = true,
int  Timeout = kDefaultOpenTimeout,
bool  StreamOnly = false 
)
static

Creates a RingBuffer instance.

You can explicitly disable the readahead thread by setting readahead to false or by just not calling Start(void).

Parameters
FilenameName of file to read or write.
WriteIf true an encapsulated writer is created
UseReadAheadIf false a call to Start(void) will not a pre-buffering thread, otherwise Start(void) will start a pre-buffering thread.
Timeoutif < 0, then we will not open the file. Otherwise it's how long to try opening the file after the first failure in milliseconds before giving up.
StreamOnlyIf true disallow DVD and Bluray (used by FileTransfer)

Definition at line 104 of file mythmediabuffer.cpp.

Referenced by CopyFile(), FlagCommercials(), TVRec::GetProgramRingBufferForLiveTV(), PreviewGenerator::GetScreenGrab(), TV::HandleStateChange(), NuppelVideoRecorder::Initialize(), MythFileOpen(), MythAVFormatWriter::OpenFile(), pid_counter(), pid_filter(), pid_printer(), RebuildSeekTable(), ImportRecorder::run(), RunCCExtract(), TV::SwitchInputs(), TVRec::SwitchRecordingRingBuffer(), VideoPerformanceTest::Test(), Transcode::TranscodeFile(), and TVRec::TuningNewRecorder().

◆ GetType()

MythBufferType MythMediaBuffer::GetType ( ) const

◆ BitrateToString()

QString MythMediaBuffer::BitrateToString ( uint64_t  Rate,
bool  Hz = false 
)
static

◆ AVFormatInitNetwork()

void MythMediaBuffer::AVFormatInitNetwork ( void  )
static

◆ SetOldFile()

void MythMediaBuffer::SetOldFile ( bool  Old)

Tell RingBuffer if this is an old file or not.

Normally the RingBuffer determines that the file is old if it has not been modified in the last minute. This allows one to override that determination externally.

If for instance you are slowly writing to the file you could call this with the value of false. If you just finished writing the file you could call it with the value true. Knowing that the file is old allows MythTV to determine that a read at the end of the file is really an end-of-file condition more quickly. But if the file is growing it can also cause the RingBuffer to report an end-of-file condition prematurely.

Definition at line 1740 of file mythmediabuffer.cpp.

Referenced by FileTransfer::SetTimeout().

◆ UpdateRawBitrate()

void MythMediaBuffer::UpdateRawBitrate ( uint  RawBitrate)

Set the raw bit rate, to allow RingBuffer adjust effective bitrate.

Parameters
RawBitrateStreams average number of kilobits per second when playspeed is 1.0

Definition at line 301 of file mythmediabuffer.cpp.

Referenced by NuppelDecoder::GetFrame(), MythPlayer::JumpToProgram(), MythPlayer::JumpToStream(), NuppelDecoder::OpenFile(), AvFormatDecoder::ScanStreams(), and MythPlayer::SwitchToProgram().

◆ UpdatePlaySpeed()

void MythMediaBuffer::UpdatePlaySpeed ( float  PlaySpeed)

Set the play speed, to allow RingBuffer adjust effective bitrate.

Parameters
play_speedSpeed to set. (1.0 for normal speed)

Definition at line 329 of file mythmediabuffer.cpp.

◆ EnableBitrateMonitor()

void MythMediaBuffer::EnableBitrateMonitor ( bool  Enable)

Definition at line 337 of file mythmediabuffer.cpp.

Referenced by TV::timerEvent(), and TV::ToggleOSDDebug().

◆ SetBufferSizeFactors()

void MythMediaBuffer::SetBufferSizeFactors ( bool  EstBitrate,
bool  Matroska 
)

Tells RingBuffer that the raw bitrate may be inaccurate and the underlying container is matroska, both of which may require a larger buffer size.

Definition at line 352 of file mythmediabuffer.cpp.

Referenced by AvFormatDecoder::ScanStreams().

◆ SetWaitForWrite()

void MythMediaBuffer::SetWaitForWrite ( void  )

Definition at line 342 of file mythmediabuffer.cpp.

Referenced by RunCCExtract().

◆ GetSafeFilename()

QString MythMediaBuffer::GetSafeFilename ( void  )

Definition at line 1756 of file mythmediabuffer.cpp.

Referenced by MythPlayer::GetPlaybackData(), and MythPlayer::OpenFile().

◆ GetFilename()

QString MythMediaBuffer::GetFilename ( void  ) const

◆ GetSubtitleFilename()

QString MythMediaBuffer::GetSubtitleFilename ( void  ) const

Definition at line 1761 of file mythmediabuffer.cpp.

Referenced by PlayerContext::CreatePlayer(), and MythPlayer::JumpToProgram().

◆ GetLastError()

QString MythMediaBuffer::GetLastError ( void  ) const

◆ GetCommsError()

bool MythMediaBuffer::GetCommsError ( void  ) const

Definition at line 1777 of file mythmediabuffer.cpp.

Referenced by MythPlayer::EventLoop().

◆ ResetCommsError()

void MythMediaBuffer::ResetCommsError ( void  )

Definition at line 1782 of file mythmediabuffer.cpp.

Referenced by MythPlayer::EventLoop().

◆ GetStopReads()

bool MythMediaBuffer::GetStopReads ( void  ) const

Definition at line 1787 of file mythmediabuffer.cpp.

Referenced by MythPlayer::OpenFile(), and FileTransfer::RequestBlock().

◆ GetDecoderRate()

QString MythMediaBuffer::GetDecoderRate ( void  )

Definition at line 1542 of file mythmediabuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

◆ GetStorageRate()

QString MythMediaBuffer::GetStorageRate ( void  )

Definition at line 1547 of file mythmediabuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

◆ GetAvailableBuffer()

QString MythMediaBuffer::GetAvailableBuffer ( void  )

Definition at line 1552 of file mythmediabuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

◆ GetBufferSize()

uint MythMediaBuffer::GetBufferSize ( void  ) const

Definition at line 1562 of file mythmediabuffer.cpp.

Referenced by MythPlayer::GetPlaybackData().

◆ IsNearEnd()

bool MythMediaBuffer::IsNearEnd ( double  Framerate,
uint  Frames 
) const

Definition at line 429 of file mythmediabuffer.cpp.

Referenced by MythPlayer::IsReallyNearEnd().

◆ GetWritePosition()

long long MythMediaBuffer::GetWritePosition ( void  ) const

◆ GetRealFileSize()

long long MythMediaBuffer::GetRealFileSize ( void  ) const

◆ IsDisc()

bool MythMediaBuffer::IsDisc ( void  ) const

◆ IsDVD()

bool MythMediaBuffer::IsDVD ( void  ) const

Definition at line 1839 of file mythmediabuffer.cpp.

Referenced by MythDVDPlayer::CalcMaxFFTime(), MythDVDPlayer::ChangeSpeed(), TV::ChangeVolume(), MythDVDPlayer::DecoderGetFrameREW(), MythDVDPlayer::DisableCaptions(), MythDVDPlayer::DisplayDVDButton(), MythDVDPlayer::DisplayPauseFrame(), DecoderBase::DoFastForward(), MythDVDDecoder::DoFastForwardSeek(), MythDVDPlayer::DoJumpChapter(), MythDVDDecoder::DoRewindSeek(), MythDVDDecoder::DVDFindPosition(), MythDVDPlayer::EnableCaptions(), MythDVDDecoder::GetAudioLanguage(), MythDVDPlayer::GetBookmark(), MythDVDPlayer::GetChapterTimes(), MythDVDPlayer::GetCurrentChapter(), MythDVDPlayer::GetNumChapters(), MythDVDPlayer::GetSecondsPlayed(), AvFormatDecoder::GetTrackDesc(), MythDVDPlayer::GoToDVDProgram(), MythDVDPlayer::GoToMenu(), TV::HandleLCDTimerEvent(), TV::HandleStateChange(), AvFormatDecoder::InitVideoCodec(), IsDisc(), AvFormatDecoder::MpegPreProcessPkt(), AvFormatDecoder::OpenFile(), TV::OSDDialogEvent(), DecoderBase::PosMapFromDb(), MythDVDDecoder::PostProcessTracks(), MythDVDPlayer::PrepareAudioSample(), TV::ProcessKeypressOrGesture(), TV::ProcessNetworkControlCommand(), AvFormatDecoder::ProcessSubtitlePacket(), AvFormatDecoder::ProcessVideoFrame(), AvFormatDecoder::ProcessVideoPacket(), ReadDirect(), AvFormatDecoder::ScanStreams(), MythDVDPlayer::SeekForScreenGrab(), AvFormatDecoder::SeekReset(), MythDVDPlayer::SetBookmark(), TV::ShowLCDDVDInfo(), TV::ShowOSDStopWatchingRecording(), MythDVDPlayer::StillFrameCheck(), MythDVDDecoder::StreamChangeCheck(), DecoderBase::SyncPositionMap(), MythDVDDecoder::UpdateFramesPlayed(), and MythDVDPlayer::VideoLoop().

◆ IsBD()

bool MythMediaBuffer::IsBD ( void  ) const

◆ DVD() [1/2]

const MythDVDBuffer * MythMediaBuffer::DVD ( void  ) const

Definition at line 1849 of file mythmediabuffer.cpp.

Referenced by TV::ActiveHandleAction(), MythDVDPlayer::CalcMaxFFTime(), MythDVDPlayer::ChangeSpeed(), MythDVDDecoder::CheckContext(), MythDVDPlayer::DecoderGetFrameREW(), MythDVDPlayer::DisableCaptions(), MythDVDPlayer::DisplayDVDButton(), MythDVDPlayer::DisplayPauseFrame(), DecoderBase::DoFastForward(), MythDVDPlayer::DoJumpChapter(), MythDVDDecoder::DVDFindPosition(), MythDVDPlayer::EnableCaptions(), MythDVDPlayer::EventEnd(), MythDVDPlayer::EventStart(), MythDVDDecoder::GetAudioLanguage(), MythDVDDecoder::GetAudioTrackType(), MythDVDPlayer::GetBookmark(), MythDVDPlayer::GetChapterTimes(), MythDVDPlayer::GetCurrentAngle(), MythDVDPlayer::GetCurrentChapter(), MythDVDPlayer::GetNumAngles(), MythDVDPlayer::GetNumChapters(), MythDVDPlayer::GetSecondsPlayed(), MythDVDPlayer::GoToDVDProgram(), MythDVDPlayer::GoToMenu(), MythDVDPlayer::InitialSeek(), AvFormatDecoder::MpegPreProcessPkt(), DecoderBase::PosMapFromDb(), MythDVDDecoder::PostProcessTracks(), MythDVDPlayer::PrepareAudioSample(), MythDVDDecoder::ProcessDataPacket(), AvFormatDecoder::ProcessSubtitlePacket(), MythDVDDecoder::ProcessVideoPacket(), MythDVDDecoder::ReadPacket(), AvFormatDecoder::ScanStreams(), MythDVDPlayer::SeekForScreenGrab(), MythDVDPlayer::SetBookmark(), MythDVDPlayer::SetTrack(), TV::ShowLCDDVDInfo(), MythDVDPlayer::StillFrameCheck(), MythDVDDecoder::StreamChangeCheck(), MythDVDPlayer::SwitchAngle(), DecoderBase::SyncPositionMap(), MythDVDDecoder::UpdateFramesPlayed(), MythDVDPlayer::VideoLoop(), and MythDVDPlayer::VideoStart().

◆ DVD() [2/2]

MythDVDBuffer * MythMediaBuffer::DVD ( void  )

Definition at line 1859 of file mythmediabuffer.cpp.

◆ BD() [1/2]

const MythBDBuffer * MythMediaBuffer::BD ( void  ) const

◆ BD() [2/2]

MythBDBuffer * MythMediaBuffer::BD ( void  )

Definition at line 1864 of file mythmediabuffer.cpp.

◆ Read()

int MythMediaBuffer::Read ( void *  Buffer,
int  Count 
)

This is the public method for reading from a file, it calls the appropriate read method if the file is remote or buffered, or a BD/DVD.

Parameters
bufPointer to where data will be written
countNumber of bytes to read
Returns
Returns number of bytes read

Definition at line 1495 of file mythmediabuffer.cpp.

Referenced by CopyFile(), NuppelDecoder::GetFrame(), NuppelDecoder::OpenFile(), pid_counter(), pid_filter(), pid_printer(), MythAVFormatBuffer::Read(), NuppelDecoder::ReadFileheader(), NuppelDecoder::ReadFrameheader(), and FileTransfer::RequestBlock().

◆ Peek()

int MythMediaBuffer::Peek ( void *  Buffer,
int  Count 
)
Note
Only works with readahead

Definition at line 1191 of file mythmediabuffer.cpp.

Referenced by MythPlayer::OpenFile(), ReadDirect(), and ReadPriv().

◆ Reset()

void MythMediaBuffer::Reset ( bool  Full = false,
bool  ToAdjust = false,
bool  ResetInternal = false 
)

Resets the read-ahead thread and our position in the file.

Definition at line 260 of file mythmediabuffer.cpp.

Referenced by MythPlayer::FileChanged(), MythPlayer::JumpToProgram(), MythInteractiveBuffer::OpenFile(), and MythPlayer::SwitchToProgram().

◆ Pause()

void MythMediaBuffer::Pause ( void  )

◆ Unpause()

void MythMediaBuffer::Unpause ( void  )

◆ WaitForPause()

void MythMediaBuffer::WaitForPause ( void  )

◆ Start()

void MythMediaBuffer::Start ( void  )

Starts the read-ahead thread.

If the RingBuffer constructor was not called with a usereadahead of true of if this was reset to false because we're dealing with a DVD the read ahead thread will not be started.

If this RingBuffer is in write-mode a warning will be printed and the read ahead thread will not be started.

If the read ahead thread is already running a warning will be printed and the read ahead thread will not be started.

Definition at line 634 of file mythmediabuffer.cpp.

Referenced by FileTransfer::FileTransfer(), MythFileOpen(), MythPlayer::OpenFile(), and MythDVDStream::SafeRead().

◆ StopReads()

void MythMediaBuffer::StopReads ( void  )

◆ StartReads()

void MythMediaBuffer::StartReads ( void  )

◆ Seek()

long long MythMediaBuffer::Seek ( long long  Position,
int  Whence,
bool  HasLock = false 
)

◆ SetAdjustFilesize()

long long MythMediaBuffer::SetAdjustFilesize ( void  )

Definition at line 1179 of file mythmediabuffer.cpp.

Referenced by MythPlayer::SwitchToProgram().

◆ GetReadBufAvail()

int MythMediaBuffer::GetReadBufAvail ( void  ) const

Returns number of bytes available for reading from buffer.

Definition at line 479 of file mythmediabuffer.cpp.

Referenced by AvFormatDecoder::InitByteContext().

◆ SetReadInternalMode()

bool MythMediaBuffer::SetReadInternalMode ( bool  Mode)

Definition at line 540 of file mythmediabuffer.cpp.

Referenced by MythAVFormatBuffer::SetInInit().

◆ IsReadInternalMode()

bool MythMediaBuffer::IsReadInternalMode ( void  ) const

Definition at line 565 of file mythmediabuffer.cpp.

◆ LiveMode()

bool MythMediaBuffer::LiveMode ( void  ) const

Returns true if this RingBuffer has been assigned a LiveTVChain.

See also
SetLiveMode(LiveTVChain*)

Definition at line 1807 of file mythmediabuffer.cpp.

Referenced by NuppelDecoder::GetFrame(), NuppelVideoRecorder::Initialize(), IsStreamed(), and MythPlayer::OpenFile().

◆ SetLiveMode()

void MythMediaBuffer::SetLiveMode ( LiveTVChain Chain)

Assigns a LiveTVChain to this RingBuffer.

See also
LiveMode(void)

Definition at line 1819 of file mythmediabuffer.cpp.

Referenced by TV::HandleStateChange(), and TV::SwitchInputs().

◆ IgnoreLiveEOF()

void MythMediaBuffer::IgnoreLiveEOF ( bool  Ignore)

Tells RingBuffer whether to ignore the end-of-file.

Definition at line 1827 of file mythmediabuffer.cpp.

Referenced by MythPlayer::JumpToProgram(), TV::PauseLiveTV(), TV::SwitchInputs(), and TV::UnpauseLiveTV().

◆ Write()

int MythMediaBuffer::Write ( const void *  Buffer,
uint  Count 
)

◆ IsIOBound()

bool MythMediaBuffer::IsIOBound ( void  ) const

◆ WriterFlush()

void MythMediaBuffer::WriterFlush ( void  )

◆ Sync()

void MythMediaBuffer::Sync ( void  )

Calls ThreadedFileWriter::Sync(void)

Definition at line 1670 of file mythmediabuffer.cpp.

◆ WriterSeek()

long long MythMediaBuffer::WriterSeek ( long long  Position,
int  Whence,
bool  HasLock = false 
)

◆ WriterSetBlocking()

bool MythMediaBuffer::WriterSetBlocking ( bool  Lock = true)

◆ GetReadPosition()

virtual long long MythMediaBuffer::GetReadPosition ( void  ) const
pure virtual

◆ IsOpen()

virtual bool MythMediaBuffer::IsOpen ( void  ) const
pure virtual

◆ IsStreamed()

virtual bool MythMediaBuffer::IsStreamed ( void  )
inlinevirtual

◆ IsSeekingAllowed()

virtual bool MythMediaBuffer::IsSeekingAllowed ( void  )
inlinevirtual

◆ IsBookmarkAllowed()

virtual bool MythMediaBuffer::IsBookmarkAllowed ( void  )
inlinevirtual

◆ BestBufferSize()

virtual int MythMediaBuffer::BestBufferSize ( void  )
inlinevirtual

Reimplemented in MythDVDBuffer.

Definition at line 126 of file mythmediabuffer.h.

Referenced by AvFormatDecoder::InitByteContext().

◆ StartFromBeginning()

virtual bool MythMediaBuffer::StartFromBeginning ( void  )
inlinevirtual

Reimplemented in MythDVDBuffer, and MythBDBuffer.

Definition at line 127 of file mythmediabuffer.h.

Referenced by AvFormatDecoder::OpenFile().

◆ IgnoreWaitStates()

virtual void MythMediaBuffer::IgnoreWaitStates ( bool  )
inlinevirtual

Reimplemented in MythDVDBuffer, and MythBDBuffer.

Definition at line 128 of file mythmediabuffer.h.

Referenced by MythDVDPlayer::InitialSeek(), AvFormatDecoder::OpenFile(), and TV::StopStuff().

◆ IsInMenu()

virtual bool MythMediaBuffer::IsInMenu ( void  ) const
inlinevirtual

◆ IsInStillFrame()

virtual bool MythMediaBuffer::IsInStillFrame ( void  ) const
inlinevirtual

◆ IsInDiscMenuOrStillFrame()

virtual bool MythMediaBuffer::IsInDiscMenuOrStillFrame ( void  ) const
inlinevirtual

◆ HandleAction()

virtual bool MythMediaBuffer::HandleAction ( const QStringList &  ,
int64_t   
)
inlinevirtual

Reimplemented in MythDVDBuffer, and MythBDBuffer.

Definition at line 132 of file mythmediabuffer.h.

Referenced by TV::DiscMenuHandleAction().

◆ OpenFile()

virtual bool MythMediaBuffer::OpenFile ( const QString &  Filename,
uint  Retry = static_cast< uint >(kDefaultOpenTimeout) 
)
pure virtual

◆ ReOpen()

virtual bool MythMediaBuffer::ReOpen ( const QString &  = "")
inlinevirtual

Reimplemented in MythFileBuffer.

Definition at line 134 of file mythmediabuffer.h.

Referenced by MythAVFormatWriter::ReOpen(), and FileTransfer::ReOpen().

◆ run()

void MythMediaBuffer::run ( void  )
overrideprotectedvirtual

Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.

Note
If you override this method you must call RunProlog before you do any work and RunEpilog before you exit the run method.

Reimplemented from MThread.

Definition at line 841 of file mythmediabuffer.cpp.

◆ CreateReadAheadBuffer()

void MythMediaBuffer::CreateReadAheadBuffer ( void  )
protected

Definition at line 793 of file mythmediabuffer.cpp.

Referenced by run(), and SetBufferSizeFactors().

◆ CalcReadAheadThresh()

void MythMediaBuffer::CalcReadAheadThresh ( void  )
protected

Calculates m_fillMin, m_fillThreshold, and m_readBlockSize from the estimated effective bitrate of the stream.

Warning
Must be called with rwlock in write lock state.

Definition at line 368 of file mythmediabuffer.cpp.

Referenced by CreateReadAheadBuffer(), MythBDBuffer::OpenFile(), MythDVDBuffer::OpenFile(), MythFileBuffer::OpenFile(), MythInteractiveBuffer::OpenFile(), ResetReadAhead(), run(), UpdatePlaySpeed(), and UpdateRawBitrate().

◆ PauseAndWait()

bool MythMediaBuffer::PauseAndWait ( void  )
protected

Definition at line 750 of file mythmediabuffer.cpp.

Referenced by run().

◆ ReadPriv()

int MythMediaBuffer::ReadPriv ( void *  Buffer,
int  Count,
bool  Peek 
)
protected

When possible reads from the read-ahead buffer, otherwise reads directly from the device.

Parameters
BufferPointer to where data will be written
CountNumber of bytes to read
PeekIf true, don't increment read count
Returns
Returns number of bytes read

Definition at line 1340 of file mythmediabuffer.cpp.

Referenced by Peek(), and Read().

◆ ReadDirect()

int MythMediaBuffer::ReadDirect ( void *  Buffer,
int  Count,
bool  Peek 
)
protected

Definition at line 1265 of file mythmediabuffer.cpp.

Referenced by ReadPriv().

◆ WaitForReadsAllowed()

bool MythMediaBuffer::WaitForReadsAllowed ( void  )
protected

Definition at line 1202 of file mythmediabuffer.cpp.

Referenced by ReadPriv().

◆ WaitForAvail()

int MythMediaBuffer::WaitForAvail ( int  Count,
int  Timeout 
)
protected

Definition at line 1230 of file mythmediabuffer.cpp.

Referenced by ReadPriv().

◆ ReadBufFree()

int MythMediaBuffer::ReadBufFree ( void  ) const
protected

Returns number of bytes available for reading into buffer.

Warning
Must be called with rwlock in locked state.

Definition at line 468 of file mythmediabuffer.cpp.

Referenced by run().

◆ ReadBufAvail()

int MythMediaBuffer::ReadBufAvail ( void  ) const
protected

Returns number of bytes available for reading from buffer.

Warning
Must be called with rwlock in locked state.

Definition at line 572 of file mythmediabuffer.cpp.

Referenced by GetReadBufAvail(), GetRealFileSize(), ReadPriv(), Seek(), and WaitForAvail().

◆ ResetReadAhead()

void MythMediaBuffer::ResetReadAhead ( long long  NewInternal)
protected

Restart the read-ahead thread at the 'newinternal' position.

This is called after a Seek(long long, int) so that the read-ahead buffer doesn't contain any stale data, and so that it will read any new data from the new position in the file.

Warning
Must be called with rwlock and poslock in write lock state.
Parameters
NewInternalPosition in file to start reading data from

Definition at line 592 of file mythmediabuffer.cpp.

Referenced by Reset(), run(), MythBDBuffer::SeekInternal(), MythDVDBuffer::SeekInternal(), MythFileBuffer::SeekInternal(), and MythInteractiveBuffer::SeekInternal().

◆ KillReadAheadThread()

void MythMediaBuffer::KillReadAheadThread ( void  )
protected

◆ UpdateDecoderRate()

uint64_t MythMediaBuffer::UpdateDecoderRate ( uint64_t  Latest = 0)
protected

Definition at line 1567 of file mythmediabuffer.cpp.

Referenced by GetDecoderRate(), and Read().

◆ UpdateStorageRate()

uint64_t MythMediaBuffer::UpdateStorageRate ( uint64_t  Latest = 0)
protected

Definition at line 1598 of file mythmediabuffer.cpp.

Referenced by GetStorageRate(), ReadDirect(), and run().

◆ SafeRead()

virtual int MythMediaBuffer::SafeRead ( void *  Buffer,
uint  Size 
)
protectedpure virtual

◆ GetRealFileSizeInternal()

virtual long long MythMediaBuffer::GetRealFileSizeInternal ( void  ) const
inlineprotectedvirtual

Reimplemented in MythStreamingBuffer, MythInteractiveBuffer, MythFileBuffer, and HLSRingBuffer.

Definition at line 155 of file mythmediabuffer.h.

Referenced by GetRealFileSize().

◆ SeekInternal()

virtual long long MythMediaBuffer::SeekInternal ( long long  Position,
int  Whence 
)
protectedpure virtual

Friends And Related Function Documentation

◆ MythInteractiveBuffer

friend class MythInteractiveBuffer
friend

Definition at line 51 of file mythmediabuffer.h.

Member Data Documentation

◆ kDefaultOpenTimeout

const int MythMediaBuffer::kDefaultOpenTimeout = 2000
static

Definition at line 61 of file mythmediabuffer.h.

Referenced by MythFileOpen().

◆ kLiveTVOpenTimeout

const int MythMediaBuffer::kLiveTVOpenTimeout = 10000
static

◆ m_type

MythBufferType MythMediaBuffer::m_type
protected

Definition at line 160 of file mythmediabuffer.h.

Referenced by GetAvailableBuffer(), GetType(), IsBD(), and IsDVD().

◆ m_posLock

QReadWriteLock MythMediaBuffer::m_posLock
mutableprotected

◆ m_readPos

long long MythMediaBuffer::m_readPos { 0 }
protected

◆ m_writePos

long long MythMediaBuffer::m_writePos { 0 }
protected

Definition at line 164 of file mythmediabuffer.h.

Referenced by GetWritePosition(), MythFileBuffer::ReOpen(), Reset(), Write(), and WriterSeek().

◆ m_internalReadPos

long long MythMediaBuffer::m_internalReadPos { 0 }
protected

◆ m_ignoreReadPos

long long MythMediaBuffer::m_ignoreReadPos { -1 }
protected

◆ m_rbrLock

QReadWriteLock MythMediaBuffer::m_rbrLock
mutableprotected

◆ m_rbrPos

int MythMediaBuffer::m_rbrPos { 0 }
protected

◆ m_rbwLock

QReadWriteLock MythMediaBuffer::m_rbwLock
mutableprotected

◆ m_rbwPos

int MythMediaBuffer::m_rbwPos { 0 }
protected

◆ m_stopReads

volatile bool MythMediaBuffer::m_stopReads {false}
protected

◆ m_safeFilename

QString MythMediaBuffer::m_safeFilename
protected

◆ m_rwLock

QReadWriteLock MythMediaBuffer::m_rwLock
mutableprotected

◆ m_filename

QString MythMediaBuffer::m_filename
protected

◆ m_subtitleFilename

QString MythMediaBuffer::m_subtitleFilename
protected

Definition at line 183 of file mythmediabuffer.h.

Referenced by GetSubtitleFilename(), and MythFileBuffer::OpenFile().

◆ m_lastError

QString MythMediaBuffer::m_lastError
protected

◆ m_tfw

ThreadedFileWriter* MythMediaBuffer::m_tfw { nullptr }
protected

◆ m_fd2

int MythMediaBuffer::m_fd2 { -1 }
protected

◆ m_writeMode

bool MythMediaBuffer::m_writeMode { false }
protected

◆ m_remotefile

RemoteFile* MythMediaBuffer::m_remotefile { nullptr }
protected

◆ m_bufferSize

uint MythMediaBuffer::m_bufferSize { BUFFER_SIZE_MINIMUM }
protected

◆ m_lowBuffers

bool MythMediaBuffer::m_lowBuffers { false }
protected

Definition at line 190 of file mythmediabuffer.h.

Referenced by CalcReadAheadThresh(), and WaitForAvail().

◆ m_fileIsMatroska

bool MythMediaBuffer::m_fileIsMatroska { false }
protected

Definition at line 191 of file mythmediabuffer.h.

Referenced by CreateReadAheadBuffer(), and SetBufferSizeFactors().

◆ m_unknownBitrate

bool MythMediaBuffer::m_unknownBitrate { false }
protected

Definition at line 192 of file mythmediabuffer.h.

Referenced by CreateReadAheadBuffer(), and SetBufferSizeFactors().

◆ m_startReadAhead

bool MythMediaBuffer::m_startReadAhead { false }
protected

◆ m_readAheadBuffer

char* MythMediaBuffer::m_readAheadBuffer { nullptr }
protected

Definition at line 194 of file mythmediabuffer.h.

Referenced by CreateReadAheadBuffer(), ReadPriv(), run(), and ~MythMediaBuffer().

◆ m_readAheadRunning

bool MythMediaBuffer::m_readAheadRunning { false }
protected

◆ m_reallyRunning

bool MythMediaBuffer::m_reallyRunning { false }
protected

Definition at line 196 of file mythmediabuffer.h.

Referenced by run(), and Start().

◆ m_requestPause

bool MythMediaBuffer::m_requestPause { false }
protected

◆ m_paused

bool MythMediaBuffer::m_paused { false }
protected

Definition at line 198 of file mythmediabuffer.h.

Referenced by IsNearEnd(), PauseAndWait(), and WaitForPause().

◆ m_ateof

bool MythMediaBuffer::m_ateof { false }
protected

◆ m_waitForWrite

bool MythMediaBuffer::m_waitForWrite { false }
protected

Definition at line 200 of file mythmediabuffer.h.

Referenced by run(), and SetWaitForWrite().

◆ m_beingWritten

bool MythMediaBuffer::m_beingWritten { false }
protected

Definition at line 201 of file mythmediabuffer.h.

Referenced by run().

◆ m_readsAllowed

bool MythMediaBuffer::m_readsAllowed { false }
protected

◆ m_readsDesired

bool MythMediaBuffer::m_readsDesired { false }
protected

◆ m_recentSeek

volatile bool MythMediaBuffer::m_recentSeek { true }
protected

◆ m_setSwitchToNext

bool MythMediaBuffer::m_setSwitchToNext { false }
protected

◆ m_rawBitrate

uint MythMediaBuffer::m_rawBitrate { 8000 }
protected

◆ m_playSpeed

float MythMediaBuffer::m_playSpeed { 1.0F }
protected

Definition at line 207 of file mythmediabuffer.h.

Referenced by CalcReadAheadThresh(), IsNearEnd(), and UpdatePlaySpeed().

◆ m_fillThreshold

int MythMediaBuffer::m_fillThreshold { 65536 }
protected

Definition at line 208 of file mythmediabuffer.h.

Referenced by CalcReadAheadThresh(), and run().

◆ m_fillMin

int MythMediaBuffer::m_fillMin { -1 }
protected

◆ m_readBlockSize

int MythMediaBuffer::m_readBlockSize { DEFAULT_CHUNK_SIZE}
protected

◆ m_wantToRead

int MythMediaBuffer::m_wantToRead { 0 }
protected

Definition at line 211 of file mythmediabuffer.h.

Referenced by ReadPriv(), and WaitForAvail().

◆ m_numFailures

int MythMediaBuffer::m_numFailures { 0 }
protected

◆ m_commsError

bool MythMediaBuffer::m_commsError { false }
protected

◆ m_oldfile

bool MythMediaBuffer::m_oldfile { false }
protected

◆ m_liveTVChain

LiveTVChain* MythMediaBuffer::m_liveTVChain { nullptr }
protected

◆ m_ignoreLiveEOF

bool MythMediaBuffer::m_ignoreLiveEOF { false }
protected

Definition at line 216 of file mythmediabuffer.h.

Referenced by IgnoreLiveEOF(), and run().

◆ m_readAdjust

long long MythMediaBuffer::m_readAdjust { 0 }
protected

◆ m_readOffset

int MythMediaBuffer::m_readOffset { 0 }
protected

Definition at line 218 of file mythmediabuffer.h.

Referenced by ReadPriv(), ResetReadAhead(), Seek(), and SetReadInternalMode().

◆ m_readInternalMode

bool MythMediaBuffer::m_readInternalMode { false }
protected

◆ m_bitrateMonitorEnabled

bool MythMediaBuffer::m_bitrateMonitorEnabled { false }
protected

Definition at line 222 of file mythmediabuffer.h.

Referenced by EnableBitrateMonitor(), UpdateDecoderRate(), and UpdateStorageRate().

◆ m_decoderReadLock

QMutex MythMediaBuffer::m_decoderReadLock
protected

Definition at line 223 of file mythmediabuffer.h.

Referenced by UpdateDecoderRate().

◆ m_decoderReads

QMap<qint64, uint64_t> MythMediaBuffer::m_decoderReads
protected

Definition at line 224 of file mythmediabuffer.h.

Referenced by UpdateDecoderRate().

◆ m_storageReadLock

QMutex MythMediaBuffer::m_storageReadLock
protected

Definition at line 225 of file mythmediabuffer.h.

Referenced by UpdateStorageRate().

◆ m_storageReads

QMap<qint64, uint64_t> MythMediaBuffer::m_storageReads
protected

Definition at line 226 of file mythmediabuffer.h.

Referenced by UpdateStorageRate().

◆ m_generalWait

QWaitCondition MythMediaBuffer::m_generalWait
protected

◆ s_subExtLock

QMutex MythMediaBuffer::s_subExtLock
static

◆ s_subExt

QStringList MythMediaBuffer::s_subExt
static

◆ s_subExtNoCheck

QStringList MythMediaBuffer::s_subExtNoCheck
static

Definition at line 240 of file mythmediabuffer.h.

Referenced by IsSubtitlePossible(), and MythMediaBuffer().

◆ m_bitrateInitialized

bool MythMediaBuffer::m_bitrateInitialized { false }
private

Definition at line 243 of file mythmediabuffer.h.

Referenced by CalcReadAheadThresh(), and UpdateRawBitrate().


The documentation for this class was generated from the following files: