MythTV  master
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
MythInteractiveBuffer Class Reference

#include <mythinteractivebuffer.h>

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

Public Member Functions

 MythInteractiveBuffer (const QString &Url, MythMediaBuffer *Parent=nullptr)
 
 ~MythInteractiveBuffer () override
 
bool IsOpen (void) const override
 
long long GetReadPosition (void) const override
 
bool OpenFile (const QString &Url, std::chrono::milliseconds Retry=kDefaultOpenTimeout) override
 Opens a BBC NetStream for reading. More...
 
bool IsStreamed (void) override
 
bool IsSeekingAllowed (void) override
 
bool IsBookmarkAllowed (void) override
 
MythMediaBufferTakeBuffer (void)
 
- Public Member Functions inherited from MythMediaBuffer
 ~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)
 
int Peek (std::vector< char > &Buffer)
 
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 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 &, mpeg::chrono::pts)
 
virtual bool ReOpen (const QString &="")
 

Protected Member Functions

int SafeRead (void *Buffer, uint Size) override
 
long long GetRealFileSizeInternal (void) const override
 
long long SeekInternal (long long Position, int Whence) override
 
- Protected Member Functions inherited from MythMediaBuffer
 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, std::chrono::milliseconds 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)
 
- 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 (std::chrono::milliseconds time=std::chrono::milliseconds::max())
 Wait for the MThread to exit, with a maximum timeout. More...
 

Private Attributes

NetStreamm_stream { nullptr }
 
MythMediaBufferm_parent { nullptr }
 

Additional Inherited Members

- Static Public Member Functions inherited from MythMediaBuffer
static MythMediaBufferCreate (const QString &Filename, bool Write, bool UseReadAhead=true, std::chrono::milliseconds 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 inherited from MythMediaBuffer
static constexpr std::chrono::milliseconds kDefaultOpenTimeout { 2s }
 
static constexpr std::chrono::milliseconds kLiveTVOpenTimeout { 10s }
 
- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void usleep (std::chrono::microseconds time)
 
template<typename R , typename P >
static std::enable_if_t< std::chrono::treat_as_floating_point< R >::value, void > usleep (std::chrono::duration< R, P > 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)
 
- Protected Attributes inherited from MythMediaBuffer
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< std::chrono::milliseconds, uint64_t > m_decoderReads
 
QMutex m_storageReadLock
 
QMap< std::chrono::milliseconds, 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}
 

Detailed Description

Definition at line 9 of file mythinteractivebuffer.h.

Constructor & Destructor Documentation

◆ MythInteractiveBuffer()

MythInteractiveBuffer::MythInteractiveBuffer ( const QString &  Url,
MythMediaBuffer Parent = nullptr 
)
explicit

Definition at line 15 of file mythinteractivebuffer.cpp.

◆ ~MythInteractiveBuffer()

MythInteractiveBuffer::~MythInteractiveBuffer ( )
override

Definition at line 23 of file mythinteractivebuffer.cpp.

Member Function Documentation

◆ IsOpen()

bool MythInteractiveBuffer::IsOpen ( void  ) const
overridevirtual

Implements MythMediaBuffer.

Definition at line 30 of file mythinteractivebuffer.cpp.

Referenced by TakeBuffer().

◆ GetReadPosition()

long long MythInteractiveBuffer::GetReadPosition ( void  ) const
overridevirtual

Implements MythMediaBuffer.

Definition at line 87 of file mythinteractivebuffer.cpp.

◆ OpenFile()

bool MythInteractiveBuffer::OpenFile ( const QString &  Url,
std::chrono::milliseconds  Retry = kDefaultOpenTimeout 
)
overridevirtual

Opens a BBC NetStream for reading.

Parameters
UrlUrl of the stream to read.
Returns
Returns true if the stream was opened.

Implements MythMediaBuffer.

Definition at line 41 of file mythinteractivebuffer.cpp.

Referenced by MythInteractiveBuffer().

◆ IsStreamed()

bool MythInteractiveBuffer::IsStreamed ( void  )
inlineoverridevirtual

Reimplemented from MythMediaBuffer.

Definition at line 18 of file mythinteractivebuffer.h.

◆ IsSeekingAllowed()

bool MythInteractiveBuffer::IsSeekingAllowed ( void  )
inlineoverridevirtual

Reimplemented from MythMediaBuffer.

Definition at line 19 of file mythinteractivebuffer.h.

◆ IsBookmarkAllowed()

bool MythInteractiveBuffer::IsBookmarkAllowed ( void  )
inlineoverridevirtual

Reimplemented from MythMediaBuffer.

Definition at line 20 of file mythinteractivebuffer.h.

◆ TakeBuffer()

MythMediaBuffer * MythInteractiveBuffer::TakeBuffer ( void  )

Definition at line 150 of file mythinteractivebuffer.cpp.

◆ SafeRead()

int MythInteractiveBuffer::SafeRead ( void *  Buffer,
uint  Size 
)
overrideprotectedvirtual

Implements MythMediaBuffer.

Definition at line 137 of file mythinteractivebuffer.cpp.

◆ GetRealFileSizeInternal()

long long MythInteractiveBuffer::GetRealFileSizeInternal ( void  ) const
overrideprotectedvirtual

Reimplemented from MythMediaBuffer.

Definition at line 145 of file mythinteractivebuffer.cpp.

◆ SeekInternal()

long long MythInteractiveBuffer::SeekInternal ( long long  Position,
int  Whence 
)
overrideprotectedvirtual

Implements MythMediaBuffer.

Definition at line 92 of file mythinteractivebuffer.cpp.

Member Data Documentation

◆ m_stream

NetStream* MythInteractiveBuffer::m_stream { nullptr }
private

◆ m_parent

MythMediaBuffer* MythInteractiveBuffer::m_parent { nullptr }
private

Definition at line 31 of file mythinteractivebuffer.h.

Referenced by OpenFile(), TakeBuffer(), and ~MythInteractiveBuffer().


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