MythTV  master
mythmediabuffer.h
Go to the documentation of this file.
1 #ifndef MYTHMEDIABUFFER_H
2 #define MYTHMEDIABUFFER_H
3 
4 // Qt
5 #include <QReadWriteLock>
6 #include <QWaitCondition>
7 #include <QString>
8 #include <QMutex>
9 #include <QMap>
10 
11 // MythTV
12 #include "libmythbase/mythconfig.h"
13 #include "libmythtv/mythtvexp.h"
14 #include "libmythbase/mthread.h"
15 #include "libmythbase/mythchrono.h"
16 
17 // FFmpeg
18 extern "C" {
19 #include "libavcodec/avcodec.h"
20 }
21 
22 // Size of PNG header plus one empty chunk
23 static constexpr qint64 kReadTestSize { 20 };
24 
25 // about one second at 35Mb
26 static constexpr uint32_t BUFFER_SIZE_MINIMUM { 4 * 1024 * 1024 };
27 static constexpr uint8_t BUFFER_FACTOR_NETWORK { 2 };
28 static constexpr uint8_t BUFFER_FACTOR_BITRATE { 2 };
29 static constexpr uint8_t BUFFER_FACTOR_MATROSKA { 2 };
30 
31 static constexpr int32_t DEFAULT_CHUNK_SIZE { 32768 };
32 
33 static inline QString seek2string(int Whence)
34 {
35  if (SEEK_SET == Whence)
36  return "SEEK_SET";
37  if (SEEK_CUR == Whence)
38  return "SEEK_CUR";
39  return "SEEK_END";
40 }
41 
42 class ThreadedFileWriter;
43 class MythDVDBuffer;
44 class MythBDBuffer;
45 class LiveTVChain;
46 class RemoteFile;
47 
48 enum MythBufferType : std::uint8_t
49 {
57 };
58 
60 {
61  friend class MythInteractiveBuffer;
62 
63  public:
64  static MythMediaBuffer *Create(const QString &Filename, bool Write,
65  bool UseReadAhead = true,
66  std::chrono::milliseconds Timeout = kDefaultOpenTimeout,
67  bool StreamOnly = false);
68  ~MythMediaBuffer() override = 0;
69  MythBufferType GetType() const;
70 
71  static constexpr std::chrono::milliseconds kDefaultOpenTimeout { 2s };
72  static constexpr std::chrono::milliseconds kLiveTVOpenTimeout { 10s };
73  static QString BitrateToString (uint64_t Rate, bool Hz = false);
74  static void AVFormatInitNetwork (void);
75 
76  void SetOldFile (bool Old);
77  void UpdateRawBitrate (uint RawBitrate);
78  void UpdatePlaySpeed (float PlaySpeed);
79  void EnableBitrateMonitor (bool Enable);
80  void SetBufferSizeFactors (bool EstBitrate, bool Matroska);
81  void SetWaitForWrite (void);
82  QString GetSafeFilename (void);
83  QString GetFilename (void) const;
84  QString GetSubtitleFilename (void) const;
85  QString GetLastError (void) const;
86  bool GetCommsError (void) const;
87  void ResetCommsError (void);
88  bool GetStopReads (void) const;
89  QString GetDecoderRate (void);
90  QString GetStorageRate (void);
91  QString GetAvailableBuffer (void);
92  uint GetBufferSize (void) const;
93  bool IsNearEnd (double Framerate, uint Frames) const;
94  long long GetWritePosition (void) const;
95  long long GetRealFileSize (void) const;
96  bool IsDisc (void) const;
97  bool IsDVD (void) const;
98  bool IsBD (void) const;
99  const MythDVDBuffer *DVD (void) const;
100  MythDVDBuffer *DVD (void);
101  const MythBDBuffer *BD (void) const;
102  MythBDBuffer *BD (void);
103  int Read (void *Buffer, int Count);
104  int Peek (void *Buffer, int Count);
105  int Peek (std::vector<char>& Buffer);
106  void Reset (bool Full = false, bool ToAdjust = false, bool ResetInternal = false);
107  void Pause (void);
108  void Unpause (void);
109  void WaitForPause (void);
110  void Start (void);
111  void StopReads (void);
112  void StartReads (void);
113  long long Seek (long long Position, int Whence, bool HasLock = false);
114  long long SetAdjustFilesize (void);
115 
116  // LiveTV used utilities
117  int GetReadBufAvail (void) const;
118  bool SetReadInternalMode (bool Mode);
119  bool IsReadInternalMode (void) const;
120  bool LiveMode (void) const;
121  void SetLiveMode (LiveTVChain *Chain);
122  void IgnoreLiveEOF (bool Ignore);
123 
124  // ThreadedFileWriter proxies
125  int Write (const void *Buffer, uint Count);
126  bool IsIOBound (void) const;
127  void WriterFlush (void);
128  void Sync (void);
129  long long WriterSeek (long long Position, int Whence, bool HasLock = false);
130  bool WriterSetBlocking (bool Lock = true);
131 
132  virtual long long GetReadPosition (void) const = 0;
133  virtual bool IsOpen (void) const = 0;
134  virtual bool IsStreamed (void) { return LiveMode(); }
135  virtual bool IsSeekingAllowed (void) { return true; }
136  virtual bool IsBookmarkAllowed (void) { return true; }
137  virtual int BestBufferSize (void) { return DEFAULT_CHUNK_SIZE; }
138  virtual bool StartFromBeginning(void) { return true; }
139  virtual void IgnoreWaitStates (bool /*Ignore*/) { }
140  virtual bool IsInMenu (void) const { return false; }
141  virtual bool IsInStillFrame (void) const { return false; }
142  virtual bool IsInDiscMenuOrStillFrame(void) const { return IsInMenu() || IsInStillFrame(); }
143  virtual bool HandleAction (const QStringList &/*Action*/, mpeg::chrono::pts /*Pts*/) { return false; }
144  virtual bool OpenFile (const QString &Filename, std::chrono::milliseconds Retry = kDefaultOpenTimeout) = 0;
145  virtual bool ReOpen (const QString& /*Filename*/ = "") { return false; }
146 
147  protected:
148  explicit MythMediaBuffer(MythBufferType Type);
149 
150  void run(void) override;
151  void CreateReadAheadBuffer (void);
152  void CalcReadAheadThresh (void);
153  bool PauseAndWait (void);
154  int ReadPriv (void *Buffer, int Count, bool Peek);
155  int ReadDirect (void *Buffer, int Count, bool Peek);
156  bool WaitForReadsAllowed (void);
157  int WaitForAvail (int Count, std::chrono::milliseconds Timeout);
158  int ReadBufFree (void) const;
159  int ReadBufAvail (void) const;
160  void ResetReadAhead (long long NewInternal);
161  void KillReadAheadThread (void);
162  uint64_t UpdateDecoderRate (uint64_t Latest = 0);
163  uint64_t UpdateStorageRate (uint64_t Latest = 0);
164 
165  virtual int SafeRead (void *Buffer, uint Size) = 0;
166  virtual long long GetRealFileSizeInternal(void) const { return -1; }
167  virtual long long SeekInternal (long long Position, int Whence) = 0;
168 
169 
170  protected:
172 
173  mutable QReadWriteLock m_posLock;
174  long long m_readPos { 0 };
175  long long m_writePos { 0 };
176  long long m_internalReadPos { 0 };
177  long long m_ignoreReadPos { -1 };
178 
179  mutable QReadWriteLock m_rbrLock;
180  int m_rbrPos { 0 };
181 
182  mutable QReadWriteLock m_rbwLock;
183  int m_rbwPos { 0 };
184 
185  // note should not go under rwLock..
186  // this is used to break out of read_safe where rwLock is held
187  volatile bool m_stopReads {false};
188 
189  // unprotected (for debugging)
190  QString m_safeFilename;
191 
192  mutable QReadWriteLock m_rwLock;
193  QString m_filename;
195  QString m_lastError;
196  ThreadedFileWriter *m_tfw { nullptr };
197  int m_fd2 { -1 };
198  bool m_writeMode { false };
199  RemoteFile *m_remotefile { nullptr };
201  bool m_lowBuffers { false };
202  bool m_fileIsMatroska { false };
203  bool m_unknownBitrate { false };
204  bool m_startReadAhead { false };
205  char *m_readAheadBuffer { nullptr };
206  bool m_readAheadRunning { false };
207  bool m_reallyRunning { false };
208  bool m_requestPause { false };
209  bool m_paused { false };
210  bool m_ateof { false };
211  bool m_waitForWrite { false };
212  bool m_beingWritten { false };
213  bool m_readsAllowed { false };
214  bool m_readsDesired { false };
215  volatile bool m_recentSeek { true }; // not protected by rwLock
216  bool m_setSwitchToNext { false };
217  uint m_rawBitrate { 8000 };
218  float m_playSpeed { 1.0F };
219  int m_fillThreshold { 65536 };
220  int m_fillMin { -1 };
222  int m_wantToRead { 0 };
223  int m_numFailures { 0 }; // (see note 1)
224  bool m_commsError { false };
225  bool m_oldfile { false };
227  bool m_ignoreLiveEOF { false };
228  long long m_readAdjust { 0 };
229  int m_readOffset { 0 };
230  bool m_readInternalMode { false };
231  // End of section protected by rwLock
232 
233  bool m_bitrateMonitorEnabled { false };
235  QMap<std::chrono::milliseconds, uint64_t> m_decoderReads;
237  QMap<std::chrono::milliseconds, uint64_t> m_storageReads;
238 
239  // note 1: numfailures is modified with only a read lock in the
240  // read ahead thread, but this is safe since all other places
241  // that use it are protected by a write lock. But this is a
242  // fragile state of affairs and care must be taken when modifying
243  // code or locking around this variable.
244 
246  QWaitCondition m_generalWait; // protected by rwLock
247 
248  private:
249  bool m_bitrateInitialized { false };
250 };
251 #endif
MythMediaBuffer::BD
const MythBDBuffer * BD(void) const
Definition: mythmediabuffer.cpp:1855
kMythBufferDVD
@ kMythBufferDVD
Definition: mythmediabuffer.h:52
MythMediaBuffer::BestBufferSize
virtual int BestBufferSize(void)
Definition: mythmediabuffer.h:137
MythMediaBuffer::m_tfw
ThreadedFileWriter * m_tfw
Definition: mythmediabuffer.h:196
MythMediaBuffer::SetBufferSizeFactors
void SetBufferSizeFactors(bool EstBitrate, bool Matroska)
Tells RingBuffer that the raw bitrate may be inaccurate and the underlying container is matroska,...
Definition: mythmediabuffer.cpp:330
MythMediaBuffer::PauseAndWait
bool PauseAndWait(void)
Definition: mythmediabuffer.cpp:734
MythMediaBuffer::m_rbrPos
int m_rbrPos
Definition: mythmediabuffer.h:180
MythMediaBuffer::m_readAdjust
long long m_readAdjust
Definition: mythmediabuffer.h:228
MythMediaBuffer::ReOpen
virtual bool ReOpen(const QString &="")
Definition: mythmediabuffer.h:145
MythMediaBuffer::m_startReadAhead
bool m_startReadAhead
Definition: mythmediabuffer.h:204
MythMediaBuffer::Seek
long long Seek(long long Position, int Whence, bool HasLock=false)
Definition: mythmediabuffer.cpp:479
MythMediaBuffer::StopReads
void StopReads(void)
Definition: mythmediabuffer.cpp:669
MythMediaBuffer::UpdatePlaySpeed
void UpdatePlaySpeed(float PlaySpeed)
Set the play speed, to allow RingBuffer adjust effective bitrate.
Definition: mythmediabuffer.cpp:307
MythMediaBuffer::m_commsError
bool m_commsError
Definition: mythmediabuffer.h:224
MythMediaBuffer::m_oldfile
bool m_oldfile
Definition: mythmediabuffer.h:225
MythMediaBuffer::EnableBitrateMonitor
void EnableBitrateMonitor(bool Enable)
Definition: mythmediabuffer.cpp:315
MythMediaBuffer::WriterSetBlocking
bool WriterSetBlocking(bool Lock=true)
Calls ThreadedFileWriter::SetBlocking(bool)
Definition: mythmediabuffer.cpp:1718
mythtvexp.h
MythMediaBuffer::GetWritePosition
long long GetWritePosition(void) const
Returns how far into a ThreadedFileWriter file we have written.
Definition: mythmediabuffer.cpp:1796
MythMediaBuffer::m_fd2
int m_fd2
Definition: mythmediabuffer.h:197
MythMediaBuffer::m_safeFilename
QString m_safeFilename
Definition: mythmediabuffer.h:190
MythMediaBuffer::GetDecoderRate
QString GetDecoderRate(void)
Definition: mythmediabuffer.cpp:1543
MythMediaBuffer::kLiveTVOpenTimeout
static constexpr std::chrono::milliseconds kLiveTVOpenTimeout
Definition: mythmediabuffer.h:72
MythMediaBuffer::CalcReadAheadThresh
void CalcReadAheadThresh(void)
Calculates m_fillMin, m_fillThreshold, and m_readBlockSize from the estimated effective bitrate of th...
Definition: mythmediabuffer.cpp:367
MythMediaBuffer::m_type
MythBufferType m_type
Definition: mythmediabuffer.h:171
MythMediaBuffer::ReadDirect
int ReadDirect(void *Buffer, int Count, bool Peek)
Definition: mythmediabuffer.cpp:1255
RemoteFile
Definition: remotefile.h:17
MythMediaBuffer::Write
int Write(const void *Buffer, uint Count)
Writes buffer to ThreadedFileWriter::Write(const void*,uint)
Definition: mythmediabuffer.cpp:1634
MythMediaBuffer::m_readOffset
int m_readOffset
Definition: mythmediabuffer.h:229
MythMediaBuffer
Definition: mythmediabuffer.h:59
MythMediaBuffer::IgnoreWaitStates
virtual void IgnoreWaitStates(bool)
Definition: mythmediabuffer.h:139
MythMediaBuffer::IsDVD
bool IsDVD(void) const
Definition: mythmediabuffer.cpp:1840
MythMediaBuffer::Unpause
void Unpause(void)
Unpauses the read-ahead thread. Calls StartReads(void).
Definition: mythmediabuffer.cpp:704
MythMediaBuffer::GetSafeFilename
QString GetSafeFilename(void)
Definition: mythmediabuffer.cpp:1757
MythMediaBuffer::GetReadBufAvail
int GetReadBufAvail(void) const
Returns number of bytes available for reading from buffer.
Definition: mythmediabuffer.cpp:462
MythMediaBuffer::m_lastError
QString m_lastError
Definition: mythmediabuffer.h:195
MythMediaBuffer::m_generalWait
QWaitCondition m_generalWait
Condition to signal that the read ahead thread is running.
Definition: mythmediabuffer.h:246
MythMediaBuffer::HandleAction
virtual bool HandleAction(const QStringList &, mpeg::chrono::pts)
Definition: mythmediabuffer.h:143
MythMediaBuffer::ReadBufFree
int ReadBufFree(void) const
Returns number of bytes available for reading into buffer.
Definition: mythmediabuffer.cpp:451
MythInteractiveBuffer::SeekInternal
long long SeekInternal(long long Position, int Whence) override
Definition: mythinteractivebuffer.cpp:92
MythMediaBuffer::IsBD
bool IsBD(void) const
Definition: mythmediabuffer.cpp:1845
MythMediaBuffer::SetAdjustFilesize
long long SetAdjustFilesize(void)
Definition: mythmediabuffer.cpp:1158
MythMediaBuffer::IsInMenu
virtual bool IsInMenu(void) const
Definition: mythmediabuffer.h:140
MythMediaBuffer::WaitForReadsAllowed
bool WaitForReadsAllowed(void)
Definition: mythmediabuffer.cpp:1186
kMythBufferMHEG
@ kMythBufferMHEG
Definition: mythmediabuffer.h:56
MythMediaBuffer::UpdateRawBitrate
void UpdateRawBitrate(uint RawBitrate)
Set the raw bit rate, to allow RingBuffer adjust effective bitrate.
Definition: mythmediabuffer.cpp:279
MythMediaBuffer::StartFromBeginning
virtual bool StartFromBeginning(void)
Definition: mythmediabuffer.h:138
MythMediaBuffer::BitrateToString
static QString BitrateToString(uint64_t Rate, bool Hz=false)
Definition: mythmediabuffer.cpp:1510
MythMediaBuffer::m_paused
bool m_paused
Definition: mythmediabuffer.h:209
MythMediaBuffer::m_decoderReadLock
QMutex m_decoderReadLock
Definition: mythmediabuffer.h:234
MythMediaBuffer::m_readsAllowed
bool m_readsAllowed
Definition: mythmediabuffer.h:213
MythMediaBuffer::GetStopReads
bool GetStopReads(void) const
Definition: mythmediabuffer.cpp:1788
MythMediaBuffer::GetBufferSize
uint GetBufferSize(void) const
Definition: mythmediabuffer.cpp:1563
BUFFER_FACTOR_NETWORK
static constexpr uint8_t BUFFER_FACTOR_NETWORK
Definition: mythmediabuffer.h:27
MythMediaBuffer::WaitForAvail
int WaitForAvail(int Count, std::chrono::milliseconds Timeout)
Definition: mythmediabuffer.cpp:1215
MythMediaBuffer::m_rawBitrate
uint m_rawBitrate
Definition: mythmediabuffer.h:217
MythMediaBuffer::ReadPriv
int ReadPriv(void *Buffer, int Count, bool Peek)
When possible reads from the read-ahead buffer, otherwise reads directly from the device.
Definition: mythmediabuffer.cpp:1330
MythMediaBuffer::m_liveTVChain
LiveTVChain * m_liveTVChain
Definition: mythmediabuffer.h:226
MythInteractiveBuffer::GetReadPosition
long long GetReadPosition(void) const override
Definition: mythinteractivebuffer.cpp:87
MythMediaBuffer::GetFilename
QString GetFilename(void) const
Definition: mythmediabuffer.cpp:1749
MythMediaBuffer::GetRealFileSize
long long GetRealFileSize(void) const
Definition: mythmediabuffer.cpp:468
MythMediaBuffer::SetOldFile
void SetOldFile(bool Old)
Tell RingBuffer if this is an old file or not.
Definition: mythmediabuffer.cpp:1741
MythMediaBuffer::m_readPos
long long m_readPos
Definition: mythmediabuffer.h:174
MythMediaBuffer::m_beingWritten
bool m_beingWritten
Definition: mythmediabuffer.h:212
MythInteractiveBuffer::IsOpen
bool IsOpen(void) const override
Definition: mythinteractivebuffer.cpp:30
kMythBufferFile
@ kMythBufferFile
Definition: mythmediabuffer.h:51
MythMediaBuffer::WaitForPause
void WaitForPause(void)
Waits for Pause(void) to take effect.
Definition: mythmediabuffer.cpp:718
MythMediaBuffer::IsInDiscMenuOrStillFrame
virtual bool IsInDiscMenuOrStillFrame(void) const
Definition: mythmediabuffer.h:142
MythMediaBuffer::WriterSeek
long long WriterSeek(long long Position, int Whence, bool HasLock=false)
Calls ThreadedFileWriter::Seek(long long,int).
Definition: mythmediabuffer.cpp:1681
MythMediaBuffer::m_requestPause
bool m_requestPause
Definition: mythmediabuffer.h:208
MythMediaBuffer::m_readInternalMode
bool m_readInternalMode
Definition: mythmediabuffer.h:230
MythMediaBuffer::~MythMediaBuffer
~MythMediaBuffer() override=0
Deletes.
Definition: mythmediabuffer.cpp:219
MythMediaBuffer::GetSubtitleFilename
QString GetSubtitleFilename(void) const
Definition: mythmediabuffer.cpp:1762
MythMediaBuffer::m_remotefile
RemoteFile * m_remotefile
Definition: mythmediabuffer.h:199
MythMediaBuffer::UpdateStorageRate
uint64_t UpdateStorageRate(uint64_t Latest=0)
Definition: mythmediabuffer.cpp:1599
MythMediaBuffer::m_decoderReads
QMap< std::chrono::milliseconds, uint64_t > m_decoderReads
Definition: mythmediabuffer.h:235
MythMediaBuffer::ResetCommsError
void ResetCommsError(void)
Definition: mythmediabuffer.cpp:1783
MythMediaBuffer::IsIOBound
bool IsIOBound(void) const
MythMediaBuffer::m_writePos
long long m_writePos
Definition: mythmediabuffer.h:175
MythMediaBuffer::m_readBlockSize
int m_readBlockSize
Definition: mythmediabuffer.h:221
MythMediaBuffer::m_rbwLock
QReadWriteLock m_rbwLock
Definition: mythmediabuffer.h:182
MythMediaBuffer::GetCommsError
bool GetCommsError(void) const
Definition: mythmediabuffer.cpp:1778
MythMediaBuffer::m_waitForWrite
bool m_waitForWrite
Definition: mythmediabuffer.h:211
MythBDBuffer
Definition: mythbdbuffer.h:19
MythMediaBuffer::m_setSwitchToNext
bool m_setSwitchToNext
Definition: mythmediabuffer.h:216
MythMediaBuffer::m_readAheadBuffer
char * m_readAheadBuffer
Definition: mythmediabuffer.h:205
BUFFER_FACTOR_BITRATE
static constexpr uint8_t BUFFER_FACTOR_BITRATE
Definition: mythmediabuffer.h:28
MythMediaBuffer::m_numFailures
int m_numFailures
Definition: mythmediabuffer.h:223
MythMediaBuffer::m_bufferSize
uint m_bufferSize
Definition: mythmediabuffer.h:200
MythMediaBuffer::LiveMode
bool LiveMode(void) const
Returns true if this RingBuffer has been assigned a LiveTVChain.
Definition: mythmediabuffer.cpp:1808
MythMediaBuffer::m_lowBuffers
bool m_lowBuffers
Definition: mythmediabuffer.h:201
MythMediaBuffer::m_fillThreshold
int m_fillThreshold
Definition: mythmediabuffer.h:219
MythMediaBuffer::m_filename
QString m_filename
Definition: mythmediabuffer.h:193
MThread::run
virtual void run(void)
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: mthread.cpp:315
BUFFER_FACTOR_MATROSKA
static constexpr uint8_t BUFFER_FACTOR_MATROSKA
Definition: mythmediabuffer.h:29
kMythBufferUnknown
@ kMythBufferUnknown
Definition: mythmediabuffer.h:50
MythMediaBuffer::CreateReadAheadBuffer
void CreateReadAheadBuffer(void)
Definition: mythmediabuffer.cpp:777
MythBufferType
MythBufferType
Definition: mythmediabuffer.h:48
MythMediaBuffer::IgnoreLiveEOF
void IgnoreLiveEOF(bool Ignore)
Tells RingBuffer whether to ignore the end-of-file.
Definition: mythmediabuffer.cpp:1828
kReadTestSize
static constexpr qint64 kReadTestSize
Definition: mythmediabuffer.h:23
MythMediaBuffer::Read
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 i...
Definition: mythmediabuffer.cpp:1496
ThreadedFileWriter
This class supports the writing of recordings to disk.
Definition: threadedfilewriter.h:42
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
MythMediaBuffer::IsReadInternalMode
bool IsReadInternalMode(void) const
Definition: mythmediabuffer.cpp:548
MythMediaBuffer::m_rbrLock
QReadWriteLock m_rbrLock
Definition: mythmediabuffer.h:179
MythMediaBuffer::m_readsDesired
bool m_readsDesired
Definition: mythmediabuffer.h:214
MythMediaBuffer::WriterFlush
void WriterFlush(void)
Calls ThreadedFileWriter::Flush(void)
Definition: mythmediabuffer.cpp:1707
MythMediaBuffer::KillReadAheadThread
void KillReadAheadThread(void)
Stops the read-ahead thread, and waits for it to stop.
Definition: mythmediabuffer.cpp:653
MythMediaBuffer::AVFormatInitNetwork
static void AVFormatInitNetwork(void)
Definition: mythmediabuffer.cpp:1870
MythMediaBuffer::IsBookmarkAllowed
virtual bool IsBookmarkAllowed(void)
Definition: mythmediabuffer.h:136
MythMediaBuffer::m_playSpeed
float m_playSpeed
Definition: mythmediabuffer.h:218
Buffer
Definition: MythExternControl.h:36
MythMediaBuffer::m_recentSeek
volatile bool m_recentSeek
Definition: mythmediabuffer.h:215
MythMediaBuffer::m_ignoreLiveEOF
bool m_ignoreLiveEOF
Definition: mythmediabuffer.h:227
MythMediaBuffer::m_storageReadLock
QMutex m_storageReadLock
Definition: mythmediabuffer.h:236
MythMediaBuffer::m_unknownBitrate
bool m_unknownBitrate
Definition: mythmediabuffer.h:203
MythMediaBuffer::ResetReadAhead
void ResetReadAhead(long long NewInternal)
Restart the read-ahead thread at the 'newinternal' position.
Definition: mythmediabuffer.cpp:575
MythMediaBuffer::IsInStillFrame
virtual bool IsInStillFrame(void) const
Definition: mythmediabuffer.h:141
seek2string
static QString seek2string(int Whence)
Definition: mythmediabuffer.h:33
MythInteractiveBuffer::OpenFile
bool OpenFile(const QString &Url, std::chrono::milliseconds Retry=kDefaultOpenTimeout) override
Opens a BBC NetStream for reading.
Definition: mythinteractivebuffer.cpp:41
MythMediaBuffer::MythMediaBuffer
MythMediaBuffer(MythBufferType Type)
Definition: mythmediabuffer.cpp:198
MythMediaBuffer::SetReadInternalMode
bool SetReadInternalMode(bool Mode)
Definition: mythmediabuffer.cpp:523
MythMediaBuffer::m_fileIsMatroska
bool m_fileIsMatroska
Definition: mythmediabuffer.h:202
MythMediaBuffer::m_wantToRead
int m_wantToRead
Definition: mythmediabuffer.h:222
BUFFER_SIZE_MINIMUM
static constexpr uint32_t BUFFER_SIZE_MINIMUM
Definition: mythmediabuffer.h:26
MythMediaBuffer::GetRealFileSizeInternal
virtual long long GetRealFileSizeInternal(void) const
Definition: mythmediabuffer.h:166
MythMediaBuffer::IsDisc
bool IsDisc(void) const
Definition: mythmediabuffer.cpp:1835
MythMediaBuffer::Start
void Start(void)
Starts the read-ahead thread.
Definition: mythmediabuffer.cpp:617
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
MythMediaBuffer::GetAvailableBuffer
QString GetAvailableBuffer(void)
Definition: mythmediabuffer.cpp:1553
mythchrono.h
mthread.h
MythInteractiveBuffer
Definition: mythinteractivebuffer.h:9
kMythBufferHLS
@ kMythBufferHLS
Definition: mythmediabuffer.h:55
MythMediaBuffer::ReadBufAvail
int ReadBufAvail(void) const
Returns number of bytes available for reading from buffer.
Definition: mythmediabuffer.cpp:555
MythMediaBuffer::Create
static MythMediaBuffer * Create(const QString &Filename, bool Write, bool UseReadAhead=true, std::chrono::milliseconds Timeout=kDefaultOpenTimeout, bool StreamOnly=false)
Creates a RingBuffer instance.
Definition: mythmediabuffer.cpp:99
MythMediaBuffer::m_bitrateInitialized
bool m_bitrateInitialized
Definition: mythmediabuffer.h:249
MythMediaBuffer::GetLastError
QString GetLastError(void) const
Definition: mythmediabuffer.cpp:1770
mpeg::chrono::pts
std::chrono::duration< CHRONO_TYPE, std::ratio< 1, 90000 > > pts
Definition: mythchrono.h:55
kMythBufferBD
@ kMythBufferBD
Definition: mythmediabuffer.h:53
MythMediaBuffer::m_reallyRunning
bool m_reallyRunning
Definition: mythmediabuffer.h:207
MythMediaBuffer::SetLiveMode
void SetLiveMode(LiveTVChain *Chain)
Assigns a LiveTVChain to this RingBuffer.
Definition: mythmediabuffer.cpp:1820
MythMediaBuffer::m_subtitleFilename
QString m_subtitleFilename
Definition: mythmediabuffer.h:194
MythMediaBuffer::m_writeMode
bool m_writeMode
Definition: mythmediabuffer.h:198
MythMediaBuffer::DVD
const MythDVDBuffer * DVD(void) const
Definition: mythmediabuffer.cpp:1850
MythMediaBuffer::m_posLock
QReadWriteLock m_posLock
Definition: mythmediabuffer.h:173
MythMediaBuffer::m_bitrateMonitorEnabled
bool m_bitrateMonitorEnabled
Definition: mythmediabuffer.h:233
MythInteractiveBuffer::SafeRead
int SafeRead(void *Buffer, uint Size) override
Definition: mythinteractivebuffer.cpp:137
MythMediaBuffer::Peek
int Peek(void *Buffer, int Count)
Definition: mythmediabuffer.cpp:1170
MythMediaBuffer::m_stopReads
volatile bool m_stopReads
Definition: mythmediabuffer.h:187
DEFAULT_CHUNK_SIZE
static constexpr int32_t DEFAULT_CHUNK_SIZE
Definition: mythmediabuffer.h:31
MythMediaBuffer::IsNearEnd
bool IsNearEnd(double Framerate, uint Frames) const
Definition: mythmediabuffer.cpp:412
MythMediaBuffer::IsStreamed
virtual bool IsStreamed(void)
Definition: mythmediabuffer.h:134
MythMediaBuffer::m_rwLock
QReadWriteLock m_rwLock
Definition: mythmediabuffer.h:192
MythMediaBuffer::StartReads
void StartReads(void)
Definition: mythmediabuffer.cpp:679
MythDVDBuffer
Definition: mythdvdbuffer.h:37
MythMediaBuffer::m_storageReads
QMap< std::chrono::milliseconds, uint64_t > m_storageReads
Definition: mythmediabuffer.h:237
MythMediaBuffer::m_ateof
bool m_ateof
Definition: mythmediabuffer.h:210
MythMediaBuffer::IsSeekingAllowed
virtual bool IsSeekingAllowed(void)
Definition: mythmediabuffer.h:135
MythMediaBuffer::kDefaultOpenTimeout
static constexpr std::chrono::milliseconds kDefaultOpenTimeout
Definition: mythmediabuffer.h:71
MythMediaBuffer::GetStorageRate
QString GetStorageRate(void)
Definition: mythmediabuffer.cpp:1548
MythMediaBuffer::UpdateDecoderRate
uint64_t UpdateDecoderRate(uint64_t Latest=0)
Definition: mythmediabuffer.cpp:1568
MythMediaBuffer::m_internalReadPos
long long m_internalReadPos
Definition: mythmediabuffer.h:176
kMythBufferHTTP
@ kMythBufferHTTP
Definition: mythmediabuffer.h:54
MythMediaBuffer::Pause
void Pause(void)
Pauses the read-ahead thread. Calls StopReads(void).
Definition: mythmediabuffer.cpp:690
MythMediaBuffer::Sync
void Sync(void)
Calls ThreadedFileWriter::Sync(void)
Definition: mythmediabuffer.cpp:1671
MythMediaBuffer::m_rbwPos
int m_rbwPos
Definition: mythmediabuffer.h:183
Mode
Mode
Definition: synaesthesia.h:23
MythMediaBuffer::m_ignoreReadPos
long long m_ignoreReadPos
Definition: mythmediabuffer.h:177
MythMediaBuffer::m_readAheadRunning
bool m_readAheadRunning
Definition: mythmediabuffer.h:206
MythMediaBuffer::Reset
void Reset(bool Full=false, bool ToAdjust=false, bool ResetInternal=false)
Resets the read-ahead thread and our position in the file.
Definition: mythmediabuffer.cpp:238
uint
unsigned int uint
Definition: freesurround.h:24
MythMediaBuffer::GetType
MythBufferType GetType() const
Definition: mythmediabuffer.cpp:204
MythMediaBuffer::m_fillMin
int m_fillMin
Definition: mythmediabuffer.h:220
LiveTVChain
Keeps track of recordings in a current LiveTV instance.
Definition: livetvchain.h:32
MythMediaBuffer::SetWaitForWrite
void SetWaitForWrite(void)
Definition: mythmediabuffer.cpp:320